Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp914349pxb; Fri, 22 Jan 2021 02:24:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHTbsoaQNofEwjCF28FX3Eeq63r5BzCw+XwHVmw8eSuTq8RsL98ZzbOnnNjMg1P1LQ2QZb X-Received: by 2002:a17:906:e48:: with SMTP id q8mr2467652eji.478.1611311084572; Fri, 22 Jan 2021 02:24:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611311084; cv=none; d=google.com; s=arc-20160816; b=kizmmC5IAKCv3D+JdtVc5g4Jmj7JjId0wIkehZX7hRvXMPwW/R6uZP2RbiQ8Zi5S56 FultB3u8gi+IMLtahp0NUxrDkx5ZZ+rqadT8MwSXKPSePGmbWJiYqX/mTDaD6uwEPa5R 3xGinTm2XZO0ZenxY3GF6saupbZSQzi7JgsMM4ltn03tOtfj3CYeuq0EEpbNL7/yxk/d r7uDmCO6fEK5iWtm5mThtd/i5gqvLo0snGPFHExkvs5TB6z6/mt+c6HpLeQr1sqRySw/ konwo6choX+UkgwvhXID09iTObwPCCiaY101+01JR0p181SX/uJZK9VP8NOF7EMG5aTD qqTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=mU3/EpmZtlDnJqFtR9aO0ufg341ZlPWrh3KTxpKOK5Q=; b=Fa4lsuR1McHZPvMmBKwTHrxmuMTdFLGL+uLeIMvEX0MYlcuQ/9VEX/OPm46FmxIcCI iaLIA1xkaWDM6wE+nZfhMteOX8nBYBSH+u7Nyqha+nxbVacHRNmG6eJJ32zg9/VCvBry nPOG6R7gMfkW/zBd3+LDJODTkB4zFcFqC66el06lLMyS6eefYHi8+jqOsIJJ6r9dC4Fh mG2RI/SEeS8KB1k+1P/yg1w5qMjWErgDoh4BODusX7H+Xxm5Lx67Ig3/EKbh4s/jcwOv 4PF/r6ZDClD9l600zmv2lxCpTpiBi8tjPuAlxMQrOMhkQAgMZSZND7DhQeCSkWNCniiw 9RuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a89si3513339ede.326.2021.01.22.02.24.16; Fri, 22 Jan 2021 02:24:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727908AbhAVKWC (ORCPT + 99 others); Fri, 22 Jan 2021 05:22:02 -0500 Received: from mga05.intel.com ([192.55.52.43]:36660 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727825AbhAVKJA (ORCPT ); Fri, 22 Jan 2021 05:09:00 -0500 IronPort-SDR: Oei/IflOQRDhkV1ZlAF8GqrAhptQ62GpPQu+UVAb9UNwdJKqNxdO8ILn8onfJKB+EYyMQQuepB 3xCnmvlL/Nsg== X-IronPort-AV: E=McAfee;i="6000,8403,9871"; a="264244104" X-IronPort-AV: E=Sophos;i="5.79,366,1602572400"; d="scan'208";a="264244104" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2021 02:05:52 -0800 IronPort-SDR: GTVcV40CII561+g1c4ZQEaXgUOCdiGelZbxh/WWOVbfil8fndYoLNlP0ch3/or33rw5JoYOFYX F08IjTXyVxVg== X-IronPort-AV: E=Sophos;i="5.79,366,1602572400"; d="scan'208";a="427923843" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.163]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2021 02:05:47 -0800 Received: by lahna (sSMTP sendmail emulation); Fri, 22 Jan 2021 12:05:45 +0200 Date: Fri, 22 Jan 2021 12:05:45 +0200 From: Mika Westerberg To: Mingchuang Qiao Cc: Bjorn Helgaas , Bjorn Helgaas , "Rafael J. Wysocki" , Utkarsh H Patel , linux-pci@vger.kernel.org, matthias.bgg@gmail.com, lambert.wang@mediatek.com, linux-mediatek@lists.infradead.org, haijun.liu@mediatek.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Alex Williamson Subject: Re: [PATCH v2] PCI: Re-enable downstream port LTR if it was previously enabled Message-ID: <20210122100545.GL1988617@lahna.fi.intel.com> References: <20210121223139.GA2698934@bjorn-Precision-5520> <1611298991.5980.42.camel@mcddlt001> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1611298991.5980.42.camel@mcddlt001> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Jan 22, 2021 at 03:03:11PM +0800, Mingchuang Qiao wrote: > On Thu, 2021-01-21 at 16:31 -0600, Bjorn Helgaas wrote: > > [+cc Alex and Mingchuang et al from > > https://lore.kernel.org/r/20210112072739.31624-1-mingchuang.qiao@mediatek.com] > > > > On Tue, Jan 19, 2021 at 04:14:10PM +0300, Mika Westerberg wrote: > > > PCIe r5.0, sec 7.5.3.16 says that the downstream ports must reset the > > > LTR enable bit if the link goes down (port goes DL_Down status). Now, if > > > we had LTR previously enabled and the PCIe endpoint gets hot-removed and > > > then hot-added back the ->ltr_path of the downstream port is still set > > > but the port now does not have the LTR enable bit set anymore. > > > > > > For this reason check if the bridge upstream had LTR enabled previously > > > and re-enable it before enabling LTR for the endpoint. > > > > > > Reported-by: Utkarsh H Patel > > > Signed-off-by: Mika Westerberg > > > > I think this and Mingchuang's patch, which is essentially identical, > > are right and solves the problem for hot-remove/hot-add. In that > > scenario we call pci_configure_ltr() on the hot-added device, and > > with this patch, we'll re-enable LTR on the bridge leading to the new > > device before enabling LTR on the new device itself. > > > > But don't we have a similar problem if we simply do a Fundamental > > Reset on a device? I think the reset path will restore the device's > > state, including PCI_EXP_DEVCTL2, but it doesn't do anything with the > > upstream bridge, does it? > > > > Yes. I think the same problem exists under such scenario, and that’s the > issue my patch intends to resolve. > I also prepared a v2 patch for review(update the patch description). > Shall I submit the v2 patch for review? I looked at your patch and indeed it is essentially doing the same as this one. So let's forget this patch and go forward with yours :) Would you like to expand your patch to handle the reset case too that Bjorn desribes below? > > So if a bridge and a device below it both have LTR enabled, can't we > > have the following: > > > > - bridge LTR enabled > > - device LTR enabled > > - reset device, e.g., via Secondary Bus Reset > > - link goes down, bridge disables LTR > > - link comes back up, LTR disabled in both bridge and device > > - restore device state, including LTR enable > > - device sends LTR message > > - bridge reports Unsupported Request