Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp378844rdb; Thu, 25 Jan 2024 20:07:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGAdOJ949XaU8/MrvDm9XZL7WY8zk0UFi9x3gxRTF8iy5fJwZfEq2mN2gTOfRwhWPBpoRl X-Received: by 2002:a17:90a:5ac4:b0:28e:8027:baad with SMTP id n62-20020a17090a5ac400b0028e8027baadmr588272pji.21.1706242024366; Thu, 25 Jan 2024 20:07:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706242024; cv=pass; d=google.com; s=arc-20160816; b=FMa1mmg5bfa2gor+ymPZtAeKAGvk8CwZXqQu+tv1aiv7L6Kezjd+Hp4eqX+F/JdQNf lIqj91ihcWoZMFmQCCyopsEGkYnZ5oL9PsScb7kNaibhrCLysGoj4r6mIHMLBhZyw8wr /J/FKkZUK/7Jqnu+lH73oAK0aHrpp828DsmS50UytPhm3dEyc/BwfZjEoutUBi5MuAo9 R0FPbsQRVEabxFj4U0pW1JUuNDY5K6N1LKVpBxv8ymBSEDWjnpXTjCqRqameOZfQ4Nkr qiHnMeJehVJ3Kc13zZ8fx2zazwgCLYRVYeg6Uj5PGkPI75BH5ScmfnD7piWuXhLqQZ4Q 8Wqg== 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=O6bbo7onAbs116pEZ/+qAXhovL9Sh1xKhmPONjyaMbM=; fh=JEThTfG+ZTt+DBlApihnVPN9UmE/ctZ0fI2V3ICmK2U=; b=OU+n5Dv5bOH9WQKZ61eF1a5KqS+iiOwfaQ4B8FIw+EK//v01iHic1l2zfjRLr8iUab Qdqq1OpfFFnwOHFXJXA322m5X2JjDxsDECKD9H3bmfW8cy16OP9KxJSMpqfFEUaqOB3i aPxk1W3JWC7L6oInWBh/CJJG6baDhpngUnA5S/FbJVomcZ8EsIOtEnbmcOxqOf3HShWw 8K4KtHIYTARSdRStdghVIcbVUvThoMs1jKUn1knHakYyUVclpNHw0zg+5U4SKJA714Q7 +HJOCGXu6S8rMtPpwVntouiUEmAhOYvgCCpaXkzrKeTaRU6aQpdrvObLaOVg9XS8UT8U 1ALQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hFpKaysN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i17-20020a17090332d100b001bb8c4279f5si423253plr.148.2024.01.25.20.07.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 20:07:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hFpKaysN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9968E290E8F for ; Fri, 26 Jan 2024 01:41:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D40D98C18; Fri, 26 Jan 2024 01:40:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hFpKaysN" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 7D364522E; Fri, 26 Jan 2024 01:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706233229; cv=none; b=mCLAhwEMrgSB+51dMLL4OorBUZvaD9dnjSIb0HeiYUJpBV8P8OPahQ2K8BFQMmEfk19YtOd3GYiQWjbABLyaQclWqcnl5wsPg4JjeK78ilOd7KaJEWG1VM/RRFi4Zljx9swLPrzHuSc7Xj6f+xsKcWPsHu62Bd5/wHEoNRllsAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706233229; c=relaxed/simple; bh=dEKy3mt/WPL6E30nghtcx9sbGmG9T5AiLwENf8K/kU4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y0JEP5XIEjmP0HMl3vEK3GiWZKPxC0vHgmwR8WHH0gVPjY5eTFa9Ow9hXhh3K4cW2FDyrnj2tGiJ6XKBtxPtX+6XtL/D6RI5obwXYg82vCrdMfVaZ345rWoLIRGNygu8YEsgzLTkV/d0Lh3cCGdV7mGpDK4lex+WIH8vjuNYybg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hFpKaysN; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706233226; x=1737769226; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dEKy3mt/WPL6E30nghtcx9sbGmG9T5AiLwENf8K/kU4=; b=hFpKaysN3cQSoyCaMPhka0oe39bMBe4cnlyo2WTwxRZPJ9E3WmLq/Jwr 1YnfoNT/tB5STV24o3KPT3wkzHMqHXPKy7CubtCzFsCynx6MJ/O6CE6kx mUGh22/7+/B0pkYhaqez//m/uJ9AroX6SifdpGcgEjX92AhxabvQmSy4F oiDzMo4L8cADJcjKNcDths22JyigytfFrYtzGtX28KqbI0PVakdTSLhg0 koMCU3drEbbU6paCh0w5K6sXmrfBw0xx0wu/e1G/EwGRgjfTm56J23SHF De6hbK7CHR9xkZvLX2mqpsoFSO5dNU0DcF5NZ09OwS1hZ5fzNSLeqBytY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="15718453" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="15718453" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 17:40:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="2533094" Received: from unknown (HELO ply01-vm-store.amr.corp.intel.com) ([10.238.153.201]) by fmviesa003.fm.intel.com with ESMTP; 25 Jan 2024 17:40:23 -0800 From: Ethan Zhao To: baolu.lu@linux.intel.com, bhelgaas@google.com, robin.murphy@arm.com, jgg@ziepe.ca Cc: kevin.tian@intel.com, dwmw2@infradead.org, will@kernel.org, lukas@wunner.de, yi.l.liu@intel.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Ethan Zhao , Haorong Ye Subject: [PATCH v11 1/5] PCI: make pci_dev_is_disconnected() helper public for other drivers Date: Thu, 25 Jan 2024 20:39:58 -0500 Message-Id: <20240126014002.481294-2-haifeng.zhao@linux.intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240126014002.481294-1-haifeng.zhao@linux.intel.com> References: <20240126014002.481294-1-haifeng.zhao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Tested-by: Haorong Ye Signed-off-by: Ethan Zhao --- 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 2336a8d1edab..94118c4cff54 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -368,11 +368,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 add9368e6314..19dfe5f16fc9 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2512,6 +2512,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.31.1