Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E9FEC433EF for ; Wed, 16 Feb 2022 08:58:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 56C2783A2D; Wed, 16 Feb 2022 09:58:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1645001887; bh=26giMstkY9Ot8YFoIoNwkFZfel8vhil9KAKjLvRE9iE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=efP04pe1qGBQwLkgrhMjOIo0JrjpwusrS8sozKKZi1cs0GiomDiMQ8aot8q/qx7KN 1XdA1FnXAYrlxStfqwUlfqqT2zzPls/pU2TyZKmFGrG8sSf6FbGkAZKAziZMNU+/+Z Um6vvc1eQZ38yPxJCil4nzGYWw9UKuP2NtTCGKZy/r4vCOE0g22vc2/GVi88iEVmWz 5E9JNlJqQI07PHz/hzutS5MIwH3u3GjA36fr0FccO+OXrGNX5mXEP+vy2HgccruYs1 YKt19Apo2ljxDKmfW7QTSs4hJknN5/zM0ifcjJ92lWSY0dRW/RyiCP3rcg0JqzGClf oC0winz0eRq2w== Received: by phobos.denx.de (Postfix, from userid 109) id 1062383A3A; Wed, 16 Feb 2022 09:58:05 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F0821839EC for ; Wed, 16 Feb 2022 09:58:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4JzBgY3vQlz9sT2; Wed, 16 Feb 2022 09:58:01 +0100 (CET) Message-ID: Date: Wed, 16 Feb 2022 09:57:57 +0100 MIME-Version: 1.0 Subject: Re: [PATCH u-boot-marvell 1/3] arm: a37xx: pci: Do not try to access other buses when link is down Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de References: <20220215102337.18426-1-pali@kernel.org> From: Stefan Roese In-Reply-To: <20220215102337.18426-1-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 2/15/22 11:23, Pali Rohár wrote: > If a PIO request is executed while link-down, the whole controller gets > stuck in a non-functional state, and even after link comes up again, PIO > requests won't work anymore, and a reset of the whole PCIe controller is > needed. Therefore we need to prevent sending PIO requests while the link > is down. > > Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese Thanks, Stefan > --- > drivers/pci/pci-aardvark.c | 38 +++++++++++++++++++++----------------- > 1 file changed, 21 insertions(+), 17 deletions(-) > > diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c > index 1eb257ea8b4a..ccaeecaca8e3 100644 > --- a/drivers/pci/pci-aardvark.c > +++ b/drivers/pci/pci-aardvark.c > @@ -177,6 +177,23 @@ static inline uint advk_readl(struct pcie_advk *pcie, uint reg) > return readl(pcie->base + reg); > } > > +/** > + * pcie_advk_link_up() - Check if PCIe link is up or not > + * > + * @pcie: The PCI device to access > + * > + * Return true on link up. > + * Return false on link down. > + */ > +static bool pcie_advk_link_up(struct pcie_advk *pcie) > +{ > + u32 val, ltssm_state; > + > + val = advk_readl(pcie, ADVK_LMI_PHY_CFG0); > + ltssm_state = (val & ADVK_LMI_PHY_CFG0_LTSSM_MASK) >> ADVK_LMI_PHY_CFG0_LTSSM_SHIFT; > + return ltssm_state >= ADVK_LMI_PHY_CFG0_LTSSM_L0 && ltssm_state < ADVK_LMI_PHY_CFG0_LTSSM_DISABLED; > +} > + > /** > * pcie_advk_addr_valid() - Check for valid bus address > * > @@ -195,6 +212,10 @@ static bool pcie_advk_addr_valid(struct pcie_advk *pcie, > if (busno == 0 && (dev != 0 || func != 0)) > return false; > > + /* Access to other buses is possible when link is up */ > + if (busno != 0 && !pcie_advk_link_up(pcie)) > + return false; > + > /* > * In PCI-E only a single device (0) can exist on the secondary bus. > * Beyond the secondary bus, there might be a Switch and anything is > @@ -618,23 +639,6 @@ retry: > return ret; > } > > -/** > - * pcie_advk_link_up() - Check if PCIe link is up or not > - * > - * @pcie: The PCI device to access > - * > - * Return 1 (true) on link up. > - * Return 0 (false) on link down. > - */ > -static int pcie_advk_link_up(struct pcie_advk *pcie) > -{ > - u32 val, ltssm_state; > - > - val = advk_readl(pcie, ADVK_LMI_PHY_CFG0); > - ltssm_state = (val & ADVK_LMI_PHY_CFG0_LTSSM_MASK) >> ADVK_LMI_PHY_CFG0_LTSSM_SHIFT; > - return ltssm_state >= ADVK_LMI_PHY_CFG0_LTSSM_L0 && ltssm_state < ADVK_LMI_PHY_CFG0_LTSSM_DISABLED; > -} > - > /** > * pcie_advk_wait_for_link() - Wait for link training to be accomplished > * Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de