From patchwork Fri Jun 2 11:47:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 102521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp979007vqr; Fri, 2 Jun 2023 05:10:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ464LeYzm0xaPL5hdoWfiJO1BYAAb5JAcKmWrGuFH+AajhvZOVJJcoCfhIEstnP6vPWiykk X-Received: by 2002:a17:902:e801:b0:1a5:22a:165c with SMTP id u1-20020a170902e80100b001a5022a165cmr1698062plg.0.1685707849615; Fri, 02 Jun 2023 05:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685707849; cv=none; d=google.com; s=arc-20160816; b=SgbuYwWUD5BpgvcLonAiZxAz9NCP140yO+5sKeWy7o8Q9fS9TZGdiOz5FgZIXUHsku /czSIaYulgEU81mF3yquJacOvjJQdcQciYVZNCnNmyefCa3ovym+hE0DfqI4bVPkVOq+ bw6gfladZv5bIVOiAb0idq8DrRKX31MjFYrEXruSAR/DZezNTWPSRtYiY6An+AtYFoo1 KL4tA4ElUt6PqYnmzb5wYfUiclF3iv5JsRZ+ATH92c+SNRpQ/3RHanZCgEHAgRpcUnz2 rjCLExwWJ9ENCkTi/VekwvMwzR37rPKqDLcALHDEafIpkPYQ+ME4ZokQpreoLVKKxkOI W1xw== 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=4j8KViiPpieJIwzx/HkMOnLfHIY+6oaSvv/q7uA8YAk=; b=AyRuKzoUmY2etOr2IFmZJzTWHGAh8YO1WdPTx8ktgKk4AyEQcYmHEVvzF8gdaR429r gIvGwRdViqs4Par8Xyc897btRDeB80E+EOgI89ZnMNV9tTJLvn0wZU+Wmqd4JHlzKlss 8RnN5aT/yK+PAr1y6EgGdliSLMFTqWsFZjRZqymnkBDJwOpjJlj64Bp488efuGXwWU/b +tL1SITXyjtqOSWRbGZBHbyDO3PgtvHfeUN+UPnD3ljG59ZxslEUgCdCECK2oHIUnskQ /tU2mU/v/rgaA+IkFGjE45hxMmWGKNYii0sccc6/gyC2ostHODDV52fyEVy0V6mjdCUw di0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nVjj+tS4; 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 b17-20020a170902d51100b001ae4a01a7e0si859586plg.236.2023.06.02.05.10.36; Fri, 02 Jun 2023 05:10:49 -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=nVjj+tS4; 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 S235615AbjFBLuU (ORCPT + 99 others); Fri, 2 Jun 2023 07:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235589AbjFBLty (ORCPT ); Fri, 2 Jun 2023 07:49:54 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C46EE63; Fri, 2 Jun 2023 04:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685706566; x=1717242566; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jGXAxasqLUJNCCsewqKuozH1mOZUvPCSOeFXiURbrcI=; b=nVjj+tS4Mx7xe20SIiFMGmTsVujt3v+aQDoe/N3sAoHZSPPWDu2HHWFO BbZpDf49xgCg6G51JyizgJ+Jt3xNziAf5Hjd+6//LL5TPE+DNzqmm3c0f WzdilcyIag8fxY25rbiN7wkEieh4AMw4SqBZO9aXKZgPhGbCfBM7vAZdF kmfZPH4X73EUAyIxMbMjW6+toMAvWaCUOb2p6bYqWOxL1YCF8XmUyDu/C cFXhOT+RbQv5VXyFgvtOB4UQSkDzMQyIVnJ3W9Yr23WH+neNFWq0ynhcn T9Bmcy7Z1vCrGldhX+OeoBBGSlpQ1j/x4LXDQ02T4EwClwYxK9ZEGKOBn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="358279726" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="358279726" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707819513" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707819513" Received: from rspatil-mobl3.gar.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.208.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:48:44 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [RFC PATCH v1 08/13] e1000e: Remove unreliable pci_disable_link_state{,_locked}() workaround Date: Fri, 2 Jun 2023 14:47:45 +0300 Message-Id: <20230602114751.19671-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> References: <20230602114751.19671-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767592793733552933?= X-GMAIL-MSGID: =?utf-8?q?1767592793733552933?= pci_disable_link_state() and pci_disable_link_state_locked() were made reliable regardless of ASPM CONFIG and OS being disallowed to change ASPM states to allow drivers to rely on them working. Remove driver working around unreliable pci_disable_link_state{,_locked}() from e1000e driver and just call the functions directly. Signed-off-by: Ilpo Järvinen --- drivers/net/ethernet/intel/e1000e/netdev.c | 77 +--------------------- 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index bd7ef59b1f2e..d680d059a681 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -6763,79 +6763,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) return 0; } -/** - * __e1000e_disable_aspm - Disable ASPM states - * @pdev: pointer to PCI device struct - * @state: bit-mask of ASPM states to disable - * @locked: indication if this context holds pci_bus_sem locked. - * - * Some devices *must* have certain ASPM states disabled per hardware errata. - **/ -static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state, int locked) -{ - struct pci_dev *parent = pdev->bus->self; - u16 aspm_dis_mask = 0; - u16 pdev_aspmc, parent_aspmc; - - switch (state) { - case PCIE_LINK_STATE_L0S: - case PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1: - aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L0S; - fallthrough; /* can't have L1 without L0s */ - case PCIE_LINK_STATE_L1: - aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L1; - break; - default: - return; - } - - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &pdev_aspmc); - pdev_aspmc &= PCI_EXP_LNKCTL_ASPMC; - - if (parent) { - pcie_capability_read_word(parent, PCI_EXP_LNKCTL, - &parent_aspmc); - parent_aspmc &= PCI_EXP_LNKCTL_ASPMC; - } - - /* Nothing to do if the ASPM states to be disabled already are */ - if (!(pdev_aspmc & aspm_dis_mask) && - (!parent || !(parent_aspmc & aspm_dis_mask))) - return; - - dev_info(&pdev->dev, "Disabling ASPM %s %s\n", - (aspm_dis_mask & pdev_aspmc & PCI_EXP_LNKCTL_ASPM_L0S) ? - "L0s" : "", - (aspm_dis_mask & pdev_aspmc & PCI_EXP_LNKCTL_ASPM_L1) ? - "L1" : ""); - -#ifdef CONFIG_PCIEASPM - if (locked) - pci_disable_link_state_locked(pdev, state); - else - pci_disable_link_state(pdev, state); - - /* Double-check ASPM control. If not disabled by the above, the - * BIOS is preventing that from happening (or CONFIG_PCIEASPM is - * not enabled); override by writing PCI config space directly. - */ - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &pdev_aspmc); - pdev_aspmc &= PCI_EXP_LNKCTL_ASPMC; - - if (!(aspm_dis_mask & pdev_aspmc)) - return; -#endif - - /* Both device and parent should have the same ASPM setting. - * Disable ASPM in downstream component first and then upstream. - */ - pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_dis_mask); - - if (parent) - pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, - aspm_dis_mask); -} - /** * e1000e_disable_aspm - Disable ASPM states. * @pdev: pointer to PCI device struct @@ -6846,7 +6773,7 @@ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state, int locked) **/ static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) { - __e1000e_disable_aspm(pdev, state, 0); + pci_disable_link_state(pdev, state); } /** @@ -6859,7 +6786,7 @@ static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) **/ static void e1000e_disable_aspm_locked(struct pci_dev *pdev, u16 state) { - __e1000e_disable_aspm(pdev, state, 1); + pci_disable_link_state_locked(pdev, state); } static int e1000e_pm_thaw(struct device *dev)