From patchwork Fri Jul 22 22:37:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guru Das Srinagesh X-Patchwork-Id: 12926947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9A76C43334 for ; Fri, 22 Jul 2022 22:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236971AbiGVWkR (ORCPT ); Fri, 22 Jul 2022 18:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236966AbiGVWkB (ORCPT ); Fri, 22 Jul 2022 18:40:01 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31D9B20F47; Fri, 22 Jul 2022 15:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1658529498; x=1690065498; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GKC8VfcyGF4rHCVnV7RvZpNWBnM1QHRzWAdSlQXvS9I=; b=SXXqrNYw4fxD8U99utCIfrl/T4mAmwfrD/sbG5fAZAvzMaRwF8PRRtIh CvSa9ozqhYrWFiPng7NWgpGJ267YElNVb/nMiG0qSiV+eNZlIpkamLCqV JeJZiTHf05VXHAyVMx5k/pc+dMG/P4qTlEIyaIcaVs8iQlB/E9WJDOkBI U=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 22 Jul 2022 15:37:25 -0700 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 15:37:25 -0700 Received: from hu-gurus-sd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 22 Jul 2022 15:37:25 -0700 From: Guru Das Srinagesh To: Andy Gross , Bjorn Andersson , Philipp Zabel , , CC: David Heidelberg , Robert Marko , Rajendra Nayak , Elliot Berman , Guru Das Srinagesh Subject: [PATCH v2 0/5] SCM: Add support for wait-queue aware firmware Date: Fri, 22 Jul 2022 15:37:13 -0700 Message-ID: <1658529438-9234-1-git-send-email-quic_gurus@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This patch series enables the QCOM SCM driver to support firmware (FW) versions that expect the high-level OS (HLOS) to be tolerant of SCM call requests not being processed right away and, instead, being placed on a wait-queue in FW and processed accordingly. The problem this feature is fixing is as follows. In a scenario where there is a VM in addition to HLOS (and an underlying hypervisor): 1. HLOS makes an SMC call on core 5 2. The hypervisor scheduling interrupt interrupts this SMC call. 3. The hypervisor schedules the VM on core 5. 4. The VM makes an SMC call on core 5. 5. The SMC call is non-interruptibly stuck on FW spinlock on core 5. 6. HLOS cannot reschedule since core 5 is not responding to Reschedule IPIs. 7. Watchdog timer expires waiting for core 5. This problem is solved by FW returning a new return code SCM_WAITQ_SLEEP to HLOS right away when it is overwhelmed by the VM's SMC call. HLOS then places the call on a wait-queue and wakes it up when it receives an interrupt that signifies "all-clear". This new design also supports scenarios involving only HLOS (and no other VMs). Such scenarios make use of a second new return code SCM_WAITQ_WAKE. There are three new SMC calls also being defined in this design that, together with the two new return codes, form the handshake protocol between Linux and FW. This design is also backwards-compatible with existing firmware versions that do not support this feature. --- v2: - Changes made to patches 4 and 5 are listed therein. - Rebased dt-bindings on top of the YAML conversion patch [1]. [1] https://lore.kernel.org/lkml/20220708090431.30437-1-david@ixit.cz/ --- Guru Das Srinagesh (5): dt-bindings: firmware: qcom-scm: Add "allow-multi-call" property firmware: qcom: scm: Optionally remove SCM call serialization dt-bindings: firmware: qcom-scm: Add optional interrupt firmware: qcom: scm: Add wait-queue helper functions firmware: qcom: scm: Add wait-queue handling logic .../devicetree/bindings/firmware/qcom,scm.yaml | 10 ++ drivers/firmware/qcom_scm-smc.c | 140 +++++++++++++++++++-- drivers/firmware/qcom_scm.c | 125 +++++++++++++++++- drivers/firmware/qcom_scm.h | 14 +++ 4 files changed, 279 insertions(+), 10 deletions(-)