From patchwork Mon Jul 8 15:47:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168677 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331129ilk; Mon, 8 Jul 2019 08:47:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAS7JgVo31L1ZIoljIpokMBKva60dQYXprDhtDoGJz+bPVUjyctijOmzyLYul2VL+fb3qJ X-Received: by 2002:a63:4c14:: with SMTP id z20mr24662016pga.360.1562600870776; Mon, 08 Jul 2019 08:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600870; cv=none; d=google.com; s=arc-20160816; b=emWq5Sg9br54cQbixJsYg9hyLOHVP2TAPxJRhzt4X5nUNknU8UPgRrEcQSWr7QINWe 2rYK5qoouxy7lYaBIJnUnJ3egxxiAELScMD0hcJULYrYFauo9iAxGGq/kExB30VmM6dp qAYNV8hL+QZ8HkidHe5xOeDjtaxbdg0sC/nh8BuUbCbJmp8/eG04Yld2KLmO8zxT1DXt y9BYrVh3hcrcXp1tAHy9RoRGrkjm7YQar2QMU/iEFPk5/w1ZSyUmuJXe7g19G/taq7Na faMbB7rCEp6cxwCRwKzzaEGnXNIKUfARsXQQqjavZzKfUWDmUfATCqRn7xDYAWBZyRd1 qdvA== 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=FeopbYsfh9LsOs0qP3rx+WAYv8Qbig4VwCedicEqRTg=; b=znXkT/LAfiP9B98ew/IHs7kd1CBwTSmU1juD2w0Z3XPMIXfu1XbVOA3u8MzLBfhD0q VVG6pE4C8UUZ87ZDwhWvf9LhPoVd1hGCWBuc3P7RwsGryxxwV3Co8eMQmQfaQ6BzjXkE fF/BMXeA8UXn2Y3w5WxJgMxRQ6AVnTjOD18Ttyg/PpxWbmp1Qy+5VLSEacCwbU+maCES dRE0AXZqoTJot1UnxBZZ9faJcfTW11x+h5mERKW1GlaSeGZQ8X/2wLM9GYUIMp//KFTG tlpgROKv4ea0qFSC26r9T1GfPxmuOCErReCp5SqVd0NY20SUHMULQ1jhAxl1kpydi6aB KrmA== 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 f74si19378230pfa.57.2019.07.08.08.47.50; Mon, 08 Jul 2019 08:47:50 -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 S2391322AbfGHPrt (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:49 -0400 Received: from foss.arm.com ([217.140.110.172]:52352 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391283AbfGHPrp (ORCPT ); Mon, 8 Jul 2019 11:47:45 -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 08E25360; Mon, 8 Jul 2019 08:47:45 -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 061383F59C; Mon, 8 Jul 2019 08:47:43 -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 03/11] firmware: arm_scmi: Add receive channel support for notifications Date: Mon, 8 Jul 2019 16:47:22 +0100 Message-Id: <20190708154730.16643-4-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 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 f7fb6d5bfc64..e9b762348eff 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,12 +657,16 @@ 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; /* 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; } @@ -701,7 +707,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; @@ -711,6 +717,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) @@ -724,7 +741,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; @@ -767,12 +784,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; @@ -842,6 +860,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; }