From patchwork Mon Jan 11 17:14:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 360486 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3048508jai; Mon, 11 Jan 2021 09:07:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIOOYLbXdi8bpyeIZ/wi3NeWg3cJv3rhwlG/f1cIZcFVHamFvqAwj64Z2QSI1gW7gbzwFc X-Received: by 2002:a50:8b66:: with SMTP id l93mr253553edl.384.1610384851341; Mon, 11 Jan 2021 09:07:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610384851; cv=none; d=google.com; s=arc-20160816; b=k/6av+p3CHJENGiOawLmGxNblXRnqP7IUPK+AN5pZQ1J2fh4iCQlu7L0BA0XTRYbNU VMaO73iCmf0VraDNSpk0VPKiDOREFH1V0MP9IXLTp2ZQ384fdPoDY2WcXEBfW3htsBgd Wz6LjdDuQHfgBoEF/wi8I/NnYPLGDLIthELEIlw3skm8sAXPXESJvvN4grD20RZ3SkfC DPuseEG7DjiSJ57I3Gow5hbvpRe3rLG+/5Ns84umThPYV6AxTfhLQ1S4g/UXPSWdhrvr yx3NqeGv9rUFHewySJD5VACiHEmWzqVIJe2HFAxDVMh8I8wgne3BI528p8KzHo4jGJP/ EERw== 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=vwEuGTAg8MCcoWdbFy5MCVq6l6VzLlb1eCQDujHd3RzvKDnI3QFMdCC6mSyjFBivAt D23POtSONaFiB82n4eZBoD56W2N7aVh6RtwGLZlRpJ6Cehxl7ePjcBrqolW3ruMF4M15 M9nxwRyUid1HzwxR9b8aNsPbI8sFLutC++uNNroNAY1gBZRu2Vo5QRAxZKBYYzM1GgOD m4+vz8mqDIaPGCbEwfWPFTbUsOv0V/nIyGNjLHIs9voN5HhYQxwIdD0T8/P7agKNdBEb dWIx8ZMHuNP05gOdNi+YLaBHm9Kyr/kLxNa3i4kTcEPmt084I0mO6EjOpWs/2XJ61rm6 g2pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hc4SWnDg; 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 dt5si11936ejb.639.2021.01.11.09.07.31; Mon, 11 Jan 2021 09:07:31 -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=hc4SWnDg; 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 S2389168AbhAKRHR (ORCPT + 15 others); Mon, 11 Jan 2021 12:07:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389150AbhAKRHR (ORCPT ); Mon, 11 Jan 2021 12:07:17 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E12C061795 for ; Mon, 11 Jan 2021 09:06:36 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id w5so485598wrm.11 for ; Mon, 11 Jan 2021 09:06:36 -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=hc4SWnDgCRkdhFw5rmB6qjPg+Nzrzldtt+7SAGFruq/vYPlVDBPgwI83U21xVtTzsv I95EFlAa4aVxi6k5UO/M0rfISOaAqof9Hr2WaBvXyvKVNgJtckXL8Z6TUH2vVjMvqBB8 gmBqVW618gX5k9a4xXPeWT9F8hkmXh2BkoVeFpES9t0oVqZpH9QNk7VWuwiw11QSmR5i 8bxm8eGMhZTikQg0nPTyRxtnlBFcQH0QH6xghxQHvwLIDNuWagitPrelC5KlydA4QIxD V4ekF6+QSDSOOZOiB0ur0Fq3TqoguNVpAv5HEyOwiBwvLCYfV0dG1bHj2tIt3fxYGEw4 NkjA== 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=hvtY1S1RBFfiNkXtohCxpQh5buQhOvhSWq4GKeijjX6TFyF50QB43n7j7at6eCeFB/ sC//URLcYBRePQkPWwPqQ9WK8H2VbvoMT/Skhk3Ky0+68rUMO3yszaJlwyGAWjOlBHmk JpceFkeSYP4kdIBJJIY/2NaGKntAPkJaTFxUTc1tpjGfVF9voMBrkknKgcn/y1YyFcO6 URvN9chN06cvCxV2n+ig5VrEuqpu63lCN6h1539eKMVb97JKsEMhPn4Y63sPzgcyRRr7 Tf+1I+ILC2TC9n9ysAH4I8M55pOUVLik6bPsnO3o1juuP92x9xMJsSTTl25D3gJfsmNW Wu7Q== X-Gm-Message-State: AOAM530ZB4pejPn3pZVLyR3xD4tVRniy+uHeulnMeIsZJl8UfDq119Rh Cj9shghMQx/B5OK5VJOf1zuLjA== X-Received: by 2002:adf:f78e:: with SMTP id q14mr114826wrp.320.1610384795406; Mon, 11 Jan 2021 09:06:35 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id j59sm336806wrj.13.2021.01.11.09.06.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2021 09:06:35 -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 1/3] bus: mhi: core: Add helper API to return number of free TREs Date: Mon, 11 Jan 2021 18:14:09 +0100 Message-Id: <1610385251-14947-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:14:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 360487 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3048538jai; Mon, 11 Jan 2021 09:07:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkfoSu/N7BrXi2d3wCM5CrshLQhHDarPT6I7OtAKWo12lVdPiNYvfbKQPeJcod9kjNpLn6 X-Received: by 2002:a17:906:3712:: with SMTP id d18mr338488ejc.178.1610384852949; Mon, 11 Jan 2021 09:07:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610384852; cv=none; d=google.com; s=arc-20160816; b=ZmPGXRVPhwS4LOoX9taozQSkClROHUXaL3xoGRlhvJ+VWqzu+LQI01gPofTAdFUMDA gG2OHqxANralqb26DVlI3SZCc//ZcLnxMWr0rzfdXmd3xoeoE0MhwuMFUMxhWcNuJGgK WRZhlz8zPDmF6lNAzNxPI+MMAXlo/NSNkTahl2JZ+FZHsOG/eCDIKDoIsttHJKjIQJtZ eyVNKhwTyyZ02omRqpIBJ0a4Kf5/O9q2I06K8VP00GKL+NV8/k5CXEM/nmRlbFCa+z/E 0KndsGYK/DXPhlE12X1Iq92xMCjLj5h47jVBjL081Kv+cgeg2uAAbePufuKw7roMCd3P qhlg== 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=D7MUURUUcmDZMINVnHDQMADh0J9BnHkBZZZYc5NziihN+g7R494X7SLfHwTRXRlZD+ 6tZwzrVgOYcYQCkCFhwJNm/Pyk62rw5BbhSYwNkvg1yvo/aZ9lr9dcf6Y2I743Muth97 CRID9xFaZxvDHGK4mLFlTYLztgEqBlzXu+vejz79EUWbYU93vfkIiCvCt6SRf83nau3k GQEZuHm9VR0mDWMiAjkWK/ERmKLUryTNMa9Pug7z3JNRKPkC3lPO6hUh6hE1gcxlOC7W KCJW9X9+GnXZyOmx1QeAS3lcF/qbp66IpxWV8O7kIsaAWK05U1dZbxkIDWzycH5CNAPT LvsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SC3B5EkH; 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 dt5si11936ejb.639.2021.01.11.09.07.32; Mon, 11 Jan 2021 09:07: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=SC3B5EkH; 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 S2389182AbhAKRHT (ORCPT + 15 others); Mon, 11 Jan 2021 12:07:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389181AbhAKRHS (ORCPT ); Mon, 11 Jan 2021 12:07:18 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DF61C0617A2 for ; Mon, 11 Jan 2021 09:06:38 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id i9so534148wrc.4 for ; Mon, 11 Jan 2021 09:06:37 -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=SC3B5EkHlLEmR6il3eQiRW6k8K2+HExqspyouE4pNfeCHqvIkh/kboRCjti7DbJqOr gHdmRwjXL6ignsaOqSM5L9098cg9ykY00uFOECGo3+yItxBY6dy/TO3Yx6vUulRlwEGT 08QXLH+CBQJKOuQoVG+2eNzaLS+OtMVYouQU3N0QdzfZgfL7I8GWJXFFd52WqxOGYqWK nz6bxmgY6DlI8krhj3J28GRws7+IAlGV5MP4RTEb/uVtIpgISBCXRpCjJo20JNEt9E0l ZENLIYWHEKsaX3pVZWncUbbHrNKVvz78q1yOGURMuV6FuE8PHfy9uRj+Kq3r59XQHHOt 29Xw== 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=C4jSS8j9isUhtvAG//BBkSWM7YoUgobfx8wvQldUvleuQWJY19X4SfPah2ml+BxhN+ zMFCtnPBeB/2Un542TOgtq2pu/sfy3J3pgcz0A8AhJaKQhaRHXs+4wU5+AanqA6QjN50 g0vVaCgEJ3atg3pqB/lS+myCCNFccyFbvETAhGvYACtnHk7jLhmGvOI116pf4B2FsOEl J16vGjVRczekkuLP5jaQkQp8w3Ue8zNU/YvpcuKgSQbpquZGaq0j3AjvsWbGYsDTRYKP I+c1a90HUIKSDp2kEktnpZn/VXJoDwF22rsvkXEXle10zXaaUepPNSS74pgnh/o2DtJx 1ZGA== X-Gm-Message-State: AOAM533zhMcrWgMtvrt77UB+9zQ3VjkSUcEgjZEVl2Fcuh7B4IyLW4AV l8WfXPcquMqPs8DVX/VSZFx4cA== X-Received: by 2002:adf:fbc5:: with SMTP id d5mr143401wrs.82.1610384796791; Mon, 11 Jan 2021 09:06:36 -0800 (PST) Received: from localhost.localdomain ([88.122.66.28]) by smtp.gmail.com with ESMTPSA id j59sm336806wrj.13.2021.01.11.09.06.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2021 09:06:36 -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 2/3] net: mhi: Get RX queue size from MHI core Date: Mon, 11 Jan 2021 18:14:10 +0100 Message-Id: <1610385251-14947-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610385251-14947-1-git-send-email-loic.poulain@linaro.org> References: <1610385251-14947-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;