From patchwork Thu Nov 18 14:03:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627089 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 37465C433EF for ; Thu, 18 Nov 2021 14:04:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A46361101 for ; Thu, 18 Nov 2021 14:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232110AbhKROHn (ORCPT ); Thu, 18 Nov 2021 09:07:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232237AbhKROHh (ORCPT ); Thu, 18 Nov 2021 09:07:37 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93BDCC061204; Thu, 18 Nov 2021 06:04:36 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id g18so6104816pfk.5; Thu, 18 Nov 2021 06:04:36 -0800 (PST) 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=lRVr/MvmbDbYCYZVQvovIm632g48TSctaBpAr4pPMBs=; b=ki3zJclRT5gZaLLE08IwbhWAxIbTzKFMLWGKODRFKxJMYkkPV57hmCyWQs7c+DPosB 5mGT3f3d4Xo32+oDwKv9/J9AYz0Y6ZUF4Ipfd/dezlJppudIle8DSVT2t52Axq6FE2ot pk0I9ygiRZzF/58Mf0M0Iyyx4J1CAb84WkGwpfjx/lMlEYg2kQ6SLyCGodPMAHwZpthr zUord0VXRyBh+6WBJIxc+wTFGBSTEJ4ll7/W3L4JjXvX//SDdLbzbAeJorDa2ip/qyCV uafNAyEYulpT3XpNjH5DhcLk5X+YBwhuElAMWAST4BDJSDBuEF6VmBIm/tNDUMfCBcUf knMA== 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=lRVr/MvmbDbYCYZVQvovIm632g48TSctaBpAr4pPMBs=; b=MLBRkBcPhAf9CL+jWEyj81/NmAEVogFqYq5/9EIkSZ5illiY2z0ahsVRS2PbL6/C3R +m4hKXzpgJDvHjg8G+NDxUaLLjPfHVrQyoA9r+WUwS9tV/AsjqH/pqvKg5njkFE495Oh 9X4bs5KnUpbN6xpxhlHg05Cek3F9InOELWBOHN8MRaVQ8coE/yBiZ0vVBE72ITFvLjHN fWPndNCNUdSQVEIAVikwktbnN1R1R/50kLpG3982ychldnvkYYwkmd+yJqmU9S12EgQM StxOUcSbYplJCayJYv5j9t/k6ogVdQCFTamTleevlthqaXzooodr5/l26DWnkcsJOuYh SZoA== X-Gm-Message-State: AOAM530iDX2llRN/hdZhZtA+dWSwJDIFMzsCzwtJaixq485uOXQU457s U7N5Ey+k76Vep2VFVyabuDY= X-Google-Smtp-Source: ABdhPJwgSJAJzb9GnmZhNCiuC4sXvl/+OpI7uHAkOxqyhJ9kXcl1osCLvoOYPljMeoii6U1rnBhr8w== X-Received: by 2002:a05:6a00:24cd:b0:49f:bf3f:c42c with SMTP id d13-20020a056a0024cd00b0049fbf3fc42cmr15229341pfv.54.1637244276068; Thu, 18 Nov 2021 06:04:36 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:04:35 -0800 (PST) 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, =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= Subject: [PATCH v4 01/25] PCI: Add PCI_ERROR_RESPONSE and it's related definitions Date: Thu, 18 Nov 2021 19:33:11 +0530 Message-Id: <55563bf4dfc5d3fdc96695373c659d099bf175b1.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Add a PCI_ERROR_RESPONSE definition for that and use it where appropriate to make these checks consistent and easier to find. Also add helper definitions PCI_SET_ERROR_RESPONSE and PCI_POSSIBLE_ERROR to make the code more readable. Suggested-by: Bjorn Helgaas Reviewed-by: Pali Rohár Signed-off-by: Naveen Naidu --- include/linux/pci.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 18a75c8e615c..0ce26850470e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -154,6 +154,15 @@ enum pci_interrupt_pin { /* The number of legacy PCI INTx interrupts */ #define PCI_NUM_INTX 4 +/* + * Reading from a device that doesn't respond typically returns ~0. A + * successful read from a device may also return ~0, so you need additional + * information to reliably identify errors. + */ +#define PCI_ERROR_RESPONSE (~0ULL) +#define PCI_SET_ERROR_RESPONSE(val) (*(val) = ((typeof(*(val))) PCI_ERROR_RESPONSE)) +#define PCI_POSSIBLE_ERROR(val) ((val) == ((typeof(val)) PCI_ERROR_RESPONSE)) + /* * pci_power_t values must match the bits in the Capabilities PME_Support * and Control/Status PowerState fields in the Power Management capability. From patchwork Thu Nov 18 14:03:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627091 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 66D6FC433EF for ; Thu, 18 Nov 2021 14:04:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EFE261101 for ; Thu, 18 Nov 2021 14:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232107AbhKROH6 (ORCPT ); Thu, 18 Nov 2021 09:07:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbhKROH6 (ORCPT ); Thu, 18 Nov 2021 09:07:58 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23EB2C061764; Thu, 18 Nov 2021 06:04:58 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id fv9-20020a17090b0e8900b001a6a5ab1392so5815568pjb.1; Thu, 18 Nov 2021 06:04:58 -0800 (PST) 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=wlP4fOTykbzU+g6/cyJ7zYPFE/ryfY0EbZlV8FvMVqc=; b=QMZKVQdPimZWc3wObLr6wjuQGAwHXkdQDB35x1/7IsVYaRyQu4fqsUSWsoDVljOFp2 AlNYLrnHMAWyb3/pzbxu+DGmWyu+RVv0uKekuGFYlopisJ0EfzpVYA/tWjPfMNO5bg8s mJ97HEoGIP6eIjyy1qAc0Km4T1VD/m7A/25keQriLTkppDl7WVBKrI55CEMOCGX2QvGr rdrAlZwTBdJe81puVKg/rTmj5A/DVX7qJf28eVjZBjUCV3ifDJgTvTqzoAkWRV6pcYM2 IPbrH7LEBG8rT2Fw4QbL6ZHIwMlDNXFEjr2eK9hA1AgGZQggJ0MYUYBNS97vHkh3VFiK x/ng== 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=wlP4fOTykbzU+g6/cyJ7zYPFE/ryfY0EbZlV8FvMVqc=; b=47Xm12dgxa+XlIf8U0PnB6bJLPo6S70jes4DiYZxqixhlZeDmszuDClmR7vskb+k+H 6yE6qqRuS/vmscpdvvPbCGKo9xPF9xE0yezs1ja5Ffjbmj9yp5mMwCvNBF5FFkv9GXCC u7YcnCXm15n3a7hT47u3nTVhZUHVfJ3K9O++I0a7QdJvSP/LcvIikPSOFKyZiYsvCjlx QiY/GJdYYMa2hwKtrA5TJZQ4DOX/Br627e73DevRcxeXUK3l7udsqyOUM5K5deLGCCp0 C0tMVbo/jUf5ogRDPK+oii7RNvKXLpNP2gDgEKDE1W7njZwq2zO6DGVo1eK6dXIerSCe mfAQ== X-Gm-Message-State: AOAM532MaM4clE8A9aPrmtySS3Wey8aQIBYyVapmWpqPuS49P+1qhgBl Zybx5+23ZCUKX5Z6W9ErJOI= X-Google-Smtp-Source: ABdhPJyqiWgfNZtzNB6ARnHM9Du0xQAnLthgWfbNHaay3g2LSkWtotEgtBlLYBTm34GwuWKUyw8oaA== X-Received: by 2002:a17:903:32c2:b0:141:eed4:ec1c with SMTP id i2-20020a17090332c200b00141eed4ec1cmr67258899plr.33.1637244297661; Thu, 18 Nov 2021 06:04:57 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:04:57 -0800 (PST) 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, Rob Herring , =?utf-8?q?Pali_Roh=C3=A1r?= Subject: [PATCH v4 02/25] PCI: Set error response in config access defines when ops->read() fails Date: Thu, 18 Nov 2021 19:33:12 +0530 Message-Id: <4188fc5465631ce0d472d1423de3d9fb2f09b8ff.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Make PCI_OP_READ and PCI_USER_READ_CONFIG set the data value with error response (~0), when the PCI device read by a host controller fails. This ensures that the controller drivers no longer need to fabricate (~0) value when they detect error. It also gurantees that the error response (~0) is always set when the controller drivers fails to read a config register from a device. This makes error response fabrication consistent and helps in removal of a lot of repeated code. Suggested-by: Rob Herring Reviewed-by: Rob Herring Reviewed-by: Pali Rohár Signed-off-by: Naveen Naidu --- drivers/pci/access.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 46935695cfb9..eac0765d8bed 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -42,7 +42,10 @@ int noinline pci_bus_read_config_##size \ if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ pci_lock_config(flags); \ res = bus->ops->read(bus, devfn, pos, len, &data); \ - *value = (type)data; \ + if (res) \ + PCI_SET_ERROR_RESPONSE(value); \ + else \ + *value = (type)data; \ pci_unlock_config(flags); \ return res; \ } @@ -228,7 +231,10 @@ int pci_user_read_config_##size \ ret = dev->bus->ops->read(dev->bus, dev->devfn, \ pos, sizeof(type), &data); \ raw_spin_unlock_irq(&pci_lock); \ - *val = (type)data; \ + if (ret) \ + PCI_SET_ERROR_RESPONSE(val); \ + else \ + *val = (type)data; \ return pcibios_err_to_errno(ret); \ } \ EXPORT_SYMBOL_GPL(pci_user_read_config_##size); From patchwork Thu Nov 18 14:03:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627093 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 22F9BC433F5 for ; Thu, 18 Nov 2021 14:05:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C56860EFD for ; Thu, 18 Nov 2021 14:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbhKROID (ORCPT ); Thu, 18 Nov 2021 09:08:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232210AbhKROIC (ORCPT ); Thu, 18 Nov 2021 09:08:02 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4A05C061570; Thu, 18 Nov 2021 06:05:02 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id np6-20020a17090b4c4600b001a90b011e06so5776450pjb.5; Thu, 18 Nov 2021 06:05:02 -0800 (PST) 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=MV39JGkKDIkXiPRnH+W6MhpRBxyv9EoW3jrMZU+eQgA=; b=BlIoxgRHAtlgaOA4X+KHVoZAtRRhSolSqdc/mUyB/pQLj6YVZ5NFGN3eQi6c5hQdoh S3ioEu71pyjzWILjnXCGEwswEB8Woji8zTq3Tu97wbK7Sh3WegwGOUl4pvGZTCC8sXYt paDdTGZrNN4cY2Arv6On5cUy7+4Pp3yWuIq8/F3wTeDQj1QoJSUbMPV8xmI49BhqT0LJ N/1eC3FVxHdhfpvq5qMQ+QeUVDPXtNozLP1tN14Rd4y5rXcmgV5oYTFTZBHrfayrGvE/ CUZGMW+ZOcjI7WPA0JvxEsgTyP9877Kwda4jnLqi3O+gQsDZJJuyaKoOHrAOilp2N+JM b3zQ== 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=MV39JGkKDIkXiPRnH+W6MhpRBxyv9EoW3jrMZU+eQgA=; b=mb+hsvS4TmbTzzP94/KOFhShTV5VrlPWFK64++QZMixw/74mH82zXvqdnbvvVvxYQP kY9pf4MKBhTR3/Hk8OcVyVeMPlGc2ZsSlnxRsddsfAgTxdZoebeRJEkAFn9e9jb00szR cPDAM/nwZqxGyA2mu7BbBNG1QSw5ycl33Gq9/UOqFlODgTV2ptl5r8vJKaQZWuMm22QO ZUid1nuNnITQDK4ye0c/sKtP925x4JpFvZARMd5j7vdxMce5RXCZpOppAhIM061McdKR Bsf8+lByf2NoDGxgatmR/qNWmeFr6Ep+etysIr0njtwR0ISDasmu+rkDfHGpLO9UmhwR /WZw== X-Gm-Message-State: AOAM5330MfHBCiLO1fM3z42KgHT8qtaloL637MUqYijrIoRCNflp+9NW 3hUpWZ8BbFE6na9y8tjUG1w= X-Google-Smtp-Source: ABdhPJztsAl12367c92Fw/hcVl1vu1Gs8QO8s7YyCtOAlPzDY8J+Wko11a7iJsaUTWNOAkmhz5U/Dw== X-Received: by 2002:a17:902:b7c6:b0:141:9a3a:f213 with SMTP id v6-20020a170902b7c600b001419a3af213mr66374177plz.15.1637244302278; Thu, 18 Nov 2021 06:05:02 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:05:01 -0800 (PST) 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 Subject: [PATCH v4 03/25] PCI: Use PCI_SET_ERROR_RESPONSE() when device not found Date: Thu, 18 Nov 2021 19:33:13 +0530 Message-Id: <29db0a6874716db80757e4e3cdd03562f13eb0cb.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Use PCI_SET_ERROR_RESPONSE() to set the error response, when a faulty read occurs. This helps unify PCI error response checking and make error check consistent and easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index eac0765d8bed..e1add90494ec 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -529,7 +529,7 @@ EXPORT_SYMBOL(pcie_capability_clear_and_set_dword); int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val) { if (pci_dev_is_disconnected(dev)) { - *val = ~0; + PCI_SET_ERROR_RESPONSE(val); return PCIBIOS_DEVICE_NOT_FOUND; } return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val); @@ -539,7 +539,7 @@ EXPORT_SYMBOL(pci_read_config_byte); int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val) { if (pci_dev_is_disconnected(dev)) { - *val = ~0; + PCI_SET_ERROR_RESPONSE(val); return PCIBIOS_DEVICE_NOT_FOUND; } return pci_bus_read_config_word(dev->bus, dev->devfn, where, val); @@ -550,7 +550,7 @@ int pci_read_config_dword(const struct pci_dev *dev, int where, u32 *val) { if (pci_dev_is_disconnected(dev)) { - *val = ~0; + PCI_SET_ERROR_RESPONSE(val); return PCIBIOS_DEVICE_NOT_FOUND; } return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val); From patchwork Thu Nov 18 14:03:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627095 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 ABF39C433EF for ; Thu, 18 Nov 2021 14:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CDE160EFD for ; Thu, 18 Nov 2021 14:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232213AbhKROIT (ORCPT ); Thu, 18 Nov 2021 09:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232229AbhKROIH (ORCPT ); Thu, 18 Nov 2021 09:08:07 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B23C7C061200; Thu, 18 Nov 2021 06:05:07 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id r5so5412285pgi.6; Thu, 18 Nov 2021 06:05:07 -0800 (PST) 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=zxXrUZht15oO1Xjz6QWdqaAcujYVEC+9jBLeu7+7g0c=; b=HbXpWZrZFoaUh8ToyYcOr4IeJCt9Wtb/Ii4qTWagMTuHX7bBJ408OnaIHcxI6Aydah JcN5EhV7L+2xpGF7TR51D0VZb585s/LREfwS14xSPHw2V/jvXmopFLGnbqor/FNbm8DY Jf/IDZK+dS22PSV9/J4C5iuyEPNNVEkZVb8S+eueWHOek3vTdeiBGsN+6NhdGO4ZcoLF GJtCPA5N2xZQ165JR+wTN72S8dX21PRK+X6tlSksm0DWdb3ajFZkrNYdbqpc5kgjKvhT XPqraYIqNUphptmr1sD7LurQPDjPHlIaXrUBAvmJcZ30mG1iQFLMn54+fGN4mG8m5IkB Tj8Q== 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=zxXrUZht15oO1Xjz6QWdqaAcujYVEC+9jBLeu7+7g0c=; b=0lbyUm02hy9hOb8mR4Z7YZ+D/4siFPaF+h0KVSxnQ2ibbZZ+SQgj7F110agsmvwgIc oglBGkqyaa7ns83h6xiCQ4xdX8OokpfSBq/5oPGAq96ZhEFSG2FCqnwS/y1+Z4vSmf9C +4o8cNZ+21WxzBIrYTc7BBz87qayy/5OQ2+rJH0XPMNU3/+OL6wkgql7PLg2YsjgTBgN irea1WypTgEzdCsG49bnsmNz9068dBkEOzkt1jK7tqTKSCTJdBkVfR9+cHt6d7yrhkSc zX0GRGP+5PFF5uTcQ+pTgjpx+GNgaxCC3abPzpGfENsV6tm/CdcXphfysILNyvqAdp3C Layw== X-Gm-Message-State: AOAM531VM+HYOUyWUKP35b6onOJ1SEL10Vh/39fBuY2sbUUQpEzpHEwx 1Nl63GUf3z/dbskSOkX8+CI= X-Google-Smtp-Source: ABdhPJwOXyE6HEQbNhPVgekg9gPYV7L5WppEDsCgRjqxmDA8X9Db0i/xJwXn6bbQv5oaIkUB7CnPhw== X-Received: by 2002:a63:2c53:: with SMTP id s80mr11543263pgs.6.1637244307202; Thu, 18 Nov 2021 06:05:07 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:05:06 -0800 (PST) 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, Rob Herring Subject: [PATCH v4 04/25] PCI: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:14 +0530 Message-Id: <1b2edb060cf19b45f70645b331e6c08c9ba798c0.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Reviewed-by: Rob Herring Signed-off-by: Naveen Naidu --- drivers/pci/access.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index e1add90494ec..a92637627845 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -83,10 +83,8 @@ int pci_generic_config_read(struct pci_bus *bus, unsigned int devfn, void __iomem *addr; addr = bus->ops->map_bus(bus, devfn, where); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } if (size == 1) *val = readb(addr); @@ -125,10 +123,8 @@ int pci_generic_config_read32(struct pci_bus *bus, unsigned int devfn, void __iomem *addr; addr = bus->ops->map_bus(bus, devfn, where & ~0x3); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } *val = readl(addr); From patchwork Thu Nov 18 14:03:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627097 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 3D1C5C433F5 for ; Thu, 18 Nov 2021 14:05:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2231660EFD for ; Thu, 18 Nov 2021 14:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232244AbhKROIe (ORCPT ); Thu, 18 Nov 2021 09:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbhKROId (ORCPT ); Thu, 18 Nov 2021 09:08:33 -0500 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 972B0C061570; Thu, 18 Nov 2021 06:05:33 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id y8so5345759plg.1; Thu, 18 Nov 2021 06:05:33 -0800 (PST) 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=/1DR3OOSzZuxfUtlUJMZJiGVE0NaIRWqbUvxoOW0jlM=; b=jdSkECp3SP2RSmPMNet1SnMVaDyeo8yKkV5XHhVCvBhepg39GB2PfKzHjI+JTCDOEd guMiR3Jz/cAYlAQZmKlQjSrTuQ9GsLk6ntRuvGW+LNSHWj9DGA+EH+dJZwkDmB0upCqa KoQ/F8hvOOqHkXQTqf7ey2jAwYO4YZd1QWmdlxXb+nJgU7oLMjbGVJrms2xRStItbWqS 3wrwCSjD6xcmyik3lX3vTdmKuYBwqZTqmuUIFJqS/pM6qeS+PreJLe/cVu0HL1hF2qdh Ys5BoxlLTUTsYytDVQhE6LH5h/6F+1Qme6HtPpolIQAk3KfkWJr7PuZ8rVhw5aitmm7D 3+rQ== 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=/1DR3OOSzZuxfUtlUJMZJiGVE0NaIRWqbUvxoOW0jlM=; b=m1fz5SYWXM0MUZcfgbulBam9ih7fRH8ijYzhI/NaD2IVhbPf2GeftplCixadZIwA26 oqBnVlfIwv7Rm3dRMuHXAExf15BNQ7Wg4lJ2DsaaG5Ih1traq+PI0IrsTey83T4b+QF1 lCHbK/1NBxfnbMzlTNIZV1Y4cHsf9FBbFhy6HdTbA2HRkKMPszOMJ16K/eXCixKXtWFP Fye/ISIVbXu/B1HE4R7/KUjZAKsHGAYASwxXTapx0pjfHaL/1x5QvF4NydgcpfBPRCQ+ MSSTJB2zd+Iwoud8qFeGyJYz94tDZoqKMTQalcGhBXkSF6Oox3xHR/2N7sKuRp8pBWX4 hjqA== X-Gm-Message-State: AOAM5317hRrQ5sGwUs3475Fv/riQ8YF2oXFuqzL3xnWwCzJ5gOmOIIs5 JuLk+0wpfXhR9blLGZZ+Q3w= X-Google-Smtp-Source: ABdhPJylY1j0PXT0hDdZWfRI0y02595GqGzG4pRAVnMOmOXr655gaWX9MhLwp3Tgo0soIDQbH4IMtQ== X-Received: by 2002:a17:902:9303:b0:143:d6c7:babc with SMTP id bc3-20020a170902930300b00143d6c7babcmr21577067plb.58.1637244333020; Thu, 18 Nov 2021 06:05:33 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:05:32 -0800 (PST) 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_Wilczy=C5=84ski?= , linux-arm-kernel@lists.infradead.org (moderated list:PCIE DRIVER FOR CAVIUM THUNDERX) Subject: [PATCH v4 05/25] PCI: thunder: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:15 +0530 Message-Id: <22f471b638276422926c49f3d42ac41bc7b28b3d.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/controller/pci-thunder-ecam.c index e9d5ca245f5e..b5bd10a62adb 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 == 0x4) { addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */ - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v = readl(addr); v &= ~0xf; v |= 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; addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */ - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + barl_orig = readl(addr + 0); writel(0xffffffff, addr + 0); barl_rb = readl(addr + 0); @@ -72,10 +70,9 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus, } if (where_a == 0xc) { addr = bus->ops->map_bus(bus, devfn, bar + 4); /* BAR 1 */ - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v = 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, } addr = bus->ops->map_bus(bus, devfn, where_a); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } v = readl(addr); @@ -135,10 +130,8 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn, int where_a = where & ~3; addr = bus->ops->map_bus(bus, devfn, 0xc); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } v = readl(addr); @@ -146,10 +139,8 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn, cfg_type = (v >> 16) & 0x7f; addr = bus->ops->map_bus(bus, devfn, 8); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } class_rev = readl(addr); if (class_rev == 0xffffffff) @@ -176,10 +167,8 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn, } addr = bus->ops->map_bus(bus, devfn, 0); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } vendor_device = readl(addr); if (vendor_device == 0xffffffff) @@ -196,10 +185,9 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn, bool is_tns = (vendor_device == 0xa01f177d); addr = bus->ops->map_bus(bus, devfn, 0x70); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + /* E_CAP */ v = readl(addr); has_msix = (v & 0xff00) != 0; @@ -211,10 +199,9 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn, } if (where_a == 0xb0) { addr = bus->ops->map_bus(bus, devfn, where_a); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v = 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 *bus, unsigned int devfn, if (where_a == 0x70) { addr = bus->ops->map_bus(bus, devfn, where_a); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } + v = 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/controller/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 = bus->sysdata; struct thunder_pem_pci *pem_pci = (struct thunder_pem_pci *)cfg->priv; - if (devfn != 0 || where >= 2048) { - *val = ~0; + if (devfn != 0 || where >= 2048) return PCIBIOS_DEVICE_NOT_FOUND; - } /* * 32-bit accesses only. Write the address to the low order From patchwork Thu Nov 18 14:03:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627099 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 DC1D7C433F5 for ; Thu, 18 Nov 2021 14:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C419D60EFD for ; Thu, 18 Nov 2021 14:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232287AbhKROIk (ORCPT ); Thu, 18 Nov 2021 09:08:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232281AbhKROIk (ORCPT ); Thu, 18 Nov 2021 09:08:40 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5545FC061570; Thu, 18 Nov 2021 06:05:40 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id b11so5299042pld.12; Thu, 18 Nov 2021 06:05:40 -0800 (PST) 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=nZn4SxDZvh+tavMY8+enW7L1nqxNB0bRzV0t3A5PNmg=; b=JG5K9Trd1o3s4rrA6V+Ay1LKEJnXRI5kjwDECp3bKxrUj+eDe+iJmCOxM5RXaT7FBj wEHlIjohorJgsIIb/ELmE0bh34ntCQCc9Wp6Vmbtq00W4kdPbwQ6n4rCIphJNy7Fju6Q 4Zpx3SndARG4CvzkOtorq1A1jbfbAR1UKd3x99AELcG7XRA9l2y5lW2KpA3wWXJEJBHb OKyIlxB8PqJ9RUWcV89WDhgxB/ptMVQjvisEzBZa7VsepHzxGFkyKJdWXHT6u4GqyuO6 STb6sTk5n2jjW1HfkB+mxZZlHikXjN73pqTyz7JjsHdJXKPEEuHDwx3tYkTN2fb8yLz3 Mwow== 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=nZn4SxDZvh+tavMY8+enW7L1nqxNB0bRzV0t3A5PNmg=; b=wm2MvKLOHifsAbq9BbVVhuIofB3zlwTBKkqd9QCtwQ7Nrkrr3IHxM+MC65WK9PFOZp fU+4Ku0xe9O+XUC9QNUeZwMZ8gDGQT6jAwCNYD+M2iOdaNJnQvJfh0gFc5lWLAhFvCdQ e0oKQ0GzyK4We52A2H4x/xt+KXMfHvS5wwXsX9qkyH68ZhBDaOgFz/4bBsKlTL02HAaK ah6ybTZx9zZdHmHibteMsMeLJDMbcpYSeJLpYkdQ/Q0UzRcP+t8ady1u1oMTpl0qvT22 Tf25ogl3a+pbiRp7+YQceA/ghf8uZdY4CS1GzTgx8PBNjgYWzUZN2LgyQTOboboqbsjs 5uXw== X-Gm-Message-State: AOAM5312HL0RpLZ/T54ZcIUy1A1/NgyNGqIqUKvPvLQAEvkoPwkIQYmQ 8gWeoiUNAaZu7huc74N+oQI= X-Google-Smtp-Source: ABdhPJz9L+8is2Ip8jLLWfzTNi/us5Q4tilWZCGXKU5MU+FnoFZb+E4/5NFsc5dQ6k9M0TzIAtqBrA== X-Received: by 2002:a17:90a:d49:: with SMTP id 9mr11086261pju.115.1637244339812; Thu, 18 Nov 2021 06:05:39 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:05:39 -0800 (PST) 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, Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com (maintainer:BROADCOM IPROC ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM IPROC ARM ARCHITECTURE) Subject: [PATCH v4 06/25] PCI: iproc: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:16 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/pcie-iproc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index 36b9d2c46cfa..b3e75bc61ff1 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -659,10 +659,8 @@ static int iproc_pci_raw_config_read32(struct iproc_pcie *pcie, void __iomem *addr; addr = iproc_pcie_map_cfg_bus(pcie, 0, devfn, where & ~0x3); - if (!addr) { - *val = ~0; + if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; - } *val = readl(addr); From patchwork Thu Nov 18 14:03:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627101 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 BEF7BC433EF for ; Thu, 18 Nov 2021 14:05:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A78B061AE3 for ; Thu, 18 Nov 2021 14:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232320AbhKROIw (ORCPT ); Thu, 18 Nov 2021 09:08:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232281AbhKROIw (ORCPT ); Thu, 18 Nov 2021 09:08:52 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78982C061570; Thu, 18 Nov 2021 06:05:52 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id z6so6098263pfe.7; Thu, 18 Nov 2021 06:05:52 -0800 (PST) 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=E2kMW7De0WUTFR8R6pbmw+v+DfoEFjJfFZEPmx6TpIo=; b=jmYMhdUPtwXlk7YxNRrEY39ARKEZzJckayE37oIVTUa4nPyIslNcR6XMOv+FjMg22s S/2TjPlBw5NarH79TxwrLYnoAVvWIZ0ppI9goUKtPGdcd0slD6cnqVcnAcmR2QXi6HrW 8+7CI+lO7fFXcHknuE0JmXhZ9a5KqyZcFnX4cBMhbOQxCVWJJNIZaMOHFOcmYvr6vB1w pltr2d5RvAkg0R5l+YmyEilG8etz39ddfm+YhEh18pVpohNq8By50UkP5pvHXKBFDxd3 9HBmaDizaekYvA2ywKzrnX+8OKZJm2K/jRoIj7A8oOVDYNxiGAyi68IMrf7PY9dIX6YG g3qQ== 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=E2kMW7De0WUTFR8R6pbmw+v+DfoEFjJfFZEPmx6TpIo=; b=CbBmS0JFUZN442pT4Yrufare90DBND4H62r6GLW+M1Cgw71LBeJ+CwkkIUlEsQx/34 C8g5z1uWECsTEWhyXo0thRN6fU7j3PbXT3fE08lwbTONeMacL7oj9oiG7Ll8wOuCtftn IZK/R0xcriFiXvtFJWkvN4nwOV3hHw753+x7FiYUV1R/iSbFqgMB942PQ1ec++cGAq2B Hj8V0Jn2wXz4Md35PsVB9f9yGeKEYgleX6ALON7bPuaWkxATxxPzqnyO73Wvb6GGZ1h6 Oyc5aWY5pgUYWZHv7skekcMbVuUIM89Y0j2QsvtoapjNemGiUrpy/pqaZycBntMgEleo XUNA== X-Gm-Message-State: AOAM531mYtsT4IIDIT8JWvPhSdFeEPDr8nXFZo4LpGAes6JV77pCqvD2 X7HOJMbk5MCJupofacZxJB8= X-Google-Smtp-Source: ABdhPJyV+0mLAR5xy7BosKaOERagEd3ZKVQwr7/RwK2rniXrlnNRhEmZz+hP+50EUyrGGs3nj1a7sw== X-Received: by 2002:a63:b0d:: with SMTP id 13mr11503398pgl.190.1637244351963; Thu, 18 Nov 2021 06:05:51 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:05:51 -0800 (PST) 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, Ryder Lee , Jianjun Wang , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Matthias Brugger , linux-mediatek@lists.infradead.org (open list:PCIE DRIVER FOR MEDIATEK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Subject: [PATCH v4 07/25] PCI: mediatek: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:17 +0530 Message-Id: <666127469482f9ca177805ff52aeb7bccb26e4c9.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/pcie-mediatek.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 2f3f974977a3..a19f8ec5d392 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -365,19 +365,12 @@ static int mtk_pcie_config_read(struct pci_bus *bus, unsigned int devfn, { struct mtk_pcie_port *port; u32 bn = bus->number; - int ret; port = mtk_pcie_find_port(bus, devfn); - if (!port) { - *val = ~0; + if (!port) return PCIBIOS_DEVICE_NOT_FOUND; - } - - ret = mtk_pcie_hw_rd_cfg(port, bn, devfn, where, size, val); - if (ret) - *val = ~0; - return ret; + return mtk_pcie_hw_rd_cfg(port, bn, devfn, where, size, val); } static int mtk_pcie_config_write(struct pci_bus *bus, unsigned int devfn, From patchwork Thu Nov 18 14:03:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627103 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 7DA6FC433FE for ; Thu, 18 Nov 2021 14:06:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6455B61AE2 for ; Thu, 18 Nov 2021 14:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbhKROJA (ORCPT ); Thu, 18 Nov 2021 09:09:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232358AbhKROJA (ORCPT ); Thu, 18 Nov 2021 09:09:00 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47CDCC061570; Thu, 18 Nov 2021 06:06:00 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id k4so5310213plx.8; Thu, 18 Nov 2021 06:06:00 -0800 (PST) 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=MJKYZ0DmEpP1c+Cyc4zstBHahVie6foEwa+j6qM9UhA=; b=jR4j+uWajdUBW8ioVx4f5AGVPE7plrg5Zo34hJRLJitbZCha37QIAEH8v3C2MoJa7L q5wQ/GZsXlkwhuooU5p0AbAlaFsADi6OUHnZsNN0WnvMrj6hC6uvKz8BX1vW1VuX64VR VTrlRCt4jn5QRUohdQMSMtX1OifQ1IZnPX7w+5MyfhrI1JMAd4mjkd2C8nmmPK0L7UPF f2YNQcjanKRL62xIjI+ejIjkPwS1WNldYOfy1AQukRqjRNKSndUpwb9Mb/9Ot4hEXnJH Pp6a8QIVJs25PViapKLN86m1IC+q/kZSX+IZfMehrG1tO9WDiiLbBnlnELHSAgcCwOYU TKag== 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=MJKYZ0DmEpP1c+Cyc4zstBHahVie6foEwa+j6qM9UhA=; b=OS5C6l6yfk2MlES0BGsARAi25JdYyI4LoQcjSK9Y2hjDM0TYu3SkLNYb0kI9HKAbv4 vT07oCexBLj9JD8PpjYTuCh1YFKX1KUntQ5lmp/3jXjEGzhBfsSIxR8wbP4eG05GZGHC h6K517sPmVfVKPO8tkoumJN6xcvhAT9Ji9EZzU6PqqYnFeT0Im0QDbJUKYnj1VrxPmrg WmN2smc59sKa1FXhrbmbRhW4ighdSteO4EyLe+ksaFsl2jQMeDOQxFHItuQj0khVWE8l rnIEZFjJsiA/Ul5sX1fhD4oKh46MxQvmLniqp+lKlzElZEjrEK1tslcbDDiVZ/tLGklH gyFA== X-Gm-Message-State: AOAM5313lfkPvRCcMvOlGN7mN395XMVP+NtwlwIkTAlion3an/HYyrl+ SewI9+5++0zEHvq5YbWt+VM= X-Google-Smtp-Source: ABdhPJzzq68/X527KYUYiq6BXWx7Pi6UkM26Xbb7lDccllJj01D67EBk5gsrY3Egw/rUWXJ/CLdhdA== X-Received: by 2002:a17:90a:1f45:: with SMTP id y5mr11000237pjy.138.1637244359702; Thu, 18 Nov 2021 06:05:59 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:05:59 -0800 (PST) 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, Jingoo Han , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org (moderated list:PCI DRIVER FOR SAMSUNG EXYNOS), linux-samsung-soc@vger.kernel.org (open list:PCI DRIVER FOR SAMSUNG EXYNOS) Subject: [PATCH v4 08/25] PCI: exynos: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:18 +0530 Message-Id: <765c2f27d85fcee4eb137023dc0a8f864eee9e36.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/dwc/pci-exynos.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c index c24dab383654..f9526d6de160 100644 --- a/drivers/pci/controller/dwc/pci-exynos.c +++ b/drivers/pci/controller/dwc/pci-exynos.c @@ -216,10 +216,8 @@ static int exynos_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn, { struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); - if (PCI_SLOT(devfn)) { - *val = ~0; + if (PCI_SLOT(devfn)) return PCIBIOS_DEVICE_NOT_FOUND; - } *val = dw_pcie_read_dbi(pci, where, size); return PCIBIOS_SUCCESSFUL; From patchwork Thu Nov 18 14:03:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627105 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 CCEF2C433F5 for ; Thu, 18 Nov 2021 14:06:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B13E161107 for ; Thu, 18 Nov 2021 14:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232373AbhKROJH (ORCPT ); Thu, 18 Nov 2021 09:09:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232408AbhKROJH (ORCPT ); Thu, 18 Nov 2021 09:09:07 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9290C061570; Thu, 18 Nov 2021 06:06:06 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id h63so5382126pgc.12; Thu, 18 Nov 2021 06:06:06 -0800 (PST) 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=FA4eEA0vKwb58YOkbLP9K2NVmJYtwGLqPjb+iaCxg5k=; b=pvFZ0MRzAJrj8pt979HKbEHcM6RZZRo84yo77627EYv7H5wrgSzp+Tof5GsOgr6wmL DPAA5oSOmTX+Fz9oXY1GFjV6XxP3Csvm+jcu9V+6t0GXEPIpTIPxC1geB6HIdWwuNY4+ sk5l4jsU1SifopQYlOtZLV/P7hdsHgV/2wh8F7PAJP6ZDNRNJ7N5pBGj3aK75YfFhZRZ GCJiIHMbk96TSg8nM0qOcdoXp3pcX5B9K16CH3HC+YiYhAI2ZWtytvT0NZWV5uq2bCW3 zKdewD7ldn6cCDPa9jaZ4J++AeBybJbKcswV3mfPUtq+bCJ6Kj3bYaaYTlPv+vW4Ecze rKGw== 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=FA4eEA0vKwb58YOkbLP9K2NVmJYtwGLqPjb+iaCxg5k=; b=rbyJ/HfDcagt1dcCXRWx/an0sUjFh15SC+yggi4lSUnU9W+h8rFlBWATOvgGIJudWu McqfeuYxNX2mJVeo3LCaU7cvjZPsjNS+El16Y+/2t5qEGXpi79m/D5giPz0avm2rJdxH mTfzPjKh+RVlbEIF9f/E3mmD49tLOh/EyEhaodBKCv+tcFcF8e237VwKtyEQDE/9rTej mffyO6WVcJ8aP51Hv3bfcXnxQNFLdH0c4m9DsvBj8OXiaokPA9EDjJ+Jc97YZViHLHxn Ycu4830eZuTMioHfTS+eoFQO3dVfO6FfOyZZtXaKIHARa7PA4e5NRAixSVUMrgfWDoVc GAGw== X-Gm-Message-State: AOAM532tfMUnMZ2n+fRF1vS/09DRxhOUVluypKTKDPfcJWn/NPkgs80z O0BpxMZzqqxyMmAS39lvKrk= X-Google-Smtp-Source: ABdhPJyYmcR/6DtK9DVRdL5nij9z3SmJ2ySPLjdsrWeskedGCKj8rft+HErV7xfOCFlSXzH7EUe/EQ== X-Received: by 2002:a65:5589:: with SMTP id j9mr11358991pgs.291.1637244366422; Thu, 18 Nov 2021 06:06:06 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:06:06 -0800 (PST) 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, Shawn Guo , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Subject: [PATCH v4 09/25] PCI: histb: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:19 +0530 Message-Id: <7da7ea760abc5f85cad6e9b0d3e59eebd93f50d3.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/dwc/pcie-histb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-histb.c b/drivers/pci/controller/dwc/pcie-histb.c index 86f9d16c50d7..410555dccb6d 100644 --- a/drivers/pci/controller/dwc/pcie-histb.c +++ b/drivers/pci/controller/dwc/pcie-histb.c @@ -127,10 +127,8 @@ static int histb_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn, { struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); - if (PCI_SLOT(devfn)) { - *val = ~0; + if (PCI_SLOT(devfn)) return PCIBIOS_DEVICE_NOT_FOUND; - } *val = dw_pcie_read_dbi(pci, where, size); return PCIBIOS_SUCCESSFUL; From patchwork Thu Nov 18 14:03:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627107 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 E972EC433F5 for ; Thu, 18 Nov 2021 14:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFA6561107 for ; Thu, 18 Nov 2021 14:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232301AbhKROJg (ORCPT ); Thu, 18 Nov 2021 09:09:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbhKROJf (ORCPT ); Thu, 18 Nov 2021 09:09:35 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADA94C061570; Thu, 18 Nov 2021 06:06:35 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id p18-20020a17090ad31200b001a78bb52876so8281070pju.3; Thu, 18 Nov 2021 06:06:35 -0800 (PST) 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=8lsW4hpjhviqEYY030z6kfRyw6NTRFOimRsTY0Dd4qI=; b=R/sJSkzEx601ikKdcFXXcXBLPdX8M36alq3M409uEktIk9JmQzDH/88j+OTcY6m972 oOCg2sOWlarizgYgRP/kZETioJd/V8hfz34YvW1/jTu9SjD29YddWg+Rjijc9dU5aJeT nIoQQcA4D7r5NWm345J0f5UH6Ha/yIQUXAQcraPv45NX8kDOzcgrTAv4+8ZfX73OnvXt yhCSzkxyY9V2Pjt6Ndq+hqexPvSdtjWCw4iUQHopkkxDTwEm4Akcg5zKeDASUu7HJyOj HoeWg7ASFeSEcY7OWnZCR5zkbtVroKZ8WpbFKbY6ppTefVKFBsHeF6wjUS4oLW/Oy5lU b/aQ== 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=8lsW4hpjhviqEYY030z6kfRyw6NTRFOimRsTY0Dd4qI=; b=Nb7sMzMD7SH/ousLdAQuV3QW9RWy3ZonXk8lv6pTXaDN92jqLrc7s+Te70mWEZDmEG 1uENVpgOA6ZLQXG8eENoQQnR4rU7m1ezyV3qjknI0oNGmHs9PnbdLtyry+Y0V6jpapMY aBUjtR5ob8W9NdhjpMB7i676kHm02ZHhj/yvYf8x8Z91L/qqm9GDpHGsQRUe+yz8KdMD Ij4IXHMt7eoaJ2K1lxkxeZ5mUjs4imDvjJGQboVBvJhBOHMCd/Nvxu0P+vrk9QqzNMJW z8CjVOEDxAycFaxl51Klf63IVKHrMJyO9aBtVRcRgspEw0mwI89V6ao/QIcpSepZnrFl CcwA== X-Gm-Message-State: AOAM53098WQS0wIl5fGo+8ANbWahy1q/kJRFkt4qctUFcgy2yOjIBdr5 Zx9x3s/tnWMLi7hhqbGG8L4= X-Google-Smtp-Source: ABdhPJzwsIz1FjnbkpaH+NZP6qwJ7t3ZNQ3Pl2HaHBCCx4yHGcbyTsopAFtMN1jFwxxEYO/VtU+oWQ== X-Received: by 2002:a17:90b:33d0:: with SMTP id lk16mr10713763pjb.66.1637244395195; Thu, 18 Nov 2021 06:06:35 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:06:34 -0800 (PST) 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, Xiaowei Song , Binghui Wang , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Subject: [PATCH v4 10/25] PCI: kirin: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:20 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/dwc/pcie-kirin.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index 095afbccf9c1..e6dcac79c02a 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -530,10 +530,8 @@ static int kirin_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn, { struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); - if (PCI_SLOT(devfn)) { - *val = ~0; + if (PCI_SLOT(devfn)) return PCIBIOS_DEVICE_NOT_FOUND; - } *val = dw_pcie_read_dbi(pci, where, size); return PCIBIOS_SUCCESSFUL; From patchwork Thu Nov 18 14:03:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627109 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 AE9C1C433FE for ; Thu, 18 Nov 2021 14:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 987C461AE2 for ; Thu, 18 Nov 2021 14:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232378AbhKROJo (ORCPT ); Thu, 18 Nov 2021 09:09:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbhKROJo (ORCPT ); Thu, 18 Nov 2021 09:09:44 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C76C061570; Thu, 18 Nov 2021 06:06:44 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id z6so6101143pfe.7; Thu, 18 Nov 2021 06:06:44 -0800 (PST) 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=n/yt+ar9LeJXp+LgPRjnz08fHYE7Y6D7uP8N5v1qSeQ=; b=ju5IgyBkawORLGdE5+lvjqmVMlAJUBHJQunyAtZAHZeDq2OXPFfbOCXZ/z6XcreEmd 8Gb5fyu/w7VxIygaGX06SKEUiejhTJb+VroQuBSLQUew7HaeAiJfxxhAxBh34f7i2HVA zZM8dL5hfTR+iWHlqmLBHG8qMmBc0uN9ZJv4QqsaMEP4gN5rV+7WFHhuoQqxkXQmhCNL d23U7KjYdmtAVrH8eLX9VAmblo3HQd9kc60htoY0gkWIRoKbUOclN4VQnRhKvWgB+EUG 7fMw/n104iCAB9CKf0WenkQ88x3KHJfrQwgovVliRSHPm22klNnEiPbspoDUXf++2rH7 C6PQ== 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=n/yt+ar9LeJXp+LgPRjnz08fHYE7Y6D7uP8N5v1qSeQ=; b=SgVzyLy/ue4UUFfuf/ZFyx/HQ/xJ8G9m4XAWqZEgSgSwzBTWNu/8b72ji0x5S7k9qK 4h68KH4PXks4ctPb0Ud7YDa0O/awqW34UTDs2gIwKgBejqoiinnZg2TFXyPc6CNY67F7 f8FIkSMuRXnwtKClR9QvgS2Zsic3MGROU6FvLW+ztrZ9iFEE+2rzCnsYFnkTVLGVS7/q vKVBI8Q/2IZ7PKWNbByMYh/dYGg+q0BGC57OF8fOzsEke4VVvwWJSrnrUf7bq1e+/jDB Q23NNbC+PJdHeFAy2ruej9OMBAFmQaOpM1IWZXl5VZi9eKeKvg81EQ5Y/pTvwYc47MbT YzNg== X-Gm-Message-State: AOAM533M7awL05kJEQkjU+kUIOAA5FF39GWdTNSTWzyM3AtFXMQDWhrq JgIHPjebyoZDLu40nhiOVSA= X-Google-Smtp-Source: ABdhPJwRC2+Zew+d+pDpceltjCbSl2htV5tAPVKvoWCpsnfdWeC89UX5XOOHSvDvVdy5CjvvBZKwLg== X-Received: by 2002:a05:6a00:2283:b0:49f:dea0:b9ba with SMTP id f3-20020a056a00228300b0049fdea0b9bamr15379492pfe.56.1637244403560; Thu, 18 Nov 2021 06:06:43 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:06:43 -0800 (PST) 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, =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , Thomas Petazzoni , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-arm-kernel@lists.infradead.org (moderated list:PCI DRIVER FOR AARDVARK (Marvell Armada 3700)) Subject: [PATCH v4 11/25] PCI: aardvark: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:21 +0530 Message-Id: <335014f2b44cdf24ed1e37cb7c88f6c5de896cc2.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Reviewed-by: Pali Rohár Signed-off-by: Naveen Naidu --- drivers/pci/controller/pci-aardvark.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index c5300d49807a..1de41d2c9b44 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1026,10 +1026,8 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, u32 reg; int ret; - if (!advk_pcie_valid_device(pcie, bus, devfn)) { - *val = 0xffffffff; + if (!advk_pcie_valid_device(pcie, bus, devfn)) return PCIBIOS_DEVICE_NOT_FOUND; - } if (pci_is_root_bus(bus)) return pci_bridge_emul_conf_read(&pcie->bridge, where, From patchwork Thu Nov 18 14:03:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627111 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 28595C433EF for ; Thu, 18 Nov 2021 14:07:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FE7360EFD for ; Thu, 18 Nov 2021 14:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbhKROKn (ORCPT ); Thu, 18 Nov 2021 09:10:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232460AbhKROKm (ORCPT ); Thu, 18 Nov 2021 09:10:42 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E371C061570; Thu, 18 Nov 2021 06:07:42 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id gb13-20020a17090b060d00b001a674e2c4a8so5792817pjb.4; Thu, 18 Nov 2021 06:07:42 -0800 (PST) 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=j6PFmrQZfsZKbN43caoyPHUp+nOh1/rI/bPUZ2uC0hc=; b=BvRkTG9QWh/nDql0vdChRnHccpwZ0VM4CIM6EBHq/1BgkYqp8nyvYg5knfbTMtAm9S ONlfHuNPSw+chm+zhOREpoCqOzSkBHPKq75nMzMfYfiZlXJxO1UzO+C4gtA3QmzLKDht 5Bh9Bb28TGsINdTlHnoi5ncLJOJaSg/5E0PcUP9CNVvwPbL1vmYQSvju02y+it/aKDyo bHC7GrlUfpx1NQeiTbAYZCf2+wSQkkFEQBQnTN0Oj1LnMZ4GV0qjtQiwT0flkCu+B/VH bQ/E1ZigUq2WIZaIk1/PHMG9CyxkEykKLu6Udtb8QqjOAh1HqyDy+b9+qLN6PKFCLy2B JMig== 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=j6PFmrQZfsZKbN43caoyPHUp+nOh1/rI/bPUZ2uC0hc=; b=7vZzS6Ej42orbFfZrrFKLd3ifYQsJ3HHzakG4x17HHQ7bhVyGk4k4MrNsJdbpTxri2 Yimtn2Xc9NWHraGlYmJHf4KXbt+DAATfACUzxGn/aBAnvvaF9YsVoyZTVrTGrJ7W9D89 9+9IngD4LskIfRNRzbvbnwlmMS0yAfIy1oO9fCDryMKDeEW5yeH5w0aMzRBbBbfOPdWJ iRfEwrfD2hjpXbE8LcV965FeT1zYYp8nFlKGdHFMVjKdNUXR5TQYA7LVckH2WLU7CsND bT8cYGqhi/v6MCKR6MxqMEk6+L9ByZdWRG+cwyX4KNqlCbb8Xa6u+D57p3fDMnm9NG4v 40GA== X-Gm-Message-State: AOAM533xUDHaRTM4o79zkTLEkMw6+4rhmCmJqRHxdv9WOfqSJZgdVz7F aCzBmgcIClFkZC+j6KdoiS0= X-Google-Smtp-Source: ABdhPJyvJjeiaFKSgytjId5brKyWz+xbwXrqFdhy7A6dGUOrftB/u/RY89uvHrTE/ZR0106/YqLWVA== X-Received: by 2002:a17:90b:3b81:: with SMTP id pc1mr10785668pjb.67.1637244462074; Thu, 18 Nov 2021 06:07:42 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:07:41 -0800 (PST) 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, Thomas Petazzoni , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 12/25] PCI: mvebu: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:22 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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-mvebu.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index ed13e81cd691..70a96af8cd2f 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -653,20 +653,16 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, int ret; port = mvebu_pcie_find_port(pcie, bus, devfn); - if (!port) { - *val = 0xffffffff; + if (!port) return PCIBIOS_DEVICE_NOT_FOUND; - } /* Access the emulated PCI-to-PCI bridge */ if (bus->number == 0) return pci_bridge_emul_conf_read(&port->bridge, where, size, val); - if (!mvebu_pcie_link_up(port)) { - *val = 0xffffffff; + if (!mvebu_pcie_link_up(port)) return PCIBIOS_DEVICE_NOT_FOUND; - } /* Access the real PCIe interface */ ret = mvebu_pcie_hw_rd_conf(port, bus, devfn, From patchwork Thu Nov 18 14:03:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627113 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 47CA1C433EF for ; Thu, 18 Nov 2021 14:07:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28E7861B29 for ; Thu, 18 Nov 2021 14:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232478AbhKROKu (ORCPT ); Thu, 18 Nov 2021 09:10:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232487AbhKROKs (ORCPT ); Thu, 18 Nov 2021 09:10:48 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D814C061766; Thu, 18 Nov 2021 06:07:48 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id x5so6175320pfr.0; Thu, 18 Nov 2021 06:07:48 -0800 (PST) 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=oxis35XdZSIgJr6mklaAXMEQHUEVDMfz+GZuoz2m4I8=; b=CfdlCofkOkudUS2qd1NsvEsYuT7jk4wE1tunfAm4T9FgxQkNInv2u6Ao0B3dgzI+cp MBMg06DQ2ISnqX1E8DL4tFvodGh3V26fGl4gI90ndgXwt0ILK6dyREzbrk/ntTcRfLsO NQ1vJyHsPH6wdr2gr2WuWe0A4rPL7km89KeGF+8FimeuZLbRPpfQcn4+a9QU41Rmj/A4 xlqTGNv7PzYykiz1mzFRyJ9jBQm55fQwg/ZITxxqAhJ7/PoZSHQlVA8GGeCaejFzyMGZ zraEelTYLMHHqHjeKMhYs8nVXwQaV4/5e09WsMghtAsMGemsv/R/ne8JoFLJB4WZCfrz lx/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=oxis35XdZSIgJr6mklaAXMEQHUEVDMfz+GZuoz2m4I8=; b=xPF9xSy4udoyyvo38hGOn7wNTBgm/A1K1IkknocjJ8E9/euK6HQXWFEK1w1sNlHT4U UkPthpEjsOyeJt1jYUgcyCJUAWfkumsRrtGXATNEUufZX7KhV5sMPUx/MuePIyQ2FmvF 6SxD47D+0U2/watpqtUnhnlcbetyh4gef7DggpPjjMgAGwXXLLZn0GtWsLP1uryKunm3 ye+WmuaD3KBS9XdCWfDVq5IIZVZi6XhILvDgNJ0P0uqR6QiEkmbpMKEZ8ngu4zzH1KEl iGwHvRJriZpYHpon/agINfSeKf0SdmotgGCoWoNlH5VvAHnhvn+YSujFvkzZGyM0mFA0 V9ZA== X-Gm-Message-State: AOAM530etGU0dBA3mAVYHWPAeLJc5DRV96jQbw8AKcY7cCwiU8ai4kIQ vg8VYT/xgQCEjNx28XI5l1qiVLxGRdRE9uiV X-Google-Smtp-Source: ABdhPJyKNAsM7vj4XKSIROaJKxPYIQuQZ53f9v5gQ+OOMhKVWBQJbsKOev6gGAPfsMdgsSBm2WrYFw== X-Received: by 2002:a05:6a00:248b:b0:49f:9d7f:84e2 with SMTP id c11-20020a056a00248b00b0049f9d7f84e2mr56766723pfv.40.1637244467554; Thu, 18 Nov 2021 06:07:47 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:07:47 -0800 (PST) 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, Joyce Ooi , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Subject: [PATCH v4 13/25] PCI: altera: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:23 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/pcie-altera.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c index 2513e9363236..a6bdf9aff833 100644 --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -510,10 +510,8 @@ static int altera_pcie_cfg_read(struct pci_bus *bus, unsigned int devfn, if (altera_pcie_hide_rc_bar(bus, devfn, where)) return PCIBIOS_BAD_REGISTER_NUMBER; - if (!altera_pcie_valid_device(pcie, bus, PCI_SLOT(devfn))) { - *value = 0xffffffff; + if (!altera_pcie_valid_device(pcie, bus, PCI_SLOT(devfn))) return PCIBIOS_DEVICE_NOT_FOUND; - } return _altera_pcie_cfg_read(pcie, bus->number, devfn, where, size, value); From patchwork Thu Nov 18 14:03:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627115 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 E4A4BC433F5 for ; Thu, 18 Nov 2021 14:07:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8B2B61107 for ; Thu, 18 Nov 2021 14:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232487AbhKROKz (ORCPT ); Thu, 18 Nov 2021 09:10:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbhKROKy (ORCPT ); Thu, 18 Nov 2021 09:10:54 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89E93C061570; Thu, 18 Nov 2021 06:07:54 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id x5so6175666pfr.0; Thu, 18 Nov 2021 06:07:54 -0800 (PST) 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=MC+uMtAqzrUGxiPuMGV2uquDaVscrAuApobHOB73Khc=; b=iujRsX4QPoiun7MHP0bUBZW28PjBf6o6gfGjY/YCm/Lpia8P/wzPGdCWhiyGfZG09g Gjrmitr/DvKW1Se/u30W1xBctEtQ460BlEKz4w4a4RRLsG/Z9uYu8quQ3S8YNaXabwUL c0ODX2zYAPzZEc+6s3kYCQfPner0LQoYLnPLwcCCQxCnx5DSiPpfmdj91JA28o2Bh+zR Xxth8mCjdAdYY8DkskQ2AL8PFVJqPwsIgFNlvyqn9V5Q7seZuDDq1aaOMfpUVkRLcLVb p2wov/u8f1vPaBr2+y9SQZFEwiXZ5iREzuqbl0+ygDk3ftzRQ2vbE6NVCZ+zPwJOU+sx PG0A== 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=MC+uMtAqzrUGxiPuMGV2uquDaVscrAuApobHOB73Khc=; b=4AmvMsilUFcc9yAL0G1NHGdVHQX1A7b376rkqlxdCW3fwAule/EkVKnarNDNZD3Xu5 tw4mRzYvBHUKfiaiNzF2p9tjsSBevq4V9FOCFvpE8yPhMviUvEw/XB+Bx0Y2Q//kGoW1 8ALbAfFz87Bs6bf3PDZC12jP2z1a/mU+45oXSzBuw7p8hzzJ/z/QfOtEsh9tEo9sUmxY fDxW/SoMlmOoBAtuNDyFG4cBYMHi0bdrWWV8DNjOKn9aj8S/AYNF7V3bHUWrNY9O8xpA SlNGlem4d4+n1R9jhu92AB0e+ejDvdcmFwdNBWzPIVsEPLlvFcnDoXGZsze7PimU23gG 1R/w== X-Gm-Message-State: AOAM530nda8+C5DufGi/C/JmEO2M1TdPnqCfjpgdGjG/TehvRG0JrR3x G0qPPrz7epsTWAQALOGPXJw= X-Google-Smtp-Source: ABdhPJyuYGF3D5BwP9dBQadEZLcKBgGb+caRhXPH1nLvYia+cdRfnIzBQGuarTkOzB+UKMsDzzIvlg== X-Received: by 2002:a63:725e:: with SMTP id c30mr11339989pgn.240.1637244474011; Thu, 18 Nov 2021 06:07:54 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:07:53 -0800 (PST) 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, Geert Uytterhoeven , Marek Vasut , Yoshihiro Shimoda , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-renesas-soc@vger.kernel.org (open list:PCI DRIVER FOR RENESAS R-CAR) Subject: [PATCH v4 14/25] PCI: rcar: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:24 +0530 Message-Id: <83540eb3ae76a0d28bbe03d69d685a6d549b456b.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Reviewed-by: Geert Uytterhoeven Signed-off-by: Naveen Naidu --- drivers/pci/controller/pcie-rcar-host.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c index e12c2d8be05a..6bd5619fbbf4 100644 --- a/drivers/pci/controller/pcie-rcar-host.c +++ b/drivers/pci/controller/pcie-rcar-host.c @@ -159,10 +159,8 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_READ, bus, devfn, where, val); - if (ret != PCIBIOS_SUCCESSFUL) { - *val = 0xffffffff; + if (ret != PCIBIOS_SUCCESSFUL) return ret; - } if (size == 1) *val = (*val >> (BITS_PER_BYTE * (where & 3))) & 0xff; From patchwork Thu Nov 18 14:03:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627117 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 305C3C433F5 for ; Thu, 18 Nov 2021 14:08:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 112D460EFD for ; Thu, 18 Nov 2021 14:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232539AbhKROLN (ORCPT ); Thu, 18 Nov 2021 09:11:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232538AbhKROLN (ORCPT ); Thu, 18 Nov 2021 09:11:13 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F4DDC061570; Thu, 18 Nov 2021 06:08:13 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id x131so6105167pfc.12; Thu, 18 Nov 2021 06:08:13 -0800 (PST) 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=g4G4Yffk64HxtbjZzw9/E8PSnsLTvUujtQvSwE3J4gU=; b=FEbJrXxCeKEEGR3YZzQOCO7CCSBIhw9NTelVNkIxCZruozHn8xhBs2z7SKtVg3Y7mb Spm+q3WhNteQeCkW5pRlBczWhIVXYdP5caVWHfusUnz+MFU142BG/j/2/ZuZy+4ddBav YTe7rJsZ3tvLaL8BMpNjkewMFAYPWnLS8iYtZ9oWwSjUtrH3/r1aacSIWAJNgCgv2Rbx 9JjrlPIcL64R5NbYNUUSJy7V8FwH1P6BD8BvQ7gbdYKGISMWkSGLaV1qc5T70ka6GpX0 HiymHCl5lSCgQHx8uSdIFmYjYITQV5yefpf3EZUJSFtCTZbG2Ychrh85/HhM6Dr5hIOM 3fHw== 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=g4G4Yffk64HxtbjZzw9/E8PSnsLTvUujtQvSwE3J4gU=; b=hZ3LfeRaKsw1Jlcgs2T77/FwVe8rbzxAyDL0uAQheJdAI5DDi7JWzXIfxZqTMVOU4P /k9lGkIfZstceS7gshc5XfpXtlKNutKtFcJPqLCHqvOeMLYguTGrJqYN5atUR04ZhoPK +xfZb3mP0UR5pQrEb7OheKlkzC+DQerbPYEyAoyKsqB7xBm2gVFu3Xzi1NK8Q9tX8+pq oW2/6UrlwDJcfeE8eUDTeazPCneb4wQKjR4DbVkIMa4jyXue2CHJtU5RADzxuWMmH9QY gdZGOEyjjMbgXh+3gKH/GztqunOHyElr7hTJSGRrpx57RWjvDmyXw49zj5Oq4RLzstjz ODEQ== X-Gm-Message-State: AOAM532kRf/ng/AGTqvj1pjwxAk94qY0bu8Omld1FXMdo0/AjfHO5erW sfgPW93aeHAbfc+isbaZXD0= X-Google-Smtp-Source: ABdhPJx6ZoumMEGNj/EK6eVg69IbF74XwG8Czzauu8jXNtFO2IC2J8wksDYPCGoh99ek/ZBkGjo1RA== X-Received: by 2002:a63:7d01:: with SMTP id y1mr11448956pgc.343.1637244492845; Thu, 18 Nov 2021 06:08:12 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:08:12 -0800 (PST) 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, Shawn Lin , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Heiko Stuebner , linux-rockchip@lists.infradead.org (open list:PCIE DRIVER FOR ROCKCHIP), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support) Subject: [PATCH v4 15/25] PCI: rockchip: Remove redundant error fabrication when device read fails Date: Thu, 18 Nov 2021 19:33:25 +0530 Message-Id: <50f9a6fa16521a86cb24d2f27c1f66eb3568cb9a.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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/pcie-rockchip-host.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index c52316d0bfd2..45a28880f322 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -221,10 +221,8 @@ static int rockchip_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, { struct rockchip_pcie *rockchip = bus->sysdata; - if (!rockchip_pcie_valid_device(rockchip, bus, PCI_SLOT(devfn))) { - *val = 0xffffffff; + if (!rockchip_pcie_valid_device(rockchip, bus, PCI_SLOT(devfn))) return PCIBIOS_DEVICE_NOT_FOUND; - } if (pci_is_root_bus(bus)) return rockchip_pcie_rd_own_conf(rockchip, where, size, val); From patchwork Thu Nov 18 14:03:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627119 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 A7786C433F5 for ; Thu, 18 Nov 2021 14:08:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95FC361AE2 for ; Thu, 18 Nov 2021 14:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232537AbhKROLS (ORCPT ); Thu, 18 Nov 2021 09:11:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232544AbhKROLR (ORCPT ); Thu, 18 Nov 2021 09:11:17 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8702C061570; Thu, 18 Nov 2021 06:08:17 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id gx15-20020a17090b124f00b001a695f3734aso5853149pjb.0; Thu, 18 Nov 2021 06:08:17 -0800 (PST) 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=lqepzKgKYKi0P/3AF7cx3PfHQnBbwZONrKqYokz0hlw=; b=UVcUH05cevJt7DhkBXedOq96PKvg/OMKRZzlqYVaDh2NHhIU4skU5s/MLYh9LrYbUg anK7NJo5BlOG0CJAhhYuQo6HgFLcIKSqDo/Fo3apB0yQBc8QxHwsoLQ4mEKsmdPqk03j EGHwZetKrtO75nyrF4BT0EAvLDvrUMCpnlt5jf7qboZzlFsWIyGaausOAETQfrytNCXn fDQPHFM+oR8nMT8xe2NeSdPA/qwP6xqyfzy6ZWXOzU47M5qkEPlgs6s/4qf7ENEua6Gx OnMqNuiTqkqZ72PyOPEx68/xxDW021+iDLsJA4l1j5EHAM+16WydrjdTGunvZzNtCob8 1lsQ== 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=lqepzKgKYKi0P/3AF7cx3PfHQnBbwZONrKqYokz0hlw=; b=3zaSejH4iepYoZWTpO6nMADPJHuCol8KfrfEjHQLUX97DNZM8mIjzv0i2YX6gQHCP6 VrzIvnkfEiaP14KMFysls/nl0ndC976awInzUS1npgjCKF9rEkFxWGgi2RFeF63fk7M1 tJ6ONcDeTNee05XfKyJnKGQbCb7C9jQYbWjyOOXYoDCyVASKM1ZAKZtyL25sqa8aO4kG Kl4TIE14rx+nxYB380rVJ0uw30nBU0Gt/LfCjINoeAhXNscCNWu/ff0Goz8x/Xwie4SK uyaaE0HNQcPl/TIAA5DJyICQ0MsMEc8+QOAlxdxGvuW0GY5LkC5F1BX82yQhd1jTZaCq EHxw== X-Gm-Message-State: AOAM533cTqfhAt55fYDswo6vpuwDriiVQuukM0xBhE9yM/Jss2vvhoTz MVQ4DEyXJTWLzYVMqBHWHS8= X-Google-Smtp-Source: ABdhPJz++pJuPHrS+vU1AfDbegw9RqV6bph8Lx+Xo2st+ejZBGqczMctqLtmJraUUKXa9EOgtQVJVQ== X-Received: by 2002:a17:902:dacb:b0:141:e931:3b49 with SMTP id q11-20020a170902dacb00b00141e9313b49mr66184334plx.45.1637244497153; Thu, 18 Nov 2021 06:08:17 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:08:16 -0800 (PST) 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 Subject: [PATCH v4 16/25] PCI/ERR: Use PCI_POSSIBLE_ERROR() to check read from hardware Date: Thu, 18 Nov 2021 19:33:26 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Use PCI_POSSIBLE_ERROR() to check the response we get when we read data from hardware. This unifies PCI error response checking and make error checks consistent and easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/pci.c | 10 +++++----- drivers/pci/probe.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 3d2fb394986a..bc82699ed105 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1115,7 +1115,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) return -EIO; pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); - if (pmcsr == (u16) ~0) { + if (PCI_POSSIBLE_ERROR(pmcsr)) { pci_err(dev, "can't change power state from %s to %s (config space inaccessible)\n", pci_power_name(dev->current_state), pci_power_name(state)); @@ -1271,16 +1271,16 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) * After reset, the device should not silently discard config * requests, but it may still indicate that it needs more time by * responding to them with CRS completions. The Root Port will - * generally synthesize ~0 data to complete the read (except when - * CRS SV is enabled and the read was for the Vendor ID; in that - * case it synthesizes 0x0001 data). + * generally synthesize ~0 (PCI_ERROR_RESPONSE) data to complete + * the read (except when CRS SV is enabled and the read was for the + * Vendor ID; in that case it synthesizes 0x0001 data). * * Wait for the device to return a non-CRS completion. Read the * Command register instead of Vendor ID so we don't have to * contend with the CRS SV value. */ pci_read_config_dword(dev, PCI_COMMAND, &id); - while (id == ~0) { + while (PCI_POSSIBLE_ERROR(id)) { if (delay > timeout) { pci_warn(dev, "not ready %dms after %s; giving up\n", delay - 1, reset_type); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 087d3658f75c..c48fe1ab1961 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -206,14 +206,14 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, * memory BAR or a ROM, bit 0 must be clear; if it's an io BAR, bit * 1 must be clear. */ - if (sz == 0xffffffff) + if (PCI_POSSIBLE_ERROR(sz)) sz = 0; /* * I don't know how l can have all bits set. Copied from old code. * Maybe it fixes a bug on some ancient platform. */ - if (l == 0xffffffff) + if (PCI_POSSIBLE_ERROR(l)) l = 0; if (type == pci_bar_unknown) { @@ -1683,7 +1683,7 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev) if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL) return PCI_CFG_SPACE_SIZE; - if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev)) + if (PCI_POSSIBLE_ERROR(status) || pci_ext_cfg_is_aliased(dev)) return PCI_CFG_SPACE_SIZE; return PCI_CFG_SPACE_EXP_SIZE; @@ -2371,8 +2371,8 @@ bool pci_bus_generic_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) return false; - /* Some broken boards return 0 or ~0 if a slot is empty: */ - if (*l == 0xffffffff || *l == 0x00000000 || + /* Some broken boards return 0 or ~0 (PCI_ERROR_RESPONSE) if a slot is empty: */ + if (PCI_POSSIBLE_ERROR(*l) || *l == 0x00000000 || *l == 0x0000ffff || *l == 0xffff0000) return false; From patchwork Thu Nov 18 14:03:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627131 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 260E4C433F5 for ; Thu, 18 Nov 2021 14:08:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DC6F610CA for ; Thu, 18 Nov 2021 14:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232590AbhKROL5 (ORCPT ); Thu, 18 Nov 2021 09:11:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbhKROL4 (ORCPT ); Thu, 18 Nov 2021 09:11:56 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD6BC061764; Thu, 18 Nov 2021 06:08:56 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id y8so5353891plg.1; Thu, 18 Nov 2021 06:08:56 -0800 (PST) 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=0wzxd9WltV+kgpmgehfeEa35+HeAAqxQYv7He1qYUFw=; b=Vtge5Jzv3Q+gqha8QfyzXjXdN7qKuArxFBnAJRdzO9mfBwXwoVtuG/ZQD13QTse5J/ rYOYd4DUndtFj+rDNHyjsYdJ4K9M1RKx6MSMRqYAugJWJki8o9nZPQre09so5YQ+9Xuu 9hyBBZlXB2etwNVlsHZoZ7K4HmlF2rA8n8wLTr1g6fqkzttPV2rPt+X5+o6aDktNKwdJ 5c7AfRmuou01iz6q5uNdTgefcCQLkmPzuGDY56Naz2Y09FOwg6L4S9DF6w0WQe5Xn3Km PkU4wKjMbkmca2bn8N2NvQ7yNgKFm8TwOUPpB7co65xNXsk4EmPSW1ANfCfFCLisX6vI TQJw== 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=0wzxd9WltV+kgpmgehfeEa35+HeAAqxQYv7He1qYUFw=; b=m3HsmsEE5SeDsbfFEU41X8dZA0cPtphcUHRL9tUXD9poAwwTVV4IbADhZ4sAWaEd5z wjzEVQJCdphDjT6dkqAVpMqtNkJ36whp0qTQ3rPypDlird2JTR+6MAV/rrzwBOTvvuT8 0Hc736rlj/rbFgiDXUJMawqhjvXT7MxDk8V2zT92sO7HDrA4cXIpED4AAzn/u8Wkgs8S CjXF6S3vqWXKfw/lGhxcYKCOrG5i6kHFv9apbq40fTaRul+MJf4eKiAaL+PP4c7J/3OP 8GSBd2+/2TItd6HK5E4AUr0D/xbNyEeH8Glog2I/O3MK3OdUj5ZETbUIvwllASr6Jo+q g+qA== X-Gm-Message-State: AOAM530vSj8Y1EH/1Qt9zgIAJl0p8islTvbPCTx4LuN2hJAzJt67PUaI XP7KOvwyceJyLGz+xkR4wqM= X-Google-Smtp-Source: ABdhPJxf4xirjTfa6NfIeW2moya1k5DpgGZPxhSfUAKHoEymIOn99zlGld0PMa8NpD4v08nzP0clfg== X-Received: by 2002:a17:90a:5d8e:: with SMTP id t14mr10603930pji.95.1637244535782; Thu, 18 Nov 2021 06:08:55 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:08:55 -0800 (PST) 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, Jonathan Derrick , Nirmal Patel , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Subject: [PATCH v4 17/25] PCI: vmd: Use PCI_POSSIBLE_ERROR() to check read from hardware Date: Thu, 18 Nov 2021 19:33:27 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Use PCI_POSSIBLE_ERROR() to check the response we get when we read data from hardware. This helps unify PCI error response checking and make error checks consistent and easier to find. Reviewed-by: Jonathan Derrick Signed-off-by: Naveen Naidu --- drivers/pci/controller/vmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index a45e8e59d3d4..515d05605204 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -541,7 +541,7 @@ static int vmd_get_phys_offsets(struct vmd_dev *vmd, bool native_hint, int ret; ret = pci_read_config_dword(dev, PCI_REG_VMLOCK, &vmlock); - if (ret || vmlock == ~0) + if (ret || PCI_POSSIBLE_ERROR(vmlock)) return -ENODEV; if (MB2_SHADOW_EN(vmlock)) { From patchwork Thu Nov 18 14:03:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627133 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 9CC68C433EF for ; Thu, 18 Nov 2021 14:09:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FCD460EE4 for ; Thu, 18 Nov 2021 14:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232597AbhKROME (ORCPT ); Thu, 18 Nov 2021 09:12:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232619AbhKROMD (ORCPT ); Thu, 18 Nov 2021 09:12:03 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4006BC061570; Thu, 18 Nov 2021 06:09:03 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id m14so6115797pfc.9; Thu, 18 Nov 2021 06:09:03 -0800 (PST) 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=Vbg/UnTog8RoKm/UkVGv08OHT0zawheRaXb/CoLLpao=; b=kpkiTq1voUXK2udIAm7nn8bKXcX8D9jsQpymoepWezzkgBKh4dCfxwmufnVK1hUXWD lMfY3DghFpDBEA3VHmQu+8e82/61zvDIZ/1sfhL7kpf8EG7uvn8bNc7j0jcviv6ISogU SOfEHOdIzgoJDzZArwAh7xtnctsnbOJ8B+GsNFOTYFhFbusdHxOcIPeJVScl4m9IzzyV Z+N3mBQdIKWG9GbQUa2OoW1RcuxHpf6o9R2YB6GCh+woBV0hktLQhO8TOo6nxngSaXhB byXxJsuqs5p8LC0gsKpgGMpUFM0tld81Jf/zbpl0IZZSa0dELmLnOgCUOgvGKU0powac 0JlQ== 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=Vbg/UnTog8RoKm/UkVGv08OHT0zawheRaXb/CoLLpao=; b=w5PnFd0Bqcqprz7s9ohgOV0vHBFu3i2A4kZoOLABY1IPg8po/OtYk8mgG89laEK9Oi sPPMuuTqh0YxqBDvalLrm4HMlb/thi68Pyqo5kD/F+Zvym3LPf0gKhwIrFlMVLDNSuBu VCMHnOK7/7G7Gw62yM41qQCWKCayTHWQYDtwSoxU9ao9di8pkIC6nEWnbJ+UN0M9PAds Kw6dYOaaIRPQW7l0iouzw2aIhgwmS76elKBK0pZ9wB0vsknbCAF0jfPOgQnmhepJGX9w e6WV71wMZPGYRBiW5q2cVkcQIYiHrhW27AqrHPc+SmnFATkDVtNX40h1Xc17iQlDYSID 2Prg== X-Gm-Message-State: AOAM530l64tWEvrasWOmmsIdeIaLOmhUVQBIJsH/cVUWnyoxa05U+UrM mt0D1bebVpSdaJ1/ZNgxnAc= X-Google-Smtp-Source: ABdhPJwmm78uc+5YsW3BcjjnnfSmqDBvQIgonYyGNaRf+SElCcvORFbsZG99JbsJxmiT3Pf3TOKpmA== X-Received: by 2002:a05:6a00:1ac9:b0:49f:b38d:fe7 with SMTP id f9-20020a056a001ac900b0049fb38d0fe7mr56900554pfv.63.1637244542719; Thu, 18 Nov 2021 06:09:02 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:02 -0800 (PST) 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, Lukas Wunner , Kuppuswamy Sathyanarayanan , Amey Narkhede Subject: [PATCH v4 18/25] PCI: pciehp: Use PCI_POSSIBLE_ERROR() to check read from hardware Date: Thu, 18 Nov 2021 19:33:28 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Use PCI_POSSIBLE_ERROR() to check the response we get when we read data from hardware. This helps unify PCI error response checking and make error checks consistent and easier to find. Compile tested only. Acked-by: Lukas Wunner Signed-off-by: Naveen Naidu --- drivers/pci/hotplug/pciehp_hpc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 83a0fa119cae..e94914e50fca 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -89,7 +89,7 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout) do { pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); - if (slot_status == (u16) ~0) { + if (PCI_POSSIBLE_ERROR(slot_status)) { ctrl_info(ctrl, "%s: no response from device\n", __func__); return 0; @@ -165,7 +165,7 @@ static void pcie_do_write_cmd(struct controller *ctrl, u16 cmd, pcie_wait_cmd(ctrl); pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl); - if (slot_ctrl == (u16) ~0) { + if (PCI_POSSIBLE_ERROR(slot_ctrl)) { ctrl_info(ctrl, "%s: no response from device\n", __func__); goto out; } @@ -236,7 +236,7 @@ int pciehp_check_link_active(struct controller *ctrl) int ret; ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); - if (ret == PCIBIOS_DEVICE_NOT_FOUND || lnk_status == (u16)~0) + if (ret == PCIBIOS_DEVICE_NOT_FOUND || PCI_POSSIBLE_ERROR(lnk_status)) return -ENODEV; ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); @@ -443,7 +443,7 @@ int pciehp_card_present(struct controller *ctrl) int ret; ret = pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); - if (ret == PCIBIOS_DEVICE_NOT_FOUND || slot_status == (u16)~0) + if (ret == PCIBIOS_DEVICE_NOT_FOUND || PCI_POSSIBLE_ERROR(slot_status)) return -ENODEV; return !!(slot_status & PCI_EXP_SLTSTA_PDS); @@ -621,7 +621,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) read_status: pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &status); - if (status == (u16) ~0) { + if (PCI_POSSIBLE_ERROR(status)) { ctrl_info(ctrl, "%s: no response from device\n", __func__); if (parent) pm_runtime_put(parent); From patchwork Thu Nov 18 14:03:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627135 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 1A98EC433F5 for ; Thu, 18 Nov 2021 14:09:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F289760EE4 for ; Thu, 18 Nov 2021 14:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232657AbhKROMK (ORCPT ); Thu, 18 Nov 2021 09:12:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232634AbhKROMJ (ORCPT ); Thu, 18 Nov 2021 09:12:09 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 883ADC061570; Thu, 18 Nov 2021 06:09:09 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id m14so6116125pfc.9; Thu, 18 Nov 2021 06:09:09 -0800 (PST) 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=gBBH/Q+4DT6MMFzudxxMo6qTH2zDvIqJYCuHRS/x8Gs=; b=h4pBbCLrdpXpef+w/kUpZbJP1X3ldT63Q8bGt/bh2RhSlt94aUaf0PVnzja8+EzyiX 5iYMNQKu/SyG4Nub6ksbx6VzPbGJRE/BZuFwnSSp+NgUjuqj2NhPYTKPM4zl6GDf1tKk eK61KC8EUBYRAicc/ZNdM+7b7GmVwetmqBzyBFB975MngUwTm9aw4E2AL054rU9cFaPo j+lKkLALHvmJGsPT61Y0tz5nJQZn9IMSHtNRdhRP9Yeb4mcwTwBjq2MzY9LTbmoj3JWS x19JINYr4ISze+T9+hz9gOPl/KfmZVS+6YlJCCcOTFIQsQZYOt6jbkfEFPctsM8nThJQ wFjQ== 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=gBBH/Q+4DT6MMFzudxxMo6qTH2zDvIqJYCuHRS/x8Gs=; b=vckFNNi+hvDSmrTjVSzQOb8A9eay/0pWWnkRCMh/Zgd2gajakMSygP6HT9oQsgmjew F9qMwqrPdq4C1peWKL7QkDLjugEnHUvOKBO0VN90cvzCtAFQWJKCoiTUcJkuHRIyuy8K QmTie9M4/k6cgOTDvy/4aOo54VH5f7rqPvSIxC3GmAgxtjDilpcAm7OPyuJUK2YyVis3 29BzCF5peJx8ziba4rsJztQcEUcCn85H21ftw1ezQRx2ME32jR14E5CPa8Q04wgLQiBc KUJEm9JJCYXU+F+Pj+9a9eBCF/0WHXuKGiGTigWd1UnIlqUWsPXaRSSiygCpF9JIaF3F EnYg== X-Gm-Message-State: AOAM532upNzzD7W6kXTeH7cVryloHhpFX51Qy/9V8PxnlTso8/WcBnR7 gQV2k9Ioi7MQzz2GyMBrz7w= X-Google-Smtp-Source: ABdhPJx6pongqUzF2GCWPf3PPjoh1vz7OEj8FQ/voPke/8ceAr1mP50zFni4Hu2G4gWzSziUIk45mQ== X-Received: by 2002:a63:ff23:: with SMTP id k35mr11505864pgi.28.1637244548964; Thu, 18 Nov 2021 06:09:08 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:08 -0800 (PST) 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, Russell Currey , "Oliver O'Halloran" , linuxppc-dev@lists.ozlabs.org (open list:PCI ENHANCED ERROR HANDLING (EEH) FOR POWERPC) Subject: [PATCH v4 19/25] PCI/DPC: Use PCI_POSSIBLE_ERROR() to check read from hardware Date: Thu, 18 Nov 2021 19:33:29 +0530 Message-Id: <9b0632f1f183432149f495cf12bdd5a72cc597a4.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Use PCI_POSSIBLE_ERROR() to check the response we get when we read data from hardware. This helps unify PCI error response checking and make error checks consistent and easier to find. Compile tested only. Signed-off-by: Naveen Naidu --- drivers/pci/pcie/dpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index c556e7beafe3..3e9afee02e8d 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -79,7 +79,7 @@ static bool dpc_completed(struct pci_dev *pdev) u16 status; pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_STATUS, &status); - if ((status != 0xffff) && (status & PCI_EXP_DPC_STATUS_TRIGGER)) + if ((!PCI_POSSIBLE_ERROR(status)) && (status & PCI_EXP_DPC_STATUS_TRIGGER)) return false; if (test_bit(PCI_DPC_RECOVERING, &pdev->priv_flags)) @@ -312,7 +312,7 @@ static irqreturn_t dpc_irq(int irq, void *context) pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status); - if (!(status & PCI_EXP_DPC_STATUS_INTERRUPT) || status == (u16)(~0)) + if (!(status & PCI_EXP_DPC_STATUS_INTERRUPT) || PCI_POSSIBLE_ERROR(status)) return IRQ_NONE; pci_write_config_word(pdev, cap + PCI_EXP_DPC_STATUS, From patchwork Thu Nov 18 14:03:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627137 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 91A0CC433EF for ; Thu, 18 Nov 2021 14:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 790C061B5F for ; Thu, 18 Nov 2021 14:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232663AbhKROMQ (ORCPT ); Thu, 18 Nov 2021 09:12:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232673AbhKROMP (ORCPT ); Thu, 18 Nov 2021 09:12:15 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D949CC061764; Thu, 18 Nov 2021 06:09:15 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id gt5so5230971pjb.1; Thu, 18 Nov 2021 06:09:15 -0800 (PST) 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=QEAi0JFFmcVSfLYqvSz9Q36wWsFfdlN527IzY0Xl91w=; b=BNYCIDqXF+9y4b/vF54ZSXcAvHm4L/wOgKJ/UAkZhYW0nozO7Zv8Bks/tDz5yrZ4OD DnPhR2IdEnwjppvTVmQkRGPuCiIl0QVMJNewSDmcbRdga9pHVy8S13vilB1txU8u87tb H7SJ4o1SKk44fDZwqtM5tZc7vZlRH9O4XBhjatHklAJQffJRieEN7xrzQn+flJq9o6LI Himzw2igxlwHQSzjflP/bLgEKcJqNWOHrS2bDE4ZsUfmNPJi7RxiPm92CcH0S0Khe/Cv qZSmJMQdLKSW80RcvtU+J0e4r4E/76uplT2xL+3pucAxz50waGVHUBU9cnZyCl7pIhyM ibZA== 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=QEAi0JFFmcVSfLYqvSz9Q36wWsFfdlN527IzY0Xl91w=; b=u6AKamwP3PDPuLf61lj4oSCwMPWdpdT7Z/QogXQvnyyYUtRib5FyVzKrgKP+howcqd HsPoFlx5QWIq1EAYieMdKRGPHuX6qa3NtmZf86unW8IzI8Rt3nRGotoIJBUoyNpe1LWl qQpi0TFQQQoI5jM4m3wE7tsprGtsVZV+wfkZz3axCDR8fEDlDqtBYrX73QsBFh3Qlbqy JQmF90m78w6/wQaOhpRtuLZcoNXpW1qFONooA7spEHdOG1OB1sevXrOtUj53h886am6/ fyk284PuFrnkdzsG6++653Wp9eJXLVCD/jOZw93VITGqI3IgPRvnADhKYGhujUkWQXLp FFBQ== X-Gm-Message-State: AOAM5328Ang7mhU0unmwKtyIu5MoiZ0jh75Z8uhlienZoRJo5RvBNV9b 8H/vs6QLJhzq8bYGXU516Pk= X-Google-Smtp-Source: ABdhPJx0eGowQg8TSYbw2PJfbQZPFwpWcMyafhZX/7yhfmbbQRXIJXEOBIrKypVY6wqJ7VQxAwOcEw== X-Received: by 2002:a17:90b:4f44:: with SMTP id pj4mr11118669pjb.150.1637244555360; Thu, 18 Nov 2021 06:09:15 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:15 -0800 (PST) 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, Sean V Kelley , =?utf-8?q?Krzysztof_Wilczy=C5=84sk?= =?utf-8?q?i?= , Qiuxu Zhuo Subject: [PATCH v4 20/25] PCI/PME: Use PCI_POSSIBLE_ERROR() to check read from hardware Date: Thu, 18 Nov 2021 19:33:30 +0530 Message-Id: <679ce049bccf10df3ca9ef4918ee2c3235afdaea.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Use PCI_POSSIBLE_ERROR() to check the response we get when we read data from hardware. This helps unify PCI error response checking and make error checks consistent and easier to find. Compile tested only. Signed-off-by: Naveen Naidu --- drivers/pci/pcie/pme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 1d0dd77fed3a..ef8ce436ead9 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c @@ -224,7 +224,7 @@ static void pcie_pme_work_fn(struct work_struct *work) break; pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); - if (rtsta == (u32) ~0) + if (PCI_POSSIBLE_ERROR(rtsta)) break; if (rtsta & PCI_EXP_RTSTA_PME) { @@ -274,7 +274,7 @@ static irqreturn_t pcie_pme_irq(int irq, void *context) spin_lock_irqsave(&data->lock, flags); pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); - if (rtsta == (u32) ~0 || !(rtsta & PCI_EXP_RTSTA_PME)) { + if (PCI_POSSIBLE_ERROR(rtsta) || !(rtsta & PCI_EXP_RTSTA_PME)) { spin_unlock_irqrestore(&data->lock, flags); return IRQ_NONE; } From patchwork Thu Nov 18 14:03:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627139 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 19807C433F5 for ; Thu, 18 Nov 2021 14:09:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 044A461AFF for ; Thu, 18 Nov 2021 14:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232672AbhKROMW (ORCPT ); Thu, 18 Nov 2021 09:12:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232603AbhKROMV (ORCPT ); Thu, 18 Nov 2021 09:12:21 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3021C061570; Thu, 18 Nov 2021 06:09:21 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id x7so5265864pjn.0; Thu, 18 Nov 2021 06:09:21 -0800 (PST) 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=ByrJc6V6pFIbCg9CK06og+Vh8Z2tFbEYzVqTge5gTXU=; b=bw9D8T7VGU0U6t3XTDa+/29iZvtjMy3TORIZVvpr7GkFUUyqIWFmi9S6dH5g+nH1O2 F29jkDXF25KJ3pDd4LEbvXxmGowfCRJmCy7cUadRVXIl7YA+uih+GK1NfybSbnT1NPs4 ydPuWMolf3cAYXA1YGh29vxlbc/fPeeDQasBG5zKX615DEsIt1G8p1O5JkIqbjVeFm5S PXQR5SGfu8r3c3YjLjsQfc6uTHVh1M9veIyq+NxfhdVSx2cpciECR6F3lbASXAsrNdcv YHMPvGHzxWcMN/qmOeuehJtfUN7pli0CHdYuu4z3DswVzjLnnFQiEmfyiFF7OsjtBdny V72g== 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=ByrJc6V6pFIbCg9CK06og+Vh8Z2tFbEYzVqTge5gTXU=; b=M/1tX1rsLLnrGDXFhCwihIRQBAlZrKlfRb8b79j2tPcJWUuWA1Bkxm2Qfd8wKKa5z0 XdQDUt09p3wAWaOFLphTC68+zIiCz7QFd/1UboNg5LU1BtujOXqtfg8ahXRjILwk916d jMshA3a2bPZ93o7UPujML1druJImxgCoMPUfiPd/KDR0VXrrv4uHm5vflTGUKb5Rra/t dEvM/Eqq2grNWSkb//qMJ3OidMVxZWpDxLltIVAOkM/yA998k2cGSPQwF0Cd1ouwA36r IUF9FPY0QxpVr51t2WTPbVMunwbQHyiIeTbZxo2imXPSFmhIsBPw9ER0NI5gaq/lp93x VmEQ== X-Gm-Message-State: AOAM532lh+3rTd52iHLa2h5u3ISDYLc4hAoKhdGiINkOmfGSVGnX94x5 hfAQT7AuK5JOdLss3/bGj00= X-Google-Smtp-Source: ABdhPJyBMJ8Ar7910Sf+u3fPK0BtqoYWwruzkyCL7U13bQSD88A+4r71N/gTt/BQQpV04BYMPTvgKg== X-Received: by 2002:a17:902:a717:b0:142:76bc:da69 with SMTP id w23-20020a170902a71700b0014276bcda69mr67440911plq.12.1637244561252; Thu, 18 Nov 2021 06:09:21 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:20 -0800 (PST) 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, =?utf-8?q?Krzyszto?= =?utf-8?q?f_Wilczy=C5=84ski?= Subject: [PATCH v4 21/25] PCI: cpqphp: Use PCI_POSSIBLE_ERROR() to check read from hardware Date: Thu, 18 Nov 2021 19:33:31 +0530 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Use PCI_POSSIBLE_ERROR() to check the response we get when we read data from hardware. This helps unify PCI error response checking and make error checks consistent and easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/hotplug/cpqphp_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index ed7b58eb64d2..93fd2a621822 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c @@ -2273,7 +2273,7 @@ static u32 configure_new_device(struct controller *ctrl, struct pci_func *func while ((function < max_functions) && (!stop_it)) { pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID); - if (ID == 0xFFFFFFFF) { + if (PCI_POSSIBLE_ERROR(ID)) { function++; } else { /* Setup slot structure. */ @@ -2517,7 +2517,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func pci_bus_read_config_dword(pci_bus, PCI_DEVFN(device, 0), 0x00, &ID); pci_bus->number = func->bus; - if (ID != 0xFFFFFFFF) { /* device present */ + if (!PCI_POSSIBLE_ERROR(ID)) { /* device present */ /* Setup slot structure. */ new_slot = cpqhp_slot_create(hold_bus_node->base); From patchwork Thu Nov 18 14:03:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627141 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 52D2FC433F5 for ; Thu, 18 Nov 2021 14:09:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BDEE61107 for ; Thu, 18 Nov 2021 14:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232694AbhKROM2 (ORCPT ); Thu, 18 Nov 2021 09:12:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbhKROM1 (ORCPT ); Thu, 18 Nov 2021 09:12:27 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09DB8C061766; Thu, 18 Nov 2021 06:09:27 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id r132so5412093pgr.9; Thu, 18 Nov 2021 06:09:27 -0800 (PST) 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=tG2Z+jbkFRvw9IYmwc/ViuisLBeS5zDki/9SkrDHf8E=; b=ct9yZCQ5VcjePNT24JBl3ImNLFFun3txYvUKafBcydv3zyDa84ktDQQ2ia5k5KpeTh ZCiBhggoB3y63rJJWsK7gP5v3mWIppoyd5nlThMhVLLb5G1yepYQzzADNR1syEQmbRF1 aVQOrkLI6jAFp0gOkI7OSKbiETUZQKqjsa2zSV+rs1FZPT4NX/FRyP8l1/vFf5yQOlAs miQDTNz718Gy4ghr1f5tRjgNbOfzvbqPP8We2aXm8L9IEQ94OdoHFktgneA9JR4AjMNe j1oP9Oj7+1ZpkRLNqDviue/No0zniTPSayURrAOCqFlioIeUkbb6kw63FgODNF5u71w1 K1vw== 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=tG2Z+jbkFRvw9IYmwc/ViuisLBeS5zDki/9SkrDHf8E=; b=dd8s+z3hTLOVpyv2zs875d0pInsUg/kTZBryV+cV+VrbifjHLE6/8Fz/aknn8fbcDa 5pY/B0qGNhrADxNF2eZI/wXqX/cCEUBWDv5+H09UmRtz2RvP+kAF4OFAOpBLzj02PAxG oPHpf44oZrzHDA5/yJV+VokdGRh2Jl+HLhN6hA/RWEIDYFY8KpoD9vbKjqiuzc8Ship6 LS6u+P2R9pzVBgM5j+xx14iirrvFmZCbRq1rPDVr5aWhSHFYgeFlXggWQFzD7jmctsij nn7eVbSJtAiLYwnVohQGeXdKA9c9uEGmGoSMtCj9D0rRn2GvWpc/Vr+E87byI42Q918M NR/g== X-Gm-Message-State: AOAM533bS2UavA1lfrM/kFoguxPfwTPfEarJC700+FFkceYRV/yafMKY CDvBrlEAoX2zL1TlHm8yhPMslOy6z1v4QQ8x X-Google-Smtp-Source: ABdhPJw11oe0nh0XBOBBqnfa0shN0dahRuIrHjoMwAfFlkTwGFIRQ/teuzpWXSmFw87mZvdJ6FFqhw== X-Received: by 2002:a63:7d01:: with SMTP id y1mr11455196pgc.343.1637244566532; Thu, 18 Nov 2021 06:09:26 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:26 -0800 (PST) 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 Subject: [PATCH v4 22/25] PCI: Use PCI_ERROR_RESPONSE to specify hardware error Date: Thu, 18 Nov 2021 19:33:32 +0530 Message-Id: <866e2db544df45af70df7e64659bf02e03998ae3.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Include PCI_ERROR_RESPONSE along with 0xFFFF and 0xFFFFFFFF in the comment to specify a hardware error. This makes MMIO read errors easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/access.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index a92637627845..a07b76761d74 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -413,8 +413,8 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val) ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val); /* * Reset *val to 0 if pci_read_config_word() fails, it may - * have been written as 0xFFFF if hardware error happens - * during pci_read_config_word(). + * have been written as 0xFFFF (PCI_ERROR_RESPONSE) if hardware error + * happens during pci_read_config_word(). */ if (ret) *val = 0; @@ -448,8 +448,8 @@ int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val) ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val); /* * Reset *val to 0 if pci_read_config_dword() fails, it may - * have been written as 0xFFFFFFFF if hardware error happens - * during pci_read_config_dword(). + * have been written as 0xFFFFFFFF (PCI_ERROR_RESPONSE) if hardware + * error happens during pci_read_config_dword(). */ if (ret) *val = 0; From patchwork Thu Nov 18 14:03:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627143 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 7AEB9C433EF for ; Thu, 18 Nov 2021 14:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67DF961406 for ; Thu, 18 Nov 2021 14:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbhKROMl (ORCPT ); Thu, 18 Nov 2021 09:12:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232697AbhKROMk (ORCPT ); Thu, 18 Nov 2021 09:12:40 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E01BAC061570; Thu, 18 Nov 2021 06:09:40 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id v19so5335386plo.7; Thu, 18 Nov 2021 06:09:40 -0800 (PST) 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=rnLnMx9TiMvb2DdIMVT7WpH5F3wdHvIfMbTto6KwZSg=; b=ZlyJBwCs9fX3OI3DBnfqs1+YetJVATb6F0OrBd/S15BMkfSIVB/4Ev46eCRb8qAhFp LmSRZI/TQJhrxZ1gmjQjaxQpQbN+6izQvAxoAWq7Oq+7n3Rm6jz5+4m64bzC03P+7KmA wZRCUkmwTrDqmqw+AQW4/hBiAIUgNKJWk588rt95Xb1J1d/K7PqaFok+TMLfDHMiN5Zx R2hueyMZ8J4ycNg+p60PrfZcVPwI5vxvsYmwS9qyLcMrnZgJk6rqo/Z4Va0DLJ3s71Rb ol62Uoee1JVICrGAheOqOPnfTDWPjGrlTz/b4+rR0Yt435keV/RScmYW5oGVPZUCgKV+ lzUg== 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=rnLnMx9TiMvb2DdIMVT7WpH5F3wdHvIfMbTto6KwZSg=; b=GvJk8SCfloh34Z1UEeLSOLTj/UvbQt+DGVL2z48y3iV8Of4Aryn9LV3udzmV0xTQri Zw/cgA0szEl1zVbjWGcfDxxmFJTuLBigpAObTC0qwnOJ66TyXdRQSsuRwd1pMoVNR2xy +K/dvJb2KbIlur30BrZ6oZsWLSpyPCjYqP2u2SpJbBrSe3JC5T+TKXN6d4B1b6LAUYxn YtbmwjetbjYLSxrMF3I8lBgSVfBC1xAe52UzgslLIHkTmcZnEvr7Qdhxek5O2pFSYQaH 7HnMGnzzE0fblY2OfbFNWVCwFX5kTLR1DkzUdJWd6Ddf+995BIZz3wdp2ctsqTMRYY6/ P7HQ== X-Gm-Message-State: AOAM5339gnTBlJErjvzWtduTjaETwyrrOqf+acgcJX365vGWRzeQPrCZ x5KaPS59QrnrjDPBkCVm6cs= X-Google-Smtp-Source: ABdhPJx6bAYCBNMopBObWn1R/36X8oy51voH2S7zgf1akIZRIAsvFVTFdhusBzEyksz1DU35UcQp2Q== X-Received: by 2002:a17:902:b189:b0:143:8079:3d3b with SMTP id s9-20020a170902b18900b0014380793d3bmr66696974plr.71.1637244580292; Thu, 18 Nov 2021 06:09:40 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:40 -0800 (PST) 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, Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Jingoo Han , Kishon Vijay Abraham I , Marc Zyngier Subject: [PATCH v4 23/25] PCI: keystone: Use PCI_ERROR_RESPONSE to specify hardware error Date: Thu, 18 Nov 2021 19:33:33 +0530 Message-Id: <6ae6b071d92052dc511407513e2a7c0035aff9e7.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Include PCI_ERROR_RESPONSE along with 0xffffffff in the comment to specify a hardware error. This makes MMIO read errors easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/controller/dwc/pci-keystone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index 865258d8c53c..25b11610b500 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c @@ -748,8 +748,8 @@ static int ks_pcie_config_legacy_irq(struct keystone_pcie *ks_pcie) #ifdef CONFIG_ARM /* * When a PCI device does not exist during config cycles, keystone host gets a - * bus error instead of returning 0xffffffff. This handler always returns 0 - * for this kind of faults. + * bus error instead of returning 0xffffffff (PCI_ERROR_RESPONSE). + * This handler always returns 0 for this kind of faults. */ static int ks_pcie_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) From patchwork Thu Nov 18 14:03:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627145 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 6CFEDC433EF for ; Thu, 18 Nov 2021 14:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58BA761414 for ; Thu, 18 Nov 2021 14:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232697AbhKROMs (ORCPT ); Thu, 18 Nov 2021 09:12:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232744AbhKROMr (ORCPT ); Thu, 18 Nov 2021 09:12:47 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1711C061570; Thu, 18 Nov 2021 06:09:47 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id fv9-20020a17090b0e8900b001a6a5ab1392so5828730pjb.1; Thu, 18 Nov 2021 06:09:47 -0800 (PST) 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=otIBlbR4NTHUrEp/WYu2Y03OTgd+6umgzibtCvzje0s=; b=gVoIOcI852I7EU2zy3TSd3RJe/detUUq1Ve0b3AIMbrSUDE/Vy/VCFqYM7pe6sx8Cc gux7B4/DgiCaPuKEKCRsNwXS3JqSk7yWtMgvSSDQNuLhRhinw2yjJQ8qvYnBRmQVs7hP DryNQCHnbGa+5OjqEqJEYooh8gr/jtHaOiJn/fyQcg5IKPy5uACoLLey4/+t6tFGKzMD 1iYCeMTAxrjLbn6W5Y9jOt0vLOzQoK3qvpRDHqUPhd2HgPd4azd0UhfMVxtaD3R2tLJY X3NUgIFIZhBqq9W+UX92825pbxcVAf+dFZPcsAZ+3ZabFsJUl/XE7AXu5cukLw8htrMN 1JNg== 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=otIBlbR4NTHUrEp/WYu2Y03OTgd+6umgzibtCvzje0s=; b=4YsSu1O1rp7loKIFO5w9XqH0u8GHcErjcFtT5f+Zrl/6lgquwWcbBnzIAMJw+dMHPZ YAIk8BP48mGQcL0wiS+HPqoYIHcN9tUYWQvNmsWqmEBnqKQXWqrWkUMf7XrbroEHBI9t kCYsIjQT5xsGUQRQZgd3EuT5M2uXVJVdwMa7U3dBDQCoiQLYtBSvZFKArD/8lIoxJcEJ P6aN/+p3n/Asw07Xg9ia9lrBQkQtSUwqyNxQyowFr33XLvRpyOcFG/sTrOPWA5Zc32Yf E1Y4h8wQBRivlnEx0bMqxHg3IYuMioS1S7hapcG29YOVlqqfE0jhEC1/XN8LOwCgbiqC OjDA== X-Gm-Message-State: AOAM533KLyCG7hDeL9tEYvfQGTcRI6EesJhHrB2ce6njiEcz4yq6J9nM cGoV8SijwoN3QRQlV5ActCY= X-Google-Smtp-Source: ABdhPJx1zPuGcWopRuFR6Vd9E6bpdnVaEtb9yWanVmd73lNDx+Q1NhxffyXrU/L5bDlA9BloyDAtFg== X-Received: by 2002:a17:90b:128d:: with SMTP id fw13mr10927636pjb.50.1637244587334; Thu, 18 Nov 2021 06:09:47 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:47 -0800 (PST) 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, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-hyperv@vger.kernel.org (open list:Hyper-V/Azure CORE AND DRIVERS) Subject: [PATCH v4 24/25] PCI: hv: Use PCI_ERROR_RESPONSE to specify hardware read error Date: Thu, 18 Nov 2021 19:33:34 +0530 Message-Id: <12124f41cab7d8aa944de05f85d9567bfe157704.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Include PCI_ERROR_RESPONSE along with 0xFFFFFFFF in the comment to specify a hardware error. This makes MMIO read errors easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/controller/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 6733cb14e775..1f961d0b5d6b 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1774,7 +1774,7 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) * If the memory enable bit is already set, Hyper-V silently ignores * the below BAR updates, and the related PCI device driver can not * work, because reading from the device register(s) always returns - * 0xFFFFFFFF. + * 0xFFFFFFFF (PCI_ERROR_RESPONSE). */ list_for_each_entry(hpdev, &hbus->children, list_entry) { _hv_pcifront_read_config(hpdev, PCI_COMMAND, 2, &command); From patchwork Thu Nov 18 14:03:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Naidu X-Patchwork-Id: 12627147 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 6E2F4C433F5 for ; Thu, 18 Nov 2021 14:09:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 525B461107 for ; Thu, 18 Nov 2021 14:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232747AbhKROMy (ORCPT ); Thu, 18 Nov 2021 09:12:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232755AbhKROMx (ORCPT ); Thu, 18 Nov 2021 09:12:53 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 471F7C061570; Thu, 18 Nov 2021 06:09:53 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id h63so5391761pgc.12; Thu, 18 Nov 2021 06:09:53 -0800 (PST) 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=zB5XsRc0hZcCafw5hLwjwE1ROreQcocPtbGP32SH7qk=; b=CcSVQRzC7FXSFIlS2qpJ/HUOdyBR5TMsGgaMfCh2axue8nls25qACZnuGDAfyapleu wo/lATjkWu2ELnZMyXo/2GADE2BsptJIrOlIVpTUbQkSd9qn88B/1VneLRVXfvmZHPUg zhoN4krfHxRuyV82pYDbizhtRy3sCWoAGvckBxyxVLY471CZRaovUwagQaoZaAM1Jpgz CetmBN4sVXawTd216K+AheZqBtsTjeWaAUZIUTUE9xfcmwApORNxUvtv5/RPWUKi1v/Y xBPRXfKDl8wj0WPuiMQLl6k2mem5ATDQqMTvahMapFDmbpujEX0DI5DcCx3XdDZl5SW1 /uxw== 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=zB5XsRc0hZcCafw5hLwjwE1ROreQcocPtbGP32SH7qk=; b=b/SrhFIGGa/ymKGiuj6QP49KTx6YaVfoC60jwxkg5xpYx+3AsYi5yf3newpj6wtN8q ntCMOLYj4qSzNFo2o42AGrQWDZP6AW4oLdJ7/gQRMot5x+Ya1TeAtCUDpt4tPdZIfNM4 34DKEoPK75KQvnxtOsM66PNHscj809qGix+zx0nK6UKNmzPpkT2/XjjhI8nhtFU/i5FX JX1iv1B9hCCFfoNIPQ3VSCNG9PJvaqLGQ3LOl3a5JjWqcc+l0ZHxSPpJSKts/j6MT38R JGQ/QWQli120Xenk+Anoy/8EiSv9Z3K7fbETJjwSxnKcHY+hN5BNmivjWv1igJTo2TSZ rgGQ== X-Gm-Message-State: AOAM533LTMLnK2YoV33WA8Fe9I/cKGCEwoYTDnT1hgi5JBzLc4Dm5KNV PGOe9e1lBVGL2FOvL6OEUO8= X-Google-Smtp-Source: ABdhPJxHe5yoN311wNnxMelRGgb5M8SJ/v09H+EE0Bt/IwVrvmRmADVScTGYdONmLDvX0shcdVjBdw== X-Received: by 2002:a62:dd0d:0:b0:494:6e7a:23d with SMTP id w13-20020a62dd0d000000b004946e7a023dmr15374639pff.17.1637244592768; Thu, 18 Nov 2021 06:09:52 -0800 (PST) Received: from localhost.localdomain ([2406:7400:63:2c47:5ffe:fc34:61f0:f1ea]) by smtp.gmail.com with ESMTPSA id x14sm2822878pjl.27.2021.11.18.06.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 06:09:52 -0800 (PST) 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, Toan Le , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-arm-kernel@lists.infradead.org (moderated list:PCI DRIVER FOR APPLIEDMICRO XGENE) Subject: [PATCH v4 25/25] PCI: xgene: Use PCI_ERROR_RESPONSE to specify hardware error Date: Thu, 18 Nov 2021 19:33:35 +0530 Message-Id: <388b9733bd55394581c447be9f3df42ca2c9759c.1637243717.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Include PCI_ERROR_RESPONSE along with 0xffffffff in the comment to specify a hardware error. This makes MMIO read errors easier to find. Signed-off-by: Naveen Naidu --- drivers/pci/controller/pci-xgene.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index 56d0d50338c8..89ea81ffb532 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c @@ -175,10 +175,10 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn, * Retry Status (CRS) logic: when CRS Software Visibility is * enabled and we read the Vendor and Device ID of a non-existent * device, the controller fabricates return data of 0xFFFF0001 - * ("device exists but is not ready") instead of 0xFFFFFFFF - * ("device does not exist"). This causes the PCI core to retry - * the read until it times out. Avoid this by not claiming to - * support CRS SV. + * ("device exists but is not ready") instead of + * 0xFFFFFFFF (PCI_ERROR_RESPONSE) ("device does not exist"). This causes + * the PCI core to retry the read until it times out. + * Avoid this by not claiming to support CRS SV. */ if (pci_is_root_bus(bus) && (port->version == XGENE_PCIE_IP_VER_1) && ((where & ~0x3) == XGENE_V1_PCI_EXP_CAP + PCI_EXP_RTCTL))