From patchwork Mon Jul 8 15:47:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168683 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331613ilk; Mon, 8 Jul 2019 08:48:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyw90Zywz3OJbFgaGDc8+PVoKQwgLJIIpiUmG9QRi8kVsLmLgfBnuPaXBrRkz+DEZXfrksb X-Received: by 2002:a17:902:fe14:: with SMTP id g20mr24579224plj.54.1562600898027; Mon, 08 Jul 2019 08:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600898; cv=none; d=google.com; s=arc-20160816; b=TxQHp73B6lMj2aCe/zWCGd3cJgeNwcZsVD7PO8JvDrIqeO5Z+KvZ0yUoPEGQdFfdbF j90IY2pkcMKICvDgMr5GResR1Bct4kqdav872BBDnYrr6Cu0A/kpI5RUqdgN1TTDOrUH QI9Zj6Z0kx51M2C/tVx9VJ3kGjw5SFJecRC7m4T0rfAIr1qxe572ed5loARxSRymjt5t HyhP3ckQ1G56GDoq2qescLgfjxrDaEPeVCqlGIrjDtgeVGZcPF8q0vCjPCdeAbKwp1S+ /2OOpSbo5oQQvIbVavxTeB2BjmHJfLv5yafPF3H1hZcCSS36xt2TUhHDnWml+eScdGyR P1sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=g/3WsBsgQJoCdVtn+mXu+FHko0OYuBudeVV55osqeOk=; b=D56i539aIJ0vGg962q942FHDziwGEwYGtR25DqgkT+iB+jHzw4J89plnkqZ/Ltpo/c 8LDZrG9T9RM7HGlq3MxFqUb+F83KPWpx3Mb0UPh4jmcnL/YQTSMz7NIjpCXwbDtAVRUi 0kCJE80Qld6dUugvHFeh+U0ORQDkjX7oV++/vtzxQ0VahHXA1fEWmmBoOrKPUG/Kz/Rj 13CjAC4LfkB2xpgmN8/O4wXcF5tyykrC0HyCUa+37kIf3g1AgnNwKtc4xGWILQwp4ieg QeSeeA72UnV+eqHL5KAy6ji/JYgfqhDUae5ngm69TSJaiK7CT9JEBMbWDudNZec4Z/ju LszQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7si13060799plr.95.2019.07.08.08.48.17; Mon, 08 Jul 2019 08:48:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403926AbfGHPsQ (ORCPT + 30 others); Mon, 8 Jul 2019 11:48:16 -0400 Received: from foss.arm.com ([217.140.110.172]:52378 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391302AbfGHPrs (ORCPT ); Mon, 8 Jul 2019 11:47:48 -0400 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 75F64CFC; Mon, 8 Jul 2019 08:47:47 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 734513F59C; Mon, 8 Jul 2019 08:47:46 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 05/11] firmware: arm_scmi: Add receive buffer support for notifications Date: Mon, 8 Jul 2019 16:47:24 +0100 Message-Id: <20190708154730.16643-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With all the plumbing in place, let's just add the separate dedicated receive buffers to handle notifications that can arrive asynchronously from the platform firmware to OS. Also add check to see if the platform supports any receive channels before allocating the receive buffers. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 1a7ffd3f8534..eb5a2f271806 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -112,6 +112,7 @@ struct scmi_chan_info { * @version: SCMI revision information containing protocol version, * implementation version and (sub-)vendor identification. * @tx_minfo: Universal Transmit Message management info + * @rx_minfo: Universal Receive Message management info * @tx_idr: IDR object to map protocol id to Tx channel info pointer * @rx_idr: IDR object to map protocol id to Rx channel info pointer * @protocols_imp: List of protocols implemented, currently maximum of @@ -125,6 +126,7 @@ struct scmi_info { struct scmi_revision_info version; struct scmi_handle handle; struct scmi_xfers_info tx_minfo; + struct scmi_xfers_info rx_minfo; struct idr tx_idr; struct idr rx_idr; u8 *protocols_imp; @@ -615,13 +617,13 @@ int scmi_handle_put(const struct scmi_handle *handle) return 0; } -static int scmi_xfer_info_init(struct scmi_info *sinfo) +static int __scmi_xfer_info_init(struct scmi_info *sinfo, bool tx) { int i; struct scmi_xfer *xfer; struct device *dev = sinfo->dev; const struct scmi_desc *desc = sinfo->desc; - struct scmi_xfers_info *info = &sinfo->tx_minfo; + struct scmi_xfers_info *info = tx ? &sinfo->tx_minfo : &sinfo->rx_minfo; /* Pre-allocated messages, no more than what hdr.seq can support */ if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) { @@ -656,6 +658,16 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo) return 0; } +static int scmi_xfer_info_init(struct scmi_info *sinfo) +{ + int ret = __scmi_xfer_info_init(sinfo, true); + + if (!ret && idr_find(&sinfo->rx_idr, SCMI_PROTOCOL_BASE)) + ret = __scmi_xfer_info_init(sinfo, false); + + return ret; +} + static int scmi_mailbox_check(struct device_node *np, int idx) { return of_parse_phandle_with_args(np, "mboxes", "#mbox-cells", @@ -792,10 +804,6 @@ static int scmi_probe(struct platform_device *pdev) info->desc = desc; INIT_LIST_HEAD(&info->node); - ret = scmi_xfer_info_init(info); - if (ret) - return ret; - platform_set_drvdata(pdev, info); idr_init(&info->tx_idr); idr_init(&info->rx_idr); @@ -808,6 +816,10 @@ static int scmi_probe(struct platform_device *pdev) if (ret) return ret; + ret = scmi_xfer_info_init(info); + if (ret) + return ret; + ret = scmi_base_protocol_init(handle); if (ret) { dev_err(dev, "unable to communicate with SCMI(%d)\n", ret);