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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 3FA73C433E9 for ; Tue, 22 Dec 2020 14:57:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 F1924229CA for ; Tue, 22 Dec 2020 14:57:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1924229CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Aoa5NSRBnQPSmi31lLHrL0OZvhTBexsLnUZJbBB1ZH8=; b=o8drf+sVib7sduHltGg3GF95L5 yf11TKSECPXwco612DaapyjvUR4kt/LgypZ0gUusDWtJV+ZT1l0kj4/qbzVPj8PCtoCZZK0N0PvAB L8X1KPPnBnAlzx+m/KNs1jC1ItkmQ91kPsmJYY8taGESK8LeA2uV2LgwOaWNBwAShULuEYmoQwMU4 EOstPbKbkp9bX5a6PXRfjFGRnQ3Wp/VI32PUN53CGDKQOQVxLATAcj2BCG0YSH+XlbcLIlL2BSUXO JOUBQic7qxyIcxGQAanQIdbsKlplQu5dMidYnjQuDtqQK0iqW30UcPm5ItRAEHXmaUOZRorOYAQyd 7Q+zRjvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1krj5L-0001OZ-AS; Tue, 22 Dec 2020 14:56:23 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1krj5C-0001Mi-Gx for linux-arm-kernel@lists.infradead.org; Tue, 22 Dec 2020 14:56:15 +0000 Received: by mail-pg1-x535.google.com with SMTP id g15so3594974pgu.9 for ; Tue, 22 Dec 2020 06:56:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iV7x9UfdRuqA/iQmTdVUBNaIN/CPGomT0d2jg4MjDb8=; b=regWSKkn/ylSxvlVizL+gK8gYy2DbuoMZ8kDvc/2cQylNuMnWCfLyAQeAsFF9W87hE XBZSVPKsKwiwjqECdTB9r/b7dDKE2aayvG2beyo9S4F+Yed8UdYJR5376HFeSAEws/xW J9u5qdrfWN2AJaMejC7ZnNrKLZveuEBktoRH0AGpXk7OJjlNPsfhE5wcIDmiaIvLybxU mWardfmCBWZ8SZS+xoTVjZshznfSfMhQXHsq8t8YlNoUtBEb4mCHp0UNskWtdEdow0Ha Tvvn0t+SqVNF4Jz58GxRsu8BG7vvBOVcM8oW6mdQa9tpipFGV8kWBFJVUDbMvJiEZrFm /XOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iV7x9UfdRuqA/iQmTdVUBNaIN/CPGomT0d2jg4MjDb8=; b=PkLw2cdVzbaxoqKvWJXFZhB3ceTb2JfpqZo3r6UghfW92On5ebydauQAKwNJtMLJ/u UtcMNZi8E9vX4gJ31ApES55cUddMhtgdsBX26/ZnQDJuNSiYgkdgEpeGp5I23P3x9V2R SA8NqK9/tFXqQtjfKg+KG6j7T+u43pBgnhdsHiTHkG71NXGeFOSYYg7QO4re0/KIYPUs yCUvNBY+1gIhFXicuNjnr2Y++RFB0iiC3BLGIcw6JzxVTm8ylRajwXUWI1/SrUky31P1 bkf84nZp2/BLJviHId7GKZQ1vo3dz642GeH/TaHqzGcxVpTu4RPM208ciqJg2o4dOs4B puow== X-Gm-Message-State: AOAM530iynaETN7G5BwrOEWlDibqIjzuXG89a6DRWD/BL+7aNAudrcTU 6x0IkkAzpurFKHxzLQ92h7U= X-Google-Smtp-Source: ABdhPJzAfYgTB2acEP+ERN90ZC9VOBebWGN7Ivs5cj6/3dE8QBNJdlWRSnEI+/BH0lXAxxSaEUFQJA== X-Received: by 2002:a63:3648:: with SMTP id d69mr20201786pga.155.1608648972788; Tue, 22 Dec 2020 06:56:12 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id k15sm21340349pfp.115.2020.12.22.06.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:56:12 -0800 (PST) From: Jim Quinlan To: Sudeep Holla , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Subject: [PATCH v4 2/2] firmware: arm_scmi: Augment SMC/HVC to allow optional interrupt Date: Tue, 22 Dec 2020 09:56:03 -0500 Message-Id: <20201222145603.40192-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222145603.40192-1-jim2101024@gmail.com> References: <20201222145603.40192-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201222_095614_666095_F65084EE X-CRM114-Status: GOOD ( 19.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: open list , "open list:SYSTEM CONTROL & POWER/MANAGEMENT INTERFACE Mes..." MIME-Version: 1.0 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 The SMC/HVC SCMI transport is modified to allow the completion of an SCMI message to be indicated by an interrupt rather than the return of the smc call. This accommodates the existing behavior of the BrcmSTB SCMI "platform" whose SW is already out in the field and cannot be changed. Signed-off-by: Jim Quinlan --- drivers/firmware/arm_scmi/smc.c | 38 ++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c index 82a82a5dc86a..fd41d436e34b 100644 --- a/drivers/firmware/arm_scmi/smc.c +++ b/drivers/firmware/arm_scmi/smc.c @@ -9,9 +9,11 @@ #include #include #include +#include #include #include #include +#include #include #include "common.h" @@ -23,6 +25,8 @@ * @shmem: Transmit/Receive shared memory area * @shmem_lock: Lock to protect access to Tx/Rx shared memory area * @func_id: smc/hvc call function id + * @irq: Optional; employed when platforms indicates msg completion by intr. + * @tx_complete: Optional, employed only when irq is valid. */ struct scmi_smc { @@ -30,8 +34,19 @@ struct scmi_smc { struct scmi_shared_mem __iomem *shmem; struct mutex shmem_lock; u32 func_id; + int irq; + struct completion tx_complete; }; +static irqreturn_t smc_msg_done_isr(int irq, void *data) +{ + struct scmi_smc *scmi_info = data; + + complete(&scmi_info->tx_complete); + + return IRQ_HANDLED; +} + static bool smc_chan_available(struct device *dev, int idx) { struct device_node *np = of_parse_phandle(dev->of_node, "shmem", 0); @@ -51,7 +66,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, struct resource res; struct device_node *np; u32 func_id; - int ret; + int ret, irq = 0; if (!tx) return -ENODEV; @@ -79,10 +94,29 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, if (ret < 0) return ret; + /* + * If there is an interrupt named "a2p", then the + * service and completion of a message is signaled by an interrupt + * rather than by the return of the SMC call. + */ + ret = of_irq_get_byname(cdev->of_node, "a2p"); + if (ret > 0) { + irq = ret; + ret = devm_request_irq(dev, irq, smc_msg_done_isr, + IRQF_NO_SUSPEND, + dev_name(dev), + scmi_info); + if (ret) { + dev_err(dev, "failed to setup SCMI smc irq\n"); + return ret; + } + init_completion(&scmi_info->tx_complete); + } scmi_info->func_id = func_id; scmi_info->cinfo = cinfo; mutex_init(&scmi_info->shmem_lock); cinfo->transport_info = scmi_info; + scmi_info->irq = irq; return 0; } @@ -111,6 +145,8 @@ static int smc_send_message(struct scmi_chan_info *cinfo, shmem_tx_prepare(scmi_info->shmem, xfer); arm_smccc_1_1_invoke(scmi_info->func_id, 0, 0, 0, 0, 0, 0, 0, &res); + if (scmi_info->irq) + wait_for_completion(&scmi_info->tx_complete); scmi_rx_callback(scmi_info->cinfo, shmem_read_header(scmi_info->shmem)); mutex_unlock(&scmi_info->shmem_lock); -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel