From nobody Sun Sep 22 15:23:02 2024 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF73CC433FE for ; Thu, 21 Oct 2021 15:10:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C565060F9F for ; Thu, 21 Oct 2021 15:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231781AbhJUPMw (ORCPT ); Thu, 21 Oct 2021 11:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbhJUPMv (ORCPT ); Thu, 21 Oct 2021 11:12:51 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BAC1C0613B9; Thu, 21 Oct 2021 08:10:35 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id u6so644742ple.2; Thu, 21 Oct 2021 08:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wdvW0++TQSaLpnlhn3di6k88yfCHb1cy15TmRrFrgvg=; b=nn6UzH9K9xm3BbgtRQT6//j7LivuHHqgkWvtklOkW7BxcAWXi6Rd3wDo0ZMLlHD6Jl NRcnBGrGQ1ZfkNe5rRWEQ0JQ/mM3SVw90rPXXq4UEClymVBFEo2/hYL4S72QvEomDSWW oliXHekIGSCz1mEQuSIzvaJAfV+o0Na3hlhpMrArEX0ePY3PIiCA/SbBbVZ8zstP05F3 4LnrCFGoiSabuUSczr3kkL6WkQMjJsBLXxqzyEbVvTbvHul0SrcUz9JNZX9r5yxgaXVt 1kinykOuYgmINjXMI/Rrj406Xsjo8n4/P+tO2WTw8CnQGG5HABdOrzMIIvUoSV5bwV2o 2P/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wdvW0++TQSaLpnlhn3di6k88yfCHb1cy15TmRrFrgvg=; b=tt4AnwtveVE2He0KKIxyLdkp96ICMpX5b/walCD1nh6IJXHHdCfMRAOhi/WOKRUtpM vhAZ+1LbTwz0kz/Pe1i6cDRlLj97+hvOuxUJ6XJjX/ziQ0MZEsguK9+je9nPqTg3VKiD JQIJ97l4L9p1QbDW92RMaC0qfx/+26yB534RZaUvTS6aeRqmDxp27kgm1+evQGhISAcV l9huNl0elGQwrQOxCvAh7xeTozqefN6Y493KBYBQE48hqsaCGBt4Xm/J8TbN/oIISafK A7JquoKCfAhxSx8jtW7baMCbpfBv1Zgf/adNGssmB1XesDotdCm53CNYLJPMHh5+GmMq KVPg== X-Gm-Message-State: AOAM531d7+0Pvnk9CmO/mFD0RLR8oYETBaQuSWVF/M7PzFv50wz/tVmC f9kASxoJ9S925xXUotXkeZ4= X-Google-Smtp-Source: ABdhPJwQAqO9qqsqzDQINhSUMNkWXH1PmXLf2/63QLfNEoLTgPrpMEAnn6+IoPd3F6XdClY7Gx/RiA== X-Received: by 2002:a17:902:6808:b0:13e:a85b:52bd with SMTP id h8-20020a170902680800b0013ea85b52bdmr5630098plk.76.1634829035035; Thu, 21 Oct 2021 08:10:35 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:29a4:d874:a949:6890:f95f]) by smtp.gmail.com with ESMTPSA id c9sm5508027pgq.58.2021.10.21.08.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 08:10:34 -0700 (PDT) From: Naveen Naidu To: bhelgaas@google.com Cc: Naveen Naidu , linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, Robert Richter , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , linux-arm-kernel@lists.infradead.org (moderated list:PCIE DRIVER FOR CAVIUM THUNDERX) Subject: [PATCH v3 05/25] PCI: thunder: Remove redundant error fabrication when device read fails Date: Thu, 21 Oct 2021 20:37:30 +0530 Message-Id: <823658699653e78ffe9ff856d0bff5058f5d6a8f.1634825082.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" An MMIO read from a PCI device that doesn't exist or doesn't respond causes a PCI error. There's no real data to return to satisfy the CPU read, so most hardware fabricates ~0 data. The host controller drivers sets the error response values (~0) and returns an error when faulty hardware read occurs. But the error response value (~0) is already being set in PCI_OP_READ and PCI_USER_READ_CONFIG whenever a read by host controller driver fails. Thus, it's no longer necessary for the host controller drivers to fabricate any error response. This helps unify PCI error response checking and make error check consistent and easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/controller/pci-thunder-ecam.c | 46 ++++++++--------------- drivers/pci/controller/pci-thunder-pem.c | 4 +- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/drivers/pci/controller/pci-thunder-ecam.c b/drivers/pci/contro= ller/pci-thunder-ecam.c index ffd84656544f..a95bb58afd52 100644 --- a/drivers/pci/controller/pci-thunder-ecam.c +++ b/drivers/pci/controller/pci-thunder-ecam.c @@ -41,10 +41,9 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus= *bus, } if (where_a =3D=3D 0x4) { addr =3D bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */ - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v =3D readl(addr); v &=3D ~0xf; v |=3D 2; /* EA entry-1. Base-L */ @@ -56,10 +55,9 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus= *bus, u32 barl_rb; =20 addr =3D bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */ - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + barl_orig =3D readl(addr + 0); writel(0xffffffff, addr + 0); barl_rb =3D readl(addr + 0); @@ -72,10 +70,9 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus= *bus, } if (where_a =3D=3D 0xc) { addr =3D bus->ops->map_bus(bus, devfn, bar + 4); /* BAR 1 */ - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v =3D readl(addr); /* EA entry-3. Base-H */ set_val(v, where, size, val); return PCIBIOS_SUCCESSFUL; @@ -104,10 +101,8 @@ static int thunder_ecam_p2_config_read(struct pci_bus = *bus, unsigned int devfn, } =20 addr =3D bus->ops->map_bus(bus, devfn, where_a); - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } =20 v =3D readl(addr); =20 @@ -135,10 +130,8 @@ static int thunder_ecam_config_read(struct pci_bus *bu= s, unsigned int devfn, int where_a =3D where & ~3; =20 addr =3D bus->ops->map_bus(bus, devfn, 0xc); - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } =20 v =3D readl(addr); =20 @@ -146,10 +139,8 @@ static int thunder_ecam_config_read(struct pci_bus *bu= s, unsigned int devfn, cfg_type =3D (v >> 16) & 0x7f; =20 addr =3D bus->ops->map_bus(bus, devfn, 8); - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } =20 class_rev =3D readl(addr); if (class_rev =3D=3D 0xffffffff) @@ -176,10 +167,8 @@ static int thunder_ecam_config_read(struct pci_bus *bu= s, unsigned int devfn, } =20 addr =3D bus->ops->map_bus(bus, devfn, 0); - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } =20 vendor_device =3D readl(addr); if (vendor_device =3D=3D 0xffffffff) @@ -196,10 +185,9 @@ static int thunder_ecam_config_read(struct pci_bus *bu= s, unsigned int devfn, bool is_tns =3D (vendor_device =3D=3D 0xa01f177d); =20 addr =3D bus->ops->map_bus(bus, devfn, 0x70); - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + /* E_CAP */ v =3D readl(addr); has_msix =3D (v & 0xff00) !=3D 0; @@ -211,10 +199,9 @@ static int thunder_ecam_config_read(struct pci_bus *bu= s, unsigned int devfn, } if (where_a =3D=3D 0xb0) { addr =3D bus->ops->map_bus(bus, devfn, where_a); - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v =3D readl(addr); if (v & 0xff00) pr_err("Bad MSIX cap header: %08x\n", v); @@ -268,10 +255,9 @@ static int thunder_ecam_config_read(struct pci_bus *bu= s, unsigned int devfn, =20 if (where_a =3D=3D 0x70) { addr =3D bus->ops->map_bus(bus, devfn, where_a); - if (!addr) { - *val =3D ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v =3D readl(addr); if (v & 0xff00) pr_err("Bad PCIe cap header: %08x\n", v); diff --git a/drivers/pci/controller/pci-thunder-pem.c b/drivers/pci/control= ler/pci-thunder-pem.c index 0660b9da204f..06a9855cb431 100644 --- a/drivers/pci/controller/pci-thunder-pem.c +++ b/drivers/pci/controller/pci-thunder-pem.c @@ -41,10 +41,8 @@ static int thunder_pem_bridge_read(struct pci_bus *bus, = unsigned int devfn, struct pci_config_window *cfg =3D bus->sysdata; struct thunder_pem_pci *pem_pci =3D (struct thunder_pem_pci *)cfg->priv; =20 - if (devfn !=3D 0 || where >=3D 2048) { - *val =3D ~0; + if (devfn !=3D 0 || where >=3D 2048) return PCIBIOS_DEVICE_NOT_FOUND; - } =20 /* * 32-bit accesses only. Write the address to the low order --=20 2.25.1