Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6459579rwb; Wed, 18 Jan 2023 05:34:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXtTshT+Myjd1XVdh/IjUt45M9YKh3TZRd30ixbpuMOPv2g+OO/ZmMk4NJeAfOFfBguEMMOe X-Received: by 2002:aa7:cf0a:0:b0:49d:a87f:ba70 with SMTP id a10-20020aa7cf0a000000b0049da87fba70mr6753314edy.38.1674048892054; Wed, 18 Jan 2023 05:34:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674048892; cv=none; d=google.com; s=arc-20160816; b=cNO73y/NH5CVr3khGDeDJIKeuog7M8MJMl2Ev7Jf+ZgUPjY5RDUAmr7SPYnLNUL8JX yHvM7px2BdrI3mr99hlKsP2LA8Xse9fesohPvaDxdn6APLVJyGreJj3NYaRVtFNQbdzn VjOCf/wgpbZ2y2SNa+aX0R4HJlh2ALzCX4Ixf3UPLbNkJAMcMw1fGPCR4d0i9fYiqs0L aYytnTyy3gkOAw6EX+kkw6cnAv0GjzP3bqNwYAGd/hlwUpRv70NrTvGNeenWh879rKP8 41nsjoapac0C5w8HEPzLhgwzprb8+HRwwjwAjD/z2FrgdNpTh0S8Dkot1+QCIpqRXe1F KgNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ooKOy4FojwJy4raDpAIeE1qcplT9irYchkp7x36dGX0=; b=Vd0Us+6y2D30e+upy0vFW93wUGklwjmI1c2g+WvjncJDya7A+aZpZkuFG8re8OD4Qz IVuG4HD/+bFaVngrBAJJOTZ31tQcNXAfWpdZjCQWKFJxCdNZ54Hv+zdon+ImxvAS3dCN CVGOBDBnAJYVI60Oi6wBBQT9IaQdu6oTDZuLU0qpyqi6F/AdXqjY2BiePZxLDzfgkW6P 7R2wiAdgutoaKn7SxiEUnGY92g5VS4IPvecP+6ruczNVHczxJBDFt888vXUt74K28fZa IR28zu7DjXQZxOv4QfYBYyQe0ljyqlgbJG0nodmXZYipB+rx4I6uMN6Fp6g3Wx5kh4Vv LcvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ww2-20020a170907084200b007c1946d08b3si27227246ejb.989.2023.01.18.05.34.40; Wed, 18 Jan 2023 05:34:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231239AbjARMxB (ORCPT + 45 others); Wed, 18 Jan 2023 07:53:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbjARMvy (ORCPT ); Wed, 18 Jan 2023 07:51:54 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0E4FA43470 for ; Wed, 18 Jan 2023 04:15:09 -0800 (PST) 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 01CEB16F8; Wed, 18 Jan 2023 04:15:51 -0800 (PST) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C76E03F71A; Wed, 18 Jan 2023 04:15:06 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, etienne.carriere@linaro.org, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, wleavitt@marvell.com, peter.hilber@opensynergy.com, nicola.mazzucato@arm.com, tarek.el-sherbiny@arm.com, quic_kshivnan@quicinc.com, cristian.marussi@arm.com Subject: [PATCH v8 03/17] firmware: arm_scmi: Refactor scmi_wait_for_message_response Date: Wed, 18 Jan 2023 12:14:12 +0000 Message-Id: <20230118121426.492864-4-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118121426.492864-1-cristian.marussi@arm.com> References: <20230118121426.492864-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor scmi_wait_for_message_response() to use a internal helper to carry out its main duties; while doing that make it accept directly an scmi_desc parameter to interact with the configured transport. No functional change. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/driver.c | 57 +++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index d7f21e81bd11..ce204a77c7f3 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -891,36 +891,18 @@ static bool scmi_xfer_done_no_timeout(struct scmi_chan_info *cinfo, ktime_after(ktime_get(), stop); } -/** - * scmi_wait_for_message_response - An helper to group all the possible ways of - * waiting for a synchronous message response. - * - * @cinfo: SCMI channel info - * @xfer: Reference to the transfer being waited for. - * - * Chooses waiting strategy (sleep-waiting vs busy-waiting) depending on - * configuration flags like xfer->hdr.poll_completion. - * - * Return: 0 on Success, error otherwise. - */ -static int scmi_wait_for_message_response(struct scmi_chan_info *cinfo, - struct scmi_xfer *xfer) +static int scmi_wait_for_reply(struct device *dev, const struct scmi_desc *desc, + struct scmi_chan_info *cinfo, + struct scmi_xfer *xfer, unsigned int timeout_ms) { - struct scmi_info *info = handle_to_scmi_info(cinfo->handle); - struct device *dev = info->dev; - int ret = 0, timeout_ms = info->desc->max_rx_timeout_ms; - - trace_scmi_xfer_response_wait(xfer->transfer_id, xfer->hdr.id, - xfer->hdr.protocol_id, xfer->hdr.seq, - timeout_ms, - xfer->hdr.poll_completion); + int ret = 0; if (xfer->hdr.poll_completion) { /* * Real polling is needed only if transport has NOT declared * itself to support synchronous commands replies. */ - if (!info->desc->sync_cmds_completed_on_ret) { + if (!desc->sync_cmds_completed_on_ret) { /* * Poll on xfer using transport provided .poll_done(); * assumes no completion interrupt was available. @@ -946,7 +928,7 @@ static int scmi_wait_for_message_response(struct scmi_chan_info *cinfo, */ spin_lock_irqsave(&xfer->lock, flags); if (xfer->state == SCMI_XFER_SENT_OK) { - info->desc->ops->fetch_response(cinfo, xfer); + desc->ops->fetch_response(cinfo, xfer); xfer->state = SCMI_XFER_RESP_OK; } spin_unlock_irqrestore(&xfer->lock, flags); @@ -970,6 +952,33 @@ static int scmi_wait_for_message_response(struct scmi_chan_info *cinfo, return ret; } +/** + * scmi_wait_for_message_response - An helper to group all the possible ways of + * waiting for a synchronous message response. + * + * @cinfo: SCMI channel info + * @xfer: Reference to the transfer being waited for. + * + * Chooses waiting strategy (sleep-waiting vs busy-waiting) depending on + * configuration flags like xfer->hdr.poll_completion. + * + * Return: 0 on Success, error otherwise. + */ +static int scmi_wait_for_message_response(struct scmi_chan_info *cinfo, + struct scmi_xfer *xfer) +{ + struct scmi_info *info = handle_to_scmi_info(cinfo->handle); + struct device *dev = info->dev; + + trace_scmi_xfer_response_wait(xfer->transfer_id, xfer->hdr.id, + xfer->hdr.protocol_id, xfer->hdr.seq, + info->desc->max_rx_timeout_ms, + xfer->hdr.poll_completion); + + return scmi_wait_for_reply(dev, info->desc, cinfo, xfer, + info->desc->max_rx_timeout_ms); +} + /** * do_xfer() - Do one transfer * -- 2.34.1