From patchwork Fri Nov 18 22:20:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 22533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp439434wrr; Fri, 18 Nov 2022 14:25:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf7qhjfRSos+RSL9B/KEJZinrplNwsG3OOkiU53aDTi0BGJyVrx6Q8JLzP/A9Yw/lvYet9fe X-Received: by 2002:a63:5c02:0:b0:476:898c:ded5 with SMTP id q2-20020a635c02000000b00476898cded5mr8591024pgb.299.1668810315836; Fri, 18 Nov 2022 14:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668810315; cv=none; d=google.com; s=arc-20160816; b=xLbCY5qCuliPiB0Mg710yREHLpvhooGRwXIMWfESD9GR1wMyrn1wx5k+DlXViIs+RM KCCLUh3M9DRk/+LOFld0VP76e4EySaZQAN9oKOgm7htKt89nXQ9W6Kq3colRtW7Qs4Ku oxo5eVz93YQD4VTWuXgptVFRPYGKcNIRJYt1O/gd6Yj2//WmVwiqGJjwkM+Bexsvs3Z/ IazKfpE9SFxv/VZJf9997NkdJ4yP4ZVY+/RqJw0hkZ0TpIVMuB62z+SCEnKoU+X+oLRg Zm2dgRcAI5mrVPkCwR0jayHMu2bswH4lnCDSjIqm6AXV0n7rHU8cv4VIP2z9I72kk5rI 0HLA== 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 :dkim-signature; bh=q2nP9uCfDBevFmEtTcMQJc0hWbBrYXC+dJVLWwDHDY4=; b=D4lv4mKt+LdlIPTyyGbDl7wkJVo8B+iexqHgMZvI0Pshv/TEI9ooYmjKWeRShgtkYm B4B5jghXc0se9fKXpNjJH/wEvfMlKv16bCICEsro73CLq9iGfIJfpd5YCTZ+SJjYB/TB YuGmmIjXcIBaOerMSgp+ZBHjiGOvAe+8KN8xMTMEq+FANOJ0rMDplZygMQPE2NnJ60jr PEEXPkUX8mwzemplfx5AdgFTOcQfZxmz7Pv3MGc4GuhA/w+tJm44+tMGXBMo28uVFcvD 9j8+i9xQiwz9HiD5c/juiRfhVYlrC4pkwN8tXB/j4YfCggFg+yGCmGP969o20MLCrFF5 dgGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RifEh9b/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a17090a634100b0020d2d54066csi4016776pjs.171.2022.11.18.14.25.03; Fri, 18 Nov 2022 14:25:15 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RifEh9b/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbiKRWWa (ORCPT + 99 others); Fri, 18 Nov 2022 17:22:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbiKRWVw (ORCPT ); Fri, 18 Nov 2022 17:21:52 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE7CEB7E80 for ; Fri, 18 Nov 2022 14:21:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 62911B82568 for ; Fri, 18 Nov 2022 22:21:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED2F7C433D6; Fri, 18 Nov 2022 22:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668810068; bh=E9ca8QoCrIeSP5fRU5kfdctSssLXX9ouXkKzqOBNjD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RifEh9b/d10HRwrBCx6g393UiIXtOcsAjsOlWfzmYu2iNwN2VuhW2aQqyWMhp0R1t ceKq7ZUUcKR/IzGWAGqh/VRoeEi1pTgpSDBi5fqY1iMGNZyHcNjqDfbWuHK8u38zOw VwAXmC4x9igXN/1CrbD9uc7A6CnVL9B/2Zly8E48NsfeiY+iNsvktPbaiLjnlhD16f rMSEYdSDvZmjaZW1+hywyW5kTwPLG+fj/SMd1c80lSS63qwCY4gFURKonF0EigCyJU 8suUaTx9TrCQj2hxoUlbvbHRhjK1tScv0OalgK6XDQee3G6feAbwkwQyeQsjatNjLh dn+hUA/R1bdQQ== From: Conor Dooley To: Conor Dooley , Jassi Brar Cc: Daire McNamara , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] soc: microchip: mpfs: handle failed system service requests Date: Fri, 18 Nov 2022 22:20:43 +0000 Message-Id: <20221118222043.1214776-2-conor@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221118222043.1214776-1-conor@kernel.org> References: <20221118222043.1214776-1-conor@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1749874445859801495?= X-GMAIL-MSGID: =?utf-8?q?1749874445859801495?= From: Conor Dooley If a service request fails, a non-zero, per-service error code will be set. Since the individual service drivers may wish to handle things differently, there's little point trying to do anything intelligent in the system controller driver. Let the caller know that things went wrong & leave the details of handling the error to it. Fixes: d0054a470c33 ("soc: add microchip polarfire soc system controller") Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index 6e20207b5756..539fc24b397d 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -52,6 +52,12 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mutex_unlock(&transaction_lock); + if (ret) + return ret; + + if (msg->response->resp_status) + ret = -EIO; + return ret; } EXPORT_SYMBOL(mpfs_blocking_transaction); From patchwork Fri Nov 18 22:20:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 22532 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp439364wrr; Fri, 18 Nov 2022 14:24:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf6cLQT5zj+QBKGdQqWTa1Wnd/SHFvZ7270jRiM02ro93KILnmgdm7T6occVoF4cxhhEalm9 X-Received: by 2002:a17:902:848d:b0:17a:b11:3c5 with SMTP id c13-20020a170902848d00b0017a0b1103c5mr1523234plo.22.1668810296332; Fri, 18 Nov 2022 14:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668810296; cv=none; d=google.com; s=arc-20160816; b=YQpqTA/rTomVZ75xpgi6Rkn8y4MMtTeUZW3mUXR9MQAyXFhIfa4Z2NuOvOL8NJ/gbo 93hBHZA8bAvKBCFBJ/d6R2gyu4BLC4xw+/2cXmGSCiHdO/1nuoWNBu57ypkT5DS9SMTg EqGuVQLgCcYvztYOsnTBM6bcGBAXBRPnjPxcdQ6TCcW/3ScSDXjIaKTz1gtQPUeTrDep 0N1plpGSjSYPJTgRGLTpGuYCRspZhp02VcnQtcDzD22PEBSN/P3+lnq4EZ+mXSR5aMGC fRzRIRahX11ysAV+0bxZTekQ91Uup3J345rMJ6qxtkYOofAFcVKqXLfL9W0y8FtIBLBH lWoQ== 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 :dkim-signature; bh=TrJ6BDH8KXnPPVFO0pSqjGzGxHNh38BtPFaR3IOdGTY=; b=YHnMh0aErsM808NWR6Dsaklryic8BgVpbux7VhKzvzRtNlXJta3l6qGaOdBTMWBe11 deS2vV2CRcXe5r31HvpJ9qeRS0zvtuZKpYxkMdKYiZ3PTqWwRrhLNDKm3kAkZFE+I22O 0NUB29vmpZKjeMM6zEet7fDwDoDsHvL1T9LnFwDJXSxfJ76ShdQ2PdT20UIwPROYvAPA S7DsB50idQuB+tho69dDFCgZt2TUTlamrmH/WiTYEjNCah7Y/OZes0G1X/pcT1hGaws7 W+UqyWRm+fteoqV9y3SNRQNXtAeDfa3sqI+yuiYtaQRKfC4pCsMR6fo2qZJuqe7mUnzW 7twA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aHlBYrVz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a1709026bc700b0018875900d97si4454070plt.20.2022.11.18.14.24.44; Fri, 18 Nov 2022 14:24:56 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aHlBYrVz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230035AbiKRWWY (ORCPT + 99 others); Fri, 18 Nov 2022 17:22:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbiKRWVw (ORCPT ); Fri, 18 Nov 2022 17:21:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A5AB855C for ; Fri, 18 Nov 2022 14:21:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E54B6279E for ; Fri, 18 Nov 2022 22:21:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AF7CC433C1; Fri, 18 Nov 2022 22:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668810069; bh=K4TWLp30MXq/vlUO4bYw+Yxu6jQkHHR0g0VL9tJJy0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHlBYrVzekL56zjVEHQIDbk21QpS5JB4djm47cUUTIl9N3czKaqcJCOvQ371Efp7X bgEg21np2uyEsEIkbB/bOUB1AKsw3qRwD+WlYzSuULyunEDetNHGpgT4TDLoguKwgo 7Od7J0jF97Jqk3sQtrikDjxMUZic+fpnByt5H1C7bg15QvTMr1txfzVNqeBYg6LGJ5 P/noDLVDp84yQ9rHJdJz2LqpPVKJN9r4r1hd1RJ+jlw74jjgg6qZ8HA4W5fGPUFYpJ 1Nde3oLOLxmIUyn7Ne8u1Ay2F8rG0S5Zf0zQcohRJaYsBk8uGktrrbtNG1FChQNU91 deNda9hb8pYZQ== From: Conor Dooley To: Conor Dooley , Jassi Brar Cc: Daire McNamara , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] mailbox: mpfs: read the system controller's status Date: Fri, 18 Nov 2022 22:20:44 +0000 Message-Id: <20221118222043.1214776-3-conor@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221118222043.1214776-1-conor@kernel.org> References: <20221118222043.1214776-1-conor@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1749874425529916636?= X-GMAIL-MSGID: =?utf-8?q?1749874425529916636?= From: Conor Dooley Some services explicitly return an error code in their response, but others rely on the system controller to set a status in its status register. The meaning of the bits varies based on what service is requested, so pass it back up to the driver that requested the service in the first place. The field in the message struct already existed, but was unused until now. If the system controller is busy, in which case we should never actually be in the interrupt handler, or if the service fails the mailbox itself should not be read. Callers should check the status before operating on the response. Fixes: 83d7b1560810 ("mbox: add polarfire soc system controller mailbox") Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index cfacb3f320a6..6b99abac0b11 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -2,7 +2,7 @@ /* * Microchip PolarFire SoC (MPFS) system controller/mailbox controller driver * - * Copyright (c) 2020 Microchip Corporation. All rights reserved. + * Copyright (c) 2020-2022 Microchip Corporation. All rights reserved. * * Author: Conor Dooley * @@ -23,6 +23,8 @@ #define MAILBOX_REG_OFFSET 0x800u #define MSS_SYS_MAILBOX_DATA_OFFSET 0u #define SCB_MASK_WIDTH 16u +#define SCB_STATUS_SHIFT 16u +#define SCB_STATUS_MASK GENMASK(31, SCB_STATUS_SHIFT) /* SCBCTRL service control register */ @@ -130,13 +132,38 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan) struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; struct mpfs_mss_response *response = mbox->response; u16 num_words = ALIGN((response->resp_size), (4)) / 4U; - u32 i; + u32 i, status; if (!response->resp_msg) { dev_err(mbox->dev, "failed to assign memory for response %d\n", -ENOMEM); return; } + /* + * The status is stored in bits 31:16 of the SERVICES_SR register. + * It is only valid when BUSY == 0. + * We should *never* get an interrupt while the controller is + * still in the busy state. If we do, something has gone badly + * wrong & the content of the mailbox would not be valid. + */ + if (mpfs_mbox_busy(mbox)) { + dev_err(mbox->dev, "got an interrupt but system controller is busy\n"); + response->resp_status = 0xDEAD; + return; + } + + status = readl_relaxed(mbox->ctrl_base + SERVICES_SR_OFFSET); + + /* + * If the status of the individual servers is non-zero, the service has + * failed. The contents of the mailbox at this point are not be valid, + * so don't bother reading them. Set the status so that the driver + * implementing the service can handle the result. + */ + response->resp_status = (status & SCB_STATUS_MASK) >> SCB_STATUS_SHIFT; + if (response->resp_status) + return; + if (!mpfs_mbox_busy(mbox)) { for (i = 0; i < num_words; i++) { response->resp_msg[i] =