From patchwork Fri Oct 28 14:08:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12319 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp858478wru; Fri, 28 Oct 2022 07:18:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4IG3UqPY7jN6xfwx/j9QW2ulRDVMkPAFMrkWyl9vOgalKllLBjcDnU9bb5HI5ls8YFktu3 X-Received: by 2002:a65:6e47:0:b0:438:c2f0:c0eb with SMTP id be7-20020a656e47000000b00438c2f0c0ebmr47005645pgb.236.1666966730991; Fri, 28 Oct 2022 07:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966730; cv=none; d=google.com; s=arc-20160816; b=xBPubYX/UZ9T58rmbaNcA4HXhOHcbqd6ffXR5jAVLseHjN7t4/YBddKuZ3iEe4g3nh nGbyJRIVsp0DCYhfvZvqB/0BWDVRgx8pKPg2JsHly+E/t9fGpsgNopLQkmLymG/FZ0bN G4Bi7cwVhyOAboRCaxx4VVFEifeDKXQlGTKV0Q2njHNhTSHALJqJbeZFjVQvXm7rpA64 OdklbmJtB+qT6I0wNadv8ONGEZaHs7UJaln+TkkBhb3mUTFYsL+LEND9oURmOtb5yEsM CIecglm3C9oiuphzRWHfBzMeMIJ0+pMZPM72FckoXs7Fwj58I9HwjFaVFi08ZyzvY4z5 1SOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=MYClztsosuOWqNf20Cspsi8kXyyUOCBiTUMfyHIU+lM=; b=Pf1R8ROYvPUMvEsobwvo14Ftz1Kj2mROs3sPUgn6wrue+LxCEEIn+nbLf7Wgz6wPzU b4yoaTo5Too5IXAtysdbqfdGarUzU0ppCVyELbdKaSLG6v2dT9srm5y8CX68dyU9pzmU Y+9luKppWvyfI/TbPAGFj2b7t1MF5TXePcv8KLq0JMFyEwq8FkmvI3KjkkwKFExBsev0 0Ag6o6jWFvzAhxUuw2vyIZOIv5i7V3aev53ZLHYv4YJVWhDzYM6l5eoAArizh8RdoZ3i sBwsRSIMCrrajfbnS9dP+FW0MIIJhORvfO5ItbZSVyFNfey69tdlNKg+PDBqClQUzFi7 7nJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y8-20020a17090322c800b0018280f67482si6681995plg.113.2022.10.28.07.18.35; Fri, 28 Oct 2022 07:18:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231467AbiJ1OJI (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231414AbiJ1OJG (ORCPT ); Fri, 28 Oct 2022 10:09:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 165271E047B for ; Fri, 28 Oct 2022 07:09:05 -0700 (PDT) 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 D92BE1FB; Fri, 28 Oct 2022 07:09:10 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE16E3F534; Fri, 28 Oct 2022 07:09:03 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com, =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= Subject: [PATCH 1/8] firmware: arm_scmi: Cleanup core driver removal callback Date: Fri, 28 Oct 2022 15:08:26 +0100 Message-Id: <20221028140833.280091-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941306960680667?= X-GMAIL-MSGID: =?utf-8?q?1747941306960680667?= Platform drivers .remove callbacks are not supposed to fail and report errors: such errors are indeed ignored by the core platform drivers stack and the driver unbind process is anyway completed. The SCMI core platform driver as it is now, instead, bails out reporting an error in case of an explicit unbind request. Fix the removal path by adding proper device links between the core SCMI device and the SCMI protocol devices so as to cause a full SCMI stack unbind when the core driver is removed: the remove process does not bail out anymore on the anomalous conditions triggered by an explicit unbind but the user is still warned. Reported-by: Uwe Kleine-König Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/bus.c | 11 +++++++++++ drivers/firmware/arm_scmi/common.h | 1 + drivers/firmware/arm_scmi/driver.c | 31 ++++++++++++++++++------------ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index d4e23101448a..35bb70724d44 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -216,9 +216,20 @@ void scmi_device_destroy(struct scmi_device *scmi_dev) device_unregister(&scmi_dev->dev); } +void scmi_device_link_add(struct device *consumer, struct device *supplier) +{ + struct device_link *link; + + link = device_link_add(consumer, supplier, DL_FLAG_AUTOREMOVE_CONSUMER); + + WARN_ON(!link); +} + void scmi_set_handle(struct scmi_device *scmi_dev) { scmi_dev->handle = scmi_handle_get(&scmi_dev->dev); + if (scmi_dev->handle) + scmi_device_link_add(&scmi_dev->dev, scmi_dev->handle->dev); } int scmi_protocol_register(const struct scmi_protocol *proto) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 61aba7447c32..9b87b5b69535 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -97,6 +97,7 @@ static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr) struct scmi_revision_info * scmi_revision_area_get(const struct scmi_protocol_handle *ph); int scmi_handle_put(const struct scmi_handle *handle); +void scmi_device_link_add(struct device *consumer, struct device *supplier); struct scmi_handle *scmi_handle_get(struct device *dev); void scmi_set_handle(struct scmi_device *scmi_dev); void scmi_setup_protocol_implemented(const struct scmi_protocol_handle *ph, diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 609ebedee9cb..7e19b6055d75 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2273,10 +2273,16 @@ int scmi_protocol_device_request(const struct scmi_device_id *id_table) sdev = scmi_get_protocol_device(child, info, id_table->protocol_id, id_table->name); - /* Set handle if not already set: device existed */ - if (sdev && !sdev->handle) - sdev->handle = - scmi_handle_get_from_info_unlocked(info); + if (sdev) { + /* Set handle if not already set: device existed */ + if (!sdev->handle) + sdev->handle = + scmi_handle_get_from_info_unlocked(info); + /* Relink consumer and suppliers */ + if (sdev->handle) + scmi_device_link_add(&sdev->dev, + sdev->handle->dev); + } } else { dev_err(info->dev, "Failed. SCMI protocol %d not active.\n", @@ -2475,20 +2481,17 @@ void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id) static int scmi_remove(struct platform_device *pdev) { - int ret = 0, id; + int ret, id; struct scmi_info *info = platform_get_drvdata(pdev); struct device_node *child; mutex_lock(&scmi_list_mutex); if (info->users) - ret = -EBUSY; - else - list_del(&info->node); + dev_warn(&pdev->dev, + "Still active SCMI users will be forcibly unbound.\n"); + list_del(&info->node); mutex_unlock(&scmi_list_mutex); - if (ret) - return ret; - scmi_notification_exit(&info->handle); mutex_lock(&info->protocols_mtx); @@ -2500,7 +2503,11 @@ static int scmi_remove(struct platform_device *pdev) idr_destroy(&info->active_protocols); /* Safe to free channels since no more users */ - return scmi_cleanup_txrx_channels(info); + ret = scmi_cleanup_txrx_channels(info); + if (ret) + dev_warn(&pdev->dev, "Failed to cleanup SCMI channels.\n"); + + return 0; } static ssize_t protocol_version_show(struct device *dev, From patchwork Fri Oct 28 14:08:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12320 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp858742wru; Fri, 28 Oct 2022 07:19:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4IWqXfQBzeoSbyeOVTxunvgPIlDUJDN5ia5uilw0NHn+9kw/Zaz7d6rnl5m1TDCRpCGZUe X-Received: by 2002:a63:de46:0:b0:46e:c3bd:e47d with SMTP id y6-20020a63de46000000b0046ec3bde47dmr31843900pgi.609.1666966763749; Fri, 28 Oct 2022 07:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966763; cv=none; d=google.com; s=arc-20160816; b=pPc1aeFEckPOZFwNCYNQI2UX8N6edu0mcgdkqtpnRIsqnbjgXKDL1Gbdje0tfMLXp3 B5KqbH7ymB4R/Y5wxegBYKLq+l7qLKpJfn1//noPlvBDcE+v1wSVetef0mSj1/SKfR1o cf6ocIEXdnbL64dEKsnsUCpU9gb6OiYO2L74cV+mEhm+SE4VEJJfnK6wrkzfHWvVvFCU d89lWO/ZJZHTwjRpdYnATrNvZcbpApS+IqjXgcEJtFrX0NHyQl+dxqkiIPV3BTxE2BkT Hd+gJQn1kgeuU2flPatGbUhTZI2rQYwfq6K2GZ/M7JokbMR9cEX/1ABQDBiTnZG3//cs EFXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HB69rOwbzG6hLeCkNDADKzZetOqmvaoJLVWAbCsnn8Q=; b=xRQjwY2YSBp5c7ROwBOKUNItBDDaFbgTjJDjVIgfZ6R6BGuWOt3TIlYg6xJYp8CxXx UnxDMgs+5SZ0k+aLnPDu6Q4k0xQYX7tnn8WOy4rJtu1S6xL28dEBpn6YXtYnyM/0dIEj xwW0A84EvUYTeUgcZ9L2sEMDUdHr1Eu5Ai7BMNaQPAlsoZEYShHdvDgg6C3U5JZVCkaa 4LHa6dycH893yL1xPyot+ssJKlYoBQLGh6+iR1EU2je/InkQhvk8T3jfrXFJLG6hPSEY sfgV1c6Ud4C0WUihQF9SXPfdMRDl0bbit3RSF60Vel1O5i5i1jxrftk0A2o7Tgukzo5h EcKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170903244700b0017ebdf9ca1bsi6253155pls.464.2022.10.28.07.19.09; Fri, 28 Oct 2022 07:19:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbiJ1OJK (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231417AbiJ1OJG (ORCPT ); Fri, 28 Oct 2022 10:09:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BFB771E047D for ; Fri, 28 Oct 2022 07:09:05 -0700 (PDT) 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 CC62923A; Fri, 28 Oct 2022 07:09:11 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE2883F534; Fri, 28 Oct 2022 07:09:04 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com Subject: [PATCH 2/8] firmware: arm_scmi: Suppress bind attributes Date: Fri, 28 Oct 2022 15:08:27 +0100 Message-Id: <20221028140833.280091-2-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028140833.280091-1-cristian.marussi@arm.com> References: <20221028140833.280091-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941341177290867?= X-GMAIL-MSGID: =?utf-8?q?1747941341177290867?= Suppress the capability to unbind the core SCMI driver since all the SCMI stack protocol drivers depend on it. Fixes: aa4f886f3893 ("firmware: arm_scmi: add basic driver infrastructure for SCMI") Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 7e19b6055d75..94be633b55a0 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2578,6 +2578,7 @@ MODULE_DEVICE_TABLE(of, scmi_of_match); static struct platform_driver scmi_driver = { .driver = { .name = "arm-scmi", + .suppress_bind_attrs = true, .of_match_table = scmi_of_match, .dev_groups = versions_groups, }, From patchwork Fri Oct 28 14:08:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12321 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp858780wru; Fri, 28 Oct 2022 07:19:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7PhVxVuZZrzy26oMl/jD+Lnc7bDWA4Vxq89kQmcd4FR/zBKlORTTWH7Ir7f9tWn7LyBOV/ X-Received: by 2002:a63:6a85:0:b0:43b:d845:f67d with SMTP id f127-20020a636a85000000b0043bd845f67dmr45895774pgc.349.1666966767531; Fri, 28 Oct 2022 07:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966767; cv=none; d=google.com; s=arc-20160816; b=0WlyebLtae+cG1t9y8eX0+A3RLKGcbuZS9EJQ7pF4nsxVTsyPkmgEQVmGfJOEHviXZ ePRcJbcSsDSWsj5InWNqcUR1GbNFh5/SNfkGDM+ilN9LdT5anmMnOOXC572M5rGipHjN sqMF+eLCJ29B3Ft3rzlrI4GGlEnMBVcC0GamgC+DbUxomxW3efwueSwGY6XAKMDNv/UT UF/FJo0qFe8i3gTGFRIQHuYmWhWvh+LRPub/1zMHG9ueZSqcTVRpBWC1uNyCMiFZsqhe 3e7/36EISlEV8M6cBnGxwVBbdTgFnR+Te/JtZhvl2Qfs8aZCYLrT2tn128QY9AgLVBdh Unug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1qmJyP1aSA8W2TVw2q8l+JVHJKtTQyM5TEAQgeb3Lj4=; b=NCBrGhE5wkILallgrD/w6dwVe7MI/iacMUvQSWTXFigs73b7JKS+wofQxnnXAvZArh 44CdDgwJu9PLrHL9/2gAQFOm8W/89kZTGeBrwdxXtZANznYumdFwQzbMSLoksKM3audY PJokopDMHV+E/yz41Vv6ggR0+Jkv0nvfS3pmXJdFddemsm2Y66fmJUHy16RQf13QOx0F qL6sgKJbFHFEuGIwBCxgdL1L1+Qeh0S9SX3jCWlLXs8/5cRxcQ3naPzi/kUOl8rvkZU2 3QPPlJU0TkMg6tV7j5gbwWtVTdupfococutHZp9hoJIpD6qS3RLxB53gvlxNhI2shvlJ H5Ig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a170902db8600b00176d89d640asi4757293pld.440.2022.10.28.07.19.13; Fri, 28 Oct 2022 07:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbiJ1OJN (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231459AbiJ1OJI (ORCPT ); Fri, 28 Oct 2022 10:09:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E0A41E0449 for ; Fri, 28 Oct 2022 07:09:07 -0700 (PDT) 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 3B6E5D6E; Fri, 28 Oct 2022 07:09:13 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C20433F534; Fri, 28 Oct 2022 07:09:05 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com, YaxiongTian , Vincent Guittot , Etienne Carriere , Florian Fainelli Subject: [PATCH 3/8] firmware: arm_scmi: Make tx_prepare time out eventually Date: Fri, 28 Oct 2022 15:08:28 +0100 Message-Id: <20221028140833.280091-3-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028140833.280091-1-cristian.marussi@arm.com> References: <20221028140833.280091-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941344935642931?= X-GMAIL-MSGID: =?utf-8?q?1747941344935642931?= SCMI transports based on Shared Memory, at start of transmissions, have to wait for the shared TX channel area to be eventually freed by the SCMI server platform before accessing the channel: in fact the channel is owned by the SCMI server platform until marked as free by the platform itself and, as such, cannot be used by the agent until relinquished. As a consequence a badly misbehaving SCMI server firmware could lock the channel indefinitely and make the kernel side SCMI stack loop forever waiting for such channel to be freed, possibly hanging the whole boot sequence. Add a timeout to the existent TX waiting spin-loop so that, when the system ends up in this situation, the SCMI stack can at least bail-out, nosily warn the user, and abort the transmission. Reported-by: YaxiongTian Suggested-by: YaxiongTian Cc: Vincent Guittot Cc: Etienne Carriere Cc: Florian Fainelli Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/common.h | 4 +++- drivers/firmware/arm_scmi/driver.c | 1 + drivers/firmware/arm_scmi/mailbox.c | 2 +- drivers/firmware/arm_scmi/optee.c | 2 +- drivers/firmware/arm_scmi/shmem.c | 31 +++++++++++++++++++++++++---- drivers/firmware/arm_scmi/smc.c | 2 +- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 9b87b5b69535..a1c0154c31c6 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -118,6 +118,7 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id); * * @dev: Reference to device in the SCMI hierarchy corresponding to this * channel + * @rx_timeout_ms: The configured RX timeout in milliseconds. * @handle: Pointer to SCMI entity handle * @no_completion_irq: Flag to indicate that this channel has no completion * interrupt mechanism for synchronous commands. @@ -127,6 +128,7 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id); */ struct scmi_chan_info { struct device *dev; + unsigned int rx_timeout_ms; struct scmi_handle *handle; bool no_completion_irq; void *transport_info; @@ -233,7 +235,7 @@ void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id); struct scmi_shared_mem; void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem, - struct scmi_xfer *xfer); + struct scmi_xfer *xfer, struct scmi_chan_info *cinfo); u32 shmem_read_header(struct scmi_shared_mem __iomem *shmem); void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem, struct scmi_xfer *xfer); diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 94be633b55a0..985775f210f9 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2013,6 +2013,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device *dev, return -ENOMEM; cinfo->dev = dev; + cinfo->rx_timeout_ms = info->desc->max_rx_timeout_ms; ret = info->desc->ops->chan_setup(cinfo, info->dev, tx); if (ret) diff --git a/drivers/firmware/arm_scmi/mailbox.c b/drivers/firmware/arm_scmi/mailbox.c index 08ff4d110beb..1e40cb035044 100644 --- a/drivers/firmware/arm_scmi/mailbox.c +++ b/drivers/firmware/arm_scmi/mailbox.c @@ -36,7 +36,7 @@ static void tx_prepare(struct mbox_client *cl, void *m) { struct scmi_mailbox *smbox = client_to_scmi_mailbox(cl); - shmem_tx_prepare(smbox->shmem, m); + shmem_tx_prepare(smbox->shmem, m, smbox->cinfo); } static void rx_callback(struct mbox_client *cl, void *m) diff --git a/drivers/firmware/arm_scmi/optee.c b/drivers/firmware/arm_scmi/optee.c index f42dad997ac9..2a7aeab40e54 100644 --- a/drivers/firmware/arm_scmi/optee.c +++ b/drivers/firmware/arm_scmi/optee.c @@ -498,7 +498,7 @@ static int scmi_optee_send_message(struct scmi_chan_info *cinfo, msg_tx_prepare(channel->req.msg, xfer); ret = invoke_process_msg_channel(channel, msg_command_size(xfer)); } else { - shmem_tx_prepare(channel->req.shmem, xfer); + shmem_tx_prepare(channel->req.shmem, xfer, cinfo); ret = invoke_process_smt_channel(channel); } diff --git a/drivers/firmware/arm_scmi/shmem.c b/drivers/firmware/arm_scmi/shmem.c index 0e3eaea5d852..1dfe534b8518 100644 --- a/drivers/firmware/arm_scmi/shmem.c +++ b/drivers/firmware/arm_scmi/shmem.c @@ -5,10 +5,13 @@ * Copyright (C) 2019 ARM Ltd. */ +#include #include #include #include +#include + #include "common.h" /* @@ -30,16 +33,36 @@ struct scmi_shared_mem { }; void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem, - struct scmi_xfer *xfer) + struct scmi_xfer *xfer, struct scmi_chan_info *cinfo) { + ktime_t stop; + /* * Ideally channel must be free by now unless OS timeout last * request and platform continued to process the same, wait * until it releases the shared memory, otherwise we may endup - * overwriting its response with new message payload or vice-versa + * overwriting its response with new message payload or vice-versa. + * Giving up anyway after twice the expected channel timeout so as + * not to bail-out on intermittent issues where the platform is + * occasionally a bit slower to answer. + * + * Note that after a timeout is detected we bail-out and carry on but + * the transport functionality is probably permanently compromised: + * this is just to ease debugging and avoid complete hangs on boot + * due to a misbehaving SCMI firmware. */ - spin_until_cond(ioread32(&shmem->channel_status) & - SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE); + stop = ktime_add_ms(ktime_get(), 2 * cinfo->rx_timeout_ms); + spin_until_cond((ioread32(&shmem->channel_status) & + SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE) || + ktime_after(ktime_get(), stop)); + if (!(ioread32(&shmem->channel_status) & + SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE)) { + WARN_ON_ONCE(1); + dev_err(cinfo->dev, + "Timeout waiting for a free TX channel !\n"); + return; + } + /* Mark channel busy + clear error */ iowrite32(0x0, &shmem->channel_status); iowrite32(xfer->hdr.poll_completion ? 0 : SCMI_SHMEM_FLAG_INTR_ENABLED, diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c index 745acfdd0b3d..87a7b13cf868 100644 --- a/drivers/firmware/arm_scmi/smc.c +++ b/drivers/firmware/arm_scmi/smc.c @@ -188,7 +188,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo, */ smc_channel_lock_acquire(scmi_info, xfer); - shmem_tx_prepare(scmi_info->shmem, xfer); + shmem_tx_prepare(scmi_info->shmem, xfer, cinfo); arm_smccc_1_1_invoke(scmi_info->func_id, 0, 0, 0, 0, 0, 0, 0, &res); From patchwork Fri Oct 28 14:08:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp859588wru; Fri, 28 Oct 2022 07:20:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6J2Mna0SCkPb+QEyQHjwG+Phx9hI7uIbEh5+NW5b6A5qrba4XRDKjN73Xx0+yNtfRb6uOA X-Received: by 2002:a17:902:e84a:b0:186:b8ff:c698 with SMTP id t10-20020a170902e84a00b00186b8ffc698mr22902831plg.143.1666966851226; Fri, 28 Oct 2022 07:20:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966851; cv=none; d=google.com; s=arc-20160816; b=WjR0qd93oGAdZcc8MFU1ZAWlNyIoh+v+IQzxPLeWN8+hj39PRbdgVgVAvBf5ZECw1a tjqclXOdBHJ0ocnroLLg8Bu5yUzCEFWhkO6FPCfIlnthbACSZ9+00A9Gi7fQ6HSPew0b uEsfsmcL2lG5BcTaG5z+zm4maxH16jIZyainWIyW2lhNXLJ1DrAwNvFETCNFbnxxLvzt q+g3Mzp1WVoSXxSD27QMS1ISbnSb7mb6Jx9Mt/Ml7l1K/JgXcP9C295oD/v9IjeujolA KpxT10QL5mNJsnluiFK1POrxMFmiDmKDoeICjDjKewENGj/PYiaDZxmlyO4TRzTmCXsj liNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=T1Zq9JQTBh6vIyiHO9Xsg8XnRRH5I+cp3Hcbqj0r9yk=; b=DEczIZRn9MrK6AjfHfgrpTkuXJa9vAip39kgiMIgJToMRcuvaZc49gWiIcwxW1Pdon sU18VUjqiM5HmvO3BjKnCeEn6n1nAxsRhuJ7uICnhqlY5wRjC3YK23NDdhTNSh8qV+W+ Ac4USD2nhwxz6FhYO0RZJl7Y29Aiafx7fVRm7oCXhQUDUCagcwqgvn1/M/SuoRhmlTRb nbxx3hF6SeR5v491/Jk+0leF9e6gVHt8OTS5wyjr/2HranXTwCUXw2lNqbaMBseELHri t/25U3M3vJHCGdUm+y+yKD6E4cbhmUHdoH/S1VtnBWMNL2FYMLLTC2/zgXr3wQ+Y17aW tNsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a170902f54a00b00186b6a32284si6145584plf.548.2022.10.28.07.20.37; Fri, 28 Oct 2022 07:20:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231485AbiJ1OJR (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbiJ1OJJ (ORCPT ); Fri, 28 Oct 2022 10:09:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1EC7E1E047C for ; Fri, 28 Oct 2022 07:09:08 -0700 (PDT) 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 2C6401042; Fri, 28 Oct 2022 07:09:14 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 312013F534; Fri, 28 Oct 2022 07:09:07 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com Subject: [PATCH 4/8] firmware: arm_scmi: Make RX chan_setup fail on memory errors Date: Fri, 28 Oct 2022 15:08:29 +0100 Message-Id: <20221028140833.280091-4-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028140833.280091-1-cristian.marussi@arm.com> References: <20221028140833.280091-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941432856079587?= X-GMAIL-MSGID: =?utf-8?q?1747941432856079587?= SCMI RX channels are optional and they can fail to be setup when not present but anyway channels setup routines must bail-out on memory errors. Make channels setup, and related probing, fail when memory errors are reported on RX channels. Fixes: 5c8a47a5a91d ("firmware: arm_scmi: Make scmi core independent of the transport type") Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 985775f210f9..f818d00bb2c6 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2045,8 +2045,12 @@ scmi_txrx_setup(struct scmi_info *info, struct device *dev, int prot_id) { int ret = scmi_chan_setup(info, dev, prot_id, true); - if (!ret) /* Rx is optional, hence no error check */ - scmi_chan_setup(info, dev, prot_id, false); + if (!ret) { + /* Rx is optional, report only memory errors */ + ret = scmi_chan_setup(info, dev, prot_id, false); + if (ret && ret != -ENOMEM) + ret = 0; + } return ret; } From patchwork Fri Oct 28 14:08:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp858906wru; Fri, 28 Oct 2022 07:19:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6yVMl2809et1NEXFy70RNmD1gZK6GO6QGAxKFO/btoS9Tuv9uK6ZbDgz7IYuIQEo9rTm9Z X-Received: by 2002:a63:c142:0:b0:43c:9fcc:c9f2 with SMTP id p2-20020a63c142000000b0043c9fccc9f2mr46719231pgi.44.1666966781163; Fri, 28 Oct 2022 07:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966781; cv=none; d=google.com; s=arc-20160816; b=l6CsIFlxz8HmldyfAxxm04nq2evIrFF0Hd0bWoVQO/1V1p6urWc6yPitcgeaZr0M5x okDqtvBda6SiFV5NB2ynGNFXLOoKsSXq85Jg/784HOqM8JAq9EKLEFym+Gsuu1MTvFtc NfwZXU7xhVR/YDXFwC04qVXS9/O48RzULqDfJs05ybjDkHIUfyBxe+LFozAP23TRqu9Q bj/k1OwZ7fr5XSB8NKsRROWGb6qxwDxFP1Nc0er9av6Mq/9Vizk0aWEhyav/bpixFa8b V/gDAqbqEgCOc+G2pY4w3CHqDiDRsljLkYupZf0fB9sWkfcedElDmY82ZZRBXSsM7b26 1DMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GN1FFIke+/ylut5zHuh8bs4SrYwUHHWxl1Ixeodu3so=; b=MmL3sT5zeAvW+sCbjLSIMqxl4Oqzl0geqy+N8q1WA6259IEqsbW/1sS0Kj5drwA0Fa trLE6Pss+8cEALTYC0xjXRq1stMHHbL0w5aGo2K4kfwBG7xb3Nknxjl0xo0UOexCihTn P3mgvMc+t6NFOLUye/b6zxY5tMXXG1B6HWEf7tOXPnmpVWzZHvIFIArYbx2PQVOEQFLX oT6Mj2MlXP8F8UyVnkMqapO909PkOtPSnaXtdOaNSYt5zf7Sw9YOhJ7n/LnvHGyCJJfI M3H1gIINqgiEz8gWeA6Zr7uL6JZ4m+FubQpStbr1n2D6Dywyj6oIULafIGdD3q54nmDF Lw/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a635505000000b004404705691dsi5212540pgb.487.2022.10.28.07.19.26; Fri, 28 Oct 2022 07:19:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbiJ1OJX (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231476AbiJ1OJK (ORCPT ); Fri, 28 Oct 2022 10:09:10 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3766B1E0449 for ; Fri, 28 Oct 2022 07:09:09 -0700 (PDT) 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 467DE1063; Fri, 28 Oct 2022 07:09:15 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 276103F534; Fri, 28 Oct 2022 07:09:08 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com, Peter Hilber Subject: [PATCH 5/8] firmware: arm_scmi: Fix devres allocation device in virtio Date: Fri, 28 Oct 2022 15:08:30 +0100 Message-Id: <20221028140833.280091-5-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028140833.280091-1-cristian.marussi@arm.com> References: <20221028140833.280091-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941359770991324?= X-GMAIL-MSGID: =?utf-8?q?1747941359770991324?= SCMI Virtio transport device managed allocations must use the main platform device in devres operations instead of the channel devices. Cc: Peter Hilber Fixes: 46abe13b5e3d ("firmware: arm_scmi: Add virtio transport") Signed-off-by: Cristian Marussi --- Since as of now (v6.1-rc2) cinfo->dev == info->dev in virtio (given ONLY one channel can exist in virtio transport), this change is sort of more semantic than real as of now, BUT it will be needed fully soon, once the per-transport-devices will be adopted (part of an unrelated series) since in that case cinfo->dev != info->dev for virtio too. So maybe I can fold this one in the SCMI Raw series carrying transport devices patch, if you prefer. --- drivers/firmware/arm_scmi/virtio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/virtio.c b/drivers/firmware/arm_scmi/virtio.c index 14709dbc96a1..36b7686843a4 100644 --- a/drivers/firmware/arm_scmi/virtio.c +++ b/drivers/firmware/arm_scmi/virtio.c @@ -444,12 +444,12 @@ static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, for (i = 0; i < vioch->max_msg; i++) { struct scmi_vio_msg *msg; - msg = devm_kzalloc(cinfo->dev, sizeof(*msg), GFP_KERNEL); + msg = devm_kzalloc(dev, sizeof(*msg), GFP_KERNEL); if (!msg) return -ENOMEM; if (tx) { - msg->request = devm_kzalloc(cinfo->dev, + msg->request = devm_kzalloc(dev, VIRTIO_SCMI_MAX_PDU_SIZE, GFP_KERNEL); if (!msg->request) @@ -458,7 +458,7 @@ static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, refcount_set(&msg->users, 1); } - msg->input = devm_kzalloc(cinfo->dev, VIRTIO_SCMI_MAX_PDU_SIZE, + msg->input = devm_kzalloc(dev, VIRTIO_SCMI_MAX_PDU_SIZE, GFP_KERNEL); if (!msg->input) return -ENOMEM; From patchwork Fri Oct 28 14:08:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp859143wru; Fri, 28 Oct 2022 07:20:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FMqDoG6cKqdA+Vde1iKhE3XktPsoB/bP1T6d54UIyhh+9+cIwdqV9ll7ObI1Eg4HA8opX X-Received: by 2002:a17:902:8491:b0:183:c3d2:2112 with SMTP id c17-20020a170902849100b00183c3d22112mr54824949plo.133.1666966802344; Fri, 28 Oct 2022 07:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966802; cv=none; d=google.com; s=arc-20160816; b=xtSc7HaT8HzyAQKT/coHzNKRWWR7zHcXj/EepH/dDsCP0lhDSldpj8kF1E238kZnxg Mpyj5eMTJFL37mfuDjQaOdIxzffgkG6G3PrX04GRmPrFPjcLNefdJ4BZ+2G3tacFJcbQ kgzIGP51w3ZSPgvBoGprNMFhrNMYT0QYSMCH9fnjxk7fdzD4jmufOWklDJvFu8t64fKV yz9W7olZHckohFl4iCpCQc/mVngVWL02jfpmqcCeQy0bLoiJLl5HmQ9Mq161wxuoytgb thNLtEuA4DTJUzDWHWr3kxmjrXLf+NGwzfO3UFAcK4D27t1QaTmwJx27xvj9NNjnHsHU g/QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rZWPEdy/PUXe6IY4C8/HpXYIjo3NSX+Olxmv7xNYExw=; b=aXPjG7xOjdYetdEjZGdwY3cel8LoqlfcH0QKMEcA3Z05JjxaVVEuW+vHxPCEmfNuYY wJF7A/AKSMrE0J2C/gdXgCbOekj7b0j7kELop7usWiV/lgqPIaxtWm9N+tdjzw+VtYEP Ge5aLV4EsC41AacH1HT2Dbxunx/IXWvuZbHqH9tdqBhVI1U9J25lZD7jlRldLf62mU5V odkDACRzx5FCjTHNg4unSH7VlCct36ijVB4X5VuwqYlrFfwPBlRIKbHeB5IYoh6PiIvz Y29i3a761TA9sjxzvCn3k//woEiydLm0oyJN0HY6I54f9vmWsEgY7fcuaXrkdwTQjE7Y Y/QA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ms19-20020a17090b235300b00211e0e9f18csi5103579pjb.40.2022.10.28.07.19.45; Fri, 28 Oct 2022 07:20:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231428AbiJ1OJ1 (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231472AbiJ1OJL (ORCPT ); Fri, 28 Oct 2022 10:09:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 495401E046A for ; Fri, 28 Oct 2022 07:09:10 -0700 (PDT) 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 55110113E; Fri, 28 Oct 2022 07:09:16 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3CAAA3F534; Fri, 28 Oct 2022 07:09:09 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com, Dan Carpenter Subject: [PATCH 6/8] firmware: arm_scmi: Fix deferred_tx_wq release on error paths Date: Fri, 28 Oct 2022 15:08:31 +0100 Message-Id: <20221028140833.280091-6-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028140833.280091-1-cristian.marussi@arm.com> References: <20221028140833.280091-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941381537538377?= X-GMAIL-MSGID: =?utf-8?q?1747941381537538377?= Use devres to allocate the dedicated deferred_tx_wq polling workqueue so as to automatically trigger the proper resource release on error path. Reported-by: Dan Carpenter Fixes: 5a3b7185c47c ("firmware: arm_scmi: Add atomic mode support to virtio transport") Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/virtio.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/arm_scmi/virtio.c b/drivers/firmware/arm_scmi/virtio.c index 36b7686843a4..33c9b81a55cd 100644 --- a/drivers/firmware/arm_scmi/virtio.c +++ b/drivers/firmware/arm_scmi/virtio.c @@ -148,7 +148,6 @@ static void scmi_vio_channel_cleanup_sync(struct scmi_vio_channel *vioch) { unsigned long flags; DECLARE_COMPLETION_ONSTACK(vioch_shutdown_done); - void *deferred_wq = NULL; /* * Prepare to wait for the last release if not already released @@ -162,16 +161,11 @@ static void scmi_vio_channel_cleanup_sync(struct scmi_vio_channel *vioch) vioch->shutdown_done = &vioch_shutdown_done; virtio_break_device(vioch->vqueue->vdev); - if (!vioch->is_rx && vioch->deferred_tx_wq) { - deferred_wq = vioch->deferred_tx_wq; + if (!vioch->is_rx && vioch->deferred_tx_wq) /* Cannot be kicked anymore after this...*/ vioch->deferred_tx_wq = NULL; - } spin_unlock_irqrestore(&vioch->lock, flags); - if (deferred_wq) - destroy_workqueue(deferred_wq); - scmi_vio_channel_release(vioch); /* Let any possibly concurrent RX path release the channel */ @@ -416,6 +410,11 @@ static bool virtio_chan_available(struct device *dev, int idx) return vioch && !vioch->cinfo; } +static void scmi_destroy_tx_workqueue(void *deferred_tx_wq) +{ + destroy_workqueue(deferred_tx_wq); +} + static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, bool tx) { @@ -430,6 +429,8 @@ static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, /* Setup a deferred worker for polling. */ if (tx && !vioch->deferred_tx_wq) { + int ret; + vioch->deferred_tx_wq = alloc_workqueue(dev_name(&scmi_vdev->dev), WQ_UNBOUND | WQ_FREEZABLE | WQ_SYSFS, @@ -437,6 +438,11 @@ static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, if (!vioch->deferred_tx_wq) return -ENOMEM; + ret = devm_add_action_or_reset(dev, scmi_destroy_tx_workqueue, + vioch->deferred_tx_wq); + if (ret) + return ret; + INIT_WORK(&vioch->deferred_tx_work, scmi_vio_deferred_tx_worker); } From patchwork Fri Oct 28 14:08:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp859518wru; Fri, 28 Oct 2022 07:20:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5MgdJ/zBoI4s8FCXW2KnkXQn124QzLYrEPgzR9lx/+PeGpwvHUZT+2vbvVJaIZinS9OFO1 X-Received: by 2002:a17:902:d54a:b0:186:e852:6775 with SMTP id z10-20020a170902d54a00b00186e8526775mr10995462plf.44.1666966843244; Fri, 28 Oct 2022 07:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966843; cv=none; d=google.com; s=arc-20160816; b=wa48uLRP2IG2aoR4IUepsHmfUzb8DHv1+OVpmygDagPJXei7z5QCpWTLLR+2+5Jh4E 5SuklMq6X8ATWZVVm7BV3ryNK/t2TEPWRO8bmLtbD76OhUSSkD5dV+UKnzbykQZNFFHx L8StdOzFjb6/TxBMsZKaX1RP0gOAfld/LYFuO1v1QE4409UROhhr4WUXvZzLUpgW2aif 3rhcA/jDrs47eH5KLQIhp4JFVnVmqtey3WWGi9Z+PCelEcJ9nE4sCQsEQDOhQgqey+yR EUFxHbF8QFTQX660FdKuPNyev1Prey1HA2F7tpyUAHoCqIgMWCwQKS/MmOrbuCObywSO LK4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1qSUksrTQVAc7hOCZjcCRRSeaEDNp3E814BOv+/LcGA=; b=tmnnpigBX07AJ1bbjn5lkRuIMhHNGH3L1GnM+HkQ+qaOour64qsVq41gRouKHn/RY6 dRd0NPa8tccWXHcGY07erHQ2q/T/Dc7X7jPJu7ltJc8XMHtJearB7VgPeMNtVRwT3Agt HPnfOlrjAlGh0AMAikqGv3+ZOt0j43zKaDIDSwdY4MqaC7mWeSHeKM7rACQWcVk0CYMM xL48s5h3UiKt8E1W+jbbQItb7Wsfy3EDgJ0Y6fzArhc0KP/K/ZUUGjTjZpbEgk6A3qRn VnIB1DHFV4PxSmXYlb0wWNQh79pE3vvH558cAZ2FT0MqZMvPS4hXO2PW/7Sn9tmswLIz YOfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix6-20020a170902f80600b00186b9b292dfsi4853154plb.71.2022.10.28.07.20.29; Fri, 28 Oct 2022 07:20:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229576AbiJ1OJb (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231459AbiJ1OJQ (ORCPT ); Fri, 28 Oct 2022 10:09:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8ADCA1E047F; Fri, 28 Oct 2022 07:09:11 -0700 (PDT) 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 9C50511FB; Fri, 28 Oct 2022 07:09:17 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4B0873F534; Fri, 28 Oct 2022 07:09:10 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com, Daniel Lezcano , Guenter Roeck , linux-hwmon@vger.kernel.org Subject: [PATCH 7/8] hwmon: (scmi) Register explicitly with Thermal Framework Date: Fri, 28 Oct 2022 15:08:32 +0100 Message-Id: <20221028140833.280091-7-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028140833.280091-1-cristian.marussi@arm.com> References: <20221028140833.280091-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941424489258489?= X-GMAIL-MSGID: =?utf-8?q?1747941424489258489?= Available sensors are enumerated and reported by the SCMI platform server using a 16bit identification number; not all such sensors are of a type supported by hwmon subsystem and, among the supported ones, only a subset could be temperature sensors that have to be registered with the Thermal Framework. Potential clashes between hwmon channels indexes and the underlying real sensors IDs do not play well with the hwmon<-->thermal bridge automatic registration routines and could need a sensible number of fake dummy sensors to be made up in order to keep indexes and IDs in sync. Avoid to use the hwmon<-->thermal bridge dropping the HWMON_C_REGISTER_TZ attribute and instead explicit register temperature sensors directly with the Thermal Framework. Cc: Daniel Lezcano Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Signed-off-by: Cristian Marussi Reviewed-by: Guenter Roeck --- drivers/hwmon/scmi-hwmon.c | 115 ++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index b1329a58ce40..124fe8ee1b9b 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -20,6 +20,11 @@ struct scmi_sensors { const struct scmi_sensor_info **info[hwmon_max]; }; +struct scmi_thermal_sensor { + const struct scmi_protocol_handle *ph; + const struct scmi_sensor_info *info; +}; + static inline u64 __pow10(u8 x) { u64 r = 1; @@ -64,16 +69,14 @@ static int scmi_hwmon_scale(const struct scmi_sensor_info *sensor, u64 *value) return 0; } -static int scmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type, - u32 attr, int channel, long *val) +static int scmi_hwmon_read_scaled_value(const struct scmi_protocol_handle *ph, + const struct scmi_sensor_info *sensor, + long *val) { int ret; u64 value; - const struct scmi_sensor_info *sensor; - struct scmi_sensors *scmi_sensors = dev_get_drvdata(dev); - sensor = *(scmi_sensors->info[type] + channel); - ret = sensor_ops->reading_get(scmi_sensors->ph, sensor->id, &value); + ret = sensor_ops->reading_get(ph, sensor->id, &value); if (ret) return ret; @@ -84,6 +87,17 @@ static int scmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type, return ret; } +static int scmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + const struct scmi_sensor_info *sensor; + struct scmi_sensors *scmi_sensors = dev_get_drvdata(dev); + + sensor = *(scmi_sensors->info[type] + channel); + + return scmi_hwmon_read_scaled_value(scmi_sensors->ph, sensor, val); +} + static int scmi_hwmon_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, const char **str) @@ -122,6 +136,25 @@ static struct hwmon_chip_info scmi_chip_info = { .info = NULL, }; +static int scmi_hwmon_thermal_get_temp(struct thermal_zone_device *tz, + int *temp) +{ + int ret; + long value; + struct scmi_thermal_sensor *th_sensor = tz->devdata; + + ret = scmi_hwmon_read_scaled_value(th_sensor->ph, th_sensor->info, + &value); + if (!ret) + *temp = value; + + return ret; +} + +static const struct thermal_zone_device_ops scmi_hwmon_thermal_ops = { + .get_temp = scmi_hwmon_thermal_get_temp, +}; + static int scmi_hwmon_add_chan_info(struct hwmon_channel_info *scmi_hwmon_chan, struct device *dev, int num, enum hwmon_sensor_types type, u32 config) @@ -149,7 +182,6 @@ static enum hwmon_sensor_types scmi_types[] = { }; static u32 hwmon_attributes[hwmon_max] = { - [hwmon_chip] = HWMON_C_REGISTER_TZ, [hwmon_temp] = HWMON_T_INPUT | HWMON_T_LABEL, [hwmon_in] = HWMON_I_INPUT | HWMON_I_LABEL, [hwmon_curr] = HWMON_C_INPUT | HWMON_C_LABEL, @@ -157,6 +189,43 @@ static u32 hwmon_attributes[hwmon_max] = { [hwmon_energy] = HWMON_E_INPUT | HWMON_E_LABEL, }; +static int scmi_thermal_sensor_register(struct device *dev, + const struct scmi_protocol_handle *ph, + const struct scmi_sensor_info *sensor) +{ + struct scmi_thermal_sensor *th_sensor; + struct thermal_zone_device *tzd; + + th_sensor = devm_kzalloc(dev, sizeof(*th_sensor), GFP_KERNEL); + if (!th_sensor) + return -ENOMEM; + + th_sensor->ph = ph; + th_sensor->info = sensor; + + /* + * Try to register a temperature sensor with the Thermal Framework: + * skip sensors not defined as part of any thermal zone (-ENODEV) but + * report any other errors related to misconfigured zones/sensors. + */ + tzd = devm_thermal_of_zone_register(dev, th_sensor->info->id, th_sensor, + &scmi_hwmon_thermal_ops); + if (IS_ERR(tzd)) { + devm_kfree(dev, th_sensor); + + if (PTR_ERR(tzd) != -ENODEV) + return PTR_ERR(tzd); + + dev_info(dev, "Sensor '%s' not attached to any thermal zone.\n", + sensor->name); + } else { + dev_dbg(dev, "Sensor '%s' attached to thermal zone ID:%d\n", + sensor->name, tzd->id); + } + + return 0; +} + static int scmi_hwmon_probe(struct scmi_device *sdev) { int i, idx; @@ -164,7 +233,7 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) enum hwmon_sensor_types type; struct scmi_sensors *scmi_sensors; const struct scmi_sensor_info *sensor; - int nr_count[hwmon_max] = {0}, nr_types = 0; + int nr_count[hwmon_max] = {0}, nr_types = 0, nr_count_temp = 0; const struct hwmon_chip_info *chip_info; struct device *hwdev, *dev = &sdev->dev; struct hwmon_channel_info *scmi_hwmon_chan; @@ -208,10 +277,8 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) } } - if (nr_count[hwmon_temp]) { - nr_count[hwmon_chip]++; - nr_types++; - } + if (nr_count[hwmon_temp]) + nr_count_temp = nr_count[hwmon_temp]; scmi_hwmon_chan = devm_kcalloc(dev, nr_types, sizeof(*scmi_hwmon_chan), GFP_KERNEL); @@ -262,8 +329,30 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) hwdev = devm_hwmon_device_register_with_info(dev, "scmi_sensors", scmi_sensors, chip_info, NULL); + if (IS_ERR(hwdev)) + return PTR_ERR(hwdev); + + for (i = 0; i < nr_count_temp; i++) { + int ret; - return PTR_ERR_OR_ZERO(hwdev); + sensor = *(scmi_sensors->info[hwmon_temp] + i); + if (!sensor) + continue; + + /* + * Warn on any misconfiguration related to thermal zones but + * bail out of probing only on memory errors. + */ + ret = scmi_thermal_sensor_register(dev, ph, sensor); + if (ret == -ENOMEM) + return ret; + else if (ret) + dev_warn(dev, + "Thermal zone misconfigured for %s. err=%d\n", + sensor->name, ret); + } + + return 0; } static const struct scmi_device_id scmi_id_table[] = { From patchwork Fri Oct 28 14:08:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp860750wru; Fri, 28 Oct 2022 07:23:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WGVavW1nyh/RMerRbq59HFJdF2V6bZ3jlpCjHl2qKzP38jpJnlHEhgG3icwHsW9Q/hcXF X-Received: by 2002:a17:90b:254b:b0:200:a860:5bf9 with SMTP id nw11-20020a17090b254b00b00200a8605bf9mr16330109pjb.176.1666966984368; Fri, 28 Oct 2022 07:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966984; cv=none; d=google.com; s=arc-20160816; b=mBcHr1lKopJEBBmj/Ig02ZK5REGtGbZskl9D7jNcZJU3kriXnbjOtN090KoPsXxtU5 QaLp8bXPthccOOoL2tGObsgQYBPrTCAkOkvGnsa+Dc8iOc7anvLqnrtGsq5SXY97Cmju A45rG77/nb5xN+rxgZBnsi91fiVaRmq9UjKBrofXBZNDyrXswqGxr0l5pgd7eQ1gk4R1 OsHDdmz35lDv7QOG4GmPPgY2HT3+uHd0DyRRZ3Mc9DHdrFla2fKgW3OwXRcKFKshxqFU BgA+jz4km08yHiCUiNiOgWN9RqHlAWPS5StZCHUOlRE6aa6lIq/mZ+il2R81dqu4/VL9 CQxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=94hMpI73PIO0h/3Vty+XMO2zi3C0gyTkN9HJvjrlbOc=; b=trY8ZBthIa1x4IA/VTRydND0n7beI51K4MDxTdqenrUgcIAoHM8FjROBSodkYfRx5H XQb8B9DYwc8kb9Pp28SsmJFEAgWx28/DLXxZJqsVobyMVzMedjxpGk0vSvg4KP7qhYfZ 8OF6iFVrttY60h1g/3w1C1zedj4QGFawVjizJpjq7by11n3r7P0mqlFWcwQGRtvGEfPj gK16a6674nebU6p8Q70JkklKC+VNnDrxqhnv07ATU3ysVUfDKQLoBY99YXzBJF5Wo0ad YOP/TyCU/V4D6mwJlauGSgqQWNdPzzNnCGFrGRoV283kunfOApD3G/yyWB0IV7rylypv 5BZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a170902f54a00b00186b6a32284si6145584plf.548.2022.10.28.07.22.50; Fri, 28 Oct 2022 07:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbiJ1OJj (ORCPT + 99 others); Fri, 28 Oct 2022 10:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbiJ1OJQ (ORCPT ); Fri, 28 Oct 2022 10:09:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3EE51E047D; Fri, 28 Oct 2022 07:09:12 -0700 (PDT) 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 E499512FC; Fri, 28 Oct 2022 07:09:18 -0700 (PDT) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 935F53F534; Fri, 28 Oct 2022 07:09:11 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com, Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org Subject: [PATCH 8/8] arm64: dts: juno: Add Thermal critical trip points Date: Fri, 28 Oct 2022 15:08:33 +0100 Message-Id: <20221028140833.280091-8-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028140833.280091-1-cristian.marussi@arm.com> References: <20221028140833.280091-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747941572683793260?= X-GMAIL-MSGID: =?utf-8?q?1747941572683793260?= When thernal zones are defined, trip points definitions are mandatory. Define a couple of critical trip points for monitoring of existing PMIC and SOC thermale zones. Cc: Rob Herring Cc: Krzysztof Kozlowski Cc: devicetree@vger.kernel.org Signed-off-by: Cristian Marussi ---- Not sure if we want to add a: Fixes: f7b636a8d83c ("arm64: dts: juno: add thermal zones for scpi sensors") --- arch/arm64/boot/dts/arm/juno-base.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/boot/dts/arm/juno-base.dtsi b/arch/arm64/boot/dts/arm/juno-base.dtsi index 2f27619d8abd..8b4d280b1e7e 100644 --- a/arch/arm64/boot/dts/arm/juno-base.dtsi +++ b/arch/arm64/boot/dts/arm/juno-base.dtsi @@ -751,12 +751,26 @@ pmic { polling-delay = <1000>; polling-delay-passive = <100>; thermal-sensors = <&scpi_sensors0 0>; + trips { + pmic_crit0: trip0 { + temperature = <90000>; + hysteresis = <2000>; + type = "critical"; + }; + }; }; soc { polling-delay = <1000>; polling-delay-passive = <100>; thermal-sensors = <&scpi_sensors0 3>; + trips { + soc_crit0: trip0 { + temperature = <80000>; + hysteresis = <2000>; + type = "critical"; + }; + }; }; big_cluster_thermal_zone: big-cluster {