Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp764114pxb; Thu, 21 Oct 2021 09:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+rAgsvGORc1ClxX/ZlOjoaK9+7phtv0u0Y01djx7wnJ+6vJz3+TZSednqYsT2Unhhbo4t X-Received: by 2002:a17:90a:9ef:: with SMTP id 102mr2103283pjo.57.1634832218078; Thu, 21 Oct 2021 09:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634832218; cv=none; d=google.com; s=arc-20160816; b=Ej5/22LLEYrJENbxBQ/EyauJ8vjVBE4zf+BBWpjhoVsSZY7Eth30WJr0yDxlAZJDB4 xaX3BL06ck4NWXHlSUVo9z+vWibwLPdzsgveEdLWxK5asUDy/WZLt4SExqU0dxPIjx+l nS4aaKTi6f5FI52iasJTbxI8KlOpqjx/8Evcc6lUl59k0421LVd3fljsRP4cU9xbSG9n kGs6NnOzgrYNOgi366j3wMxxVTCv07knXA18Iuc57eJMEtDR9aP8gEluwulS9CHGK/Jf s0rrScyWLvVGnxqPsETmtLcLFQrne+iCaqWP37D2K+BwCoZ1cm+moUjnjWGvtlGaR6hK WhqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kd7dMskfPK3wOdM0f9Mx5EiE1glNLxMA0sKb71Pn2DU=; b=Fu4xZOwVQO0UDIY81Lopv+eT84TYtgvtBjJ0fPIBy3MEDi7SG3luvc9m7Nc+IZN5Pz jPJYHmvMpSk1oNqN0z7HF7aaTaPWVc6nDOC9KBfF4SoBnpgWtDWDiYB7ek4w8qYN1aGG 9lzPMZ/NBDEMIQvjz2glOtV2O3HKK02gfaAl8yhz71ZEFpxnBYf5vFIXvFLHpRToAkB5 hH9TgqbLEtRq8cJJNliqg1/9cAgrDsu6LLDyxpIwGH7bbzPknGYM9dsygSE+kzl+WG2d 9X1SJ+J0uFZWQolPri/D2j47SI7FdtabjKnD2AyY9OPKuyD0EFPzceJdwENvUsLy905a nTnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XbjTRlbg; 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 lk7si13779190pjb.112.2021.10.21.09.03.24; Thu, 21 Oct 2021 09:03:38 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XbjTRlbg; 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 S232139AbhJUQCK (ORCPT + 99 others); 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 >