Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1431698pxj; Fri, 4 Jun 2021 14:24:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYfATZpdT4SyrHW2WDlXCSbizJV2ITZ9wBW1XXSNh68I6J2gxrJYmwil/y2OfFnXQ6wfsn X-Received: by 2002:a17:906:1dd1:: with SMTP id v17mr6176509ejh.31.1622841887845; Fri, 04 Jun 2021 14:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622841887; cv=none; d=google.com; s=arc-20160816; b=UYTeLvHI7OrTBhsiphxZuX4wRDCc2fyBhOz7plKgaiidts1RihyGcI6f/x0n7flc2X Z03jAQ3p/zXaMF3vG7R+u9ccFTCishbbJoSgdH0U6hVTvYj0nOC7uK9iVR6gxeK9yO3T wxDK/FoBJFvEy5bT/YUIW+fKt3eNi6BmJGf6aN6QsqdqNCw5/Sty8/rZaCP6Ag17bRXB m08YsOQ9qD0BPTYLinkHFg5gxX3kFq0Ht7HhQGgziFk5pJZWR4L+F5HOvrxTpDsB9jW/ dWuhnv68dy9TaUrGbx1LVNGEZ3NGyOsnPIb6z5XzFR4XeAIY4EFGsum4a0PEVJpCL5iJ o9Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=kCmd5HkvlhOu5ZhBVcWQXZfTmibVMwZ042Nk6ashSuU=; b=vAD2CL+IMZGXf7lKmTiKjLbtauvi5dJ7UCuGUx+zgTWBEKzBNZUKfR1h1EwKVNxwqQ ZdcdzK5ldoFbUjlYpo67N+lYwObts/XmYvs9fBXgIApAs00+cjfu1CRAy5g2l1z4yDVb lnc4RkG0q8RaB+SnDzGzkP24HPrUNUfA8SDa9SlqD7gKHpHYx872VtjtRioKN5Fk7Av9 Ry9p9KSftojumIjTjCG0Hy0pnO7FkM92LAMqp0YH3A7lmgat2EgJYd2YmoKO82296mS2 0OMFR7EcteUZR3b6L9eU32XJJhb2rHzqAEg8Ovk30FJ9JB8SgfddVMKd6ftZa7IF8PEL JsgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DnkOdjMl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si3386284ejj.169.2021.06.04.14.24.24; Fri, 04 Jun 2021 14:24:47 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DnkOdjMl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbhFDVX6 (ORCPT + 99 others); Fri, 4 Jun 2021 17:23:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:59842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbhFDVX5 (ORCPT ); Fri, 4 Jun 2021 17:23:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C89FC611AD; Fri, 4 Jun 2021 21:22:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622841731; bh=PUDS1LX1g2/cA5rbPUUtQNVnGSRWVHuo2k/SadWrLaw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=DnkOdjMlJI3lkYnrnqlx67z36V6vLTPI+wHSCGm4gsKhboOqtH/+ZZp93dm9nD0YX eLPZGO66noHP88yeWU603JlwtADoadvOUbQM6nuA0Z2QvshmrIAII7fqg31JU2+HFR pIKv6c1HipBn2y3G52GKaCPrWWol0Z5BVfgNwQW/Z+CFogtsKyeYm10SNJcq4jl6in RQYIo3pfAX16WXrYoRtCFecVHY+8tOCO3yOB9zIRYr41r1Wh5q8L8Vmfguyz9DEgan dSTCygPkiPViIXHBPYQTs6jvnawJsAVk3eTKikAmrAdTWu3T3NFyA86zLMtZJCuFsC 91yvAGaWf+NZw== Date: Fri, 4 Jun 2021 16:22:09 -0500 From: Bjorn Helgaas To: Nadeem Athani Cc: tjoseph@cadence.com, lorenzo.pieralisi@arm.com, robh@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kw@linux.com, kishon@ti.com, mparab@cadence.com, sjakhade@cadence.com, pthombar@cadence.com Subject: Re: [PATCH] [v2] PCI: cadence: Set LTSSM Detect Quiet state minimum delay as workaround for training defect. Message-ID: <20210604212209.GA2240608@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210528155626.21793-1-nadeem@cadence.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 28, 2021 at 05:56:26PM +0200, Nadeem Athani wrote: > PCIe fails to link up if SERDES lanes not used by PCIe are assigned to > another protocol. For example, link training fails if lanes 2 and 3 are > assigned to another protocol while lanes 0 and 1 are used for PCIe to > form a two lane link. This failure is due to an incorrect tie-off on an > internal status signal indicating electrical idle. > > Status signals going from SERDES to PCIe Controller are tied-off when a > lane is not assigned to PCIe. Signal indicating electrical idle is > incorrectly tied-off to a state that indicates non-idle. As a result, > PCIe sees unused lanes to be out of electrical idle and this causes > LTSSM to exit Detect.Quiet state without waiting for 12ms timeout to > occur. If a receiver is not detected on the first receiver detection > attempt in Detect.Active state, LTSSM goes back to Detect.Quiet and > again moves forward to Detect.Active state without waiting for 12ms as > required by PCIe base specification. Since wait time in Detect.Quiet is > skipped, multiple receiver detect operations are performed back-to-back > without allowing time for capacitance on the transmit lines to > discharge. This causes subsequent receiver detection to always fail even > if a receiver gets connected eventually. > > Adding a quirk flag "quirk_detect_quiet_flag" to program the minimum > time that LTSSM waits on entering Detect.Quiet state. > Setting this to 2ms for specific TI j7200 SOC as a workaround to resolve > a link training issue in IP. > In future revisions this setting will not be required. > > As per PCIe specification, all Receivers must meet the Z-RX-DC > specification for 2.5 GT/s within 1ms of entering Detect.Quiet LTSSM > substate. The LTSSM must stay in this substate until the ZRXDC > specification for 2.5 GT/s is met. > > 00 : 0 minimum wait time in Detect.Quiet state. > 01 : 100us minimum wait time in Detect.Quiet state. > 10 : 1ms minimum wait time in Detect.Quiet state. > 11 : 2ms minimum wait time in Detect.Quiet state. > > Changes in v2: > 1. Adding the function cdns_pcie_detect_quiet_min_delay_set in > pcie-cadence.c and invoking it from host and endpoint driver file. > > Signed-off-by: Nadeem Athani > --- > drivers/pci/controller/cadence/pcie-cadence-ep.c | 4 ++++ > drivers/pci/controller/cadence/pcie-cadence-host.c | 3 +++ > drivers/pci/controller/cadence/pcie-cadence.c | 17 +++++++++++++++++ > drivers/pci/controller/cadence/pcie-cadence.h | 15 +++++++++++++++ > 4 files changed, 39 insertions(+) > > diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c > index 897cdde02bd8..dd7df1ac7fda 100644 > --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c > +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c > @@ -623,6 +623,10 @@ int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep) > ep->irq_pci_addr = CDNS_PCIE_EP_IRQ_PCI_ADDR_NONE; > /* Reserve region 0 for IRQs */ > set_bit(0, &ep->ob_region_map); > + > + if (ep->quirk_detect_quiet_flag) > + cdns_pcie_detect_quiet_min_delay_set(&ep->pcie); > + > spin_lock_init(&ep->lock); > > return 0; > diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c > index ae1c55503513..fb96d37a135c 100644 > --- a/drivers/pci/controller/cadence/pcie-cadence-host.c > +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c > @@ -498,6 +498,9 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) > return PTR_ERR(rc->cfg_base); > rc->cfg_res = res; > > + if (rc->quirk_detect_quiet_flag) > + cdns_pcie_detect_quiet_min_delay_set(&rc->pcie); > + > ret = cdns_pcie_start_link(pcie); > if (ret) { > dev_err(dev, "Failed to start link\n"); > diff --git a/drivers/pci/controller/cadence/pcie-cadence.c b/drivers/pci/controller/cadence/pcie-cadence.c > index 3c3646502d05..65b6c8bed0d4 100644 > --- a/drivers/pci/controller/cadence/pcie-cadence.c > +++ b/drivers/pci/controller/cadence/pcie-cadence.c > @@ -7,6 +7,23 @@ > > #include "pcie-cadence.h" > > +void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie) > +{ > + u32 delay = 0x3; > + u32 ltssm_control_cap; > + > + /* > + * Set the LTSSM Detect Quiet state min. delay to 2ms. > + */ > + > + ltssm_control_cap = cdns_pcie_readl(pcie, CDNS_PCIE_LTSSM_CONTROL_CAP); > + ltssm_control_cap = ((ltssm_control_cap & > + ~CDNS_PCIE_DETECT_QUIET_MIN_DELAY_MASK) | > + CDNS_PCIE_DETECT_QUIET_MIN_DELAY(delay)); > + > + cdns_pcie_writel(pcie, CDNS_PCIE_LTSSM_CONTROL_CAP, ltssm_control_cap); > +} > + > void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn, > u32 r, bool is_io, > u64 cpu_addr, u64 pci_addr, size_t size) > diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h > index 254d2570f8c9..ccdf9cee9dde 100644 > --- a/drivers/pci/controller/cadence/pcie-cadence.h > +++ b/drivers/pci/controller/cadence/pcie-cadence.h > @@ -189,6 +189,14 @@ > /* AXI link down register */ > #define CDNS_PCIE_AT_LINKDOWN (CDNS_PCIE_AT_BASE + 0x0824) > > +/* LTSSM Capabilities register */ > +#define CDNS_PCIE_LTSSM_CONTROL_CAP (CDNS_PCIE_LM_BASE + 0x0054) > +#define CDNS_PCIE_DETECT_QUIET_MIN_DELAY_MASK GENMASK(2, 1) > +#define CDNS_PCIE_DETECT_QUIET_MIN_DELAY_SHIFT 1 > +#define CDNS_PCIE_DETECT_QUIET_MIN_DELAY(delay) \ > + (((delay) << CDNS_PCIE_DETECT_QUIET_MIN_DELAY_SHIFT) & \ > + CDNS_PCIE_DETECT_QUIET_MIN_DELAY_MASK) > + > enum cdns_pcie_rp_bar { > RP_BAR_UNDEFINED = -1, > RP_BAR0, > @@ -292,6 +300,7 @@ struct cdns_pcie { > * @avail_ib_bar: Satus of RP_BAR0, RP_BAR1 and RP_NO_BAR if it's free or > * available > * @quirk_retrain_flag: Retrain link as quirk for PCIe Gen2 > + * @quirk_detect_quiet_flag: LTSSM Detect Quiet min delay set as quirk > */ > struct cdns_pcie_rc { > struct cdns_pcie pcie; > @@ -301,6 +310,7 @@ struct cdns_pcie_rc { > u32 device_id; > bool avail_ib_bar[CDNS_PCIE_RP_MAX_IB]; > bool quirk_retrain_flag; > + bool quirk_detect_quiet_flag; > }; > > /** > @@ -331,6 +341,7 @@ struct cdns_pcie_epf { > * registers fields (RMW) accessible by both remote RC and EP to > * minimize time between read and write > * @epf: Structure to hold info about endpoint function > + * @quirk_detect_quiet_flag: LTSSM Detect Quiet min delay set as quirk > */ > struct cdns_pcie_ep { > struct cdns_pcie pcie; > @@ -345,6 +356,7 @@ struct cdns_pcie_ep { > /* protect writing to PCI_STATUS while raising legacy interrupts */ > spinlock_t lock; > struct cdns_pcie_epf *epf; > + bool quirk_detect_quiet_flag; 1) I don't see this being set anywhere. Are there follow-on patches that set it? We try not to merge things until they are actually used. 2) I typically use "unsigned int foo:1" in structures for this ancient reason [1]. But it's not always practical, e.g., with the avail_ib_bar[] array above, and I do see that this follows the existing style in the file, which is good. [1] https://lore.kernel.org/linux-fsdevel/CA+55aFzKQ6Pj18TB8p4Yr0M4t+S+BsiHH=BJNmn=76-NcjTj-g@mail.gmail.com/ > }; > > > @@ -505,6 +517,9 @@ static inline int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep) > return 0; > } > #endif > + > +void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie); > + > void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn, > u32 r, bool is_io, > u64 cpu_addr, u64 pci_addr, size_t size); > -- > 2.15.0 >