Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3905866pxb; Tue, 10 Nov 2020 03:12:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyisLerE+4vLGHKrwAR5EMM4imjmMzG36FFweKx6fGIt12OdBVz9ybE0tMPiTGz/oNbdvyv X-Received: by 2002:a17:906:911:: with SMTP id i17mr19174553ejd.40.1605006757997; Tue, 10 Nov 2020 03:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605006757; cv=none; d=google.com; s=arc-20160816; b=jqWKFSWmR2qGn+AX7DdMjpHobWPUgzbAvnS/y0SBfRs8bc4NGQ62k44gAExu9hvFg/ QE1uUaf3SJn1bCmepp156FIhWDEbzidGrIkcePevhwQ1EPCPjx2K964pKuVhy+0MR+Ou 7mRcE50IgWC92H4UHWxGVlV6e84SpZ1C8I8aJG6NhQEkEOLmc1E36o1b6anxnYWRIxL4 LIJ3h3F/GGoeyQlEEGndWAPmy5T7AO0ErYBottbvGhvg2dEPbZXgSpxc5sTAb66c3iVr 9G3YWi3GqRrTDXgMDc+3b63+vzztrhoUFOp/7dO9yyPQbanTpqbj+yInsgxUB7/ykGpo IS0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DHp9Qr/oN/1M5mUr34BLzHSuue5OEsKuWWvTqbOdF+A=; b=X1q0MvZxz8YLS96u8/4eQMfjorBckv0uTvbf6+HHPHRt37A+GbjR9NODnvgX9eOfmg RISFcVjlAkhINnvUoZ+sr9Ld6NLqKrgGDTr5Y9oNGo42XZXh1MvcfHAzD1bBPjh7RoX1 aYNVMOCNxMn+h3QxH/t+5PePW+bs9SVNh7KantdVCdR7oohlhb9zrFl/v8uDTowNBWaZ jWSZFiM6frzT10hNlFJiwUoODwprzglx3qP12s6sEydHxV8w1y6fKhXK70Hb0NQEVhUu O28JtKQYyFcRhDMjy+pJOc/w4lW1F6OU7kPMtcAxkk2Cl1OE+Q33fZtNvyXTJTzLaOUk d8oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hWytcaBG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 f3si8969333ejc.451.2020.11.10.03.12.14; Tue, 10 Nov 2020 03:12:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=hWytcaBG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1728320AbgKJLIk (ORCPT + 99 others); Tue, 10 Nov 2020 06:08:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgKJLIk (ORCPT ); Tue, 10 Nov 2020 06:08:40 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C014C0613D1 for ; Tue, 10 Nov 2020 03:08:38 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id ay21so12248525edb.2 for ; Tue, 10 Nov 2020 03:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DHp9Qr/oN/1M5mUr34BLzHSuue5OEsKuWWvTqbOdF+A=; b=hWytcaBG2v1uaXdRkR+Qbx2dTeyCzTCzrlK3iu0q5LOdGJx7wPMrvmcG4ERH4k6ndP NsPLXgzLIRNIUE3f1PJTZVfqHrJlNOLrpa5VFIwKC8KwQkNnoQ5v3J76gNsPyKK7GUc2 puf0eXfePu+WpmcKjBHiddRadqi9YyXIDRRsdQETepaGRD/Ul3r0Iv+aa5WyB+DUpLlc u+ZvSFqisy/oZiMKB42EQqZs+MI3ub5kexSKth0bFdTfMSm8rN3B/KVb9FsgVm1PNRz2 V271vXALPZtlXZFAnQ2Za6kbuen8whu7sgd0I+Dz7gIHG/WnrPvMPqM5z+c4SfRkkOvh IOAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DHp9Qr/oN/1M5mUr34BLzHSuue5OEsKuWWvTqbOdF+A=; b=cTMZXYLOkerkSDm8+0plbra9s0zgnz/pDYRdYjQ+9YdYf92K2KxmyP/u9ef3UpZfL9 yXxWi/MH6Rc4fsKcGz2cvWCi6fRaLQSMINyTBxJcYBcB1+dMUYKKSbWViDkRALHRXAfQ z0JwOgNu4+2yjp7LWDnxyeRsCGm1gsyPv9iWa6qY0vNRpRTLX6vo/HZyfWYyk8eUyEKx GrbSRA0p4MSpkD6sEM0+f1PdzF0lzSaSl2iMsm9oO2kfoQk4EsjXkw07/cs47dCFNjxG sWhUA4Y8NfEPBiMCEity40GTzwTYvmTImAlphU+9JGZF7La35qXI7OFUvbddXKIqdFrg svDg== X-Gm-Message-State: AOAM532g+eYDVrAKNT4mBAAV3JLwh9dM/LWSoMBeS5Wj0KJDx4gCvoeP O+mMdyTuz9DuqcRCW2HsZxGv7QQyjD55fTGG2KbXoA== X-Received: by 2002:a05:6402:8cc:: with SMTP id d12mr20476369edz.134.1605006516989; Tue, 10 Nov 2020 03:08:36 -0800 (PST) MIME-Version: 1.0 References: <1604961850-27671-1-git-send-email-bbhatt@codeaurora.org> <1604961850-27671-4-git-send-email-bbhatt@codeaurora.org> In-Reply-To: <1604961850-27671-4-git-send-email-bbhatt@codeaurora.org> From: Loic Poulain Date: Tue, 10 Nov 2020 12:14:27 +0100 Message-ID: Subject: Re: [PATCH v1 3/4] bus: mhi: core: Add support to pause or resume channel data transfers To: Bhaumik Bhatt Cc: Manivannan Sadhasivam , linux-arm-msm , Hemant Kumar , Jeffrey Hugo , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bhaumik, On Mon, 9 Nov 2020 at 23:44, Bhaumik Bhatt wrote: > > Some MHI clients may want to request for pausing or resuming of the > data transfers for their channels. Enable them to do so using the new > APIs provided for the same. > > Signed-off-by: Bhaumik Bhatt > --- > drivers/bus/mhi/core/main.c | 41 +++++++++++++++++++++++++++++++++++++++++ > include/linux/mhi.h | 16 ++++++++++++++++ > 2 files changed, 57 insertions(+) > > diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c > index 1226933..01845c6 100644 > --- a/drivers/bus/mhi/core/main.c > +++ b/drivers/bus/mhi/core/main.c > @@ -1560,6 +1560,47 @@ void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev) > } > EXPORT_SYMBOL_GPL(mhi_unprepare_from_transfer); > > +static int mhi_update_transfer_state(struct mhi_device *mhi_dev, > + enum mhi_ch_state_type to_state) > +{ > + struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; > + struct mhi_chan *mhi_chan; > + int dir, ret; > + > + for (dir = 0; dir < 2; dir++) { > + mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; > + > + if (!mhi_chan) > + continue; > + > + /* > + * Bail out if one of the channels fail as client will reset > + * both upon failure > + */ > + mutex_lock(&mhi_chan->mutex); > + ret = mhi_update_channel_state(mhi_cntrl, mhi_chan, to_state); > + if (ret) { > + mutex_unlock(&mhi_chan->mutex); > + return ret; > + } > + mutex_unlock(&mhi_chan->mutex); > + } > + > + return 0; > +} > + > +int mhi_pause_transfer(struct mhi_device *mhi_dev) > +{ > + return mhi_update_transfer_state(mhi_dev, MHI_CH_STATE_TYPE_STOP); > +} > +EXPORT_SYMBOL_GPL(mhi_pause_transfer); > + > +int mhi_resume_transfer(struct mhi_device *mhi_dev) > +{ > + return mhi_update_transfer_state(mhi_dev, MHI_CH_STATE_TYPE_START); > +} > +EXPORT_SYMBOL_GPL(mhi_resume_transfer); Look like it is stop and start, not pause and resume? TBH maybe we should rework/clarify MHI core and having well-defined states, maybe something like that: 1. When MHI core detects device for a driver, MHI core resets and initializes the channel(s), then call client driver probe function => channel UNKNOWN->DISABLED state => channel DISABLED->ENABLED state 2. When driver is ready for sending data, drivers calls mhi_start_transfer => Channel is ENABLED->RUNNING state 3. Driver performs normal data transfers 4. The driver can suspend/resume transfer, it stops (suspend) the channel, can => Channel is RUNNING->STOP => Channel is STOP->RUNNING ... 5. When device is removed, MHI core reset the channel => channel is (RUNNING|STOP) -> DISABLED Today mhi_prepare_for_transfer performs both ENABLE and RUNNING transition, the idea would be to keep channel enabling/disabling in the MHI core (before/after driver probe/remove) and channel start/stop managed by the client driver. Regards, Loic