Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp648445lqt; Thu, 6 Jun 2024 14:11:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKIQb+BTLai6oGtCCYmIRMs25r3e7meQwhXub6CehpCJclAPrbWUbE1gCBfmDOmNqhelfi3APVBDHIKdco1rCotH7972v1fnzKXuiPxA== X-Google-Smtp-Source: AGHT+IH9MJAowt69WFXusYXSqjvBjhl6MaHnXaWtXrTFrt605ZTSuqiu1CXQpEaeUZSJ6OwB/mwc X-Received: by 2002:a17:903:98d:b0:1f6:70b7:2f80 with SMTP id d9443c01a7336-1f6d02cf1afmr11178075ad.7.1717708260064; Thu, 06 Jun 2024 14:11:00 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd8336d0si17023385ad.643.2024.06.06.14.10.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 14:11:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205033-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=DUUoGUVc; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-205033-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205033-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.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 F2B9E287230 for ; Thu, 6 Jun 2024 21:10:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3AD3196C85; Thu, 6 Jun 2024 21:10:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="DUUoGUVc" Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2058.outbound.protection.outlook.com [40.107.241.58]) (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 EB7261BDEF; Thu, 6 Jun 2024 21:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.58 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717708249; cv=fail; b=iC9cP7QgNfwrxNx9dTeDKQLi5c9Tc2FN5Rvd5C/W59wdSYjlA4/O98xDuud5zr9AJsTulO4UfQc+jbYFVSLGg8/U/me4d6AXATUu9IC7a2lR3H3C2Gi17JLi2XnVYF4N6AYMikrKm5Bt+s9psTmwLcGAqzcc8nIpVrQGTW7D+bs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717708249; c=relaxed/simple; bh=sc/W3ZGLU6emYBsb8gg7QIEFeBry2xuOgQ0hqq4aaT0=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=D9oXu48UsB5CpkPOoCMcZr+Kke9Fe5Rh3cKiKgRKEsp1ACf4lpHE4Jzs6o/RWGC7StFBBI7V5T/8FpoexcR+2zyM2qa9w/5/ePBqFRPiZTnC/EiMQvAOs3XjifGfeVC55ETvHn2wdxOLo3AasooMDQ22HFLwpXXx7slbv5VkDo8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=DUUoGUVc; arc=fail smtp.client-ip=40.107.241.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CbKyAYUzLjzd81SlrjO9K2Fm/VqOHuH+5aN3GLdAgz14rVHnPHEPs3dRI7vhNVV3Nox3fo5HaQvb7V12Ls0zBqp9DCvXreTzG7tXrlIxKk+X8L4sZ/RYgp9OF8Vz7pqRzCE/zHZQtbHrbstcUZ9lYW4LFZckLKrFDrHY+9Y+GGGtHEMeQI4hykF7DGY5ctVHgMF3In2TVgWiyprOZu6io7H8YjqDdbfIWfWSJBM01mExkAZ1fK/yxMFVwRllPbVJZiqd1j+BoxP5CAb0UvuSN+hrozMDmnloeTAg9tDIDSCgsgd35ZibCzwfjd/YebSLCMQWI0ZGLow5p4pSibr5/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pLjwML3+LJqJe0egmg4+SzXghL6iZlUrjvqiCwPG3WM=; b=XBpEc3nfuIpPYBqr4FXAym+0h4wi6fWETK9Z2nSiut0xAJolWLPG8JTHThNmV1zntJl3xcVTPzAUgsIqwdSOSZ7E8CRokdruc4LVM+uJ8ZSqCsTTPczdmwMcYd9zWiJQwYGKxOoY6ZdB6YZhenoIO/kZv0MWz0nyTyyL79+V58hoCowSTl01mwPvu9DcC9mLBjHZi6+4bEy+ywbYcxbe6lUwx3T2xAqeTSw3exO7TbY8YdqDVhlzEPxkzsCvTE+HhIyI4oC2zKeEBMpPNeBlKOO4gQ2FEVoN/gs0eRAKaJkHCFYSzmo3YgUlVF3haMI9cvWy7a9z7JyTtZ4CnwmI8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pLjwML3+LJqJe0egmg4+SzXghL6iZlUrjvqiCwPG3WM=; b=DUUoGUVcYK4bjDs4WFZ/CBM+4l//Yl9hNUvk7wXYQENMWU+UtgAMhtUc3vaCcFwwFSmLME0a3v8Wbboi4UT8TDt96WV7T83Osez9lteRwzNVCj1d+HSFh0E11Q14ZzU2JiNRlapo1vym68c1rOSjBoh+emvEAC5sxcV81/2fDo4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PA1PR04MB10208.eurprd04.prod.outlook.com (2603:10a6:102:454::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.33; Thu, 6 Jun 2024 21:10:42 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.7633.021; Thu, 6 Jun 2024 21:10:42 +0000 Date: Thu, 6 Jun 2024 17:10:29 -0400 From: Frank Li To: Manivannan Sadhasivam Cc: Vignesh Raghavendra , Siddharth Vadapalli , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Minghuan Lian , Mingkai Hu , Roy Zang , Jesper Nilsson , Jingoo Han , Srikanth Thokala , Marek Vasut , Yoshihiro Shimoda , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Kishon Vijay Abraham I , linux-omap@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@axis.com, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-tegra@vger.kernel.org, mhi@lists.linux.dev, Niklas Cassel Subject: Re: [PATCH 2/5] PCI: endpoint: Introduce 'epc_deinit' event and notify the EPF drivers Message-ID: References: <20240606-pci-deinit-v1-0-4395534520dc@linaro.org> <20240606-pci-deinit-v1-2-4395534520dc@linaro.org> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240606-pci-deinit-v1-2-4395534520dc@linaro.org> X-ClientProxiedBy: SJ0PR13CA0188.namprd13.prod.outlook.com (2603:10b6:a03:2c3::13) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PA1PR04MB10208:EE_ X-MS-Office365-Filtering-Correlation-Id: f9585b62-22e6-40bb-3067-08dc866d1fcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|7416005|52116005|376005|1800799015|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?imY6PnzkWIsks1J2DWujzNdheRbLCnZNtaA0GHhRbzyeV+aUfUF4T+Pa4gWq?= =?us-ascii?Q?KX9m/nzGUg/JF+LaxnOd0YZcVrCMILs1b3XBWZBBzSc8KKgyXtTGZv/JAq4W?= =?us-ascii?Q?B5po1zM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SmfpEH2o7aNHEdcpI45o2M?= =?us-ascii?Q?zhOuJa8qJiRkMbh5VOsmmZNU2mUo8Q8SSJbatoxxxJk6vLly6ocx1qjb11Ni?= =?us-ascii?Q?fBv3bsFb78XvQ7Be59MEd2uj9YAoTKMsJDlREmaiWZhaa7n4LH1Ur9O/N9iw?= =?us-ascii?Q?0YbHrNwYzRlxvG5lp10l/37+62xLfkvj0EwwKO+fhnlAMv9Ld0Aakx5ewXzp?= =?us-ascii?Q?454KrLrpFVkTMzIKIF35xjNiTU+jxFdwtp1lTJZYoKCs4OZaqEwb+e1MKVf4?= =?us-ascii?Q?I//K2Go8TZglvcCi+31a+Yl2LWifA1KmZn8if5R/3xUy6QdDH3qT7xNfbRBN?= =?us-ascii?Q?kpaKO5WfKIuqAlljL3o9SYY+BBjsbfxW65KnxtaUe7p+Ik8jw2+iYbPnSt2c?= =?us-ascii?Q?/szKkbo=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(7416005)(52116005)(376005)(1800799015)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pDhM/hW/FbWSQ/bthLswklRDmLtj9asDyCQRpqHu6xHbcB3rlad+rwPSSLjB?= =?us-ascii?Q?k2baVqoLi3N+6Xon2JY8JhLACI8u1k8S2Feso46u517OMSwgHGNjs3QKEhlY?= =?us-ascii?Q?4mNVO30fVacJt1SSw2sfYu+VSnGN6QTpaNkX+aeLChAosm26xWKyH2WJxcVT?= =?us-ascii?Q?i1cCp73pgbKq17eMYKIyOqr5MSIBufWstW7DpKvVsfZjl7tCVVd2MlGRe2JU?= =?us-ascii?Q?F+kYnoYhEW+ITd6Jrj7dL5TtBwkum9fQeRT0MugihGzk7J5r2J7Re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gtVT4tZssNopUIgDp86GWePDphTr?= =?us-ascii?Q?+61CavN00T0er3r7hJcLLpGyrnBFLKT907nLi4BtmhHUxXdW2hVacZsdfWEE?= =?us-ascii?Q?7ENRPM5AjWYny/LYjqIG4qSiJqA1aUTnZXsWrbE1HXXxFwpA7wJ/y8d6p4GZ?= =?us-ascii?Q?MSt+CBL7HGmaRTIFtUpIj8gMpwxFltjEDNeHTkdAcm/0Hqj/j8exwFR0uPAv?= =?us-ascii?Q?WpQj6FocuVlVhcellWSpP3/0t2bDiv1HswN1X5tc7wjTmucFynpCCSVEnJx0?= =?us-ascii?Q?vXslR+lUaSG4MmPE/JPrRzNiVOidUIdECKxSWBejJ9H0nJ7x2s1qohRcP6XN?= =?us-ascii?Q?zjDyRVfkFFtmLgFC327IoXEEpvCwh/MsgXhNlicLnKXIIoXriTwSKCy8nB1c?= =?us-ascii?Q?jpKcPp09j3iVRU01TG4=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9585b62-22e6-40bb-3067-08dc866d1fcc X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 21:10:42.3718 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: L7bt6Tm2qzfEz4k3+o+nNFIX6XnQrhsskUdRmtbHritonSUiDhaN0OPH9ZC9LbtnJHu8YLFpHuFA1ZuTtdI6eg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10208 On Thu, Jun 06, 2024 at 12:56:35PM +0530, Manivannan Sadhasivam wrote: > As like the 'epc_init' event, that is used to signal the EPF drivers about > the EPC initialization, let's introduce 'epc_deinit' event that is used to > signal EPC deinitialization. > > The EPC deinitialization applies only when any sort of fundamental reset > is supported by the endpoint controller as per the PCIe spec. > > Reference: PCIe Base spec v5.0, sections 4.2.4.9.1 and 6.6.1. > > Currently, some EPC drivers like pcie-qcom-ep and pcie-tegra194 support > PERST# as the fundamental reset. So the 'deinit' event will be notified to > the EPF drivers when PERST# assert happens in the above mentioned EPC > drivers. > > The EPF drivers, on receiving the event through the epc_deinit() callback > should reset the EPF state machine and also cleanup any configuration that > got affected by the fundamental reset like BAR, DMA etc... > > This change also warrants skipping the cleanups in unbind() if already done > in epc_deinit(). > > Reviewed-by: Niklas Cassel > Signed-off-by: Manivannan Sadhasivam Reviewed-by: Frank Li > --- > drivers/pci/controller/dwc/pcie-designware-ep.c | 1 - > drivers/pci/controller/dwc/pcie-qcom-ep.c | 1 + > drivers/pci/controller/dwc/pcie-tegra194.c | 1 + > drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++ > drivers/pci/endpoint/functions/pci-epf-test.c | 17 +++++++++++++++-- > drivers/pci/endpoint/pci-epc-core.c | 25 +++++++++++++++++++++++++ > include/linux/pci-epc.h | 13 +++++++++++++ > include/linux/pci-epf.h | 2 ++ > 8 files changed, 76 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c > index 2e69f81baf99..78d5fc72c9cb 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > @@ -620,7 +620,6 @@ void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep) > struct dw_pcie *pci = to_dw_pcie_from_ep(ep); > > dw_pcie_edma_remove(pci); > - ep->epc->init_complete = false; > } > EXPORT_SYMBOL_GPL(dw_pcie_ep_cleanup); > > diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c > index 4d2d7457dcb3..2324e56c9bfc 100644 > --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c > +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c > @@ -507,6 +507,7 @@ static void qcom_pcie_perst_assert(struct dw_pcie *pci) > return; > } > > + pci_epc_deinit_notify(pci->ep.epc); > dw_pcie_ep_cleanup(&pci->ep); > qcom_pcie_disable_resources(pcie_ep); > pcie_ep->link_status = QCOM_PCIE_EP_LINK_DISABLED; > diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c > index 432ed9d9a463..4ca7404246a3 100644 > --- a/drivers/pci/controller/dwc/pcie-tegra194.c > +++ b/drivers/pci/controller/dwc/pcie-tegra194.c > @@ -1715,6 +1715,7 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie) > if (ret) > dev_err(pcie->dev, "Failed to go Detect state: %d\n", ret); > > + pci_epc_deinit_notify(pcie->pci.ep.epc); > dw_pcie_ep_cleanup(&pcie->pci.ep); > > reset_control_assert(pcie->core_rst); > diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c > index 205c02953f25..5832989e55e8 100644 > --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c > +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c > @@ -764,6 +764,24 @@ static int pci_epf_mhi_epc_init(struct pci_epf *epf) > return 0; > } > > +static void pci_epf_mhi_epc_deinit(struct pci_epf *epf) > +{ > + struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf); > + const struct pci_epf_mhi_ep_info *info = epf_mhi->info; > + struct pci_epf_bar *epf_bar = &epf->bar[info->bar_num]; > + struct mhi_ep_cntrl *mhi_cntrl = &epf_mhi->mhi_cntrl; > + struct pci_epc *epc = epf->epc; > + > + if (mhi_cntrl->mhi_dev) { > + mhi_ep_power_down(mhi_cntrl); > + if (info->flags & MHI_EPF_USE_DMA) > + pci_epf_mhi_dma_deinit(epf_mhi); > + mhi_ep_unregister_controller(mhi_cntrl); > + } > + > + pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no, epf_bar); > +} > + > static int pci_epf_mhi_link_up(struct pci_epf *epf) > { > struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf); > @@ -898,6 +916,7 @@ static void pci_epf_mhi_unbind(struct pci_epf *epf) > > static const struct pci_epc_event_ops pci_epf_mhi_event_ops = { > .epc_init = pci_epf_mhi_epc_init, > + .epc_deinit = pci_epf_mhi_epc_deinit, > .link_up = pci_epf_mhi_link_up, > .link_down = pci_epf_mhi_link_down, > .bus_master_enable = pci_epf_mhi_bus_master_enable, > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c > index e771be7512a1..7c2ed6eae53a 100644 > --- a/drivers/pci/endpoint/functions/pci-epf-test.c > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c > @@ -782,6 +782,15 @@ static int pci_epf_test_epc_init(struct pci_epf *epf) > return 0; > } > > +static void pci_epf_test_epc_deinit(struct pci_epf *epf) > +{ > + struct pci_epf_test *epf_test = epf_get_drvdata(epf); > + > + cancel_delayed_work(&epf_test->cmd_handler); > + pci_epf_test_clean_dma_chan(epf_test); > + pci_epf_test_clear_bar(epf); > +} > + > static int pci_epf_test_link_up(struct pci_epf *epf) > { > struct pci_epf_test *epf_test = epf_get_drvdata(epf); > @@ -803,6 +812,7 @@ static int pci_epf_test_link_down(struct pci_epf *epf) > > static const struct pci_epc_event_ops pci_epf_test_event_ops = { > .epc_init = pci_epf_test_epc_init, > + .epc_deinit = pci_epf_test_epc_deinit, > .link_up = pci_epf_test_link_up, > .link_down = pci_epf_test_link_down, > }; > @@ -905,10 +915,13 @@ static int pci_epf_test_bind(struct pci_epf *epf) > static void pci_epf_test_unbind(struct pci_epf *epf) > { > struct pci_epf_test *epf_test = epf_get_drvdata(epf); > + struct pci_epc *epc = epf->epc; > > cancel_delayed_work(&epf_test->cmd_handler); > - pci_epf_test_clean_dma_chan(epf_test); > - pci_epf_test_clear_bar(epf); > + if (epc->init_complete) { > + pci_epf_test_clean_dma_chan(epf_test); > + pci_epf_test_clear_bar(epf); > + } > pci_epf_test_free_space(epf); > } > > diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c > index 56b60330355d..47a91dcb07d7 100644 > --- a/drivers/pci/endpoint/pci-epc-core.c > +++ b/drivers/pci/endpoint/pci-epc-core.c > @@ -774,6 +774,31 @@ void pci_epc_notify_pending_init(struct pci_epc *epc, struct pci_epf *epf) > } > EXPORT_SYMBOL_GPL(pci_epc_notify_pending_init); > > +/** > + * pci_epc_deinit_notify() - Notify the EPF device about EPC deinitialization > + * @epc: the EPC device whose deinitialization is completed > + * > + * Invoke to notify the EPF device that the EPC deinitialization is completed. > + */ > +void pci_epc_deinit_notify(struct pci_epc *epc) > +{ > + struct pci_epf *epf; > + > + if (IS_ERR_OR_NULL(epc)) > + return; > + > + mutex_lock(&epc->list_lock); > + list_for_each_entry(epf, &epc->pci_epf, list) { > + mutex_lock(&epf->lock); > + if (epf->event_ops && epf->event_ops->epc_deinit) > + epf->event_ops->epc_deinit(epf); > + mutex_unlock(&epf->lock); > + } > + epc->init_complete = false; > + mutex_unlock(&epc->list_lock); > +} > +EXPORT_SYMBOL_GPL(pci_epc_deinit_notify); > + > /** > * pci_epc_bus_master_enable_notify() - Notify the EPF device that the EPC > * device has received the Bus Master > diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h > index 11115cd0fe5b..85bdf2adb760 100644 > --- a/include/linux/pci-epc.h > +++ b/include/linux/pci-epc.h > @@ -197,6 +197,8 @@ struct pci_epc_features { > > #define to_pci_epc(device) container_of((device), struct pci_epc, dev) > > +#ifdef CONFIG_PCI_ENDPOINT > + > #define pci_epc_create(dev, ops) \ > __pci_epc_create((dev), (ops), THIS_MODULE) > #define devm_pci_epc_create(dev, ops) \ > @@ -226,6 +228,7 @@ void pci_epc_linkup(struct pci_epc *epc); > void pci_epc_linkdown(struct pci_epc *epc); > void pci_epc_init_notify(struct pci_epc *epc); > void pci_epc_notify_pending_init(struct pci_epc *epc, struct pci_epf *epf); > +void pci_epc_deinit_notify(struct pci_epc *epc); > void pci_epc_bus_master_enable_notify(struct pci_epc *epc); > void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf, > enum pci_epc_interface_type type); > @@ -272,4 +275,14 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc, > phys_addr_t *phys_addr, size_t size); > void pci_epc_mem_free_addr(struct pci_epc *epc, phys_addr_t phys_addr, > void __iomem *virt_addr, size_t size); > + > +#else > +static inline void pci_epc_init_notify(struct pci_epc *epc) > +{ > +} > + > +static inline void pci_epc_deinit_notify(struct pci_epc *epc) > +{ > +} > +#endif /* CONFIG_PCI_ENDPOINT */ > #endif /* __LINUX_PCI_EPC_H */ > diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h > index dc759eb7157c..0639d4dc8986 100644 > --- a/include/linux/pci-epf.h > +++ b/include/linux/pci-epf.h > @@ -71,12 +71,14 @@ struct pci_epf_ops { > /** > * struct pci_epc_event_ops - Callbacks for capturing the EPC events > * @epc_init: Callback for the EPC initialization complete event > + * @epc_deinit: Callback for the EPC deinitialization event > * @link_up: Callback for the EPC link up event > * @link_down: Callback for the EPC link down event > * @bus_master_enable: Callback for the EPC Bus Master Enable event > */ > struct pci_epc_event_ops { > int (*epc_init)(struct pci_epf *epf); > + void (*epc_deinit)(struct pci_epf *epf); > int (*link_up)(struct pci_epf *epf); > int (*link_down)(struct pci_epf *epf); > int (*bus_master_enable)(struct pci_epf *epf); > > -- > 2.25.1 >