From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72925C4338F for ; Wed, 28 Jul 2021 17:43:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3350C61040 for ; Wed, 28 Jul 2021 17:43:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3350C61040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5qzQe8Oo0HCiYfVa3p7xYZG2E5x6Zp64FSrIF6FIdTM=; b=MuwQe+LE8+ShAX bByd/dIi52Q38gBNicF+6afnwW6uGQV9gkuq+m2YU6CTQoswzo/je9t7J1qvKkBJcUcdsTXjTMqlz CsVbhK3Wqf3aH+EJut81PrkDzHB6SjjijxX8UHFZ1pOQpEVPZvb81VTpFsIkT+KW1ORE2qZLuyNjm LymHxW7W8ha/rhUXtUNeW00NOLQu7jVWYJPCV5OvapvXg1Cn0IQeNi9ORZxh4SygeOhaNSaGtEUFU vtAIvJt/PI8+vbUVNDxWLY1U37n2xCL2ODhzEJN/pu2zgCiKDf9iphqK2TOcW0YLLviLhBI/yfCH9 MBPQ8pE6BSv7b6DMsj8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8nYv-001sFo-Jj; Wed, 28 Jul 2021 17:41:45 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8nYq-001sEq-UW for linux-arm-kernel@lists.infradead.org; Wed, 28 Jul 2021 17:41:42 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 109B36D; Wed, 28 Jul 2021 10:41:38 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D29A53F66F; Wed, 28 Jul 2021 10:41:34 -0700 (PDT) Date: Wed, 28 Jul 2021 18:41:32 +0100 From: Cristian Marussi To: Sudeep Holla Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, virtualization@lists.linux-foundation.org, virtio-dev@lists.oasis-open.org, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, etienne.carriere@linaro.org, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, igor.skalkin@opensynergy.com, peter.hilber@opensynergy.com, alex.bennee@linaro.org, jean-philippe@linaro.org, mikhail.golubev@opensynergy.com, anton.yakovlev@opensynergy.com, Vasyl.Vavrychuk@opensynergy.com, Andriy.Tryshnivskyy@opensynergy.com Subject: Re: [PATCH v6 10/17] firmware: arm_scmi: Make polling mode optional Message-ID: <20210728174132.GM6592@e120937-lin> References: <20210712141833.6628-1-cristian.marussi@arm.com> <20210712141833.6628-11-cristian.marussi@arm.com> <20210728143418.5lton6l7t2oa6rtz@bogus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210728143418.5lton6l7t2oa6rtz@bogus> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210728_104141_122730_5034E01A X-CRM114-Status: GOOD ( 29.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jul 28, 2021 at 03:34:18PM +0100, Sudeep Holla wrote: > On Mon, Jul 12, 2021 at 03:18:26PM +0100, Cristian Marussi wrote: > > Add a check for the presence of .poll_done transport operation so that > > transports that do not need to support polling mode have no need to provide > > a dummy .poll_done callback either and polling mode can be disabled in the > > SCMI core for that tranport. > > > > Signed-off-by: Cristian Marussi > > --- Hi, > > drivers/firmware/arm_scmi/driver.c | 43 ++++++++++++++++++------------ > > 1 file changed, 26 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c > > index a952b6527b8a..4183d25c9289 100644 > > --- a/drivers/firmware/arm_scmi/driver.c > > +++ b/drivers/firmware/arm_scmi/driver.c > > @@ -777,25 +777,34 @@ static int do_xfer(const struct scmi_protocol_handle *ph, > > } > > > > if (xfer->hdr.poll_completion) { > > - ktime_t stop = ktime_add_ns(ktime_get(), SCMI_MAX_POLL_TO_NS); > > - > > - spin_until_cond(scmi_xfer_done_no_timeout(cinfo, xfer, stop)); > > - > > - if (ktime_before(ktime_get(), stop)) { > > - unsigned long flags; > > - > > - /* > > - * Do not fetch_response if an out-of-order delayed > > - * response is being processed. > > - */ > > - spin_lock_irqsave(&xfer->lock, flags); > > - if (xfer->state == SCMI_XFER_SENT_OK) { > > - info->desc->ops->fetch_response(cinfo, xfer); > > - xfer->state = SCMI_XFER_RESP_OK; > > + if (info->desc->ops->poll_done) { > > + ktime_t stop = ktime_add_ns(ktime_get(), > > + SCMI_MAX_POLL_TO_NS); > > + > > + spin_until_cond(scmi_xfer_done_no_timeout(cinfo, xfer, > > + stop)); > > + > > + if (ktime_before(ktime_get(), stop)) { > > + unsigned long flags; > > + > > + /* > > + * Do not fetch_response if an out-of-order delayed > > + * response is being processed. > > + */ > > + spin_lock_irqsave(&xfer->lock, flags); > > + if (xfer->state == SCMI_XFER_SENT_OK) { > > + info->desc->ops->fetch_response(cinfo, > > + xfer); > > + xfer->state = SCMI_XFER_RESP_OK; > > + } > > + spin_unlock_irqrestore(&xfer->lock, flags); > > + } else { > > + ret = -ETIMEDOUT; > > } > > - spin_unlock_irqrestore(&xfer->lock, flags); > > } else { > > - ret = -ETIMEDOUT; > > + dev_warn_once(dev, > > + "Polling mode is not supported by transport.\n"); > > + ret = EINVAL; > > Can't we just return this error as early as possible if the user isn't > expected to use polling with this transport ? That would simplify the patch > (as most of it is due to indentation which can go away) as you need not > check it later ? > Yes, indeed at first it was something like if (xfer->hdr.poll_completion && !info->desc->ops->poll_done) return -EINVAL; at the very beginning of do_xfer(), even before attempting to send anything...and I liked much more but then I thought I would have run such if-test for each and every command do_xfer() attempted...but maybe it's just irrelevant and instead much more tidy if done as above. I'll fix it as above. Thanks, Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel