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 344A6C433FE for ; Thu, 21 Oct 2021 15:59:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BF7B6108E for ; Thu, 21 Oct 2021 15:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232153AbhJUQCK (ORCPT ); Thu, 21 Oct 2021 12:02:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:60666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbhJUQBh (ORCPT ); Thu, 21 Oct 2021 12:01:37 -0400 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 Cc: bhelgaas@google.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-mediatek@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Rob Herring , skhan@linuxfoundation.org, Robert Richter , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Ray Jui , Scott Branden , "maintainer:BROADCOM IPROC ARM ARCHITECTURE" , Ryder Lee , Jianjun Wang , Matthias Brugger , Jingoo Han , Krzysztof Kozlowski , Shawn Guo , Xiaowei Song , Binghui Wang , Thomas Petazzoni , Joyce Ooi , Marek Vasut , Yoshihiro Shimoda , Shawn Lin , Heiko Stuebner , Nirmal Patel , Jonathan Derrick , Kuppuswamy Sathyanarayanan , Lukas Wunner , Amey Narkhede , Russell Currey , Oliver O'Halloran , Sean V Kelley , Qiuxu Zhuo , Marc Zyngier , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Toan Le 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >