Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1275284pxb; Sat, 16 Oct 2021 06:04:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdmMEc1U+NYCwxGH6J10MySegZMhs1skI7xcXFb3RD6xuwdJ18HPVehFZDqJ7wIbGVvfcH X-Received: by 2002:adf:a2d8:: with SMTP id t24mr21416972wra.91.1634389457788; Sat, 16 Oct 2021 06:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634389457; cv=none; d=google.com; s=arc-20160816; b=Thxw3d+3+8k3DJM6KmEdBDyMFFithCulIRe4dxHx937liMuPq684ZUbuMUX1QTjmAj 0ljnuWSUB5mZ0LdURoyIbM2Za5L6rH24fCFyV6BGOTD9T2YitApwntkJzRDZXnTtr633 JRFuMUjz3xJBZuBsvSLtqFy/1xXA1MHctS4VCAFGszcmF8+Sx6TPtUdgOwx3sq46coel lBN+RYhNU0N7fmTA/FNz2S/wysnHV0VQiIntKvyCPhfNBVeXEHa37k6M+MPUgiNjgcKE cKmE0Nv5Bw+e8mh/gisfEgLVySBgaYZ9oILG0cB+RfzYjZelFO38BkscXetNtlqIUVJQ 67fg== 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=SRGYUiiPkOf4nvJAYXjsEdQZ9uhs5fYStilswkWIKIU=; b=v7PXSOjNC04SDT6qMtw+63m2h/quuhpdVzx1CWPRADWt0jH7+h3Phge9HPiPdigpBl 1Kwvq+lnnI4BvJKKxfu7IlUi5mZoJSPrKqB7MJtj38M2iOKctofcJ5jJ+OHDmdIqUxtt l1VJz7f5thRdEg871CcgBxoZ9fA5+AQy4hWs9QIriARe556nxaczkEhvCn/R+o2mNTx3 1oCoTidgWFumAU/xCIOmfT7GFATqLjaYrmi6nYUbQm7Xmp0iGxB4qbVusH7IricCBqtJ E3m1iABpi8Ma2zlg7DW8IWOiSPa5l59lxsO/MHf+SSTrdWug3yTVDQ8WRhMlHNkafk9g u7+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mbgR3J7v; 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 ci5si12494115ejb.113.2021.10.16.06.03.51; Sat, 16 Oct 2021 06:04:17 -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=mbgR3J7v; 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 S240277AbhJOObv (ORCPT + 99 others); Fri, 15 Oct 2021 10:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236879AbhJOObs (ORCPT ); Fri, 15 Oct 2021 10:31:48 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9F6AC061570; Fri, 15 Oct 2021 07:29:41 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id q2-20020a17090a2e0200b001a0fd4efd49so2915188pjd.1; Fri, 15 Oct 2021 07:29:41 -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=SRGYUiiPkOf4nvJAYXjsEdQZ9uhs5fYStilswkWIKIU=; b=mbgR3J7vdSv9ydYMWh/7rebsHNDZK201cmfpd/sP/GQkhd7GlhzenAoBzgbBCwnXBG CAq8Zpd7QORKvVApiIrhgnRPNKEK6ST35pkfMd2FtfsY5vF/zq9X/vg6fa8YhckkADYt tNNUwtsmHFdgdufpXYRbBziX3kyROMiDVTqLMytC6w1scCrqwTlHO4q4/hvjGJxLhCdK gGvHdPu6r4bqi2JeA9S+O8smBkUr6IXgrL4IhUajdlqSSLTjzIjCJiR5JOdmQHbXd4Gi ztnyD8kyLx77TpkEuO5F74jpZ9qlaIOOpVRconGOVNyvkwY0mi4nv74+v7Wm2sRMk4yc Xbbg== 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=SRGYUiiPkOf4nvJAYXjsEdQZ9uhs5fYStilswkWIKIU=; b=70XKNl1I57Ka7HIzIYdzZGckeoz1b1cgP2Ps6E3kKgc/3rCkQJk9aGJPjagZQl+9GJ iZlCcfcp/DWyNakikjym3wh5ykG6EizewHo6Ml14aqsQxKgaqE+yRNVTbylyveOlivFj ClU7TT08Ouv3synab5FR+67SZjZ7VhhjqT807qAB+fRO3qb8+lJfCUb5Ur7/ptkLi7tV juLXi2TXmlUq+4g/b0WYEM/GTvVhnJyP2O6jb3OCEuN4CZcZtdy0LfkUeD1deQdK73xX g/FPbAsAJyoYfm8q9c/uawoQCRDK8hfluHHLJSxUa1d/SHdT0zz6je3zbG4Qn9jkTLyi YNqQ== X-Gm-Message-State: AOAM5334yhUY++VbAd/y3HRDFNXbjFFwghyp/pQFuxMJgC8O4PmNQzw6 1WCo2fdcB+0PdKq1bQQv/zk= X-Received: by 2002:a17:90a:de0b:: with SMTP id m11mr13852310pjv.90.1634308181312; Fri, 15 Oct 2021 07:29:41 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:4806:9a51:7f4b:9b5c:337a]) by smtp.gmail.com with ESMTPSA id j12sm5210806pff.127.2021.10.15.07.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 07:29:40 -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, Rob Herring , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v2 02/24] PCI: Set error response in config access defines when ops->read() fails Date: Fri, 15 Oct 2021 19:58:17 +0530 Message-Id: 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 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..b3b2006ed1d2 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