Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1466491pxb; Sat, 16 Oct 2021 10:37:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYp0kd45RBSRY3kwLG7MUY4Y/8L63ne7Ym3bm3pz6MuEDcS1PpAi8vheVLa1xKfcFHWvSK X-Received: by 2002:a62:4d42:0:b0:44b:3078:7387 with SMTP id a63-20020a624d42000000b0044b30787387mr18540338pfb.27.1634405833014; Sat, 16 Oct 2021 10:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634405833; cv=none; d=google.com; s=arc-20160816; b=d0l3fBo6VtFIgPITQ3rtmWHFay3oU9dvsv6xkuKH8nTlbCTTc/zUDyKpMXZfTbkPwC Ifa4Nu4XaQ7ZUZbF8HZ+IHdN571Op4UF58HJ2LzvSLaQyvow0yiUWNvRM65appHxfwWM VCpKg3P59Zb0k8ly8PzVrWYDn0VGlru2Ljd9ZNKD89OfE4IRpKyVgDeTL1cGJDxHqXZ5 wkI+h6ivXEFv8NSqBN+UDO8a7OJldwNdRKhgsbqI4apOcoRi7zYSdzO+1raaHxJuDF3W r+J5tN7EVaEkOAMhyUJ37huD31BEJpWgBZo04k1O39TBoE542wkyW19/8CrNcMOLIqNV CWUw== 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=EXqQzO1oSewfqo9sAbFeLWFXnz/W3EVi0EQdPEI6sRE=; b=GKcBH0W4zVIp8/cOSaCA5z8vy0EmtnZu7t+lcE/OA49fGXJxMFUh+DwDz3+Z4vL3NP r6MRdT4MN/0dV52mIbfBb1a10+Hku+QMzb4K4uW9HsZt7FpzNrUFAAGzvchHqiwmPTWX 7wzlJKjsjlp6z4hXdJKjqPBLcneXQyd8ZmaXHhczkdY7/mJlXADLsI3DPrmmam0akWFr JKJ+xMsvAHYwh2qEbw5fRJ5C7UC2UQflAia3iVkg9lbP1nkf4h53o0+9bptvXQX98kFT APIpzokyvYi49+8/Q6jPtyuzPflXzHrjMphqw5+fhSEAkZe79X63ezHEvmWfGAIpv5DL n0iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K53e7Oe+; 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 n3si3172132pgm.571.2021.10.16.10.36.58; Sat, 16 Oct 2021 10:37:12 -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=K53e7Oe+; 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 S240695AbhJOOse (ORCPT + 99 others); Fri, 15 Oct 2021 10:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240766AbhJOOsN (ORCPT ); Fri, 15 Oct 2021 10:48:13 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80ED9C061764; Fri, 15 Oct 2021 07:46:07 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id oa12-20020a17090b1bcc00b0019f715462a8so7418609pjb.3; Fri, 15 Oct 2021 07:46:07 -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=EXqQzO1oSewfqo9sAbFeLWFXnz/W3EVi0EQdPEI6sRE=; b=K53e7Oe+f9+7D7WpNDUco3qWePYRLXAYCersP6n2gPnyhNdVyIE3Wu1/0wXNvCeD4h GQwrZ1Ch9tnNznJLjY2BCfcuNx29Ntzjkp1QpG5TUU7MSzTzCmUOq1NHcaxBCGoxZxyy zIfAW+IH/LqvtfiGH23oImVF4unRFwnBN9vExy/ehbxrgFRX7YYyzxkVcc9KuA+iIEVN x8UujC0F/DA4KmjgsLX7BCsyrLN09joYUMjO/XpoZHl2nnyh0BtSo/Ujt9fhazeGrq2+ bwvDDRhHpWmQtgwA4fSn8mw4uZYf066PvrVj1XtJxZlAJNneDe5bOTB1mzHAalmdDjLy q8LQ== 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=EXqQzO1oSewfqo9sAbFeLWFXnz/W3EVi0EQdPEI6sRE=; b=01+P60Eow/pN6alrf/0o6wBS/SLdvZmCowG2rMCvcuh/cg8GwavzyR3/5k0R7buI2p 1GIWbH/tJROgn/p08NbL9Bt6xiSXb4w4OZFdDPjv5JhlA1WrQxt9pbITnwITO46CYfbM 5O9O3MsnYWP7tHiPYHmkifkNM4N0I4Xhs99tdS0UzrWq4h8EVugaI858ZAYeUnzuTMbR ZF3OYpyhdPvwSyGc+yUKsgqOUJuVUDQG46xfXUv5J8KeLyYx40LkW2DnrLnsKUceQD8n Z0u8SukGCjIfbGjLQAEFtEzqMocLnYqkIIkJ9oJuVTLPovHu2dPDtbznFtH+Vapw8q1x mtpg== X-Gm-Message-State: AOAM530k0SJk6gxOi1MX4mmdsO9OTByqx8miQyZSd7X658foufacWI+1 mDhnOXEulPM3xwnujNWKVRc= X-Received: by 2002:a17:90a:bb82:: with SMTP id v2mr28357103pjr.57.1634309167032; Fri, 15 Oct 2021 07:46:07 -0700 (PDT) Received: from localhost.localdomain ([2406:7400:63:4806:9a51:7f4b:9b5c:337a]) by smtp.gmail.com with ESMTPSA id f18sm5293491pfa.60.2021.10.15.07.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 07:46:06 -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, Lukas Wunner , Kuppuswamy Sathyanarayanan , Amey Narkhede Subject: [PATCH v2 18/24] PCI: pciehp: Use RESPONSE_IS_PCI_ERROR() to check read from hardware Date: Fri, 15 Oct 2021 20:08:59 +0530 Message-Id: <2bc987dc1dfb753c37a65b6c8c98c32e66a4d2a0.1634306198.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 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. Use RESPONSE_IS_PCI_ERROR() to check the response we get when we read data from hardware. This helps unify PCI error response checking and make error checks consistent and easier to find. Compile tested only. Acked-by: Lukas Wunner Signed-off-by: Naveen Naidu --- drivers/pci/hotplug/pciehp_hpc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 3024d7e85e6a..8a2f6bb643b5 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -89,7 +89,7 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout) do { pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); - if (slot_status == (u16) ~0) { + if (RESPONSE_IS_PCI_ERROR(&slot_status)) { ctrl_info(ctrl, "%s: no response from device\n", __func__); return 0; @@ -165,7 +165,7 @@ static void pcie_do_write_cmd(struct controller *ctrl, u16 cmd, pcie_wait_cmd(ctrl); pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl); - if (slot_ctrl == (u16) ~0) { + if (RESPONSE_IS_PCI_ERROR(&slot_ctrl)) { ctrl_info(ctrl, "%s: no response from device\n", __func__); goto out; } @@ -236,7 +236,7 @@ int pciehp_check_link_active(struct controller *ctrl) int ret; ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); - if (ret == PCIBIOS_DEVICE_NOT_FOUND || lnk_status == (u16)~0) + if (ret == PCIBIOS_DEVICE_NOT_FOUND || RESPONSE_IS_PCI_ERROR(&lnk_status)) return -ENODEV; ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); @@ -443,7 +443,7 @@ int pciehp_card_present(struct controller *ctrl) int ret; ret = pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); - if (ret == PCIBIOS_DEVICE_NOT_FOUND || slot_status == (u16)~0) + if (ret == PCIBIOS_DEVICE_NOT_FOUND || RESPONSE_IS_PCI_ERROR(&slot_status)) return -ENODEV; return !!(slot_status & PCI_EXP_SLTSTA_PDS); @@ -621,7 +621,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) read_status: pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &status); - if (status == (u16) ~0) { + if (RESPONSE_IS_PCI_ERROR(&status)) { ctrl_info(ctrl, "%s: no response from device\n", __func__); if (parent) pm_runtime_put(parent); -- 2.25.1