Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2572855lqp; Mon, 25 Mar 2024 03:07:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaqsBJyC+1cheLJYH8tacNN70xgnSmTvgplMvJS9ZeyJCNrcyuZeYQ+RjZtADsuwpbutnYQ35qRlVuGdTi8WmPvv0QE42U1imsXdGS5A== X-Google-Smtp-Source: AGHT+IFig/IA05jpuX6Occpt/b+9bR0/V13FQtNgwD2mevzVo+W3X/b3p2l4c7QwOleou7lDn31t X-Received: by 2002:a05:6a20:5482:b0:1a3:b173:1a97 with SMTP id i2-20020a056a20548200b001a3b1731a97mr8448914pzk.1.1711361232710; Mon, 25 Mar 2024 03:07:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361232; cv=pass; d=google.com; s=arc-20160816; b=F+hLjqCzN4NrJrbDCyP7qT925fYZ9q5TO3BmzejgZRwRzngf9l8QQKOLfmdmMp5mUM 5mQKCVo2LyZ6BjQbU+smQB8ozLpbJVE+XvhItn0Shh1mprSpDPpIH5icqgej/V4fRq7/ AJ/xya/1Q29vxYCJ9YSOFasysBwOZ038XtT2ZpSxPXVvQJ+iKwAzWlEQjWHNs00IZ07h RPfsdXp/yDek3qe6lZ+aXYclqgv4RqJkbTLuMsLFa2uZllXq6m2zMNGCI/UeTGVFChFS +gc4N/IGPnGM4+vpXB+456IGG1buAFjwno5N/NrlhSr/MCDwSWmhkSs2aIgxQC57PkIh WCzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oKGuyYSL8Ed5fLPGF40QREEwxfTlqYpXJmd0RovBTCQ=; fh=5jGsJgaEw6po3N4U8EOpndReOFvAiCcsSXr18UMgLA0=; b=PA23hUzyjwUvZuoXwS7OM+q/OU8Fk5yWFhIaaLz9LyM333WG56pD49+4RJMstW9jF2 QJPmFkpoa5JER2fODWWq3oCvU8asx6x/jt74N3+ftTFgG3tEuM0DqI5+AtLpTMjuxnwy TWXAIspSiJ0ffscknOaXxA8FEjKJVUnoPvTrLFQICbbKYvXg7ZryCLMsSSrJU+2Mr+pp cN9ekQa5pEpUf3SoUWZc0wA8lFJyKNSsfHrEkonF02xy8xElLrYSHcb09yZrxWHl/xSb ZEDhAgisGwZRjp/XhdwwtgHfzEF6YNu1elmo4OCka03cJZHuD/LFUtwuLwtcrGQbwXqm 31Og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bl5rLwSm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id g17-20020a056a000b9100b006e71c651cbdsi5171856pfj.69.2024.03.25.03.07.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bl5rLwSm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 61610B3B5BF for ; Mon, 25 Mar 2024 08:18:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59D7C270C9D; Mon, 25 Mar 2024 03:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bl5rLwSm" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48AB7130A43; Sun, 24 Mar 2024 23:37:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323422; cv=none; b=KsuvMR1dC3Rz+d+ayFH8tdizjzF/SP/5JjH4cM25m5G8a6vfw6+x50i+sX8tdBErbERNuoTgTUWBZ7t0xsS02As/+Oavz/eDOzuc32WuJ2O+c6OBdXuBOY6y9fpYcFd1yDI34DB/B10FhTn7F6R6kgIRcj6XvQUVLo9XCx7Baoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323422; c=relaxed/simple; bh=1LpbIxGXcYAfUP3h7w20zYf1iL7CarMN8BxniycF2YM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vD6aPZE7zL+4AhhtrVuK2dYOzZLkf1UqZ4HgJ2lM9jwwg3ywgSMgl7Jt6J+KOtbjGaDYxGshWMdf3bWUetYWnzTimN8TEvp+p31AjvKqgwJicG20PJwdFWWcdoI6jLNZsTKmOe5vUenLE1kuNSrDIlIg66skpW0Gig/wtjrtEmU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bl5rLwSm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ECC6C433F1; Sun, 24 Mar 2024 23:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323422; bh=1LpbIxGXcYAfUP3h7w20zYf1iL7CarMN8BxniycF2YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bl5rLwSm6xEj4zStuWwi6kpQ2S8L1P1bNJH+8mtY2eOd3vRGbKm+8ZsI6LumN85xv dKpEqrwPtA+8EH+JRtnl17/6FgztT2pLj+uxrdJmAHg/qpUt+osOKLzvEVjkOM8Qae H5Tb7copU8qjcpCE9maN65g42jsZu0Xg5bVvxXu+mY01n9pCzG77/8q9zvIqeDdgQd wRkb5JNeumMnh/RQIqDtfH3gIKaavFiDCpkhFEo9SUuvkEzrSPfaU30VnVnv+Fhd2N CJvjs/3PuGEV6Z2cNA64NvvCwvJjwKF5CywFQ9NNQHhVnM3zWnQZ9Bvv8Dc+QDKhMJ WZHSvDMEMV6/w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ethan Zhao , Bjorn Helgaas , Dan Carpenter , Haorong Ye , Lu Baolu , Joerg Roedel , Sasha Levin Subject: [PATCH 5.15 124/317] PCI: Make pci_dev_is_disconnected() helper public for other drivers Date: Sun, 24 Mar 2024 19:31:44 -0400 Message-ID: <20240324233458.1352854-125-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324233458.1352854-1-sashal@kernel.org> References: <20240324233458.1352854-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Ethan Zhao [ Upstream commit 39714fd73c6b60a8d27bcc5b431afb0828bf4434 ] Make pci_dev_is_disconnected() public so that it can be called from Intel VT-d driver to quickly fix/workaround the surprise removal unplug hang issue for those ATS capable devices on PCIe switch downstream hotplug capable ports. Beside pci_device_is_present() function, this one has no config space space access, so is light enough to optimize the normal pure surprise removal and safe removal flow. Acked-by: Bjorn Helgaas Reviewed-by: Dan Carpenter Tested-by: Haorong Ye Signed-off-by: Ethan Zhao Link: https://lore.kernel.org/r/20240301080727.3529832-2-haifeng.zhao@linux.intel.com Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel Stable-dep-of: 4fc82cd907ac ("iommu/vt-d: Don't issue ATS Invalidation request when device is disconnected") Signed-off-by: Sasha Levin --- drivers/pci/pci.h | 5 ----- include/linux/pci.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 2b5337980da7d..ec968b14aa2a2 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -395,11 +395,6 @@ static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused) return 0; } -static inline bool pci_dev_is_disconnected(const struct pci_dev *dev) -{ - return dev->error_state == pci_channel_io_perm_failure; -} - /* pci_dev priv_flags */ #define PCI_DEV_ADDED 0 #define PCI_DPC_RECOVERED 1 diff --git a/include/linux/pci.h b/include/linux/pci.h index 99dfb8c1993a6..08d26b58f95ca 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2284,6 +2284,11 @@ static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev) return NULL; } +static inline bool pci_dev_is_disconnected(const struct pci_dev *dev) +{ + return dev->error_state == pci_channel_io_perm_failure; +} + void pci_request_acs(void); bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); bool pci_acs_path_enabled(struct pci_dev *start, -- 2.43.0