Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5501936rwp; Mon, 17 Jul 2023 05:23:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlGgewkQT0fjsPq2Snys8nWlPwIjrgD5Haw76t6/RsD0NXudksJRg8YFrcR3WiSJmr96sGML X-Received: by 2002:aa7:d81a:0:b0:51e:421e:d209 with SMTP id v26-20020aa7d81a000000b0051e421ed209mr10128434edq.13.1689596591260; Mon, 17 Jul 2023 05:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689596591; cv=none; d=google.com; s=arc-20160816; b=gWE2xKgLrhsP/TwOfPD773t4iayiGEkw5FGKTXm5R89IQDMtLE/o3rdcLBugHoBIij VgqPImVZb+VlKlr/jAGi4d1N7zu7ULUJZFDGOGTsboO89aAmrFwheN5xNFCc6eTemtRf ygW2fdIc7Wqc4yWpVylGgrB07chqL3LAG2ci9P4qwxtkjKb86ZJ/ylZSUWViUHb72J4W Pq1AaibDWnus+rCX9oiQ92jXZIM8KWv+68O/AzqEZPd+ISrbHDEZNcrZlHvPRukO877z KUNNvAzXDfAozkJZojP13kZFoQ32xqI2UH4reESJxSp6ulJwVKkNoGYl5XgZT9njPYxF GbOg== 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=maJMBe8vCJkYA7g8XuhhX6eiHQqqzOs/C4wUCSZb/9s=; fh=WdpmWhFYOB+tVy7nFPF5yW2OM1EVKtnBGv2nbMNyXoI=; b=b+JacZ87IbG+AcJJxSetQlXbjMG62aJH1Mh70h6vnlOqbUIUGI95j7bcXAgjVN9JHy Gi77AwCvfPTKqvY99378WMmrGMReGBKp5BSEp/2halJFPBjB406zC9Icjj5g0hCxA7sZ MJJQT6yHFXyBKFt1m0DoP7hxbllDp6zge1dYFGzm7+OCYNVtVhfJoiXFmH6uZjUsZwCn zc6Zum47pUG4Lw/AZztvFB/FCdZzZUtnKgCPS5wPq4ApP53B+VE2VJ//b4mjXWzGwQKy 21C/9544rgs0bzDhqHpT91w3g+H+VlMyEzAlnZHMNZQi37D9cnad4Hdw+ZwbWWHhQuKI O0qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S6hBKUPK; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a50ef14000000b0051e0ef8936asi13604610eds.291.2023.07.17.05.22.47; Mon, 17 Jul 2023 05:23: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=S6hBKUPK; 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 S231126AbjGQMGA (ORCPT + 99 others); Mon, 17 Jul 2023 08:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbjGQMFx (ORCPT ); Mon, 17 Jul 2023 08:05:53 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59EAB1705; Mon, 17 Jul 2023 05:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689595549; x=1721131549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7vj7apDaYugl+D8Y3pzOiM9+vaJxURJo41t4KuZm3pY=; b=S6hBKUPKD7RXY5LhcZSVGSL7Cz7XMhaTcw9lzTz/dBHrbAzpOtZ2JA2k jV9+aLSofdBItNge/iIH0INY/qGmk+cfcw8cwyPk4uF0twpnt/a14V5iQ rQXn3Wx0wahHi7lrib6z2awnM9dOUHG/e+1Pljo6rMt7vxZaE8m/cTGBa B6bIN/Dm9D9m24+RCGOVrF9TaKF/y6PXeoztzFiuyb/8QdGNwHg6fB7a+ 6QsPYw5Js23x8uPftaaXxdIyPvCdtUFUd+CWfgi04ctKI9T+Nw1yEriAH zFpzKk7FjINh4zRVl89+hE8MF+4pdMpNk1RZXL4jgM3KDmeRR2Akw1kWf g==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="432081559" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="432081559" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 05:05:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="752875949" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="752875949" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 05:05:44 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Emmanuel Grumbach , "Rafael J . Wysocki" , Heiner Kallweit , Lukas Wunner , Andy Shevchenko , Jesse Barnes , Yinghai Lu , linux-kernel@vger.kernel.org Cc: Dean Luick , =?UTF-8?q?Jonas=20Dre=C3=9Fler?= , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , stable@vger.kernel.org Subject: [PATCH v5 03/11] PCI: pciehp: Use RMW accessors for changing LNKCTL Date: Mon, 17 Jul 2023 15:04:55 +0300 Message-Id: <20230717120503.15276-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717120503.15276-1-ilpo.jarvinen@linux.intel.com> References: <20230717120503.15276-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 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 As hotplug is not the only driver touching LNKCTL, use the RMW capability accessor which handles concurrent changes correctly. Fixes: 7f822999e12a ("PCI: pciehp: Add Disable/enable link functions") Suggested-by: Lukas Wunner Signed-off-by: Ilpo Järvinen Acked-by: Rafael J. Wysocki Cc: stable@vger.kernel.org --- drivers/pci/hotplug/pciehp_hpc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 8711325605f0..fd713abdfb9f 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -332,17 +332,11 @@ int pciehp_check_link_status(struct controller *ctrl) static int __pciehp_link_set(struct controller *ctrl, bool enable) { struct pci_dev *pdev = ctrl_dev(ctrl); - u16 lnk_ctrl; - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnk_ctrl); + pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, + PCI_EXP_LNKCTL_LD, + enable ? 0 : PCI_EXP_LNKCTL_LD); - if (enable) - lnk_ctrl &= ~PCI_EXP_LNKCTL_LD; - else - lnk_ctrl |= PCI_EXP_LNKCTL_LD; - - pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl); - ctrl_dbg(ctrl, "%s: lnk_ctrl = %x\n", __func__, lnk_ctrl); return 0; } -- 2.30.2