From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43AF5C433F5 for ; Thu, 21 Oct 2021 20:20:41 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D110D61372 for ; Thu, 21 Oct 2021 20:20:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D110D61372 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HZzPg1vyLz3cCw for ; Fri, 22 Oct 2021 07:20:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=XbjTRlbg; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=pali@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=XbjTRlbg; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HZscF0VBmz2xsg for ; Fri, 22 Oct 2021 02:59:24 +1100 (AEDT) Received: by mail.kernel.org (Postfix) with ESMTPSA id 92059611F2; Thu, 21 Oct 2021 15:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634831960; bh=KPsjXWIvxRCwuDpa6Tvl31WU0C1Lqvs1IzWAmvt1LIM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XbjTRlbgoq1kwcCmsdjF6aOe2HMQK3qhZn4f6pwey2aCZwN/CceqGeZEd1NVVct/O kAtaIu0D2RzfDizb0fIaGV7yHSP7jJbkgt55srwlnfMkB82DUjcz0CJqbBsQUy4uWY IBoamL9aWl4OH1LwOg86ZcJBhBfrYJAu2hgznF4gLGRNWK5xVQ5rD6BityDTdeNgwS cRnb8Wpu7DVARlwxGUaTouRT4DDc4QAdUViv1b/jQiIFIHaDQG/uaFhrUhuqvsqihO mh/P73eh7rmz07vr2UZwwLI5zkWoGq4S3mbrF3PmKMvhKpfCLTXNCiUnOpogyL0ERX wqANqVprTGV4Q== Received: by pali.im (Postfix) id 6EFCD85E; Thu, 21 Oct 2021 17:59:18 +0200 (CEST) Date: Thu, 21 Oct 2021 17:59:18 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Naveen Naidu Subject: Re: [PATCH v3 02/25] PCI: Set error response in config access defines when ops->read() fails Message-ID: <20211021155918.kigwwylvdmsuyd3z@pali> References: <56642edd0d6bf8a8e3d20b5fcc088fd6389b827f.1634825082.git.naveennaidu479@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <56642edd0d6bf8a8e3d20b5fcc088fd6389b827f.1634825082.git.naveennaidu479@gmail.com> User-Agent: NeoMutt/20180716 X-Mailman-Approved-At: Fri, 22 Oct 2021 07:20:04 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , linux-hyperv@vger.kernel.org, Heiko Stuebner , linux-pci@vger.kernel.org, Shawn Lin , Binghui Wang , Kuppuswamy Sathyanarayanan , Matthias Brugger , Amey Narkhede , Oliver O'Halloran , Thomas Petazzoni , Lorenzo Pieralisi , Toan Le , "K. Y. Srinivasan" , Nirmal Patel , Marek Vasut , Rob Herring , Wei Liu , linux-samsung-soc@vger.kernel.org, Stephen Hemminger , Krzysztof Kozlowski , Joyce Ooi , Dexuan Cui , Jianjun Wang , linux-rockchip@lists.infradead.org, "maintainer:BROADCOM IPROC ARM ARCHITECTURE" , Jonathan Derrick , Xiaowei Song , linux-kernel-mentees@lists.linuxfoundation.org, Robert Richter , Sean V Kelley , Ray Jui , Haiyang Zhang , Ryder Lee , linux-mediatek@lists.infradead.org, skhan@linuxfoundation.org, bhelgaas@google.com, linux-arm-kernel@lists.infradead.org, Qiuxu Zhuo , Scott Branden , Jingoo Han , Yoshihiro Shimoda , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lukas Wunner , Marc Zyngier , Shawn Guo , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thursday 21 October 2021 20:37:27 Naveen Naidu wrote: > 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 > Signed-off-by: Naveen Naidu Reviewed-by: Pali Rohár > --- > 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..0f732ba2f71a 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) \ > + SET_PCI_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) \ > + SET_PCI_ERROR_RESPONSE(val); \ > + else \ > + *val = (type)data; \ > return pcibios_err_to_errno(ret); \ > } \ > EXPORT_SYMBOL_GPL(pci_user_read_config_##size); > -- > 2.25.1 >