Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp402767rdh; Wed, 7 Feb 2024 08:03:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsLF6xvormZV1SuycRFcOQK4ojUeX81Jid3X134Zt8QOzN0xoDTZh+cWmvecxzFuTEAdGc X-Received: by 2002:ac8:520c:0:b0:42c:388b:f5f9 with SMTP id r12-20020ac8520c000000b0042c388bf5f9mr4382823qtn.64.1707321780211; Wed, 07 Feb 2024 08:03:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707321780; cv=pass; d=google.com; s=arc-20160816; b=er5i1ncltfzEe848wmQ1oN+6nhga/4xeLGtR3euuVaw6T3Gd4mq2DQKlpwgGuSU2Yp 4lxm9LrJOSIaTXWDaAh3Y5N6tk2R41tg7uEi06ZXjtGQ3cp1JkUkw4MoGpYJ2nrAhkjL Qiq2F1reZbbNoZ4NCLNOArtWarQILeaMdR16nZmoe8gVo7jB/apwoZ52UOvwduP5YSLg Xvx9y0Bz58piu2HJwztspO9w/y4mxojUKvLechB8N27lCCm3O1JxeOnBxHnkr97pMWKm 7mDfTGJLT+nPqA/re/QCmtUN55Oso2/+o8skt1LriMGa+uTNW1BSpGVdecrJXbdQln56 Ik9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:organization:references :in-reply-to:date:cc:to:reply-to:from:subject:message-id :dkim-signature; bh=OrjSMyZV5BHFZku4tz8JR7fDLFoo6m4weH3m7Yay1iI=; fh=ZoqimDGntRpGVZ66M6Hg2ZFcANqA7MwT8s/IOp8oRFs=; b=NoTUQIxaIhzzJjjlgqYR80WocBBGoySqSd7RefNdWkSIX+cuOmwGLszN5pvd1ZkTAm reQm7r7xc8jCD+ok+ZOCVtR/vco7IlesYxRWcVAs08ltal0VYnZ05qSoSTkfjM30vuXb New6A0w3ZuvfwGjPpGbqFYKEkaLF1vhAZjwulnLkKpTUi68PIx95cSMxGr21CuYtiDxv Rgt+INOCsucGmJDkNXmmXV8TdreHOa0k2wawedifF9BlK9P3yZpCj3UQljMVLtbj8sJG 71GXtDqGDLeoJenJ989qELCu5wSlPutNz2N/wPmOvFjCHRnQMyrvdVHCcRlu3nGY7hH8 D1ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZA6WnA4E; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-56747-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56747-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXEiNupBHI/KoYpUT5JvLGrTi6q3YZ/4XD1Q0xFSFib0y1bhfOf5CX557J+CLnkR7uIo3sOv64L6qwsMS0yvxCtgftwyEtD5uHqplx15A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r3-20020ac85c83000000b0042c075c6f4asi1350212qta.569.2024.02.07.08.03.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 08:03:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56747-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZA6WnA4E; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-56747-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56747-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DE72E1C21D21 for ; Wed, 7 Feb 2024 16:02:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAE3F80603; Wed, 7 Feb 2024 16:02:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZA6WnA4E" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 E1AFB8002F; Wed, 7 Feb 2024 16:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707321771; cv=none; b=el8glPsHY2IzyUtJW70sDvL7Rt9ir/5uZ4cToTjFVYMXz8vBZEuLUwn/PIfz5Ic98m3AhRrjrvlOEEQod0zNb2cfGlPFxPuwxkC3OhypabvprUqT0uwxeJk1DP22/tGefuaohaR07lH+O3/aSaWYAhtNPTyLaO4uRujFhTN9HLY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707321771; c=relaxed/simple; bh=M611GcMdGJykO0N8Dmv8PbgGyZn3lTmhtUBEPLS0brw=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=bqj4xV8jrp+6VsNGtM7fD39BnNNJPD8at5qbaPOSORmA/ksCvTyvxqL31ve2mm33dG7bX2OnoO69lVTR+JEKBj9FMGJXF3iENrwsSTzbU7h8Fk2oZ099JbMtK+2dJuEff/cnSH0RVPDcq+sX1OhPKGsU5aXjllA7IyAJhUzuP2w= 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=ZA6WnA4E; arc=none smtp.client-ip=198.175.65.13 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=1707321770; x=1738857770; h=message-id:subject:from:reply-to:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=M611GcMdGJykO0N8Dmv8PbgGyZn3lTmhtUBEPLS0brw=; b=ZA6WnA4EiriqqO7GmUErIylK0nx72R1/pqaqG9Fgxb0cjtUozwhEPZB3 SsIYo/zJ6UH6m6s50l1jTNAjE/TTtI0ntdQ/psLwz4DGeAisVgtdvjqfN pGMoScENh0Ot+ICAzxXeTz0e3LqR+0R5KNZBjJNX0z1GDiTr9JsQMKoLL AGpAY7Y00JBEsFyOiJsWb5kZZ/wNmYHtvl9Fr3FR9LxzFsp4FNm6RDKuM H0+yyDlLZVBpQx5hPV0KMlBZTjz1nN5BBJQKhYtYe5GnuHxzQACKHRTbX lduyq9xrZMptLxeGL/TT57GYP8xDU+/8VbsVOXYSTrmRwP5PwkODn1n7P w==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="12104204" X-IronPort-AV: E=Sophos;i="6.05,251,1701158400"; d="scan'208";a="12104204" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2024 08:02:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,251,1701158400"; d="scan'208";a="38811757" Received: from linux.intel.com ([10.54.29.200]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2024 08:02:49 -0800 Received: from hsinjuiy-mobl.amr.corp.intel.com (unknown [10.209.57.193]) by linux.intel.com (Postfix) with ESMTP id 12A70580D94; Wed, 7 Feb 2024 08:02:49 -0800 (PST) Message-ID: <0e7944d410664153b506ea584d92cd6bb0a93f6a.camel@linux.intel.com> Subject: Re: [PATCH v3 3/3] PCI/ASPM: Fix L1SS parameters & only enable supported features when enable link state From: "David E. Box" Reply-To: david.e.box@linux.intel.com To: Jian-Hong Pan , Bjorn Helgaas , Johan Hovold , Ilpo =?ISO-8859-1?Q?J=E4rvinen?= Cc: Mika Westerberg , Nirmal Patel , Jonathan Derrick , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessos.org Date: Wed, 07 Feb 2024 08:02:48 -0800 In-Reply-To: <20240207111854.576402-2-jhp@endlessos.org> References: <20240207111854.576402-2-jhp@endlessos.org> Organization: David E. Box Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2024-02-07 at 19:18 +0800, Jian-Hong Pan wrote: > The original __pci_enable_link_state() configs the links directly without= : > * Check the L1 substates features which are supported, or not > * Calculate & program related parameters for L1.2, such as T_POWER_ON, > =C2=A0 Common_Mode_Restore_Time, and LTR_L1.2_THRESHOLD >=20 > This leads some supported L1 PM substates of the link between VMD remappe= d > PCIe Root Port and NVMe get wrong configs when a caller tries to enabled > them. >=20 > Here is a failed example on ASUS B1400CEAE with enabled VMD: >=20 > Capabilities: [900 v1] L1 PM Substates > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 L1SubCap: PCI-PM_L1.2+ PCI-PM_= L1.1- ASPM_L1.2+ ASPM_L1.1- > L1_PM_Substates+ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 PortCommonModeRestoreTime=3D32us PortTPowerO= nTime=3D10us > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 L1SubCtl1: PCI-PM_L1.2- PCI-PM= _L1.1- ASPM_L1.2+ ASPM_L1.1- > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 T_CommonMode=3D0us LTR1.2_Threshold=3D= 0ns > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 L1SubCtl2: T_PwrOn=3D10us >=20 > This patch initializes the link's L1 PM substates to get the supported > features and programs relating paramters, if some of them are going to be > enabled in __pci_enable_link_state(). Then, enables the L1 PM substates i= f > the caller intends to enable them and they are supported. >=20 > Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D218394 > Signed-off-by: Jian-Hong Pan > --- > v2: > - Prepare the PCIe LTR parameters before enable L1 Substates >=20 > v3: > - Only enable supported features for the L1 Substates part >=20 > =C2=A0drivers/pci/pcie/aspm.c | 12 +++++++----- > =C2=A01 file changed, 7 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > index a39d2ee744cb..c866971cae70 100644 > --- a/drivers/pci/pcie/aspm.c > +++ b/drivers/pci/pcie/aspm.c > @@ -1389,14 +1389,16 @@ static int __pci_enable_link_state(struct pci_dev > *pdev, int state, bool locked) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0link->aspm_default |=3D ASPM_STATE_L0S; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & PCIE_LINK_STA= TE_L1) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0link->aspm_default |=3D ASPM_STATE_L1; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* L1 PM substates require L1 = */ > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & PCIE_LINK_STATE_L1= _1) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & ASPM_STATE_L1_2_MA= SK) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0aspm_l1ss_init(link); This mixes ASPM_STATE flags with PCIE_LINK_STATE register mapping. This may= work but I don't know if it's intended to. Rather do, if (link->default & ASPM_STATE_L1_2_MASK) after collecting all of the states to be enabled. I understand that you are calling aspm_l1ss_init() to do the L1.2 calculati= ons but it does more than this that you don't need. Maybe it would be more appropriate to call aspm_calc_l12_info() directly through an additional fun= ction that finds the parent and determines both ends of the link support L1SS. > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* L1 PM substates require L1 = and should be in supported list */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & link->aspm_support= & PCIE_LINK_STATE_L1_1) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0link->aspm_default |=3D ASPM_STATE_L1_1 | ASPM_STAT= E_L1; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & PCIE_LINK_STATE_L1= _2) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & link->aspm_support= & PCIE_LINK_STATE_L1_2) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0link->aspm_default |=3D ASPM_STATE_L1_2 | ASPM_STAT= E_L1; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & PCIE_LINK_STATE_L1= _1_PCIPM) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & link->aspm_support= & PCIE_LINK_STATE_L1_1_PCIPM) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0link->aspm_default |=3D ASPM_STATE_L1_1_PCIPM | ASP= M_STATE_L1; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & PCIE_LINK_STATE_L1= _2_PCIPM) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (state & link->aspm_support= & PCIE_LINK_STATE_L1_2_PCIPM) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0link->aspm_default |=3D ASPM_STATE_L1_2_PCIPM | ASP= M_STATE_L1; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0pcie_config_aspm_link(lin= k, policy_to_aspm_state(link)); > =C2=A0 I don't think these changes are necessary. pcie_config_aspm_link() already checks link->aspm_capable which was initialized from link->aspm_support. David