Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5036065pxu; Tue, 22 Dec 2020 07:00:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJFsteHo1TrN7xn56PaIUsGeped3RQK5RRnKTdjcOhDjkZ9Jlug7H8x3L9RO9jmC72gQzA X-Received: by 2002:a17:906:d101:: with SMTP id b1mr690046ejz.80.1608649204872; Tue, 22 Dec 2020 07:00:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608649204; cv=none; d=google.com; s=arc-20160816; b=a0HZ1B2oPheAayvj+mTCo+QFptIBlkqHLcvfwp4RI83bLK+fOPpelmERniGR7cSvS8 Q6T2p2ESOIGsgpmWylil9XCBlyNRMTZDRS7zrAdtXWSvFg5Sp/nGqRcIQYXo/E778Y0I 72i7fL7KUV0Z4BZeN8BpXWes+CnZK10y3buqG8CkIwDdkOwkNyfQzF6OSW5Z3qZzrGdW aF7V5AYnG3KYPVV3PFguWZ4emKM3GUkLBey1zSutZpMxs2kurJt+FOx7dT3xhNe08vdM APMgWtyVj9lPumLFAdAOp8bBdPSp1InU/tF7UVZaLHDLExb8sF8WN5SECACOTZ80Y6r5 3KTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=iV7x9UfdRuqA/iQmTdVUBNaIN/CPGomT0d2jg4MjDb8=; b=0LY3n3zGQsX3zBGW/Qychic08tZH50lHNAh9tzVvM0Nuj1xUXepu0CE2Az3puR+Mns yHzHnAwwtQ2PKDBiHMIfEYpqYfi0mwTjSaTXvwuNXZ53Lb/aFomaAZQg0JTDQq5kqfzN 6kS6C8iObSjt+p+TIdQo3738ftvc4jQu49PSzKI3GFgIrAdhfG8hkCAr2psSylOo8W3E UnCBZZ2UyT8dWMdRDxH3Fi6DgD5rvNlhxgFkzaEfk+ZPFsAp0cqH+XT6gQH8mMt99UE2 c0951eq+zt1ZgAVTHmgH9Clu7Cx0+4ZCVUEfL55xdOAFBqykJPRK0brS8nBjw/Y8gyUP 4vyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=regWSKkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zh12si10569166ejb.148.2020.12.22.06.59.42; Tue, 22 Dec 2020 07:00:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=regWSKkn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727986AbgLVO5K (ORCPT + 99 others); Tue, 22 Dec 2020 09:57:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727533AbgLVO5J (ORCPT ); Tue, 22 Dec 2020 09:57:09 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26801C061248 for ; Tue, 22 Dec 2020 06:56:13 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id w5so8523217pgj.3 for ; Tue, 22 Dec 2020 06:56:13 -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=YktkFKWEFAtV4CVRl/MXlSSMrqqhCuGeTWP78HcF2tBcPJBJdii93EWeV1AOmE5MNM 4W/f1fPpy3ZFuaRRa9nxUBonaQLC5i6wkkWl5yYnQ3rrEFnz+ShkZMB9HtTpgpMBh5eq SSQjW0j2iF9/ttVEbcjQ2XXc0GeO/ZcR0eNXzCNhlM945kVvubBwzubBrGjRjs6fHity FEKYdoKjlKOptD7SciweiadGnzVWGbggtH/Z2e1wIcKzW615QGcVhUMq+C7VCfwnanZl L45Jcbx9hAAvbySaRpD76RRDn+RxVwwESQIsYSiVsQPVy2x9CkFrFJs4pPI+sD1Cbpjh n8Vw== X-Gm-Message-State: AOAM533+onKK32k3C21uW8Qm5YJwKP1eWydaUfiynEeLDCLTId6ZZ94T gQZy8b0PzZvm7raTWIFFNiQ= 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 Cc: linux-arm-kernel@lists.infradead.org (open list:SYSTEM CONTROL & POWER/MANAGEMENT INTERFACE Mes...), linux-kernel@vger.kernel.org (open list) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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