Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp718307pxb; Thu, 21 Oct 2021 08:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSbTmIftJnT9uWMib1UnHLLU9zP+ZCZIa6Gq+mP8XBEGN37F5LtX6RmZRwzsMF6EfGoN4a X-Received: by 2002:a7b:c4c8:: with SMTP id g8mr7243875wmk.101.1634829130512; Thu, 21 Oct 2021 08:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634829130; cv=none; d=google.com; s=arc-20160816; b=vma1D1kE9uuXykQiC1m8uS3dUMrxiTm62T8xpWyptThMiIghLJXuyB7zGjAnynx58G Am/+ksvISnPk4AhJ15vkgsz17pdIvYM1kjKCkdpT0dSxpygVZhc4JikASTeagP6+iBz2 Scm5OjggcpYsvs9ag10yizalgIEa7wKJunmB8SijAQlJisFhCFu+cwd+zpFkwoJnFPyZ tHEngj+PEs9zs5v+iyP20nUw8aP/kFl8RisGBmot4/gGDEMwLDTOWXJysMJbPFy3pvlX LJQp7wEmwOBQvgw3ggeXVqu60FEg9gBV0GHeAdtWCEN8G2wtSjKkSRblzH064Dlxc+5R 9C2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TfHsGP2yi6lWLecTIcZVrIhetTubqUKD7yLErDw3x2w=; b=KgranTDFrobw7aqdl0n6YUOojhfWD+9n4+1oZ0jO6vZcpLZfTyc9ZjVW+7fy/HRZ5B 1TKI0mZnMzn3IVaWhwtYt2kUUbkcUOl44Y4ygVoKrZVWV+jaKmsjoLuAjlt3J+sv90EE WcoCb03Z7dWe4j1bpyT+4j0H55tpuF7A+FGFHqe7Bc8mfkLdAb51Wq7aA7U+wB+qMGCT gqJSM8SkFor/beLjwkF0A3GAS6yYM7HTNNx5124gzCEj8oHfqhlGU1mS0vxt7BqcMlF2 zdEfPW3hktAtHKRqoC3Oq1ef1otQ8cta3sJAGnuOJZxBdu4Y7E1g7i86lDB2kEwXmPOZ OJ3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EUZaSbSs; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si1786172edr.67.2021.10.21.08.11.46; Thu, 21 Oct 2021 08:12:10 -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=@gmail.com header.s=20210112 header.b=EUZaSbSs; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231712AbhJUPMF (ORCPT + 99 others); Thu, 21 Oct 2021 11:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbhJUPME (ORCPT ); Thu, 21 Oct 2021 11:12:04 -0400 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 878B0C0613B9; Thu, 21 Oct 2021 08:09:48 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id q10-20020a17090a1b0a00b001a076a59640so5972767pjq.0; Thu, 21 Oct 2021 08:09:48 -0700 (PDT) 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=TfHsGP2yi6lWLecTIcZVrIhetTubqUKD7yLErDw3x2w=; b=EUZaSbSsvxfgQPDyiZv6K9FvbiaFo8lnIoEmpC0ubPuoqxNOuIOf4K8ZsIh578ws0Z 2EDdrEbYHum8lqROFe1C/onYlVaB50CDb5AwppL0LpxiFNIEWdnc8cQjEFdXeAobfidj x8qfJAw0gdtPVdlvPc21q9Yxry610dr7WFKlVHFUO1eyzNlo/F03H3hyjJckpZwfON5S b21ly6HIsBApY6VwbYgoI1P/Fu0X1AZm7c/Cai3cT3TlLzr9REQ44ISEUK3PawQUbAVm ZC1Qe6WDuHchsm5VVBggdsA8zJ1Xgd6h2KTs8gi19LGsz2M2EyYOMMdey6IAUQiBbt/o +Ubw== 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=TfHsGP2yi6lWLecTIcZVrIhetTubqUKD7yLErDw3x2w=; b=hMbFAjGWeF5HtbledEOQn4mwZraG0Xq7EPug3qqVmFqva9+xVpfhr92V8sp5Go/A2z 7K2Xkf41Vs+TSkjHdxEXOLvE8hjZwn8npusOvhX1xqwAonW7WRPTe9b3gPx6B+9I62nx VffquK5koCdh2V+luLBRZ773jo4pVTQyA40mTewdoLMYx9OZaC75EUfaPM9DRP5k8EOk 7xoZA7KEebk4i+8CZ/n0GSFLMT/6/jGZbBwch5WY2NULN8fbU9oLoCfNvjG5flVbvuWO LzxclB3tccZ/bswlwqs39OQ+xje343oWOhhUX3gnZoYELpST+2PiQO9ecHMY2KyhoE3k 1RrQ== X-Gm-Message-State: AOAM532ez8WxjX+rGe/jMsP55a6mNCPyXRAgkx3aY+n78rIN5G7Ynabl cgXqskLRqVEh+QN3mBXDQmg= X-Received: by 2002:a17:902:d4d1:b0:13f:af7:9068 with SMTP id o17-20020a170902d4d100b0013f0af79068mr5714981plg.20.1634828988016; Thu, 21 Oct 2021 08:09:48 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:29a4:d874:a949:6890:f95f]) by smtp.gmail.com with ESMTPSA id c9sm5508027pgq.58.2021.10.21.08.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 08:09:47 -0700 (PDT) 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, 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 , =?UTF-8?q?Pali=20Roh=C3=A1r?= , skhan@linuxfoundation.org, Robert Richter , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com (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: [PATCH v3 02/25] PCI: Set error response in config access defines when ops->read() fails Date: Thu, 21 Oct 2021 20:37:27 +0530 Message-Id: <56642edd0d6bf8a8e3d20b5fcc088fd6389b827f.1634825082.git.naveennaidu479@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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..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