Message ID | 20230814132721.26608-1-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2764889vqi; Mon, 14 Aug 2023 07:02:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFazJYaWPKWX/zwZYmfzl7e5zSYHzQ/PRcm7JCHgNLgtkrvzyVW9ZzW0vqFy3quf1SQqHeD X-Received: by 2002:a17:906:20dc:b0:970:c9f:2db6 with SMTP id c28-20020a17090620dc00b009700c9f2db6mr7526023ejc.63.1692021760707; Mon, 14 Aug 2023 07:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692021760; cv=none; d=google.com; s=arc-20160816; b=aIdk/Z2FqIRWm/jOhdE92wXJ4SNwf0bxD5jAvo60rTvfIt3ZStAYgOqMb3YmOHqVn+ 87MVIU9EIUjUfX6r7gPSM7RQKSby9H9saI76fH2opIUzzHhv8aL8Jot99axhRYp4nkbC IaAp9u1ud4218mTl6nTvXqKA5DlT0jbhbdWc5RTwIHIMVp29MfjQ9DBpGNSd7hRT0PBi UcoF+jsIR0LagVbW+/De1NZzl7LEV6ym4lRKSHNL5/JdVOICFg62W9tNQgmOxtZ0B/aT IW25rGQNZT8aw4YOeA5kB4YA0O71ht0DUkXx+UFzxaFWtehXqh8iDJwPmJ2D0Grs+URZ HAPA== 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:dkim-signature; bh=wz0QjStSdVBiWUDy67+txeBMwVaft/xDs4B3hEG41aY=; fh=+uK1ehcLjeUNgbMrjnWrUy+SG9emijaJ2emTeRhy6wo=; b=GyHIVGmU6T/ZK8m6FMIPrRu0RdLTXkRxeeuoCex1FY0R1zPr5xJYMC7oXuSBUnwnTw j8XRzBeJrxxQgdRzAGGalOn59s0+10gZKyfHvOvJAb2FMgS+umoN6L8+UzUcmMPG9j1L 7kf7eLX9ddSMyixbH79nDk5k2M+i1wgMUeI3mE5X/99RHNvVyLnPkic9BN3OcKHggMyg jKGz4JABAMcMrUChj40Vt7GQSL0gkVjmSt+AU0Nm0YFh1j8eZWqio5BrgHMYkAiDcRp4 I+C3NyQ0vGYf+cGYVj7Rp7uQZeHY9/mijMZR4nxt2iea82YfBm6GKWrOrAwMb+YDuL0A 1FQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bk+eyYKu; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id us11-20020a170906bfcb00b0099d79342678si6132398ejb.40.2023.08.14.07.02.13; Mon, 14 Aug 2023 07:02:40 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=bk+eyYKu; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbjHNN1h (ORCPT <rfc822;274620705z@gmail.com> + 99 others); Mon, 14 Aug 2023 09:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbjHNN1d (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Aug 2023 09:27:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8205012D; Mon, 14 Aug 2023 06:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692019652; x=1723555652; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uEAgFuelBW2HgyEvKYz5wAP7z+RpkG1urn+9Q46Dy7I=; b=bk+eyYKuBrFmu+7+0R+2HpsogVQuD8ts7xFdW/Pp6C1EArEkdnu3+4jI 19OxaOgzzDCvlgIdF31Qfb81FZ5JC+8hVhXRw2AoiTPVARHq+I/PSLLtT VAo//rcdqEiftiPjRrctjwm1jYol+8CbssBn4+NebN9+jReQd6FxBQ4XC k0Lu5V7ZoKjKnMGQQSStms3U4wqk8jwDZzQXQPKI7YndgjTSV2OTYNlJ7 ltntS49aTu0bsbBU1cBTAmYrlTaSLz265XprDPcXdxMZfNQjXxRLXtcD7 ZcISf1J/O2BUV3jqCqdGaQFvGLtPfGcMtiQfdeVHCqFhvrucMpD6nDkGD Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="458399097" X-IronPort-AV: E=Sophos;i="6.01,172,1684825200"; d="scan'208";a="458399097" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 06:27:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="768452779" X-IronPort-AV: E=Sophos;i="6.01,172,1684825200"; d="scan'208";a="768452779" Received: from lgarello-mobl.ger.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.249.40.121]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 06:27:28 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: Bjorn Helgaas <helgaas@kernel.org>, linux-pci@vger.kernel.org, Saeed Mahameed <saeedm@nvidia.com>, Leon Romanovsky <leon@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Moshe Shemesh <moshe@mellanox.com>, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> Subject: [PATCH 1/1] net/mlx5: Convert PCI error values to generic errnos Date: Mon, 14 Aug 2023 16:27:20 +0300 Message-Id: <20230814132721.26608-1-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774213409917480817 X-GMAIL-MSGID: 1774213409917480817 |
Series |
[1/1] net/mlx5: Convert PCI error values to generic errnos
|
|
Commit Message
Ilpo Järvinen
Aug. 14, 2023, 1:27 p.m. UTC
mlx5_pci_link_toggle() returns mix PCI specific error codes and generic
errnos.
Convert the PCI specific error values to generic errno using
pcibios_err_to_errno() before returning them.
Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event")
Fixes: 212b4d7251c1 ("net/mlx5: Wait for firmware to enable CRS before pci_restore_state")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
Maintainers beware, this will conflict with read+write -> set/clear_word
fixes in pci.git/pcie-rmw. As such, it might be the easiest for Bjorn to
take it instead of net people.
I wonder if these PCIBIOS_* error codes are useful at all? There's 1:1
mapping into errno values so no information loss if the functions would just
return errnos directly. Perhaps this is just legacy nobody has bothered to
remove? If nobody opposes, I could take a look at getting rid of them.
---
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Comments
On Mon, Aug 14, 2023 at 04:27:20PM +0300, Ilpo Järvinen wrote: > mlx5_pci_link_toggle() returns mix PCI specific error codes and generic > errnos. > > Convert the PCI specific error values to generic errno using > pcibios_err_to_errno() before returning them. > > Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event") > Fixes: 212b4d7251c1 ("net/mlx5: Wait for firmware to enable CRS before pci_restore_state") > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > > --- > > Maintainers beware, this will conflict with read+write -> set/clear_word > fixes in pci.git/pcie-rmw. As such, it might be the easiest for Bjorn to > take it instead of net people. I provisionally rebased and applied it on pci/pcie-rmw. Take a look and make sure I didn't botch it -- I also found a case in mlx5_check_dev_ids() that looks like it needs the same conversion. The commit as applied is below. If networking folks would prefer to take this, let me know and I can drop it. > I wonder if these PCIBIOS_* error codes are useful at all? There's 1:1 > mapping into errno values so no information loss if the functions would just > return errnos directly. Perhaps this is just legacy nobody has bothered to > remove? If nobody opposes, I could take a look at getting rid of them. I don't think the PCIBIOS error codes are very useful outside of arch/x86. They're returned by x86 PCIBIOS functions, and I think we still use those calls, but I don't think there's value in exposing the x86 error codes outside arch/x86. Looks like a big job to clean it up though ;) > --- > drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c > index 4804990b7f22..0afd9dbfc471 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c > @@ -371,7 +371,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) > > err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, &dev_id); > if (err) > - return err; > + return pcibios_err_to_errno(err); > err = mlx5_check_dev_ids(dev, dev_id); > if (err) > return err; > @@ -386,16 +386,16 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) > /* PCI link toggle */ > err = pci_read_config_word(bridge, cap + PCI_EXP_LNKCTL, ®16); > if (err) > - return err; > + return pcibios_err_to_errno(err); > reg16 |= PCI_EXP_LNKCTL_LD; > err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16); > if (err) > - return err; > + return pcibios_err_to_errno(err); > msleep(500); > reg16 &= ~PCI_EXP_LNKCTL_LD; > err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16); > if (err) > - return err; > + return pcibios_err_to_errno(err); > > /* Check link */ > if (!bridge->link_active_reporting) { > @@ -408,7 +408,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) > do { > err = pci_read_config_word(bridge, cap + PCI_EXP_LNKSTA, ®16); > if (err) > - return err; > + return pcibios_err_to_errno(err); > if (reg16 & PCI_EXP_LNKSTA_DLLLA) > break; > msleep(20); > @@ -426,7 +426,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) > do { > err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, ®16); > if (err) > - return err; > + return pcibios_err_to_errno(err); > if (reg16 == dev_id) > break; > msleep(20); commit a48c6af2d2a5 ("net/mlx5: Convert PCI error values to generic errnos") Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Date: Mon Aug 14 16:27:20 2023 +0300 net/mlx5: Convert PCI error values to generic errnos mlx5_pci_link_toggle() returns a mix of PCI-specific error codes and generic errnos. Convert the PCI-specific error values to generic errno using pcibios_err_to_errno() before returning them. Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event") Fixes: 212b4d7251c1 ("net/mlx5: Wait for firmware to enable CRS before pci_restore_state") Link: https://lore.kernel.org/r/20230814132721.26608-1-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [bhelgaas: rebase to pci/pcie-rmw, also convert in mlx5_check_dev_ids()] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c index 99dcbd006357..85a2dfbb5c46 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -311,7 +311,7 @@ static int mlx5_check_dev_ids(struct mlx5_core_dev *dev, u16 dev_id) list_for_each_entry(sdev, &bridge_bus->devices, bus_list) { err = pci_read_config_word(sdev, PCI_DEVICE_ID, &sdev_id); if (err) - return err; + return pcibios_err_to_errno(err); if (sdev_id != dev_id) { mlx5_core_warn(dev, "unrecognized dev_id (0x%x)\n", sdev_id); return -EPERM; @@ -371,7 +371,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, &dev_id); if (err) - return err; + return pcibios_err_to_errno(err); err = mlx5_check_dev_ids(dev, dev_id); if (err) return err; @@ -386,11 +386,11 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) /* PCI link toggle */ err = pcie_capability_set_word(bridge, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_LD); if (err) - return err; + return pcibios_err_to_errno(err); msleep(500); err = pcie_capability_clear_word(bridge, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_LD); if (err) - return err; + return pcibios_err_to_errno(err); /* Check link */ if (!bridge->link_active_reporting) { @@ -403,7 +403,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) do { err = pci_read_config_word(bridge, cap + PCI_EXP_LNKSTA, ®16); if (err) - return err; + return pcibios_err_to_errno(err); if (reg16 & PCI_EXP_LNKSTA_DLLLA) break; msleep(20); @@ -421,7 +421,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) do { err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, ®16); if (err) - return err; + return pcibios_err_to_errno(err); if (reg16 == dev_id) break; msleep(20);
On 14 Aug 17:32, Bjorn Helgaas wrote: >On Mon, Aug 14, 2023 at 04:27:20PM +0300, Ilpo Järvinen wrote: >> mlx5_pci_link_toggle() returns mix PCI specific error codes and generic >> errnos. >> >> Convert the PCI specific error values to generic errno using >> pcibios_err_to_errno() before returning them. >> >> Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event") >> Fixes: 212b4d7251c1 ("net/mlx5: Wait for firmware to enable CRS before pci_restore_state") >> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> >> >> --- >> >> Maintainers beware, this will conflict with read+write -> set/clear_word >> fixes in pci.git/pcie-rmw. As such, it might be the easiest for Bjorn to >> take it instead of net people. > >I provisionally rebased and applied it on pci/pcie-rmw. Take a look >and make sure I didn't botch it -- I also found a case in >mlx5_check_dev_ids() that looks like it needs the same conversion. > >The commit as applied is below. > >If networking folks would prefer to take this, let me know and I can >drop it. > I Just took this patch into my mlx5 submission queue and sent it to netdev tree, please drop it from your tree. Thanks for the patch, Saeed.
On Wed, Aug 16, 2023 at 02:45:15PM -0700, Saeed Mahameed wrote: > On 14 Aug 17:32, Bjorn Helgaas wrote: > > On Mon, Aug 14, 2023 at 04:27:20PM +0300, Ilpo Järvinen wrote: > > > mlx5_pci_link_toggle() returns mix PCI specific error codes and generic > > > errnos. > > > > > > Convert the PCI specific error values to generic errno using > > > pcibios_err_to_errno() before returning them. > > > > > > Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event") > > > Fixes: 212b4d7251c1 ("net/mlx5: Wait for firmware to enable CRS before pci_restore_state") > > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > > > > > > --- > > > > > > Maintainers beware, this will conflict with read+write -> set/clear_word > > > fixes in pci.git/pcie-rmw. As such, it might be the easiest for Bjorn to > > > take it instead of net people. > > > > I provisionally rebased and applied it on pci/pcie-rmw. Take a look > > and make sure I didn't botch it -- I also found a case in > > mlx5_check_dev_ids() that looks like it needs the same conversion. > > > > The commit as applied is below. > > > > If networking folks would prefer to take this, let me know and I can > > drop it. > > I Just took this patch into my mlx5 submission queue and sent it to netdev > tree, please drop it from your tree. OK, will do. Note that this will generate a conflict between netdev and the PCI tree during the merge window. Bjorn
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c index 4804990b7f22..0afd9dbfc471 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -371,7 +371,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, &dev_id); if (err) - return err; + return pcibios_err_to_errno(err); err = mlx5_check_dev_ids(dev, dev_id); if (err) return err; @@ -386,16 +386,16 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) /* PCI link toggle */ err = pci_read_config_word(bridge, cap + PCI_EXP_LNKCTL, ®16); if (err) - return err; + return pcibios_err_to_errno(err); reg16 |= PCI_EXP_LNKCTL_LD; err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16); if (err) - return err; + return pcibios_err_to_errno(err); msleep(500); reg16 &= ~PCI_EXP_LNKCTL_LD; err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16); if (err) - return err; + return pcibios_err_to_errno(err); /* Check link */ if (!bridge->link_active_reporting) { @@ -408,7 +408,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) do { err = pci_read_config_word(bridge, cap + PCI_EXP_LNKSTA, ®16); if (err) - return err; + return pcibios_err_to_errno(err); if (reg16 & PCI_EXP_LNKSTA_DLLLA) break; msleep(20); @@ -426,7 +426,7 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) do { err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, ®16); if (err) - return err; + return pcibios_err_to_errno(err); if (reg16 == dev_id) break; msleep(20);