Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1492180pxb; Wed, 20 Oct 2021 06:16:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/ZwPU/GVEolkqC2tquv8TAvaKT2fvLb+1hYG7np0GeZw4LVZVmtBrq0uFyT5EyK6I7hQI X-Received: by 2002:a05:6000:154b:: with SMTP id 11mr51198210wry.422.1634735785444; Wed, 20 Oct 2021 06:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634735785; cv=none; d=google.com; s=arc-20160816; b=Ci8RhUbi9deHVO9Rnm3Wwg9swcUqqXdZaKzT/B0IUgvd9F3jUxI8r6iOLKHcQWMwJX /+BPuMrWpz4xajvcDuq3QKI02mdYkjFMEIcbqirYTEu6nBn9nzCAuF7St5E1ZEHDvHJP vPPhwcmLtpXq+wuRsP1FTcfHEKk1k0OuLImU0TAiNT4IZ3r74OEmDPQyEuPlAMODClko GZ43ARyTgEKxvB4d0iQu5240goj0U/6XtLbMr1+GbrvfEgOuCLfQHzChGb+b66oZ/4W2 XOgG1JKkB261BPdlmTnnF13b2di30+E2oxUFaRFK2Ngule6fV1WzYgJydIbJ7QiMEFCJ Zn7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2r3mbgEOKCAphWOTFN2e6UULnD2H9GQNAPamdyEgIXU=; b=sCeRJQHR3NcBitaTlwqTfTh+PzBdRpUEHEg6bvhN0on8U2At7r9rLWOnPqAmnvTAUi OaveKAar2qQQwIPc5S4nPtXBLZn7q5/YvxreCDKT19uBHEw2Cfvfa36O3MswG92tYHdi Yx+7rgdHqZpRh9Zub4gL8N+y5b768F8Zp7MDoBRWRJzsJnp4iALEZ71rzPPDOQEhalJk //z8SLiDTV49xYHskIW+y6FEBdkrNMDt8cAojzP+7SX0vasHB+UneawrTE1NuIV5TgHL 75lwJZHvqyFdQZ/0Kgz5qPesNfFiQgyO06SpS9iqx2eEqc0/1axpT7J3cY9FKjvp5c5j OJxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq38si3754340ejc.492.2021.10.20.06.15.53; Wed, 20 Oct 2021 06:16:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbhJTNPW (ORCPT + 99 others); Wed, 20 Oct 2021 09:15:22 -0400 Received: from mail-oi1-f171.google.com ([209.85.167.171]:44572 "EHLO mail-oi1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbhJTNPW (ORCPT ); Wed, 20 Oct 2021 09:15:22 -0400 Received: by mail-oi1-f171.google.com with SMTP id y207so9540201oia.11; Wed, 20 Oct 2021 06:13:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2r3mbgEOKCAphWOTFN2e6UULnD2H9GQNAPamdyEgIXU=; b=vyq964GmUK0EE+Mo4BBu5QcF5gxc+dFOTUkVcNM4wCnPiTDy4u/JHdjTHHY0FcVoAV fS1cYytFQ1THR7l/OXCi6ib9Ilp3hVJfqR4r7PEoAWGa83zJiZInAzo7eN3OvvVS4G/s Ui44YZ1wWgDTlBEAvKMY5kUGVPPIHHTxX4mN/DJQofpmWmCypb0IBTNWSdXJn9Zrb/Ap y+4nYcwXlkSD1Tep2nIkaV6LCRRLNxF6gI9Yry56UfLTkv9cfEDtXe4zFyjYWTcA/U6C MsGUIQWQmMCmMT1HFGTnGVufU8wZ3Pw1Qg2xB9al9TZ+G3VIrwbfMGU4pGmntupsXslQ KjQg== X-Gm-Message-State: AOAM533QNlM3/R0gaid0xJAvUbBW1l++w+T7IC1k5IGEhQVKswYWnGpr TzEnv6zFFqzjIXKullz3lg== X-Received: by 2002:aca:31c7:: with SMTP id x190mr9703609oix.143.1634735587326; Wed, 20 Oct 2021 06:13:07 -0700 (PDT) Received: from robh.at.kernel.org (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.gmail.com with ESMTPSA id p14sm400670oov.0.2021.10.20.06.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 06:13:06 -0700 (PDT) Received: (nullmailer pid 2208400 invoked by uid 1000); Wed, 20 Oct 2021 13:13:05 -0000 Date: Wed, 20 Oct 2021 08:13:05 -0500 From: Rob Herring To: Naveen Naidu Cc: bhelgaas@google.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 03/24] PCI: Unify PCI error response checking Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 08:08:44PM +0530, Naveen Naidu wrote: > 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 SET_PCI_ERROR_RESPONSE() to set the error response and > RESPONSE_IS_PCI_ERROR() to check the error response during hardware > read. > > These definitions make error checks consistent and easier to find. > > Signed-off-by: Naveen Naidu > --- > drivers/pci/access.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/pci/access.c b/drivers/pci/access.c > index b3b2006ed1d2..03712866c818 100644 > --- a/drivers/pci/access.c > +++ b/drivers/pci/access.c > @@ -417,10 +417,10 @@ 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) > + if (RESPONSE_IS_PCI_ERROR(val)) What if there is no error (in ret) and the register value was actually ~0? We'd be corrupting the value. In general, I think we should rely more on the error codes and less on the ~0 value. > *val = 0; > return ret; > } > @@ -452,10 +452,10 @@ 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) > + if (RESPONSE_IS_PCI_ERROR(val)) > *val = 0; > return ret; > } > @@ -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; > + SET_PCI_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; > + SET_PCI_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; > + SET_PCI_ERROR_RESPONSE(val); > return PCIBIOS_DEVICE_NOT_FOUND; > } > return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val); > -- > 2.25.1 > >