From patchwork Fri Mar 1 08:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ethan Zhao X-Patchwork-Id: 208724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp958727dyb; Fri, 1 Mar 2024 01:25:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV7/gp/6YtkFePblZqOTROyjeFNNKc8Lp3e9YhjKdf7MOnqP54tZeijbLIPW4umo/8ol3xPmZqQj0sOrQ1uDhmWnez65Q== X-Google-Smtp-Source: AGHT+IGMcj/4sWh8v+7rWhG2J1hXcHML7xg8KIEEUJRQFbIPrDP/aFfO3Cg3xJmN88pSDmxhkhvf X-Received: by 2002:a05:6902:1b8c:b0:dc6:e4f8:7e22 with SMTP id ei12-20020a0569021b8c00b00dc6e4f87e22mr953751ybb.62.1709285127635; Fri, 01 Mar 2024 01:25:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709285127; cv=pass; d=google.com; s=arc-20160816; b=jtDRNH651p1PXxq68kJ4bM+Q8QEikfiBOgV8Ozf1+lwAzmVGJu+bXYvzkzRRLKZuoC ZClXjDxPgnIUshj9HbBv5KinDyhhpQpBjwCx++bQOUU39P1s5mwwhGH6cYyVnaqCVmFR 6uqTTS+AtDzgxt3KzJg34+v/b/tLiWIDg9AGGWMpNXoUrXA9YqfohIb9Q6kwSvPPZvyU 4G4Nk4uw2XGgC2u74a/g7aTdgO1mzLTGHwHwOkWk4wCRjsCeTwOYAk8OE3Pkl4Y0w43v oKt0120wtS3GDYMomS6PRfwh/yhijnrl4i+F7wCZ05zufsJIIeOJ4y18IwpFSZzNBzhg 4GHA== 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=wVLUY6uexEL9HY1IoqK/QnGh5sISAxBHmncIqdpdPYw=; fh=xE3dbeCWHXQ1zGGCAmqLTBZLDIu+JNxMIyyE3BBk0xI=; b=BDgORZUKpLT3du+pVaEtlZjBo4hs1wO21gmPeiRbCfDvXnBYqtGFw/tHj00BEm13I5 FTrSIxwYeiSaTlO5vFjzUIT7Ks/tR7AH1i+Xvm3V8BMsxLlT5R2muXqev8/Ez+0oZcEj Dj4WXcwBWjsK+bZqARHMzzCj3U9TmxzXWR2RSSOJ7cqaMbJn+y8OBgi1zUt2jabbYsX1 XbxweZeou2Z8sTidT6CfuycqePXvG0idnzK6m4Y+8AId10F17uAKm8XEU9QC77PWgYWI Dfy2rQHPgK30O0QkHTeFCoDfO9BNjzAZJlhBqSZi1wzCXfNyDRHPQ+dBn8ZL4AOsKXXr 4KYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Isp2xshy; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-88049-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88049-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pi18-20020a0562144a9200b0069037cbb6efsi3242138qvb.243.2024.03.01.01.25.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 01:25:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88049-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Isp2xshy; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-88049-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88049-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 533841C232AB for ; Fri, 1 Mar 2024 08:08:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A10E669DED; Fri, 1 Mar 2024 08:07:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Isp2xshy" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 96A0B69D1B for ; Fri, 1 Mar 2024 08:07:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709280470; cv=none; b=QySljJIhTuOpEYqjPctx+caNSjlNOokD+xtlpqEstY3QeGW0oEl/6cYSBSbde/i9OQ/ge/+GqSQT6IsUghjb8OKu2NRLodn3G2VPR7ffDEevF0mvEhQDkkiBX40WPDrNQf9qjFB+Wx8a7FHmMnjvLjACW0SgtnPHwH0ckvnz+us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709280470; c=relaxed/simple; bh=2TzLf4OIt1MGytd6q5pU6ETsxdGfZl7KkNocynO4NGg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p8+JD4MUCM91nkxc+j3/S/jz8bRNFHRJ4OP3hu9vschOB40sY08yeXgw7TpbU9PJVfr32RyD4ep2/eCbeu62bCKDXJXfxKEsXqfQqyxnZ4At//XAr4/OKDu8io/PltEjLwWd7llajbgZxeUtJ5ul/+IlBV+GuIWf+j8vO3QzsuY= 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=Isp2xshy; arc=none smtp.client-ip=198.175.65.12 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=1709280469; x=1740816469; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2TzLf4OIt1MGytd6q5pU6ETsxdGfZl7KkNocynO4NGg=; b=Isp2xshyrWtXRPmRQEPgijPgoxA3ViiExPQCAUruZod3jKsHNPHnmVOb hNj+yXeoUk8QV8CnE2cxOFeFufQ+XDfkvfg5HMcW+CnULHAv+RtjnXjWj bDeRHG6Tkv+nsbgdS54N+hXPKeRS6yyn0KePK2819UdQDjZ+IIe8Qc12o 5ijY7c1rWuAziDwBshANP7WwXTYYqfiBWt9vsZ46eNY/+hzifK2aEGo1A LpwoLEdcKdB+ycIZui314Qllppmx7Y7svic4/K8grKCnMkXTPW1SuCGEh mesveGGE27VN1tpXD7DeLzBwA0RpCv2HunzQDYxpih/xKdFjsAYwQn1Rh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="15240404" X-IronPort-AV: E=Sophos;i="6.06,195,1705392000"; d="scan'208";a="15240404" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 00:07:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,195,1705392000"; d="scan'208";a="8187467" Received: from unknown (HELO ply01-vm-store.amr.corp.intel.com) ([10.238.153.201]) by orviesa009.jf.intel.com with ESMTP; 01 Mar 2024 00:07:44 -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, dan.carpenter@linaro.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Ethan Zhao , Haorong Ye Subject: [PATCH v14 1/3] PCI: make pci_dev_is_disconnected() helper public for other drivers Date: Fri, 1 Mar 2024 03:07:25 -0500 Message-Id: <20240301080727.3529832-2-haifeng.zhao@linux.intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240301080727.3529832-1-haifeng.zhao@linux.intel.com> References: <20240301080727.3529832-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792315362037512070 X-GMAIL-MSGID: 1792315362037512070 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 --- 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 e9750b1b19ba..bfc56f7bee1c 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 7ab0d13672da..213109d3c601 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2517,6 +2517,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,