Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp719140lqs; Tue, 5 Mar 2024 14:36:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUS6c/XOGFktqc3a0tP7QPtYaCNakWy0tmh8IDcCsngewSfppmyipcBNGqAnnx0NYqjygW9LSCRjawlExwiq2Ei36vOp9fcq2qC5PeAjA== X-Google-Smtp-Source: AGHT+IFwDMh7oxW/F7n0j4HWSSsNEQrVZE2C/wpUNQ6l6gYvtATngXdGw38JdbeH5NqioGlRqyf4 X-Received: by 2002:a05:6a21:78a1:b0:1a1:4d08:cfad with SMTP id bf33-20020a056a2178a100b001a14d08cfadmr3111046pzc.28.1709678174289; Tue, 05 Mar 2024 14:36:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709678174; cv=pass; d=google.com; s=arc-20160816; b=XZ37zxYwMhDFuT5wGFYUz9c/7TUe7JBkTHLijebhpigtNnI0gJPed3nBvMdp46c2CC ZJz7ORaztWutyyZO/i7HaH/vQ8+oDRnxtApHmCTxSmRBryjL6QuRIGDYdiYJYxwAK1AO QwNO6nnlexyfSgMGgo5u8GXfhh85aKAQ+P47pYen/HG9fdQlavfLgcdHnh019TII0zyO EBNP7he0Eb0CeGg7B1rFdKdvUx+u6G8ZH0lXU1D4UNkA/Kjia4H1mxDMNiTAiWq5u0ug Vqf9Dcrqp9YHOol62K1jJT1lvLX1YRkDNejCpFy+mC3wmIl9mRDuGCUXzktjkIA3e2Qc gQwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Jwrdzv/qE+heGooV5MUk4yxYCK6TVcpl+zkESMPfgeM=; fh=c366lNyBo3faMOwx9rA/jYHuftCJtf6dhyTj/Rt/2k8=; b=lMlNEot85C7XZFlw83d8B68dV67fly7/qw7z5sNOxX/Tuvgw67dhNV1nBQV4rz6DH+ BeVjCLF4/b84N07TSHSTMNZhwHgMFzcn8ecGa0WKG2meO+VNWaWVQko9B6yvfRaIXn4A bBtws9w8TV+m9+dgxgoGeHMMBbDE98K+loCkPoxgqG6NI8UjG/4Ol2JVV6wYa9V8D5zc cttLnQK+ut1Ae30srZ7TRw32qleKPPqdDnzEMvvE6ybaQC+6VvYRgjqB0meqY1exD0Dv k9o3HdZObHLG67tz1wPIz5G5t19gRRWDk+Onsfw8nUf1dvetQ+73FIsUC1a2n+4jDqc5 tbJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q3Y+Ab0G; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-93060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z4-20020aa78884000000b006e4751b9565si10826678pfe.385.2024.03.05.14.36.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 14:36:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q3Y+Ab0G; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-93060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EDB1B289E40 for ; Tue, 5 Mar 2024 22:36:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EEBF12A16A; Tue, 5 Mar 2024 22:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q3Y+Ab0G" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E75845BF1; Tue, 5 Mar 2024 22:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709678161; cv=none; b=YpLMI61hrIVwJuDnwqOBtwBQrTJ1Z88OiQcSG3lQkzqzv0Zo3RZu79mrvmuOWRUs223EJgGpkPUdtORFtFOAh7wQmw7IsaDSA4CdvjYbddCb76f/phGUvwojAfzVQjgI6voTOPwD3nLPdRr7HkKu2kwbr1c7YHHBIRhRhP1TGCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709678161; c=relaxed/simple; bh=WI1i+Vg/4OnoURbe4EGryHRT4EGzOTvFlqPo3SYK438=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=M/89zT7hY7jsktgl2Wp6Sqxn3QyG2fOKR7lwnPvuINYVFVQDYD+IMagZ7+0iudUN/RGuwMRvLFy3ED5f2fsQBVVuw5G+dJKcwooFIGvDVI0+SkcSAB1tjPNRTm8ojUi9cs9JBOV/Omv8kpUus5b1EAIc8Rwb3H6uytnaD13kmkM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Q3Y+Ab0G; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709678159; x=1741214159; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=WI1i+Vg/4OnoURbe4EGryHRT4EGzOTvFlqPo3SYK438=; b=Q3Y+Ab0GkzbIGGC+v7zKo4kmhQJOiVwHzFaKbmBx2Tj7Pr34rahr+mvn OtVsiZtY49vu6RJm0dt+NKaxJMC2sFl/bcofGqMUYa4mudcCPeGbrTEDr vFmwpZO/joQpVxrjzvCxS9+jFIBodrded12Fm7+nyYdQJEFcIkLnCO8aY dgszXcwyA3kUmQt3Hxy5g+pxeFKziE2DncIKnF+G4OxiJZ0PXdX4gZxJB w/Ic/WvIeoSscsLCRScaKCDApj09zEUlZUapuQFVSs7DEgoBmFADXONV9 fP216K2GiABhqTOPHw+erZBf1eDNW+/u6qGjHRauiJrTXGzXN13k+P3Ne w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="4842149" X-IronPort-AV: E=Sophos;i="6.06,206,1705392000"; d="scan'208";a="4842149" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2024 14:35:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,206,1705392000"; d="scan'208";a="9953445" Received: from msavchak-mobl.amr.corp.intel.com (HELO [10.209.19.134]) ([10.209.19.134]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2024 14:35:58 -0800 Message-ID: <8aa0f7c3-0656-4c1b-94c3-cb0d056e84fe@linux.intel.com> Date: Tue, 5 Mar 2024 14:35:57 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V4] PCI/ASPM: Update saved buffers with latest ASPM Content-Language: en-US To: Bjorn Helgaas , Vidya Sagar , "David E. Box" Cc: bhelgaas@google.com, macro@orcam.me.uk, ajayagarwal@google.com, ilpo.jarvinen@linux.intel.com, hkallweit1@gmail.com, johan+linaro@kernel.org, xueshuai@linux.alibaba.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, treding@nvidia.com, jonathanh@nvidia.com, kthota@nvidia.com, mmaddireddy@nvidia.com, sagar.tv@gmail.com References: <20240305220342.GA552530@bhelgaas> From: Kuppuswamy Sathyanarayanan In-Reply-To: <20240305220342.GA552530@bhelgaas> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/5/24 2:03 PM, Bjorn Helgaas wrote: > [+to Sathy, David in case you want to update your Reviewed-by] > > On Thu, Feb 22, 2024 at 11:14:36PM +0530, Vidya Sagar wrote: >> Many PCIe device drivers save the configuration state of their respective >> devices during probe and restore the same when their 'slot_reset' hook >> is called through PCIe Error Recovery Handler. >> >> If the system has a change in ASPM policy after the driver's probe is >> called and before error event occurred, 'slot_reset' hook restores the >> PCIe configuration state to what it was at the time of probe but not to >> what it was just before the occurrence of the error event. >> This effectively leads to a mismatch in the ASPM configuration between >> the device and its upstream parent device. >> >> Update the saved configuration state of the device with the latest info >> whenever there is a change w.r.t ASPM policy. >> >> Signed-off-by: Vidya Sagar >> -void pci_save_aspm_state(struct pci_dev *pdev); >> +void pci_save_aspm_l1ss_state(struct pci_dev *pdev); > I rebased this again on top of my pci/aspm updates to remove the need > for the rename above. > >> +static void pci_save_aspm_state(struct pci_dev *dev) >> +{ >> + struct pci_cap_saved_state *save_state; >> + u16 *cap; >> + >> + if (!pci_is_pcie(dev)) >> + return; >> + >> + save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); >> + if (!save_state) >> + return; >> + >> + cap = (u16 *)&save_state->cap.data[0]; >> + pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &cap[1]); > And I changed this part so it only updates the PCI_EXP_LNKCTL_ASPMC > bits, not the entire LNKCTL. > > Updating the entire saved register probably wouldn't *break* anything, > but it could randomly hide other LNKCTL changes depending on whether > or not ASPM configuration was changed in the interim. For example: > > - driver .probe() saves LNKCTL > - LNKCTL changes some non-ASPMC thing via setpci or other mechanism > - save_state updated via pcie_config_aspm_link() > > A restore in .slot_reset() would restore different LNKCTL values for > the non-ASPMC change depending on whether pcie_config_aspm_link() was > used. > > I applied it on pci/aspm for v6.9. Please take a look and make sure > it still does what you need: > https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=aspm&id=a6315434436d587f70e489e6365c5b7e20176a71 > > Sathy and David, I didn't add your Reviewed-by because I didn't want > to presume that you were OK with my changes. But I'd be more than > happy to add them if you take a look. Your update looks fine to me. Reviewed-by: Kuppuswamy Sathyanarayanan > > Bjorn > >> +} >> + >> void pci_aspm_get_l1ss(struct pci_dev *pdev) >> { >> /* Read L1 PM substate capabilities */ >> pdev->l1ss = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_L1SS); >> } >> >> -void pci_save_aspm_state(struct pci_dev *pdev) >> +void pci_save_aspm_l1ss_state(struct pci_dev *pdev) >> { >> struct pci_cap_saved_state *save_state; >> u16 l1ss = pdev->l1ss; >> @@ -309,10 +325,12 @@ static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable) >> struct pci_bus *linkbus = link->pdev->subordinate; >> u32 val = enable ? PCI_EXP_LNKCTL_CLKREQ_EN : 0; >> >> - list_for_each_entry(child, &linkbus->devices, bus_list) >> + list_for_each_entry(child, &linkbus->devices, bus_list) { >> pcie_capability_clear_and_set_word(child, PCI_EXP_LNKCTL, >> PCI_EXP_LNKCTL_CLKREQ_EN, >> val); >> + pci_save_aspm_state(child); >> + } >> link->clkpm_enabled = !!enable; >> } >> >> @@ -931,6 +949,12 @@ static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) >> pcie_config_aspm_dev(parent, upstream); >> >> link->aspm_enabled = state; >> + >> + /* Update latest ASPM configuration in saved context */ >> + pci_save_aspm_state(link->downstream); >> + pci_save_aspm_l1ss_state(link->downstream); >> + pci_save_aspm_state(parent); >> + pci_save_aspm_l1ss_state(parent); >> } >> >> static void pcie_config_aspm_path(struct pcie_link_state *link) >> -- >> 2.25.1 >> -- Sathyanarayanan Kuppuswamy Linux Kernel Developer