From patchwork Mon Apr 4 02:12:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12799788 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 281A3C433F5 for ; Mon, 4 Apr 2022 02:12:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376885AbiDDCOe (ORCPT ); Sun, 3 Apr 2022 22:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235878AbiDDCOd (ORCPT ); Sun, 3 Apr 2022 22:14:33 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF5C35DE1 for ; Sun, 3 Apr 2022 19:12:38 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C81102130A; Mon, 4 Apr 2022 02:12:37 +0000 (UTC) Received: from pdx1-sub0-mail-a291.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5EAE42149B; Mon, 4 Apr 2022 02:12:37 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1649038357; a=rsa-sha256; cv=none; b=hTzImmG6iCu7smtfEL3ldyHt3mup9HJEwwuwyW2kWC5CTYopvvVCGqIIVmyGv8QCQ+G+J2 hIxtGd4Ej989e+9iTgmEQsPh/P4bu0zGfJgg2Law5uDaq1YQP2FocEd8GxI7PlWy6TZ1Xa y7KJzKetx5k1xu4f2WfaEGWuHBgVmZ4/ux7zilWwYsfWA/RNU3JKI8xbVY5IJ3U1Zoa5pd Ip+QPEVKkHJuJaDfbzMImqMMm+6qyxFZB90xwgMzNC8TUt4hNrZ6wCnEIRZOcPciA0JDm4 lBKMZHwToCGwBiUlcndNU7+2VzYtJYlCUszXOPUPT2AKbwdVhgJReAHSnpDabg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1649038357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wv4wN/nk0m+YPlolNyZl3U5/E6F+TwicTHeK8Y/RfeE=; b=V+WC33LKxOUB0eVixUhA51p79aQJPKy3dIIrgtsaZyeaTlHd4tzBwEhuYafh18by04exmd fYYgANohvnP6N1ygVEL9Fx1bLAyg+y6LticbMZLNVLk8wGdyqXJn+wRiPAwRy28m3K9huw 7fSHzRMwoqd7W1yZdcxOkPwW5SNk+bZAQmFN6S7Y+D2O5rgW19fDSidKBkoc/M+8Q4UEse cd+Sc4glciyWdIDPB6tC84lMnnqQqvtjEb07Zf0Rxp7Y57UtYqOVseGDzvsvIA60qNpSBC Nd0Ulr3HV1J2DFoRS+pviHl05O/KrkWZmaHKuuTm9gu9m9oCbvHAO3ynMXnu3A== ARC-Authentication-Results: i=1; rspamd-786f77c8d-gmnn5; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a291.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.107.255.190 (trex/6.7.1); Mon, 04 Apr 2022 02:12:37 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Vacuous-Share: 5e09f16367772c79_1649038357702_2074411280 X-MC-Loop-Signature: 1649038357702:813509929 X-MC-Ingress-Time: 1649038357701 Received: from localhost.localdomain (unknown [104.36.25.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a291.dreamhost.com (Postfix) with ESMTPSA id 4KWvS44GpBz1PZ; Sun, 3 Apr 2022 19:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1649038357; bh=q1KueJT9ZPCMhsJeqyptOzpcgqykjfhziky16keligg=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=dZqDkr3ttJ7YEdoyVpuL8EWgL5P+MC0Gox5hXKyQE7qKoxj3FLCSCQiSS8ah7N+yD iIIb6du+3M1E8fYRg2xNnc9hAltH0xbWw0P6x3hlfdNoKtiC3eZqIipau6wrtFZN/y IQZYgYgK44wBDGf+/LlKWRIvpq32dM7LgAjrYQlR4Z8S/WVRdQUJD1lXTvggPbX7Co kfVys0GQhhZABm/KNi8w34aiTVKFpwtxq8CAosCvQ7Kt6ilNQ3NWXBBfFdoqFp/OQe eYrKfvzKoAhNB92jzUeaPxwh6DZv7dm/aAqxIozpaDDnKycPwyDbVphtKGLhYNL7dW 1f4tlpVRN3R2Q== From: Davidlohr Bueso To: linux-cxl@vger.kernel.org Cc: dan.j.williams@intel.com, ben.widawsky@intel.com, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, a.manzanares@samsung.com, dave@stgolabs.net Subject: [PATCH 1/4] cxl/mbox: Drop mbox_mutex comment Date: Sun, 3 Apr 2022 19:12:13 -0700 Message-Id: <20220404021216.66841-2-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220404021216.66841-1-dave@stgolabs.net> References: <20220404021216.66841-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org ... we have lockdep for this. Reviewed by: Adam Manzanares Signed-off-by: Davidlohr Bueso --- drivers/cxl/core/mbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index be61a0d8016b..a586c0fa9555 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -136,7 +136,7 @@ static struct cxl_mem_command *cxl_mem_find_command(u16 opcode) * @out: Caller allocated buffer for the output. * @out_size: Expected size of output. * - * Context: Any context. Will acquire and release mbox_mutex. + * Context: Any context. * Return: * * %>=0 - Number of bytes returned in @out. * * %-E2BIG - Payload is too large for hardware. From patchwork Mon Apr 4 02:12:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12799789 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 1D864C433EF for ; Mon, 4 Apr 2022 02:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376887AbiDDCOi (ORCPT ); Sun, 3 Apr 2022 22:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358063AbiDDCOi (ORCPT ); Sun, 3 Apr 2022 22:14:38 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4D4235DD4 for ; Sun, 3 Apr 2022 19:12:40 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 4CF8021453; Mon, 4 Apr 2022 02:12:40 +0000 (UTC) Received: from pdx1-sub0-mail-a291.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 92762214E4; Mon, 4 Apr 2022 02:12:39 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1649038359; a=rsa-sha256; cv=none; b=WBHAQUwav1DeWvG3G35Kj7Yu9TinzPzbEG3ZKXRtnxyJv24uNJ7UD6SqTk8GhI3J9/rW8G dWPqY+cnOWVOKnR4l0ulU0DnqFQaj69YwDFWIy2gAZ1kFjoGNeDgJH0+cSlw7e8Iv890wP PzkA+Dv9BNBqY4Z3XSUqT9yBWPEOrkEC3j8MWv0Cqr8V6VG8NO6+bkYF+w/mOxDXgh44PY 9k0XrIr6HtFl3C90vngZXif5TGr6raN2ac02F6pqYAqd3uSbkpLuVchJxpGdRKwEeWHCpx 4jO9Vv1zSzLUegBdL2ik8iRy2+Vv+tgsYyNwShtaUKgl+Fg/tw+wGRbaeAhFGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1649038359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=q8qIRFPV0uC+cNYd2+NI4qePMQ25+vLbZPWX145AKhM=; b=3qkbKo0+dys9KEu+ej4Y/X7emq0on7e0q/ttiibIQiacxbycNKInNTVbC1JOHF4UXwggvU hWVJDIo1JpR8+MNE1uLwVekQdzr59EdVaF1IVSZv6w75PIxT9euioiWX4qrHqQPujvL3yI U5CMo9l3qb6D3dm5K+LeoISvI9fjRAxJe1TpvT2p8w5Ujz9Hxo4qK5tzFPi52JL5LsvAWP w504CERzMTbPtfziydPGcS5KMSxUz8bydkm5yBDbnHA9mCT0+/DRYKOtsGnTSjQYgE69Hy p9G2Z3DlTdEj7JCd4I8mZdjulFsJ4hUdVAt0u59n9V7OhyLiiyj/S7z1A772JQ== ARC-Authentication-Results: i=1; rspamd-786f77c8d-zm9p2; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a291.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.112.55.202 (trex/6.7.1); Mon, 04 Apr 2022 02:12:40 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Squirrel-Illegal: 15baf8174aed050b_1649038359913_4204820175 X-MC-Loop-Signature: 1649038359913:79525924 X-MC-Ingress-Time: 1649038359913 Received: from localhost.localdomain (unknown [104.36.25.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a291.dreamhost.com (Postfix) with ESMTPSA id 4KWvS52V9gz1Pg; Sun, 3 Apr 2022 19:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1649038359; bh=q8qIRFPV0uC+cNYd2+NI4qePMQ25+vLbZPWX145AKhM=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=aTQG7nTtIAP7LMjc1EnxQp+Cb/7FHha2GbO/Hdqix3QlxymEZg3dnu51UYOjKG1oF tiTsTmvBUOhz04yIQ6IlPHvE424INdbz4TGQIQq1V77N5ltBMD2I34S1aqbmOW9K3x PNIBgwO6w1HOyJXLFiHxnMwVSxxeywRieJwODkU8IohplMYY2QjBXl+Nu0oSfC8lE6 zYUAk9SibWv7VognE5S267wYJ5C4WCG2uPRnDpo7b0/NugT7tH/z4YevvWs9/oQ5fb BPufp8RxGyitxEP32on6ArEjAZLheDFSH4zfwWQLo7lXRKc2Asp3USGaWi/jfMGJ+D 8sbb2ZB2VpesA== From: Davidlohr Bueso To: linux-cxl@vger.kernel.org Cc: dan.j.williams@intel.com, ben.widawsky@intel.com, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, a.manzanares@samsung.com, dave@stgolabs.net Subject: [PATCH 2/4] cxl/pci: Use CXL_MBOX_SUCCESS to check against mbox_cmd return code Date: Sun, 3 Apr 2022 19:12:14 -0700 Message-Id: <20220404021216.66841-3-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220404021216.66841-1-dave@stgolabs.net> References: <20220404021216.66841-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Also mention the need for the caller to check against any errors from the hardware in return_code. Reviewed by: Adam Manzanares Signed-off-by: Davidlohr Bueso --- drivers/cxl/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 8a7267d116b7..8b131692ed61 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -177,9 +177,9 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds, mbox_cmd->return_code = FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg); - if (mbox_cmd->return_code != 0) { + if (mbox_cmd->return_code != CXL_MBOX_SUCCESS) { dev_dbg(dev, "Mailbox operation had an error\n"); - return 0; + return 0; /* completed but caller must check return_code */ } /* #7 */ From patchwork Mon Apr 4 02:12:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12799791 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 0BC76C433F5 for ; Mon, 4 Apr 2022 02:12:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376886AbiDDCOj (ORCPT ); Sun, 3 Apr 2022 22:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358063AbiDDCOi (ORCPT ); Sun, 3 Apr 2022 22:14:38 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5089C36179 for ; Sun, 3 Apr 2022 19:12:42 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 863C8120AAA; Mon, 4 Apr 2022 02:12:41 +0000 (UTC) Received: from pdx1-sub0-mail-a291.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id EC7F3120CED; Mon, 4 Apr 2022 02:12:40 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1649038361; a=rsa-sha256; cv=none; b=4rXLSxmhVhR2cW5St2sQvxdIOA90QgMuoBOYUbzVRwBgv2LvCmE24b7CRLgLjHcv5oQ2e3 roBPILqmGpkZMzEWrURZMdOmGzJTWJ+m5+cA3og/SVIE15fQbU7z4vbTtwNYeGhItD1gDi 7ZsiopBg9bQl/FCL7UMqAg2gYaJLm3ScbFC94BmUrHY2OV1HhVnxGPR0MxqozHrEFE9H+9 eCCbkdYzhqfjQRHRItbGhrxYproadtNKjZJ85NLADxOgdvy6o9hntmvvx7uS6X0QxdbWyY GIf2getarUyoXTiGLRY8+Pgp2ZEFy2CukoTZF2WQwzNhozU5LWA/0rVzD5XKig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1649038361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=55BdkeNpp+yee7dfWixViuBhPM+Zpl0q6QEV+CDcEL8=; b=9qR45srTrR4llX8BFP9OZVCCe5o1qq7o4T+6oMgm3Ec0AFEf8FVT7+kYEapPHtT2kW1dEh W3UWH2w58YzLSQRGQ6LM7lCMXVahDdJVYBWMGiVE5Yx+5y0z/OoASOmeMq5gHpAuvThC0/ EAN23d1+ZoekZatfjU++vg72Xz2M3PezCzVB0mm9Gr91zCt7lexBXJbc4mBFeepVaSK5WA DdHMLOJrdhvGHiRW155a0y6+TtVGcySyMxvwZ9erV/+RqpR+8R9iMntGVGHoEh1sfO1PnW NSBmr1Zhcg9DyWIKWEpCoi1gtlDpNgeUGSnz2KLCDV37dNT+oUVcFwHjDm3//Q== ARC-Authentication-Results: i=1; rspamd-786f77c8d-6kt9n; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a291.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.96.96.30 (trex/6.7.1); Mon, 04 Apr 2022 02:12:41 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Skirt-Macabre: 2463d21142c91d9b_1649038361272_856029037 X-MC-Loop-Signature: 1649038361272:3076096319 X-MC-Ingress-Time: 1649038361272 Received: from localhost.localdomain (unknown [104.36.25.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a291.dreamhost.com (Postfix) with ESMTPSA id 4KWvS74mrZz22; Sun, 3 Apr 2022 19:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1649038360; bh=55BdkeNpp+yee7dfWixViuBhPM+Zpl0q6QEV+CDcEL8=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=JIEzfRSmXnwAPNb6I21PbYQjAAUOOb7M8/8hRNpD4SWwou1SqauVelX6dzREeqqIq L332XE+tJk7WJqapQdC/CrBqlwDxlVppfI44yAesFGeyBkoSNi4CJqSrFDU2JltFSD mWZWVJal+UvcicrWlQQYeEGEh8PMKKtoX+NW/inaJM6Lx7vDjUDLL3XrELC6clQ1S5 5+R5vYSfAL3LRT4dXpcBsq0lR/AwN5pNkKCEtQHg1N8RNbuggvZsXKYyQBtRaNoMLs 1Bvy/Q6Uz/IQGtaDR7usUm3gG/m5cZxTgXSozL1B1ZSzN5MqdTbd1oUFaQZmnBP1u0 VGqZmDrvtG+og== From: Davidlohr Bueso To: linux-cxl@vger.kernel.org Cc: dan.j.williams@intel.com, ben.widawsky@intel.com, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, a.manzanares@samsung.com, dave@stgolabs.net Subject: [PATCH 3/4] cxl/mbox: Improve handling of mbox_cmd hw return codes Date: Sun, 3 Apr 2022 19:12:15 -0700 Message-Id: <20220404021216.66841-4-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220404021216.66841-1-dave@stgolabs.net> References: <20220404021216.66841-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Upon a completed command the caller is still expected to check the actual return_code register to ensure it succeed. This adds, per the spec, the potential command return codes. It maps the hardware return code with the kernel's errno style, and by default continues to use -ENXIO (Command completed, but device reported an error). Reviewed by: Adam Manzanares Signed-off-by: Davidlohr Bueso --- drivers/cxl/core/mbox.c | 2 +- drivers/cxl/cxlmem.h | 53 ++++++++++++++++++++++++++++++++++++++++- drivers/cxl/pci.c | 2 +- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index a586c0fa9555..353b3f97c7e6 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -170,7 +170,7 @@ int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in, return rc; /* TODO: Map return code to proper kernel style errno */ - if (mbox_cmd.return_code != CXL_MBOX_SUCCESS) + if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) return -ENXIO; /* diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 5d33ce24fe09..264a3cbfcad6 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -85,9 +85,60 @@ struct cxl_mbox_cmd { size_t size_in; size_t size_out; u16 return_code; -#define CXL_MBOX_SUCCESS 0 }; +/* + * Per CXL 2.0 Section 8.2.8.4.5.1 + */ +#define CMD_CMD_RC_TABLE \ + C(SUCCESS, 0, NULL), \ + C(BACKGROUND, -ENXIO, "background cmd started successfully"), \ + C(INPUT, -ENXIO, "cmd input was invalid"), \ + C(UNSUPPORTED, -ENXIO, "cmd is not supported"), \ + C(INTERNAL, -ENXIO, "internal device error"), \ + C(RETRY, -ENXIO, "temporary error, retry once"), \ + C(BUSY, -ENXIO, "ongoing background operation"), \ + C(MEDIADISABLED, -ENXIO, "media access is disabled"), \ + C(FWINPROGRESS, -ENXIO, "one FW package can be transferred at a time"), \ + C(FWOOO, -ENXIO, "FW package content was transferred out of order"), \ + C(FWAUTH, -ENXIO, "FW package authentication failed"), \ + C(FWSLOT, -ENXIO, "FW slot is not supported for requested operation"), \ + C(FWROLLBACK, -ENXIO, "rolled back to the previous active FW"), \ + C(FWRESET, -ENXIO, "FW failed to activate, needs cold reset"), \ + C(HANDLE, -ENXIO, "one or more Event Record Handles were invalid"), \ + C(PADDR, -ENXIO, "physical address specified is invalid"), \ + C(POISONLMT, -ENXIO, "poison injection limit has been reached"), \ + C(MEDIAFAILURE, -ENXIO, "permanent issue with the media"), \ + C(ABORT, -ENXIO, "background cmd was aborted by device"), \ + C(SECURITY, -ENXIO, "not valid in the current security state"), \ + C(PASSPHRASE, -ENXIO, "phrase doesn't match current set passphrase"), \ + C(MBUNSUPPORTED, -ENXIO, "unsupported on the mailbox it was issued on"),\ + C(PAYLOADLEN, -ENXIO, "invalid payload length") + +#undef C +#define C(a, b, c) CXL_MBOX_CMD_RC_##a +enum { CMD_CMD_RC_TABLE }; +#undef C +#define C(a, b, c) { b, c } +struct cxl_mbox_cmd_rc { + int err; + const char *desc; +}; + +static const +struct cxl_mbox_cmd_rc cxl_mbox_cmd_rctable[] ={ CMD_CMD_RC_TABLE }; +#undef C + +static inline const char *cxl_mbox_cmd_rc2str(struct cxl_mbox_cmd *mbox_cmd) +{ + return cxl_mbox_cmd_rctable[mbox_cmd->return_code].desc; +} + +static inline int cxl_mbox_cmd_rc2errno(struct cxl_mbox_cmd *mbox_cmd) +{ + return cxl_mbox_cmd_rctable[mbox_cmd->return_code].err; +} + /* * CXL 2.0 - Memory capacity multiplier * See Section 8.2.9.5 diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 8b131692ed61..4fbef05e9082 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -177,7 +177,7 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds, mbox_cmd->return_code = FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg); - if (mbox_cmd->return_code != CXL_MBOX_SUCCESS) { + if (mbox_cmd->return_code != CXL_MBOX_CMD_RC_SUCCESS) { dev_dbg(dev, "Mailbox operation had an error\n"); return 0; /* completed but caller must check return_code */ } From patchwork Mon Apr 4 02:12:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12799790 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 ACF6CC433FE for ; Mon, 4 Apr 2022 02:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376888AbiDDCOj (ORCPT ); Sun, 3 Apr 2022 22:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376886AbiDDCOi (ORCPT ); Sun, 3 Apr 2022 22:14:38 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC1236315 for ; Sun, 3 Apr 2022 19:12:42 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 490DF21516; Mon, 4 Apr 2022 02:12:42 +0000 (UTC) Received: from pdx1-sub0-mail-a291.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id A9B90214E3; Mon, 4 Apr 2022 02:12:41 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1649038361; a=rsa-sha256; cv=none; b=45vZmLw90pfvbS9O23635SmbY/RaMG0rnEJ9G+94OxIlLXb5Ks1m1Rnl00LLcEmHyWMVC+ HipyBQpXZ+i7e19w3uw1vVdLO62AVsDKZjN+wy7NJJ5t5inhLpLRKy6Ljdnh3k8BxGZ2pw eq4YqofVq8QKtnv+WvqpSVGWxIADiFNkomx7dSYQ6vC9g1gcMov1D+sjsfRLp8Xu7PAG4n d2V3aP1HOftZnKY4X1FX83w4bC5litz8ZcYIUzSvkkY0hrBgf5EWUbFWAW4ZxA/Bo1YeA4 JGRc4HpRnGYEURr45jjQY/TSb9UXOgIIFP9iuSczOGbboQwVCI6MJek5KfBoZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1649038361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QjAt7BEVg32lputG6KlvHYYRfRmAJUzltFsX0NgaDiE=; b=3PFTzETMlh/6AYgl6bhkVnoNvWJiyehrab9p5SVscMsKhQGWsp3a8rb6Lm8kv7Vj+wqRWG aW25miyhaisbN5095IOkx3d2YyhZpPYHjXK1z5uVVKZ6KE9wM3Ig4hOvu40DJGor8HNUL+ FGPdnyp3wLwNhem85xc7FKCwgsjHhQREaAgQNQKz4xOvYWJAPZ9ulhY/Tt7cIdXvm7OhMy 0R4QAs3OyBl6FX8H50HMx+5zwZiwFs3Slu+hSxzoUUwq4XKf1T1B0wlaz1vavbK1YKCk0c bYYR/nkPfdqQmSOAAlvvnBvbs6NY1ekTJvVkvANSAycDQ5+OWg0du19/JzLhJg== ARC-Authentication-Results: i=1; rspamd-786f77c8d-kx8xc; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a291.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.112.55.202 (trex/6.7.1); Mon, 04 Apr 2022 02:12:42 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Imminent-Grain: 67cb2353672f48ed_1649038362149_196462450 X-MC-Loop-Signature: 1649038362149:2677610679 X-MC-Ingress-Time: 1649038362149 Received: from localhost.localdomain (unknown [104.36.25.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a291.dreamhost.com (Postfix) with ESMTPSA id 4KWvS853Qgz1Pg; Sun, 3 Apr 2022 19:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1649038361; bh=QjAt7BEVg32lputG6KlvHYYRfRmAJUzltFsX0NgaDiE=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=aS8WISrSRk7HmLAC9dBwM3YJOHABM+ICNdi6Auvm6fseSdBQUrQM/v8bxio/xbror QO9kGpX3ncyK5VyPgJrGyL27OmHh11W+zJHRczPDS2ue3RlzyXERveErRZxt7mF/q+ HlS2hnLWBmagyWEH2KBh/uHEW9E9b7P3coPLiZOy4woQV/dPl+UuA8mKbbFsJtwtXM +4aX9Rz2rOu/0DsagIvPxmx0BkClgg4fKzc42wb7g5oP4HMcd/WwgWiiX+mciKuc7r qzxucazjK26UmzAPzxw6NtD7CXBM7cxZjjNxiTVuLodNxtcT/VyMczk/IygndgCEp0 Bt0zFYz02MkJg== From: Davidlohr Bueso To: linux-cxl@vger.kernel.org Cc: dan.j.williams@intel.com, ben.widawsky@intel.com, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, a.manzanares@samsung.com, dave@stgolabs.net Subject: [PATCH 4/4] cxl/mbox: Use new return_code handling Date: Sun, 3 Apr 2022 19:12:16 -0700 Message-Id: <20220404021216.66841-5-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220404021216.66841-1-dave@stgolabs.net> References: <20220404021216.66841-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Use the global cxl_mbox_cmd_rc table to improve debug messaging in __cxl_pci_mbox_send_cmd() and allow cxl_mbox_send_cmd() to map to proper kernel style errno codes - this patch continues to use -ENXIO only so no change in semantics. Reviewed by: Adam Manzanares Signed-off-by: Davidlohr Bueso --- drivers/cxl/core/mbox.c | 3 +-- drivers/cxl/pci.c | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index 353b3f97c7e6..d7286c256e1c 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -169,9 +169,8 @@ int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in, if (rc) return rc; - /* TODO: Map return code to proper kernel style errno */ if (mbox_cmd.return_code != CXL_MBOX_CMD_RC_SUCCESS) - return -ENXIO; + return cxl_mbox_cmd_rc2errno(&mbox_cmd); /* * Variable sized commands can't be validated and so it's up to the diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 4fbef05e9082..18d31fafc856 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -178,7 +178,8 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_dev_state *cxlds, FIELD_GET(CXLDEV_MBOX_STATUS_RET_CODE_MASK, status_reg); if (mbox_cmd->return_code != CXL_MBOX_CMD_RC_SUCCESS) { - dev_dbg(dev, "Mailbox operation had an error\n"); + dev_dbg(dev, "Mailbox operation had an error: %s\n", + cxl_mbox_cmd_rc2str(mbox_cmd)); return 0; /* completed but caller must check return_code */ }