Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp965522ybx; Tue, 5 Nov 2019 08:14:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyIEZ9p6C/0F6Fc6wiN9JbzuK0XAMMv1famIwAfnp8TIXC+5DsdFnkEyZ1UVrEQTTdSYnZi X-Received: by 2002:a17:906:6d4f:: with SMTP id a15mr9401540ejt.175.1572970453787; Tue, 05 Nov 2019 08:14:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572970453; cv=none; d=google.com; s=arc-20160816; b=A5p3NlwKyrdMcpQQ4CaEy+0g4RcNU3+T+90CBPEL47BaHgyQICs/QNfFU9AxTZ6/2z Fupn7KyK1WSEnqKAKColBRpeK/nIMiKt2GYMHe61GcKJ2bFjPZ4jxbQuWqfktcBl73NG F3n7jL59FnbV/Q1nTAiFxJDmGnUqQfI4EqWALP6ZxYpqytMGJPMqOvCTNCK+RLVoAi7C G4RhYgpnV3tdsLUPRi53GvJ+DGbi1+GcJBO0r5F98wjD70tcTb9ryDGE3M0WC3nxwCbg 53SGnr4y1DCzwYdXg4y3T7lKQRvpolCr6qTbRLlNx+jqLVxQWsuxEzFJbgsSM1Sr+0OP ngUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=cy19iUow6Wkab1haINVxbhjdabhn6FIl0yOC+K3yNMI=; b=PArPXColEXn+qw6D0yKeuSR5cI5xmAOVzjbHh/Irh+9j/Ey48Rcooa5S4CyWGvo/t0 FAWBkatzU+0P1lOASkt+nWPZTpVri1gT8WSQZeJqVBfvhvgXqX+xAGkrApNQ9j0870dl 3NGMwFw9DNTI+wmM4Ees8bpphAL1K5vCbr05dXEI0vbOr7lIIGPn+TOGB9dcoDq79wJu +f5Vy06bwXLI2Hm5ZgwOxpOM2bj0NiQkRzNgtwf2zI6ZY2IQwR97muUJg1OuM241LZ3N ZU4KgFEiz0wlY75QXMaeUMn0xWWGLOfK9ZFh/jZ1pjgTNoLDkj6pW+MWEv/7x3kd9nut 0+zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AUgdAJyW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si10071837edj.107.2019.11.05.08.13.49; Tue, 05 Nov 2019 08:14:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AUgdAJyW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390236AbfKEQKV (ORCPT + 99 others); Tue, 5 Nov 2019 11:10:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:55926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389907AbfKEQKU (ORCPT ); Tue, 5 Nov 2019 11:10:20 -0500 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6985E214B2; Tue, 5 Nov 2019 16:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572970219; bh=3rYnlvzuKtYKdxK2uL8463vEILCkV2bc0KCoHjG4rOg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=AUgdAJyWEH4jSZMdcNYsS+U6qdrmOkZv5GqemhXlRuuax1I6SsMFqTQoJLIV602WS q/LvLBU6oP2DsikeiDPG2a57SCUF6MKz2V7pF1eM2GuTIwQw7zoYfSxDGjtsWsHhFr pbXurPTMm9MQUw7tA+z0I2DgNwk3LHOKDZVC8S9I= Date: Tue, 5 Nov 2019 10:10:17 -0600 From: Bjorn Helgaas To: Mika Westerberg Cc: "Rafael J. Wysocki" , Len Brown , Lukas Wunner , Keith Busch , Alex Williamson , Alexandru Gagniuc , Kai-Heng Feng , Paul Menzel , Nicholas Johnson , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] PCI: Add missing link delays required by the PCIe spec Message-ID: <20191105161017.GA219591@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105152832.GC2552@lahna.fi.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 05, 2019 at 05:28:32PM +0200, Mika Westerberg wrote: > On Tue, Nov 05, 2019 at 09:00:13AM -0600, Bjorn Helgaas wrote: > > On Tue, Nov 05, 2019 at 11:54:28AM +0200, Mika Westerberg wrote: > > > On Mon, Nov 04, 2019 at 06:00:00PM -0600, Bjorn Helgaas wrote: > > > > > > > If you think it is fine to do the delay before we have restored > > > > > everything I can move it inside pci_power_up() or call it after > > > > > pci_pm_default_resume_early() as above. I think at least we should make > > > > > sure all the saved registers are restored before so that the link > > > > > activation check actually works. > > > > > > > > What needs to be restored to make pcie_wait_for_link_delay() work? > > > > > > I'm not entirely sure. I think that pci_restore_state() at least should > > > be called so that the PCIe capability gets restored. Maybe not even > > > that because Data Link Layer Layer Active always reflects the DL_Active > > > or not and it does not need to be enabled separately. > > > > > > > And what event does the restore need to be ordered with? > > > > > > Not sure I follow you here. > > > > You're suggesting that we should restore saved registers first so > > pcie_wait_for_link_delay() works. If the link activation depends on > > something being restored and we don't enforce an ordering, the > > activation might succeed or fail depending on whether it happens > > before or after the restore. So if there is a dependency, we should > > make it explicit to avoid a race like that. > > OK thanks. By explicit you mean document it in the code, right? So far all we have is a feeling that maybe we ought to restore before waiting, but I don't really know why. If there's an actual dependency, we should chase down specifically what it is and add a comment or code (e.g., a link retrain) as appropriate. > > I actually suspect there *is* a dependency -- we should respect the > > Target Link Speed and and width so the link resumes in the same > > configuration it was before suspend. And I suspect that may require > > an explicit retrain after restoring PCI_EXP_LNKCTL2. > > According the PCIe spec the PCI_EXP_LNKCTL2 Target Link Speed is marked > as RWS (S for sticky) so I suspect its value is retained after reset in > the same way as PME bits. Assuming I understood it correctly. This patch is about coming from D3cold, isn't it? I don't think we can assume sticky bits are preserved in D3cold (except maybe when auxiliary power is enabled).