From patchwork Fri Jul 26 13:51:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 169841 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp89881ilk; Fri, 26 Jul 2019 06:52:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzw+c1lW32rkLMCI7sD8Ey27MBGGDAwdrW8KDGbg9roQYV6vLyCnH6SoXKRhyTMNeEfrETI X-Received: by 2002:aa7:83ce:: with SMTP id j14mr22037276pfn.55.1564149144268; Fri, 26 Jul 2019 06:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564149144; cv=none; d=google.com; s=arc-20160816; b=YUyujuZ1eTwgyBaBl3NRGQ9rDyqYpwOeVgy9J5jpyh8kLEU5Z47r62kw0sf2Y+FBEK 13J82viKjsPn9oIa1ErHYzyMwFiCzSfj2t89cqPotDNt62+FhaEaPEYpwywwZ7VE71sM njrIluMSPRMvsGtapCl4jLhIxQ5oxsA4RCirTv32REmUMgwc5SCDVBPRj6tKPhxXMxGl QawhBjOgAg4tgtEUsl0JxeuktebF5pie3s5+GDGSczIe8FK6pzLVoqGjM2RgJ5v1dREP BUq4g8UvpH9mXyPE0sknV78yJCAH2iFob2GP0RSmJsd6qAVotuD99JT5l9PFF7CS5LSG 0hxA== 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=HFj9hozLuzzLIu5/W65WJPClKiMcoXYFNgTXss+AhaI=; b=RMv1kcxMjvGG3KPPQI8eEgdUxzxs86ptj4JXEEluS7+8TuH0iyYeMX513V3CMrirrv DjH4o/IMsC4bcwlO1L6q1hcTx37ctlpPXF3vL169ovhbPAI0yFiHWvsawE988QKFVegn MSxKoNl7/6TBKUujXWHEzkVSAFfouGfQodYgH8qAqOdL3+GXbIK3doWe+V68/cW4iF/C qmTv6qUFuoty4EoB/Bw5JXM+mup7HSg3pLheJtXufTxWh8CgbN2DR90qXlE0Otga1+hn 98Q5g7VVc6WXnpDAsBXo8tVqdhSr19rHUmirsKoloJPafpvqXocSQIYdF7uyqT+0D5+n u+og== 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 j187si20848394pge.591.2019.07.26.06.52.23; Fri, 26 Jul 2019 06:52:24 -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 S2387910AbfGZNv6 (ORCPT + 29 others); Fri, 26 Jul 2019 09:51:58 -0400 Received: from foss.arm.com ([217.140.110.172]:44460 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728274AbfGZNvw (ORCPT ); Fri, 26 Jul 2019 09:51:52 -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 53AB1337; Fri, 26 Jul 2019 06:51:51 -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 19ABE3F694; Fri, 26 Jul 2019 06:51:49 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Peng Fan , linux-kernel@vger.kernel.org, Bo Zhang , Jim Quinlan , Volodymyr Babchuk , Gaku Inami , Etienne Carriere Subject: [PATCH v2 03/10] firmware: arm_scmi: Add receive channel support for notifications Date: Fri, 26 Jul 2019 14:51:31 +0100 Message-Id: <20190726135138.9858-4-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726135138.9858-1-sudeep.holla@arm.com> References: <20190726135138.9858-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 scmi_mbox_chan_setup enabled to identify and setup both Tx and Rx, let's consolidate setting up of both the channels under the function scmi_mbox_txrx_setup. Since some platforms may opt not to support notifications or delayed response, they may not need support for Rx. Hence Rx is optional and failure of setting one up is not considered fatal. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 336673afd6ef..5a8c015bf233 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -113,6 +113,7 @@ struct scmi_chan_info { * implementation version and (sub-)vendor identification. * @minfo: Message 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 * MAX_PROTOCOLS_IMP elements allocated by the base protocol * @node: List head @@ -125,6 +126,7 @@ struct scmi_info { struct scmi_handle handle; struct scmi_xfers_info minfo; struct idr tx_idr; + struct idr rx_idr; u8 *protocols_imp; struct list_head node; int users; @@ -655,13 +657,17 @@ static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, struct device_node *shmem, *np = dev->of_node; struct scmi_chan_info *cinfo; struct mbox_client *cl; + struct idr *idr; const char *desc = tx ? "Tx" : "Rx"; /* Transmit channel is first entry i.e. index 0 */ idx = tx ? 0 : 1; + idr = tx ? &info->tx_idr : &info->rx_idr; if (scmi_mailbox_check(np, idx)) { - cinfo = idr_find(&info->tx_idr, SCMI_PROTOCOL_BASE); + cinfo = idr_find(idr, SCMI_PROTOCOL_BASE); + if (unlikely(!cinfo)) /* Possible only if platform has no Rx */ + return -EINVAL; goto idr_alloc; } @@ -703,7 +709,7 @@ static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, } idr_alloc: - ret = idr_alloc(&info->tx_idr, cinfo, prot_id, prot_id + 1, GFP_KERNEL); + ret = idr_alloc(idr, cinfo, prot_id, prot_id + 1, GFP_KERNEL); if (ret != prot_id) { dev_err(dev, "unable to allocate SCMI idr slot err %d\n", ret); return ret; @@ -713,6 +719,17 @@ static int scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, return 0; } +static inline int +scmi_mbox_txrx_setup(struct scmi_info *info, struct device *dev, int prot_id) +{ + int ret = scmi_mbox_chan_setup(info, dev, prot_id, true); + + if (!ret) /* Rx is optional, hence no error check */ + scmi_mbox_chan_setup(info, dev, prot_id, false); + + return ret; +} + static inline void scmi_create_protocol_device(struct device_node *np, struct scmi_info *info, int prot_id) @@ -726,7 +743,7 @@ scmi_create_protocol_device(struct device_node *np, struct scmi_info *info, return; } - if (scmi_mbox_chan_setup(info, &sdev->dev, prot_id, true)) { + if (scmi_mbox_txrx_setup(info, &sdev->dev, prot_id)) { dev_err(&sdev->dev, "failed to setup transport\n"); scmi_device_destroy(sdev); return; @@ -769,12 +786,13 @@ static int scmi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); idr_init(&info->tx_idr); + idr_init(&info->rx_idr); handle = &info->handle; handle->dev = info->dev; handle->version = &info->version; - ret = scmi_mbox_chan_setup(info, dev, SCMI_PROTOCOL_BASE, true); + ret = scmi_mbox_txrx_setup(info, dev, SCMI_PROTOCOL_BASE); if (ret) return ret; @@ -844,6 +862,10 @@ static int scmi_remove(struct platform_device *pdev) ret = idr_for_each(idr, scmi_mbox_free_channel, idr); idr_destroy(&info->tx_idr); + idr = &info->rx_idr; + ret = idr_for_each(idr, scmi_mbox_free_channel, idr); + idr_destroy(&info->rx_idr); + return ret; }