From patchwork Mon Jan 11 17:16:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 360488 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3050799jai; Mon, 11 Jan 2021 09:10:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzG2ZI7ObJHKLUsO2YHEvm62YpkTpRt5F8MWmXglTZmLUz1kQlxs+OjcwdYcfBl7JxAB34r X-Received: by 2002:a17:906:2681:: with SMTP id t1mr313183ejc.29.1610385030662; Mon, 11 Jan 2021 09:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610385030; cv=none; d=google.com; s=arc-20160816; b=HOjsZcxFdoFNRkNnO+juSay7r+uwp1XvJeRV/FKdfNdSnkPr3T82zxQjuGJrqj0WgJ TAmlCakFABg4U4FkgRMqP+EMEya44Lqy3Tdk+Q90GxxXlH/JLdgLxqZIwD9e5y4Bv/HT uwQevcudn44rNS8doIyBjIDqhuIHSrfCNTQxybdc8fIOs+/DoTsb8oP//H76cQ/q6Ld/ aS8KDDfbvC7UoPLjSgsyPyQjAD9R8PACiqtQ41Lkni5Rq/2K1DgQurOiQBc9a0pBNEmx kPU/E6M7H/5xTgdXMo/oJZcKJ0JsBT0O380TrD5EtP0BvbQSQPXnJZAk2XIAgxpMrzlS DXqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=i5vkZMIp6m8L5GT9AIEfOu/P1P8j2pgSz4aGREmv2dc=; b=v2jX0zVCcWriLlda2G9t1nRhvtQTorBl8cRKr43ESwbLujgVL7wHenXln/LaaTDGqM RrocqeNtO/tccufWi+8LFbzdtvECT/CgcZeXcefy2kp8doCZTohy72qZZLNP0thUdSsk HBkWy20P5x3ewVOEPzLKJhZu7lyl04DuEQQLgvvH+9beceLi48N0PQDJ87rDh3DU5x5u MbANqZMojBnKPhcEx725e2pF/4/jKJs01UpizruNRxsD/SUlXGgxl2SobhAoHaCuLWbt UfJtM5+XXXdtLL6gCviIgLOERndFsHRcRNWoSlucukT4XvG8gZNINKTM8pXK5YPQ+wUQ KxsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kUW5CqEQ; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si156790eds.239.2021.01.11.09.10.30; Mon, 11 Jan 2021 09:10:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kUW5CqEQ; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389252AbhAKRJ0 (ORCPT + 15 others); Mon, 11 Jan 2021 12:09:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389249AbhAKRJ0 (ORCPT ); Mon, 11 Jan 2021 12:09:26 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB717C061794 for ; Mon, 11 Jan 2021 09:08:44 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id a6so453772wmc.2 for ; Mon, 11 Jan 2021 09:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=i5vkZMIp6m8L5GT9AIEfOu/P1P8j2pgSz4aGREmv2dc=; b=kUW5CqEQs9SETIKZTrB6N2/ELutK/EqnMQN/CwzHvXbjSgIhpYzHwh9zCbi0+Luhy7 tYmM0jU+B0uuE+o2EX+2zjJMkzLBrfsIX0oCT672GTS3OV4NKAQoPIoHXFj1iSNPet/Y VF+baHMUY9F52SRfoRdK4YZ+qKpHTt5L+iybZYBHErnglzKbSBXxdFqyn58KPn7U6th4 SPcyY8NldxtYldlfa+tbHAwzRAI/GI9L15gow1kuMlZijAtNBJqCvb/zhi+SfzlinZgb 0zrdVAhWVtARgDPsEvK1wanyDHcsIvu9FHMWf73IH+Pq3HNX/IHPwkTlF47dgfo/sPoN KhsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=i5vkZMIp6m8L5GT9AIEfOu/P1P8j2pgSz4aGREmv2dc=; b=aJ2l6wTklIvVk9AnW6HFw3nzBxZ7psIaRzQLzy7yk2eisGGMBrc4oji40wRdaLmCgg Zx/82+skSMMnEzu6GmytMvQN5BoDqKYfb7JN1Q5dwKBV4WasozQftQmqewhs0PZX08wC a7GWQKkcxJ9DHiQ8H7o5XNehfEdUVupPJheD+WszP0Rk2+j/8v0RHBp1+TbScvlLwed1 /8ICYxsOJ1+9ec7uWcAmi8kCG8JJhisfRbzbmoflElg9bzw+QWDZ7cLxvTZVgSj7ARq/ sqzHJImBQSXva7solYf8MDbFvVmKPf0dHLnBskHGPAuFZciSetrFD6aexwy3HDl0UWe9 4ESA== X-Gm-Message-State: AOAM530Jhzb9LgUJgxktc7HrX8FIW2IfwKdIL1/AqsMNzrR55HEVLhG1 psAx3llcNV2X6FZ2R46JelXCeg== X-Received: by 2002:a1c:6506:: with SMTP id z6mr596622wmb.55.1610384923659; Mon, 11 Jan 2021 09:08:43 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id i18sm279364wrp.74.2021.01.11.09.08.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2021 09:08:43 -0800 (PST) From: Loic Poulain To: kuba@kernel.org, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, manivannan.sadhasivam@linaro.org, Hemant Kumar Subject: [PATCH net-next 1/3] bus: mhi: core: Add helper API to return number of free TREs Date: Mon, 11 Jan 2021 18:16:17 +0100 Message-Id: <1610385379-15140-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Hemant Kumar Introduce mhi_get_free_desc_count() API to return number of TREs available to queue buffer. MHI clients can use this API to know before hand if ring is full without calling queue API. Signed-off-by: Hemant Kumar Reviewed-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/main.c | 12 ++++++++++++ include/linux/mhi.h | 9 +++++++++ 2 files changed, 21 insertions(+) -- 2.7.4 diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 3db1108..4e31f4f 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -309,6 +309,18 @@ int mhi_destroy_device(struct device *dev, void *data) return 0; } +int mhi_get_free_desc_count(struct mhi_device *mhi_dev, + enum dma_data_direction dir) +{ + struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; + struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? + mhi_dev->ul_chan : mhi_dev->dl_chan; + struct mhi_ring *tre_ring = &mhi_chan->tre_ring; + + return get_nr_avail_ring_elements(mhi_cntrl, tre_ring); +} +EXPORT_SYMBOL_GPL(mhi_get_free_desc_count); + void mhi_notify(struct mhi_device *mhi_dev, enum mhi_callback cb_reason) { struct mhi_driver *mhi_drv; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index cd571ad..62da830 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -614,6 +614,15 @@ void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl, void mhi_notify(struct mhi_device *mhi_dev, enum mhi_callback cb_reason); /** + * mhi_get_free_desc_count - Get transfer ring length + * Get # of TD available to queue buffers + * @mhi_dev: Device associated with the channels + * @dir: Direction of the channel + */ +int mhi_get_free_desc_count(struct mhi_device *mhi_dev, + enum dma_data_direction dir); + +/** * mhi_prepare_for_power_up - Do pre-initialization before power up. * This is optional, call this before power up if * the controller does not want bus framework to From patchwork Mon Jan 11 17:16:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 360489 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3050813jai; Mon, 11 Jan 2021 09:10:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+byDdLGliCnsqKOBNdMWzfRlMxPu+uQ2oS1TNMHZkUTWqKfvKF7Dxwh7FJBonVdpb43OO X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr285883edv.100.1610385032409; Mon, 11 Jan 2021 09:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610385032; cv=none; d=google.com; s=arc-20160816; b=yuuhbj7y89O49ozDamF2+/+REgX8guCBNHPscJSuFRrKCXo4HBOyGXHDhEB1fdkN1Q fLqgNELR0GkSzwHXsskpBRR5FPXQIUz2Z8a3M9afC98CZuVBSO1UWy4IAmtuj9fsQe2v odOqRSg2VQyZamS1yoC1/Nxmp8N3vh1fF7IIJPfyEq3vQrRR8/VIz33zMxBBveViqpWI sfPPLVLEy6F8rdq6hLFc39fUZH8UEOn7nEtkCa/nrjWCqeoLlCp9TUhwq2+GOLPEcDLU PfkYzqckBOT85/K+2v41BwOqIgzKcEb/C6swC7SM0uKy9Pb3TI7NTaVVq5ArN+fErefG /63g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Hzqb7q+hCD/lNO+yAqM3iVZkO0rtWj2v+FJjuf+pTrs=; b=BbQdfG94amoYJIJldgDeEntXJeF0RghnV5jLvj2nEiSnyEGJWjrDBydV9fhVHcRAdF 0ngK/NmBPVSEWfD8SYC58tiYC9ky53Tq2HgmxGxLZ6GYqiPr4ZxGDC/XOCg9VGKAcAs1 MCShs5a/P+e3S11dR9CuOeWaboNeYsfpkpSc7784cCfsH0T0M+1Ganw/xz6SeZsgFm18 fA1asgSggkrhWu1b0RKgSQAVV8Jo4f5vQQQHa1MLYLErTcTUUfR/fC1UEPV5C4VFOliQ ZnVoP+9GOprPysH0EWRkVah0b/nGFectbvKqo+JYsp35Jfp+Xnm9ExTIn6IDsL3cRvNE mVVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n5asBGst; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si156790eds.239.2021.01.11.09.10.31; Mon, 11 Jan 2021 09:10:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n5asBGst; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389254AbhAKRJ1 (ORCPT + 15 others); Mon, 11 Jan 2021 12:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388904AbhAKRJ0 (ORCPT ); Mon, 11 Jan 2021 12:09:26 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C1ACC06179F for ; Mon, 11 Jan 2021 09:08:46 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id i9so541330wrc.4 for ; Mon, 11 Jan 2021 09:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hzqb7q+hCD/lNO+yAqM3iVZkO0rtWj2v+FJjuf+pTrs=; b=n5asBGstU7SJV1zKKQa9RZDbEIGxdI5F/fXnQqUbttw35z188FHKmNqqdmIarHjCcB Z4LULLoxUTuw9C9/z8hQOXB4GpSOZTfeYuWFaDlksFt/+NlJ3ihamr4rx2oUUL9k5pcZ Tka4tmxH+9wvGElhMhMvk6mnJ6oKzlMW8QBmeVhGJ2L1ER37wHa/S63vSHr+M2u+dt4C yCOJ+PtieXF6DURYB7SIS27+4qrz8cMe3FOqL5HPo7Yc0HvbTkftpQLnegCh59AnED3W SX0k6z5yBKehYatWHeKAlZib6KCBUmSLdp3kC2fkDgky+fo0RagBXHYlbJpE/izMD90j 4IKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hzqb7q+hCD/lNO+yAqM3iVZkO0rtWj2v+FJjuf+pTrs=; b=OjlzIbzbmHu9O8qKZEClIvGRfTT+zGubinbz5hckAQpp9OsrttZlt4lmmXLBh/CtuV 9KdvABth1klDKIL3kEof0YmxJjhm2YEy90s9ihuXtp5mjJDPQ6VGQ94dLksQgj+AtMvK PdKMfETaGFarmM9CzsKy25Cv8WrOPNfErKjt/JGKFPCzvj2m8rKJBpMuljRqKg+e+7T6 ihZqqP7zWkwu8ypzMYXKfwIii5p+5M1oqA6Odb/bcAuDwKzVUlju9JKhqzM64p7PKVPg nX0cE0xlZj5K5+HiKG60+vfeIQDlBsBXB8NfFJSx3YydEVSNs1xxARyZ+CK+y5m2osdV IxUg== X-Gm-Message-State: AOAM533LFrBqMID1WxLOe3Li8Q6RVde4y91vejiGTxNYXf1f7oZjk/pd MECwwJrvlxJwqYB9FTsiF6lNNQ== X-Received: by 2002:adf:e552:: with SMTP id z18mr115853wrm.29.1610384924867; Mon, 11 Jan 2021 09:08:44 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id i18sm279364wrp.74.2021.01.11.09.08.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2021 09:08:44 -0800 (PST) From: Loic Poulain To: kuba@kernel.org, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, manivannan.sadhasivam@linaro.org, Loic Poulain Subject: [PATCH net-next 2/3] net: mhi: Get RX queue size from MHI core Date: Mon, 11 Jan 2021 18:16:18 +0100 Message-Id: <1610385379-15140-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610385379-15140-1-git-send-email-loic.poulain@linaro.org> References: <1610385379-15140-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The RX queue size can be determined at runtime by retrieving the number of available transfer descriptors. Signed-off-by: Loic Poulain --- drivers/net/mhi_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c index b7f7f2e..3da820b 100644 --- a/drivers/net/mhi_net.c +++ b/drivers/net/mhi_net.c @@ -257,9 +257,6 @@ static int mhi_net_probe(struct mhi_device *mhi_dev, mhi_netdev->mdev = mhi_dev; SET_NETDEV_DEV(ndev, &mhi_dev->dev); - /* All MHI net channels have 128 ring elements (at least for now) */ - mhi_netdev->rx_queue_sz = 128; - INIT_DELAYED_WORK(&mhi_netdev->rx_refill, mhi_net_rx_refill_work); u64_stats_init(&mhi_netdev->stats.rx_syncp); u64_stats_init(&mhi_netdev->stats.tx_syncp); @@ -269,6 +266,9 @@ static int mhi_net_probe(struct mhi_device *mhi_dev, if (err) goto out_err; + /* Number of transfer descriptors determines size of the queue */ + mhi_netdev->rx_queue_sz = mhi_get_free_desc_count(mhi_dev, DMA_FROM_DEVICE); + err = register_netdev(ndev); if (err) goto out_err; From patchwork Mon Jan 11 17:16:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 360490 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3050825jai; Mon, 11 Jan 2021 09:10:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyaMvlaIUZcg6WpwDWa+GIsr0fHCKRG86WVU3Nl/b2xTOStydBvaR4wms1Ey4HI9ou+Ngn X-Received: by 2002:a05:6402:407:: with SMTP id q7mr278247edv.312.1610385033316; Mon, 11 Jan 2021 09:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610385033; cv=none; d=google.com; s=arc-20160816; b=twLbyW4LhQXSoZHRkybPG9Rox7+P1u7E1qLg/hQz85M7HxQEYamzS4adS+S7Cw0DYs bIIbl+JMPi/UJ8v97zQc0DrGv41zzv6fCgwbkc1FS3g54jHNfGsaGzdYr8xA3Wu7nBab GEg1LFVxhV+qcwYYF3gQf295XHVWsOexyCSPjVussiwsNZVfpBSsryFeO082zfdN50AM euoFPB7s7iJDZEeTf7Itg4w5GdcXq0j2ZIa1+Bs2WyEEv0coXYnoq94oBkDYCcyRVQZC Dh4xYA6lvZqLtH1PSpoltTwMx8DQ5sgJxoCgjRZ7+sGhAtKyJvRFjlnhlXWkTMnF3M7q GAXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=o6VGoAvdQqK2Elm/WglYXBR1TIROqoxTQR1mS7lNbWE=; b=Vkd9gCiJgWhGwNRdHjrGorHCS6yHIndw8bmThwNP0CLVGRRuQ6ZfCKaCfqL7g9HEon /jCclCx3rwnOxF82da2U84zRA2qIve/1YdV447eTn8ZPNV8ks6kDLMEOkSJo8KKw1zj3 s/KKC8VtChhO6/nYC11r4FI9kp5py1iX7IW9+wRWVQaxlwjBWMYKym2tq8agOXW0uGoB ZAV2Meic0PxopRPc+yp6oHvIFxC1+Bzu0hCDiqqAF2/ry7y01jldORy9KGhpCVA48hd8 BxB9tDgPejSWRRCJMs7NDPPa4Ji52nqU0uD++/iizpFO2RGB9sQQ7ZeZ+rSfHO/9wWiF IMjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BWU/SEFP"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si156790eds.239.2021.01.11.09.10.33; Mon, 11 Jan 2021 09:10:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BWU/SEFP"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387940AbhAKRKH (ORCPT + 15 others); Mon, 11 Jan 2021 12:10:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730447AbhAKRKG (ORCPT ); Mon, 11 Jan 2021 12:10:06 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C6B5C0617A3 for ; Mon, 11 Jan 2021 09:08:47 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id 91so521225wrj.7 for ; Mon, 11 Jan 2021 09:08:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o6VGoAvdQqK2Elm/WglYXBR1TIROqoxTQR1mS7lNbWE=; b=BWU/SEFPIck4zioPf/MjB1c3E14E2wQ77QB1wK1rV5VbqIEk+Ywe2+atuulJO+wW3m vtduhuEmz7FHB4XI4TwfxX9DGK0xNlhlseajdNovbabtYHRZ/xa4wrFAMpYeqd4dsIs+ 7YBS2z7TgpuK1IUWIv/SCOiwC3a5LUy5PLhIrTxKSWRjdITeFIWUUlRtcp0IOJdhYAmW s48wrsyGH2/+HSmel+ptHRJbOUj8O1V7bwEvUy/vSuepaqbZzpQYYKVgpO/ILeFWdew+ hYJ2LNpt+CaNd/zor4hI2N5d5ITfaH7YbHu145Hvf9LBP1GlOuE/YGAhhzoOK9Zstw7x JNEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o6VGoAvdQqK2Elm/WglYXBR1TIROqoxTQR1mS7lNbWE=; b=UDCIjNHQ48k6RW5dKrZKAVO8xl93K5GwCd/D6I08RkvHsvkafGSfDhg2tkSieSrRwP sFQZsMLjXcw7SWVSZupfvN2rSRp/+UsxBbSFrmbKmd7uFWHKAXDNW2X6RQTTAP22MBoO 7ddXXf26XJoPQP+cKcdsk78PIAOMXTVlHQ0Kd+y4CN5OnsnxAafJUw65EGQ1aFwlS665 TKyHkWrsM3ztjU5yZ4j1Il3N3adj3URiplvQEtuoLTwmv2d3FGSZCfqDIi26laPTxIlP TqYzTQ+wXkVo1CnQoLa4dsqQLNi5ErBbjJHJrWGKW4XRg4xdT+8kuj+Cgo1sjEj2s94M +iFQ== X-Gm-Message-State: AOAM530kti1Y+vlzqITeACcH/ywvPYAnx3zR+HhgdiT3/BbE9LjGYnwN nGMw3raVE82YySKOWi1Anvi+Bw== X-Received: by 2002:a5d:4ece:: with SMTP id s14mr76324wrv.427.1610384926104; Mon, 11 Jan 2021 09:08:46 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id i18sm279364wrp.74.2021.01.11.09.08.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2021 09:08:45 -0800 (PST) From: Loic Poulain To: kuba@kernel.org, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, manivannan.sadhasivam@linaro.org, Loic Poulain Subject: [PATCH net-next 3/3] net: mhi: Get rid of local rx queue count Date: Mon, 11 Jan 2021 18:16:19 +0100 Message-Id: <1610385379-15140-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610385379-15140-1-git-send-email-loic.poulain@linaro.org> References: <1610385379-15140-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Use the new mhi_get_free_desc_count helper to track queue usage instead of relying on the locally maintained rx_queued count. Signed-off-by: Loic Poulain --- drivers/net/mhi_net.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c index 3da820b..f83562d 100644 --- a/drivers/net/mhi_net.c +++ b/drivers/net/mhi_net.c @@ -25,7 +25,6 @@ struct mhi_net_stats { u64_stats_t tx_bytes; u64_stats_t tx_errors; u64_stats_t tx_dropped; - atomic_t rx_queued; struct u64_stats_sync tx_syncp; struct u64_stats_sync rx_syncp; }; @@ -138,9 +137,9 @@ static void mhi_net_dl_callback(struct mhi_device *mhi_dev, { struct mhi_net_dev *mhi_netdev = dev_get_drvdata(&mhi_dev->dev); struct sk_buff *skb = mhi_res->buf_addr; - int remaining; + int free_desc_count; - remaining = atomic_dec_return(&mhi_netdev->stats.rx_queued); + free_desc_count = mhi_get_free_desc_count(mhi_dev, DMA_FROM_DEVICE); if (unlikely(mhi_res->transaction_status)) { dev_kfree_skb_any(skb); @@ -164,7 +163,7 @@ static void mhi_net_dl_callback(struct mhi_device *mhi_dev, } /* Refill if RX buffers queue becomes low */ - if (remaining <= mhi_netdev->rx_queue_sz / 2) + if (free_desc_count >= mhi_netdev->rx_queue_sz / 2) schedule_delayed_work(&mhi_netdev->rx_refill, 0); } @@ -211,7 +210,7 @@ static void mhi_net_rx_refill_work(struct work_struct *work) struct sk_buff *skb; int err; - while (atomic_read(&mhi_netdev->stats.rx_queued) < mhi_netdev->rx_queue_sz) { + while (!mhi_queue_is_full(mdev, DMA_FROM_DEVICE)) { skb = netdev_alloc_skb(ndev, size); if (unlikely(!skb)) break; @@ -224,8 +223,6 @@ static void mhi_net_rx_refill_work(struct work_struct *work) break; } - atomic_inc(&mhi_netdev->stats.rx_queued); - /* Do not hog the CPU if rx buffers are consumed faster than * queued (unlikely). */ @@ -233,7 +230,7 @@ static void mhi_net_rx_refill_work(struct work_struct *work) } /* If we're still starved of rx buffers, reschedule later */ - if (unlikely(!atomic_read(&mhi_netdev->stats.rx_queued))) + if (mhi_get_free_desc_count(mdev, DMA_FROM_DEVICE) == mhi_netdev->rx_queue_sz) schedule_delayed_work(&mhi_netdev->rx_refill, HZ / 2); }