Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp258819rdb; Mon, 29 Jan 2024 00:57:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxJRLYX5hiaWinUTPNiVs5CXEGd+x/VDfbqHLVYStRd6iAfUO7GkMQ97cN+6Z9nU3SXp7+ X-Received: by 2002:a17:90b:802:b0:290:14a6:2664 with SMTP id bk2-20020a17090b080200b0029014a62664mr2943749pjb.4.1706518661215; Mon, 29 Jan 2024 00:57:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706518661; cv=pass; d=google.com; s=arc-20160816; b=Ym5TBc9nBfFvzOKimlFK1EY5Lju96OQpUvAAE9BRydV3IabnneJ9UKrSd1bXg7F5jT NtKkvzzrNYNFkFbMPrIAtv8Y4rcfTS1gHBeYYbwX9Nt2Vs9+0bfzOZgno6MGZzm0LNsx b0AH13gTDemOWqTiSM81ZABva3AJHizqLYMvj1Z+xMuLoLBxI5Yh3175R7y71BZRAQmz +QJMBov7nun5aLnzh5WlxEe8omX+/j2w8aipZkZq+yCgmM3m/Ss+D3nTTd8Q6tPUwF8n Td30XO1Ffuck058mnF9oH2WLp7aweDZ5HBD/b21XooBVp9gjZkA8T7GwbUbSq//BrJXE 1CPw== 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=NuC+MQAQISIz8qW1ly6lHwZ087qX2WnnpbtVpL+nQNUY7dWZ+D76WuSvZ3AVgMpFvm weh6r6LxXETSDoNnkb/0pDaHbUQ6F97QjEd40a8EcGxJGgEtAHRJuWXSIdbMVnrc7QnT 2a6mn3bY4wyNcuwvk29QtzHTmdqxPLXD3wpqIei8e2sAUEarkazLhfA0b7hcjtjdLgkF UDFpsTfMnpl8FtohTaHi9eyI6VomTqqYmLzvB0ZUy3sbFQNzNAhPi5lorV91QDbmwnpP y0pyE55jJhPehlpv7R2hjEd/8Onx4oyxv6ERcoLbed2LUFeYsiTzr7fK99wu+F2ZlfFH EyFw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YkSWDpE9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42141-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42141-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 w1-20020a17090abc0100b00294731fbed3si4690528pjr.146.2024.01.29.00.57.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 00:57:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42141-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=YkSWDpE9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42141-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42141-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 C8941283A27 for ; Mon, 29 Jan 2024 03:50:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E946814A9E; Mon, 29 Jan 2024 03:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YkSWDpE9" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (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 3B01A12E5B; Mon, 29 Jan 2024 03:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706500179; cv=none; b=GFmAJEugr/Y4+HVtIDKtIaNV2YybXBJ+epojPOaAnEtH4DABSoGO5Ir07g+qlkO4xfjy9fRjesDa0hAtHON70ak5mghikCnvpbZDW/mM3xtmNymWzKan7yumP4uIwUC5KIOyuWWIr34GfgpuMYgpF0FE6lraOv6Xkdj8CEUQGXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706500179; c=relaxed/simple; bh=dEKy3mt/WPL6E30nghtcx9sbGmG9T5AiLwENf8K/kU4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P1ad4bZ35DRyD2T0EmX/9PqhaaULnHPEgHnEv4BGJFXtyRsBdhQbd5fMdYRFO2rY24MPGszQEXDkBuMSbKUajjwVhK3sanbg7CytiS/hfX1DKuBtkr0XeVaGQQdoXCj9hj9tyRl8+1md2pPPn5aV+luFeKKXHAAylBJQo1Mhupw= 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=YkSWDpE9; arc=none smtp.client-ip=134.134.136.65 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=1706500177; x=1738036177; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dEKy3mt/WPL6E30nghtcx9sbGmG9T5AiLwENf8K/kU4=; b=YkSWDpE9tyBGA5FfOKWzW1b5QzoNiyQOT66lNbAaAGItk52EOsOtc27a AMxDWBdsEq4/Lp0JFqv0buZioATFtDNWmSR4BSD3t3C2eYZyOx+rJP8UW UGuuzSTbHo9AO+aUbltn0K3N9c30awnkN+14SLE7qn9r+It68OCtwxP5T 51qmF8y0gy11xSXH/d+C8NXKclzY+l1OKb/griBzWcdIHp3AF1pEssiIM a0SUwSIV25B4HTw20S9K+s6FFuP0S4nVi/0IcJHBBAG1GOK5mlDNWBfMN MONTfTWebBaTd0NY4KI3LP8AwZ03NSDMR9oYxmNLGjLeTHH9tuDm4nDZf g==; X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="406566895" X-IronPort-AV: E=Sophos;i="6.05,226,1701158400"; d="scan'208";a="406566895" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2024 19:49:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="960775187" X-IronPort-AV: E=Sophos;i="6.05,226,1701158400"; d="scan'208";a="960775187" Received: from unknown (HELO ply01-vm-store.amr.corp.intel.com) ([10.238.153.201]) by orsmga005.jf.intel.com with ESMTP; 28 Jan 2024 19:49:32 -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 v12 1/5] PCI: make pci_dev_is_disconnected() helper public for other drivers Date: Sun, 28 Jan 2024 22:49:20 -0500 Message-Id: <20240129034924.817005-2-haifeng.zhao@linux.intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240129034924.817005-1-haifeng.zhao@linux.intel.com> References: <20240129034924.817005-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