Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1875619rdb; Tue, 20 Feb 2024 09:26:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLyTB7FMJy3c88fHB1LYo9af3/Mnql1eb59FXCCemnz0cySiA9UlQeWII2uJu84Q/psO86/5NJNzAyflTwFXO8SGGrS45afgMQ7g/B6g== X-Google-Smtp-Source: AGHT+IE7BG3a6MgQAAXfPtKXwzh5RaMWLqhuVWejVonxaoHnuWgXVjWLwdVPeyxGR9FTlhgQe+a2 X-Received: by 2002:a17:90a:fa0c:b0:299:2ed1:d462 with SMTP id cm12-20020a17090afa0c00b002992ed1d462mr9999812pjb.6.1708449984944; Tue, 20 Feb 2024 09:26:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708449984; cv=pass; d=google.com; s=arc-20160816; b=ceIn00gPM50v+3eNJ2PBGeo8Zblv5u2Rjwr3vuwsCO9E3PFmnIX4fdM1sIetidOBgW 9b2bL/eeHOPU1c30RmP+ZiabJk8MQ8Lg18hxzgNLnQjbtf5TAy96hoYs3b/UReTpZe7R pTFxjgVvoLT5Kg/DsGF0vbObuF3VeP8Fb9a04LgomkwtfhfEamEW3A84aP5ATDwkcIEJ 2gd5OywTxHieyjwsjgjkHPYRWFMb6hpc6SbXQgcUnhs/sYMTS2DV969zP1m3oenG1T9o LirD47KR5wm1qG/UFhr2C6ghUArSomA8u0ATECPSZxU2X8Pqb5KatCCf7b06aNhyWRix XfhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=BcR+8WtRRZMRvhxa4VrQk7zVdP9DKRIwwr+K9eg12kI=; fh=DtvDddIYiSu37nSAGaGVcxHHDc+ctHPzoilEmKktr+s=; b=0w4li/DRFmxk/tORS1kt9EM62Mciuhvay/wLNut9GhjW5Ck4dtsaE9DWQdcxtVhf4C NLG/pHN+SGG3j1J0wzrLTqWaUIxoETaRh7ixcMg8IVo/O4jSi06qO++WErhmBm+6lozm zGQFteJZgcgSId+2rEgHVD8Ahvyu0vBRxYqYaCpIQIo32HmZJ0ghyMKOxbPVsslAwYFb D/DZAH9FPMmYQicvmM9bThmkBBnKYLt3BVeCwNEzyLZXEuStgHQtrptCIkutXq8+QNk8 K1Mbl1SluARBRjgoUzO2Mh8NVgergL5Rbq5nWxRQSYh44kSLXpw1wg1XaiaWddC5Qbou hTNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q8su+0gu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-73434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w68-20020a636247000000b005dcb793677esi6382371pgb.135.2024.02.20.09.26.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 09:26:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q8su+0gu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-73434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 01C0CB22B90 for ; Tue, 20 Feb 2024 17:23:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 830B976C8F; Tue, 20 Feb 2024 17:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q8su+0gu" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9DC1B2599; Tue, 20 Feb 2024 17:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708449813; cv=none; b=hNp+gRuO85/crxGnooHtvpNOvzmZzXop+o8x7bhlIZeggFTExFCVEeQfXa/itXMww3RBWswybwjwgbdr0cjh1vOGDqV2lAC4vXYUT9vNOyzXhw1nWiItVg2Ea3P6znqDvOmV/1WYro0x9CHZUukOoeAj0jlwxmq3wXOU3EAl8UM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708449813; c=relaxed/simple; bh=dmMWWCPUJrt43ZgfiKC2edIWPknjOvRFAVs6CZ9C13g=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=hl7SEURC5H3BpywXiIGNXnjHrfsMEMvaEj29/XCLFJDuUTddi92J5zIPl8U2pb14dwR41oSZ5Tm6NNrr2ITyPYz7TusIitrRefLTodotUHHR2lvoUBzZqoev2q3o10nwyANgmsGjwgAMyeFgOnH4HkWLA8sTnoptDD/W1zoMJfs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q8su+0gu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0DCAC433C7; Tue, 20 Feb 2024 17:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708449813; bh=dmMWWCPUJrt43ZgfiKC2edIWPknjOvRFAVs6CZ9C13g=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Q8su+0gueaLh5W/I5BSWsIJUm433FvHhhf5wJ7T0cSL1w2yEb7cnZhOY9AMBFepCX KB9EZ+9km9AoPGWz8wcNlSO5ZsRndsX8+Jti+Jtt6ekVR+FK3Vn6C9i69gKld1n3N2 PwIDvnecraaCIBXYD/QXr2XCmBvg6RMIyGKRe9q82+qLwRfzAvgnrkQ5UJR43ilSIv wIK7x3f3AfcfXaaGs4PenJFim1oCy/xXkh5+GpLj1y9C82n8ns04Tg4XRMLVse+3us wmBq94FO85R7LumuCDqiEh6aR0YJy36WSxxnGB5eyszXvZ/tqgwyT6+yLxfkBXYoit AvU0Kr0jpNKnQ== Date: Tue, 20 Feb 2024 11:23:31 -0600 From: Bjorn Helgaas To: Vidya Sagar Cc: bhelgaas@google.com, macro@orcam.me.uk, ajayagarwal@google.com, ilpo.jarvinen@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, hkallweit1@gmail.com, michael.a.bottini@linux.intel.com, johan+linaro@kernel.org, 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, "David E. Box" Subject: Re: [PATCH V3] PCI/ASPM: Update saved buffers with latest ASPM Message-ID: <20240220172331.GA1495757@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240108124248.1552420-1-vidyas@nvidia.com> [+cc David] On Mon, Jan 08, 2024 at 06:12:48PM +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 with > 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 This overlaps with David's patches that are currently queued for v6.9: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=be00f078ad2a Can you rebase this to apply on top of those (this is the pci/aspm branch)? > --- > V3: > * Addressed sathyanarayanan.kuppuswamy's review comments > > V2: > * Rebased on top of the tree code > * Addressed Bjorn's review comments > > drivers/pci/pcie/aspm.c | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > index 67b13f26ba7c..1b4f03044ce2 100644 > --- a/drivers/pci/pcie/aspm.c > +++ b/drivers/pci/pcie/aspm.c > @@ -138,16 +138,34 @@ static int policy_to_clkpm_state(struct pcie_link_state *link) > return 0; > } > > +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]); > +} > + > static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable) > { > struct pci_dev *child; > 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; > } > > @@ -767,6 +785,10 @@ 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_state(parent); > } > > static void pcie_config_aspm_path(struct pcie_link_state *link) > -- > 2.25.1 >