From patchwork Thu Jun 24 20:28:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 466366 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp788430jao; Thu, 24 Jun 2021 13:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweR8jdfYazmy2Dm5Ob4xEuE4/EA44hAOndjyxxfI1LWqCKG9CBKLs+9CLwkS4KV3WRpEhD X-Received: by 2002:a92:1806:: with SMTP id 6mr4796372ily.268.1624565923554; Thu, 24 Jun 2021 13:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624565923; cv=none; d=google.com; s=arc-20160816; b=e7k72yfFqsUKH1qP0DrCuxH4GC4ydWSKhWjMlDQ85cnnbgupUTokN29N8gaiBjqn8S /q2bPdDrk/F+gSopuL5H5sBwnLCpXpEYHdyvwxLxNApqH4KtGJgoPfKMLS5lSBY/A4T9 Po+KlFowsvn3HzrPDhts7wp0B/JDjOEs2EM935L22pocz3WtIBaGclkm0VBW5fXHJL8m wkVo1ij86FycCFZPnUZ9YbbpiwP/EgRVa/gvN8X/FvLAmxxFv8IR0ZTBek1vYStkjS3z BJR3Zh2VqieJg+M0Gyzym+25wSYrR4ypQYcRUO636QZf62aJo6OKLMZob1SwWcfi64c5 tgLQ== 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=9h1y4lq+lXshFx9dO+GKWapA5gp0BiWloqvXzuUbLDU=; b=mnwA1YA+vWtYEwnZgrxUFfnzCRzuLjUcxfH3+9K8phsQvw3BC4Omw7UIm4M5a3xpA6 Kd7cTx3D/qH6OZE7bwT1I1M+cwJd3lB2X0mTcKQPiUqagJBwLi4o9yFKP2AAJxZvbkRT rPT9Mdwqrcy+moyOLZ9t/pO4cRQBDBsFeCL62l1P3ysVGZAsW5MCjbAhQpjKKyjyTU0I xLUccOq6BYD1827F89igbQtm9ozaBOAWVGoi1FkV1YTEGlYJZsS1QOToY3B7MNUGxvcL QEmyKn1PIuanJ/4xCRLz4oolzt7j6/jAGB4DAEgVAik5XC8hmF7KhENqkG2Cl2flXIFb 4h6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kct5XZub; 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 g6si3406264iow.9.2021.06.24.13.18.42; Thu, 24 Jun 2021 13:18:43 -0700 (PDT) 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=Kct5XZub; 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 S232560AbhFXUVB (ORCPT + 17 others); Thu, 24 Jun 2021 16:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232475AbhFXUVA (ORCPT ); Thu, 24 Jun 2021 16:21:00 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E10EEC061574 for ; Thu, 24 Jun 2021 13:18:38 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id a5-20020a7bc1c50000b02901e3bbe0939bso4447906wmj.0 for ; Thu, 24 Jun 2021 13:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9h1y4lq+lXshFx9dO+GKWapA5gp0BiWloqvXzuUbLDU=; b=Kct5XZubu15LTKBaapQipiKFFZpLYJKl+v7hh7fAmS/e5JNbC8CnuWlTqJJdp62ji3 L4auJHhgVxK8PJNuJUtBonlvRL3cmNlQNTS/XSQA7iq+XOc/V2uZY1cay3/2tAk8pyOF XDHudg66tutW+xdzj27FMiG6Q1mMu+HEASO2NQKFiLLUKYk/4lRKvoXcJSADkfHvIBmZ EtKJpXb5msXJ6p1N/vOU23tSVs3rh11Rp6QHm5Dy197ryWJ2iypWe60+pJQ8k4sg1WG2 oIJpvyaqs+f8Xth/fsJHod0K0iE2hdPiYElCUyMLEvgtnTfp1glrnGHYdNZxVCACNleJ C28Q== 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=9h1y4lq+lXshFx9dO+GKWapA5gp0BiWloqvXzuUbLDU=; b=kvCVadJsZlzySsjEYuG1xC2bvwQfJM60rTmXLxjECVXZ7yrRmyjtNihni2UCuJUTJd HG7C3V3uaoZntQ2mAHN/TMCsmvSqxVkpAojcOp8A0NW/6Yb2J+kZ/9Fl7XkSoyoAtwps Eu5XLsYUlTBsfCoh9O7V77DijVO5c9Aw4eb11c17oRCsqitWo6HL+9sMKS1ovAqGlhNh 2O8G/NgoHxJ2qO6XMyahZAJNxBKlOz4yy9fuMpdsA5rjt6BUXACZ4Dk1a2am7+Nbj9Gc nPBJCxKpaU4yp4SYaev4JM4IvPBD1lD20BzBkuuSF6sGLT37VSbU4Ulw0Yk6tI3hE7j5 RLpA== X-Gm-Message-State: AOAM531sjl9C1adidavKkxRAzjLaEle5jeq8XV5gGctNYaGeEObac4+3 hafGHkEA3ojhl/V6H7f7s5tNmw== X-Received: by 2002:a7b:cbc5:: with SMTP id n5mr6462004wmi.148.1624565917324; Thu, 24 Jun 2021 13:18:37 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:82c:5f0:78f0:ea41:c81:639b]) by smtp.gmail.com with ESMTPSA id n65sm9297821wme.21.2021.06.24.13.18.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jun 2021 13:18:36 -0700 (PDT) From: Loic Poulain To: mani@kernel.org Cc: linux-arm-msm@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH v3] bus: mhi: Add inbound buffers allocation flag Date: Thu, 24 Jun 2021 22:28:40 +0200 Message-Id: <1624566520-20406-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 Currently, the MHI controller driver defines which channels should have their inbound buffers allocated and queued. But ideally, this is something that should be decided by the MHI device driver instead, which actually deals with that buffers. Add a flag parameter to mhi_prepare_for_transfer allowing to specify if buffers have to be allocated and queued by the MHI stack. Keep auto_queue flag for now, but should be removed at some point. Signed-off-by: Loic Poulain Tested-by: Bhaumik Bhatt Reviewed-by: Bhaumik Bhatt Reviewed-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam Acked-by: Jakub Kicinski Link: https://lore.kernel.org/r/1621603519-16773-1-git-send-email-loic.poulain@linaro.org Signed-off-by: Manivannan Sadhasivam --- v2: Update API in mhi_wwan_ctrl driver v3: Do not use enum for flags drivers/bus/mhi/core/internal.h | 2 +- drivers/bus/mhi/core/main.c | 9 ++++++--- drivers/net/mhi/net.c | 2 +- drivers/net/wwan/mhi_wwan_ctrl.c | 2 +- include/linux/mhi.h | 7 ++++++- net/qrtr/mhi.c | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index 5b9ea66..bc239a1 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -682,7 +682,7 @@ void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl, struct image_info *img_info); void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl); int mhi_prepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); + struct mhi_chan *mhi_chan, unsigned int flags); int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan); void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl, diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 050381d..594fe37 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -1433,7 +1433,7 @@ static void mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, } int mhi_prepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) + struct mhi_chan *mhi_chan, unsigned int flags) { int ret = 0; struct device *dev = &mhi_chan->mhi_dev->dev; @@ -1458,6 +1458,9 @@ int mhi_prepare_channel(struct mhi_controller *mhi_cntrl, if (ret) goto error_pm_state; + if (mhi_chan->dir == DMA_FROM_DEVICE) + mhi_chan->pre_alloc = !!(flags & MHI_CH_INBOUND_ALLOC_BUFS); + /* Pre-allocate buffer for xfer ring */ if (mhi_chan->pre_alloc) { int nr_el = get_nr_avail_ring_elements(mhi_cntrl, @@ -1613,7 +1616,7 @@ void mhi_reset_chan(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan) } /* Move channel to start state */ -int mhi_prepare_for_transfer(struct mhi_device *mhi_dev) +int mhi_prepare_for_transfer(struct mhi_device *mhi_dev, unsigned int flags) { int ret, dir; struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; @@ -1624,7 +1627,7 @@ int mhi_prepare_for_transfer(struct mhi_device *mhi_dev) if (!mhi_chan) continue; - ret = mhi_prepare_channel(mhi_cntrl, mhi_chan); + ret = mhi_prepare_channel(mhi_cntrl, mhi_chan, flags); if (ret) goto error_open_chan; } diff --git a/drivers/net/mhi/net.c b/drivers/net/mhi/net.c index 0d8293a..774e329 100644 --- a/drivers/net/mhi/net.c +++ b/drivers/net/mhi/net.c @@ -327,7 +327,7 @@ static int mhi_net_probe(struct mhi_device *mhi_dev, u64_stats_init(&mhi_netdev->stats.tx_syncp); /* Start MHI channels */ - err = mhi_prepare_for_transfer(mhi_dev); + err = mhi_prepare_for_transfer(mhi_dev, 0); if (err) goto out_err; diff --git a/drivers/net/wwan/mhi_wwan_ctrl.c b/drivers/net/wwan/mhi_wwan_ctrl.c index 1bc6b69..1e18420 100644 --- a/drivers/net/wwan/mhi_wwan_ctrl.c +++ b/drivers/net/wwan/mhi_wwan_ctrl.c @@ -110,7 +110,7 @@ static int mhi_wwan_ctrl_start(struct wwan_port *port) int ret; /* Start mhi device's channel(s) */ - ret = mhi_prepare_for_transfer(mhiwwan->mhi_dev); + ret = mhi_prepare_for_transfer(mhiwwan->mhi_dev, 0); if (ret) return ret; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 5eb626a..eed949c 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -719,8 +719,13 @@ void mhi_device_put(struct mhi_device *mhi_dev); * host and device execution environments match and * channels are in a DISABLED state. * @mhi_dev: Device associated with the channels + * @flags: MHI channel flags */ -int mhi_prepare_for_transfer(struct mhi_device *mhi_dev); +int mhi_prepare_for_transfer(struct mhi_device *mhi_dev, + unsigned int flags); + +/* Automatically allocate and queue inbound buffers */ +#define MHI_CH_INBOUND_ALLOC_BUFS BIT(0) /** * mhi_unprepare_from_transfer - Reset UL and DL channels for data transfer. diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index fa61167..29b4fa3 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -79,7 +79,7 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, int rc; /* start channels */ - rc = mhi_prepare_for_transfer(mhi_dev); + rc = mhi_prepare_for_transfer(mhi_dev, MHI_CH_INBOUND_ALLOC_BUFS); if (rc) return rc;