Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp716632pxb; Thu, 21 Oct 2021 08:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPVsVL7lkDED7O7CEJANk0PUbGHKulOBD8G52qPURfNYTy7aflzP5daVKp7dXS6rjuyael X-Received: by 2002:a17:902:b717:b029:11a:fae3:ba7c with SMTP id d23-20020a170902b717b029011afae3ba7cmr5735886pls.28.1634829029121; Thu, 21 Oct 2021 08:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634829029; cv=none; d=google.com; s=arc-20160816; b=zZFQaFaEGdFS28wF0DWqL3ZGksVk7jTgp0lmRzckhap3MDChPkjvlza8p9UJUQfr5h wTSTk/+twiXMcEFpkmRlp2zAQuZmVYjWagyF2zcbZBxl0+46Ar146mPV3J/rAhRI+A1E p1SdvtNKG6GCgRjIMprktJKVefKax6d7XVjSstKDWMDsIAB1H7wharzkTKiMpccZuO9b cCcN8JqwfkL5uUD0ggwK7gpLWyRPJl5IeHNvgKvPcOLC9q+SG3iobKm9BxZ9Qf2Up9de H0+uZvvTAWKFvkfle66NifXZGVt9sAKccgHe5/uHT3krDYV9TqzQ0VPEaGMOBvfqAc21 QVLA== 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=CCqTrKqg8AEEY1fy94bWXb9atpHsOzrSvfmsYcP1Hi4=; b=acXKURgiyjzAq+syG3ZSyCFvUD6iS3DDggAgpRUnP+bIkaloQPzCtPOvCENo1xmsAG VhmT9rqdhc5zIS6z4I1Z9P5BBcwtjZBV7EbikpJ7Pzj7XfcrIOJW8N4jgiYSOMAwVVqj k6WHwD0OKg2hjDIP3nKi/oqKPHkXL+63UrI+byNx87T+nWpc3XsD1gV3tPuNJPrJ4G6S Nb8ZtRqU8FkhqQLZQgjd2cuyy08gw+oQYqUnKRP4fP5qt9dTaJdXxZyRdedMQfxKsGZS /gL+qxOYTdFCkMMaLygpJHWMGeV7kN8bkSYl4msW8rJS/Dn+JeOpE6N02TnTYlEgm7Vh BiaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Me2ms/bT"; 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 i6si7252624pfg.334.2021.10.21.08.10.14; Thu, 21 Oct 2021 08:10:29 -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="Me2ms/bT"; 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 S230280AbhJUPL0 (ORCPT + 99 others); Thu, 21 Oct 2021 11:11:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231207AbhJUPLZ (ORCPT ); Thu, 21 Oct 2021 11:11:25 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2A28C0613B9; Thu, 21 Oct 2021 08:09:09 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso779067pjb.1; Thu, 21 Oct 2021 08:09:09 -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=CCqTrKqg8AEEY1fy94bWXb9atpHsOzrSvfmsYcP1Hi4=; b=Me2ms/bTDiHgSLBr6tSZnSGK57Xq0PodMkigjQOxBqKFSTP+S6Ys0c1z1cgwhGRzMq dD61uaB62U1bO0yyIAfAlye2MhW4Xb6U3f1ifwy1tiGQ5Li+LQFTluq4WPm1SzJAA/Co i6USRU558XPIJjQTcsE+KgIJOgcbw+05/L7J2UmMshSYeUp0D7qGGyY19TKpkvepf99M qKvLJ/8dCZsuaslmM7TpJXRdRFEfgA57CfrtFR+iToFz5FQ8Br1TUIR43iayrks4OUUh WctytAcN5Y8WaMGzxbsbtr5gt6lzr1z6E+AuwgB/M+xYSeNi2uzA3U+TvUDD8R6lKBJR lYXg== 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=CCqTrKqg8AEEY1fy94bWXb9atpHsOzrSvfmsYcP1Hi4=; b=EK/FgOjdBG0hfrVtlvjkEOXOWKq4QWbsph1abfgjE4PhVrc82ZZlZD14hrwKH4rayF G6SWBy4CCmMtHkuIsMxXGollfQuQ+XzU5qPdggdb+XDRWiNI141IxftAk0+K0HrzHwsn HfIhsGrbCEI7GbqgCM5+S92SIocN3q8PTJcrECm49kym1VfB7LwqtaU5HfgVnl64+nn4 doUxP7xAWBKPM8MgHBdaM90XOlOwOWuNZOq/4tWCtC/D9QZiYQzwDDIBIPNJxvgEPRwp 23Apjr51xYXHHM9AI4W5tHAZpqpgWimXEOcFDZcm3G1gNQtupCMCLdBav9nC2U0SqUYU Tg9Q== X-Gm-Message-State: AOAM5338V9xfQIoHy/OCdzCC5iqPmIH8dKCkkA5vofiBI+kTuneVwjuR F2OW+t7+2RoN0FlH9HTtewo= X-Received: by 2002:a17:90b:4d88:: with SMTP id oj8mr5111859pjb.175.1634828949353; Thu, 21 Oct 2021 08:09:09 -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.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 08:09:08 -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 01/25] PCI: Add PCI_ERROR_RESPONSE and it's related definitions Date: Thu, 21 Oct 2021 20:37:26 +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 An MMIO read from a PCI device that doesn't exist or doesn't respond causes a PCI error. There's no real data to return to satisfy the CPU read, so most hardware fabricates ~0 data. Add a PCI_ERROR_RESPONSE definition for that and use it where appropriate to make these checks consistent and easier to find. Also add helper definitions SET_PCI_ERROR_RESPONSE and RESPONSE_IS_PCI_ERROR to make the code more readable. Suggested-by: Bjorn Helgaas Signed-off-by: Naveen Naidu --- include/linux/pci.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index cd8aa6fce204..689c8277c584 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -154,6 +154,15 @@ enum pci_interrupt_pin { /* The number of legacy PCI INTx interrupts */ #define PCI_NUM_INTX 4 +/* + * Reading from a device that doesn't respond typically returns ~0. A + * successful read from a device may also return ~0, so you need additional + * information to reliably identify errors. + */ +#define PCI_ERROR_RESPONSE (~0ULL) +#define SET_PCI_ERROR_RESPONSE(val) (*(val) = ((typeof(*(val))) PCI_ERROR_RESPONSE)) +#define RESPONSE_IS_PCI_ERROR(val) ((val) == ((typeof(val)) PCI_ERROR_RESPONSE)) + /* * pci_power_t values must match the bits in the Capabilities PME_Support * and Control/Status PowerState fields in the Power Management capability. -- 2.25.1