From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F434C433E0 for ; Thu, 28 May 2020 16:26:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EAA4A207D3 for ; Thu, 28 May 2020 16:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590683173; bh=s5WtZilSKS4X6kw5tJ9m1befitlJa6Gd3ymV9rp2Huo=; h=Date:From:To:Cc:Subject:In-Reply-To:List-ID:From; b=bK1SxJM2ryP92RHd5/dEQC80fgpGUhQJJNwr3TkMW/CDVzqHELL7jeaCpF4Lh94FA dOrga5KdfBhaz1vZsecBdg6yuR5K1pUn6womfTmk/FvDvntDZK0+Bh9Ng3pYZoRpzv ER6GR/WzSmVZfEv2RAkbRwHolssc0bp+ML3g8XDQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405016AbgE1Q0L (ORCPT ); Thu, 28 May 2020 12:26:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:59116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404861AbgE1Q0H (ORCPT ); Thu, 28 May 2020 12:26:07 -0400 Received: from localhost (mobile-166-175-190-200.mycingular.net [166.175.190.200]) (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 580F32071A; Thu, 28 May 2020 16:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590683166; bh=s5WtZilSKS4X6kw5tJ9m1befitlJa6Gd3ymV9rp2Huo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=QJ8XwJziej2LVUH3WGmExbcLGJl66V+bX+uVnDH7P08JF42paigOFM8rFHZymUes8 IHKwzmDEnBGG4wlvSWEFsI9d+qvslFg02fFP7W+BNVE3Bxnee4X13xHBaNMztvYfti GccBKAoioIeSuSU5Kjbi583P4iRXW7xzHDUh08Fw= Date: Thu, 28 May 2020 11:26:04 -0500 From: Bjorn Helgaas To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Thomas Petazzoni , Lorenzo Pieralisi , Andrew Murray , Bjorn Helgaas , Marek =?iso-8859-1?Q?Beh=FAn?= , Remi Pommarel , Tomasz Maciej Nowak , Xogium , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: aardvark: Don't touch PCIe registers if no card connected Message-ID: <20200528162604.GA323482@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200528143141.29956-1-pali@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 04:31:41PM +0200, Pali Rohár wrote: > When there is no PCIe card connected and advk_pcie_rd_conf() or > advk_pcie_wr_conf() is called for PCI bus which doesn't belong to emulated > root bridge, the aardvark driver throws the following error message: > > advk-pcie d0070000.pcie: config read/write timed out > > Obviously accessing PCIe registers of disconnected card is not possible. > > Extend check in advk_pcie_valid_device() function for validating > availability of PCIe bus. If PCIe link is down, then the device is marked > as Not Found and the driver does not try to access these registers. > > Signed-off-by: Pali Rohár > --- > drivers/pci/controller/pci-aardvark.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c > index 90ff291c24f0..53a4cfd7d377 100644 > --- a/drivers/pci/controller/pci-aardvark.c > +++ b/drivers/pci/controller/pci-aardvark.c > @@ -644,6 +644,9 @@ static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, > if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) > return false; > > + if (bus->number != pcie->root_bus_nr && !advk_pcie_link_up(pcie)) > + return false; I don't think this is the right fix. This makes it racy because the link may go down after we call advk_pcie_valid_device() but before we perform the config read. I have no objection to removing the "config read/write timed out" message. The "return PCIBIOS_SET_FAILED" in the read case probably should be augmented by setting "*val = 0xffffffff". > return true; > } > > -- > 2.20.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC23EC433E1 for ; Thu, 28 May 2020 16:26:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9AD24207D3 for ; Thu, 28 May 2020 16:26:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OMvXrPVt"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="QJ8XwJzi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9AD24207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=AWfrHELh1zD2ynbRJVYyCBN7DbHfIkj2df77t3Z4s+0=; b=OMvXrPVtgBHh0b JicSNKP5t4cnM9kxSiz8biz+DHLdAYMCsUiKYTOXyG7y3cLUFifMAzPHuIv0gL5KyyxucUrs+Yamn LsZk+qBpw6QL8eXCAcofEUH2WdkgeLMeNgCEXsowqBIuD0xJYeXqWL/n1j/nvssqOQy43xisEW5LM I+TJiF7LxaTDpYG24b4oyIEN/ze72BQtv2Kk8XvP8QypoMRKE3cLO07J/6U5CZNSDqx0flvWFCXYv Khit+bTmy73xjNW9sV5cKmMFX5daidITZ7cNgItu8Ey0ktaBWNE/nGy8u4KVxTkUbMw8iUVBo0/zq ULELJJrTfN/Yro/au4OA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jeLMB-000542-4Y; Thu, 28 May 2020 16:26:11 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jeLM7-00051o-2u for linux-arm-kernel@lists.infradead.org; Thu, 28 May 2020 16:26:09 +0000 Received: from localhost (mobile-166-175-190-200.mycingular.net [166.175.190.200]) (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 580F32071A; Thu, 28 May 2020 16:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590683166; bh=s5WtZilSKS4X6kw5tJ9m1befitlJa6Gd3ymV9rp2Huo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=QJ8XwJziej2LVUH3WGmExbcLGJl66V+bX+uVnDH7P08JF42paigOFM8rFHZymUes8 IHKwzmDEnBGG4wlvSWEFsI9d+qvslFg02fFP7W+BNVE3Bxnee4X13xHBaNMztvYfti GccBKAoioIeSuSU5Kjbi583P4iRXW7xzHDUh08Fw= Date: Thu, 28 May 2020 11:26:04 -0500 From: Bjorn Helgaas To: Pali =?iso-8859-1?Q?Roh=E1r?= Subject: Re: [PATCH] PCI: aardvark: Don't touch PCIe registers if no card connected Message-ID: <20200528162604.GA323482@bjorn-Precision-5520> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200528143141.29956-1-pali@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200528_092607_145158_73E7E974 X-CRM114-Status: GOOD ( 18.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomasz Maciej Nowak , Lorenzo Pieralisi , linux-pci@vger.kernel.org, Xogium , linux-kernel@vger.kernel.org, Marek =?iso-8859-1?Q?Beh=FAn?= , Remi Pommarel , Thomas Petazzoni , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Andrew Murray Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 28, 2020 at 04:31:41PM +0200, Pali Roh=E1r wrote: > When there is no PCIe card connected and advk_pcie_rd_conf() or > advk_pcie_wr_conf() is called for PCI bus which doesn't belong to emulated > root bridge, the aardvark driver throws the following error message: > = > advk-pcie d0070000.pcie: config read/write timed out > = > Obviously accessing PCIe registers of disconnected card is not possible. > = > Extend check in advk_pcie_valid_device() function for validating > availability of PCIe bus. If PCIe link is down, then the device is marked > as Not Found and the driver does not try to access these registers. > = > Signed-off-by: Pali Roh=E1r > --- > drivers/pci/controller/pci-aardvark.c | 3 +++ > 1 file changed, 3 insertions(+) > = > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controll= er/pci-aardvark.c > index 90ff291c24f0..53a4cfd7d377 100644 > --- a/drivers/pci/controller/pci-aardvark.c > +++ b/drivers/pci/controller/pci-aardvark.c > @@ -644,6 +644,9 @@ static bool advk_pcie_valid_device(struct advk_pcie *= pcie, struct pci_bus *bus, > if ((bus->number =3D=3D pcie->root_bus_nr) && PCI_SLOT(devfn) !=3D 0) > return false; > = > + if (bus->number !=3D pcie->root_bus_nr && !advk_pcie_link_up(pcie)) > + return false; I don't think this is the right fix. This makes it racy because the link may go down after we call advk_pcie_valid_device() but before we perform the config read. I have no objection to removing the "config read/write timed out" message. The "return PCIBIOS_SET_FAILED" in the read case probably should be augmented by setting "*val =3D 0xffffffff". > return true; > } > = > -- = > 2.20.1 > = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel