From nobody Tue Feb 10 23:01:43 2026 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 969BAC7EE22 for ; Thu, 11 May 2023 13:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237570AbjEKNPX (ORCPT ); Thu, 11 May 2023 09:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238024AbjEKNPK (ORCPT ); Thu, 11 May 2023 09:15:10 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C137286B6; Thu, 11 May 2023 06:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683810899; x=1715346899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j2mH7twU8xcKQ+ibOA7cifbNNveZqlGmmYNV0ZHAcVE=; b=eeK4O2yGfVOf+BvkAaNQkzqMkwSVTBKzTBFc+yutTiWBwm4pGrqmbd2Z 1krvOInYRUkzaW5oQpYDsqt0gRBeiBSmmQkc6Q6ThQJpbDfWi7hrimfry E41TVxeB2QobzlBMpljZDD7Jwz5rFb9lZBrUwbVGi7Qo0mO5H0WnRPi3h fdx2OfWanIolAsDegiUfFTmEwi9DaXoqrBpWdtyuReP4bBhnPhE6WLs0m BXiw4pocLGqJxiHD2enbwjoeyx91jKrf+9xQfCP7TO1nzSH7O+9Go4pFR vJnau8tQRqJEoKwxtrxeoUfgYhI2zXnJJrHOOKrPaB5JCw9xUu0Mag3e0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="378619339" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="378619339" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 06:14:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="650169475" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="650169475" Received: from jsanche3-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.39.112]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 06:14:56 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Lukas Wunner , Bjorn Helgaas , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 02/17] PCI: pciehp: Protect LNKCTL changes Date: Thu, 11 May 2023 16:14:26 +0300 Message-Id: <20230511131441.45704-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230511131441.45704-1-ilpo.jarvinen@linux.intel.com> References: <20230511131441.45704-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As hotplug is not the only driver touching LNKCTL, use the pcie_lnkctl_clear_and_set() helper which handles concurrent changes correctly. Suggested-by: Lukas Wunner Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/hotplug/pciehp_hpc.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_= hpc.c index f8c70115b691..14ffbb27957c 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -332,17 +332,10 @@ int pciehp_check_link_status(struct controller *ctrl) static int __pciehp_link_set(struct controller *ctrl, bool enable) { struct pci_dev *pdev =3D ctrl_dev(ctrl); - u16 lnk_ctrl; =20 - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnk_ctrl); + pcie_lnkctl_clear_and_set(pdev, PCI_EXP_LNKCTL_LD, + !enable ? PCI_EXP_LNKCTL_LD : 0); =20 - if (enable) - lnk_ctrl &=3D ~PCI_EXP_LNKCTL_LD; - else - lnk_ctrl |=3D PCI_EXP_LNKCTL_LD; - - pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl); - ctrl_dbg(ctrl, "%s: lnk_ctrl =3D %x\n", __func__, lnk_ctrl); return 0; } =20 --=20 2.30.2