Message ID | 20230517105235.29176-7-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:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1047028vqo; Wed, 17 May 2023 04:10:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56QCkE8c2KT+mBUb4ymAxzpciqRhNEyZF1gD/kPtZem3hFnUuMMQrUUexQfEdIrz4vZoxT X-Received: by 2002:a17:902:b593:b0:1ad:ea13:1918 with SMTP id a19-20020a170902b59300b001adea131918mr16439007pls.69.1684321811847; Wed, 17 May 2023 04:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684321811; cv=none; d=google.com; s=arc-20160816; b=V49dELgmbZupe/49IXbf44NBTFf+CbyXwGO2pxZdN94rYAVCou2ZfBA5GZbAc1GaRx hQHAauSVRA4PTrREut5eS34txhZ9aUK/MH+6cvSx2kP5bIBLiYryFeMvtjKodRP1eo3C j5FNCNEKOjzF/qLLar3p7hvcivWBwY2cwdVHQEbN0houBvQx0QiYXN5bDTl1vpIr6wrp qOxLSE/hX6n9G2YM/cqzGF8ZMrDz4HqJ6EeXg8EJxBLlZ7IyxoAlGhYKH/OBBbsH0KIr kEl9EOnx3UJ3x8D1m3gDNTYxnIGr0Khsc4Ck3P5My3/atIV8DH2osWb2Kltshc7thPSD 2GZw== 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=R6XoseOWdzIU0KeNYEzt8GFOAsVR4w4kUmH50/FeGk0=; b=EDsG4/9k3i1Ei6HHNvC4V5PCfag0xcNGIs1KnsGd9wkzdAN2W4gYnhz1vI/2+cTse1 rcEIQkjCGI1ZhNYO2zsXV+EugY/X80ehl+yncbv1gpOYKNXVDvgIJb+ewiYvTo6Ni+0+ +vpCz9JxaHYtfGKvesy7vB19xA4SlwWCVa8GI46++S8l+mHHF3yzj2lP+lnR95hlIlRm rah+zvUdCrT7c8VKUjKYMeW7ZdF6Fd6dHUGh/RfRcEaNgW6CWGp45fIOAz8cfsqlirjc GGSxc5+PPHbfvLfKixstQ+39EHlMnb6hfprpA0flr1IwtJQrCa3WglT7M3OBeAYAKcm2 2cgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="niDEj/YY"; 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 x21-20020a170902821500b001a29280c544si19451701pln.263.2023.05.17.04.09.56; Wed, 17 May 2023 04:10:11 -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="niDEj/YY"; 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 S230526AbjEQK45 (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Wed, 17 May 2023 06:56:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230519AbjEQK4k (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 17 May 2023 06:56:40 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B355D2D7B; Wed, 17 May 2023 03:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684320971; x=1715856971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7umx+GxEypVIOLX+1oZG2a7eY4JTaLow3U/ElJE5Scs=; b=niDEj/YYNempx1xaXbrtHaX6FWsj/jm3KgnNMFSUXS2N79t8B2YHlMIB EVDDUIAM9/8YKDaMGnwnIBoQG+J99VcMD1oHNKL1PX0d7qEODV/bo1+qw ByqRHuaYV+8HpX4GewpSWcpYz0RKI6QBfoRuDd+Fmaw/dF2d1cYHdvzE4 D/szKuaospH7t3GF3QgY2LtZA4ug1PNKNeaoS3RsDZW5nFKd5tb/hgE5f Yla782y6inPwhM1YsgLZxj6kqyyh3z08rBfAzCtrZC9XPHtvYtu/WX9mK b4hZ0a953EZVxMUloRcSorvDbM1NDGKtSPI3HjZ9Y1lh7zQrrVLVmxtLx w==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="438071703" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="438071703" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 03:53:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="734651067" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="734651067" Received: from lnstern-mobl1.amr.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.221.185]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 03:53:29 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Rob Herring <robh@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= <kw@linux.com>, Emmanuel Grumbach <emmanuel.grumbach@intel.com>, "Rafael J . Wysocki" <rafael@kernel.org>, Heiner Kallweit <hkallweit1@gmail.com>, Lukas Wunner <lukas@wunner.de>, 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: Dean Luick <dean.luick@cornelisnetworks.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, =?utf-8?q?Ilpo_J=C3=A4?= =?utf-8?q?rvinen?= <ilpo.jarvinen@linux.intel.com>, stable@vger.kernel.org Subject: [PATCH v2 6/9] net/mlx5: Use RMW accessors for changing LNKCTL Date: Wed, 17 May 2023 13:52:32 +0300 Message-Id: <20230517105235.29176-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230517105235.29176-1-ilpo.jarvinen@linux.intel.com> References: <20230517105235.29176-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766139428245078398?= X-GMAIL-MSGID: =?utf-8?q?1766139428245078398?= |
Series |
PCI: Improve PCIe Capability RMW concurrency control
|
|
Commit Message
Ilpo Järvinen
May 17, 2023, 10:52 a.m. UTC
Don't assume that only the driver would be accessing LNKCTL of the
upstream bridge. ASPM policy changes can trigger write to LNKCTL
outside of driver's control.
Use RMW capability accessors which do proper locking to avoid losing
concurrent updates to the register value.
Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event")
Suggested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: stable@vger.kernel.org
---
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
Comments
On 5/17/2023 1:52 PM, Ilpo Järvinen wrote: > Don't assume that only the driver would be accessing LNKCTL of the > upstream bridge. ASPM policy changes can trigger write to LNKCTL > outside of driver's control. > > Use RMW capability accessors which do proper locking to avoid losing > concurrent updates to the register value. > > Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event") > Suggested-by: Lukas Wunner<lukas@wunner.de> > Signed-off-by: Ilpo Järvinen<ilpo.jarvinen@linux.intel.com> > Cc:stable@vger.kernel.org Reviewed-by: Moshe Shemesh <moshe@nvidia.com> Thanks!
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c index 50022e7565f1..f202150a5093 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -332,16 +332,11 @@ static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev) pci_cfg_access_lock(sdev); } /* PCI link toggle */ - err = pci_read_config_word(bridge, cap + PCI_EXP_LNKCTL, ®16); - if (err) - return err; - reg16 |= PCI_EXP_LNKCTL_LD; - err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16); + err = pcie_capability_set_word(bridge, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_LD); if (err) return err; msleep(500); - reg16 &= ~PCI_EXP_LNKCTL_LD; - err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16); + err = pcie_capability_clear_word(bridge, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_LD); if (err) return err;