Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1311021rwi; Thu, 13 Oct 2022 11:51:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6khqZAcOUeQzkW4fOSCYUVJ3GdHAokzt0ZGxrFljfpIfzDSu1UkFOcHslr0TZmLURKEBpD X-Received: by 2002:a63:1317:0:b0:42a:e7a5:ef5a with SMTP id i23-20020a631317000000b0042ae7a5ef5amr1146054pgl.392.1665687109145; Thu, 13 Oct 2022 11:51:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665687109; cv=pass; d=google.com; s=arc-20160816; b=s0wcSnDMGwbQi5yMOyP81UB327z02A9Dx+RHeBPAVVde0AQ5EyBywlijNHmhC3yJxI 8w4YevJudvpDcEFRvnAdmCPouMexrb9Bt41Ieyj0gIyW8l55fF/+TTFKkLpou2OBQ8qS aJD46P9+yc7LzH12q6x2FVMVOB+jpQqB/Dlcx8U2n4W0tOjp4VzLWvGbZm0BAu+NgUrN 4JPG4v6YS2ONVEYNbUPhIm/BcO/eDwc/jn8FEmzXPijem/YRXNSPxFf9i1UOc08terO/ 3esETgDDzkc+0pteULvIQM5JiKYuvI0aWY2/24jLr9MPb8jV3i26pmcvLORNmplmhcrE 6Yqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=S3cy18Z3zPwKeR82/S2tMeEOQVTTzj1T9s1HDYRLS5g=; b=qNYgPk/9fTI6DvoGXnkqXBIZr7fdgUEpAiV1rLv7YviWIY4ffWkqyRptMsPX5ZqLyS Y8HqoJi+uNSkmN0tnhQazuxUM7Vc0HKghs7CD1joWXTkAIygy3ijvYb/OoxElc00V97v B5SAwTfCGnXOooh0gD9Sp51RGixFQ91MRT15VZ5X8dJFtlVjxw/W1Egt5X67XfqRsSUC dqtPR5JTm6jFTCMMhr9fYKelaB9yIcw1uNZFdFxp5l2mXG8K1pqr2Y/x7ceCZrjtI91P aTtCtRqXrDVDtkBZAR/E2r75PAujoeICA6+CqZfZeSl3jn+ESnGk9sw9dNXsVU2fZZTm bigg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=hOdUDO1V; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q32-20020a17090a4fa300b00202c7f4631esi6474683pjh.19.2022.10.13.11.51.37; Thu, 13 Oct 2022 11:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=hOdUDO1V; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231947AbiJMSak (ORCPT + 99 others); Thu, 13 Oct 2022 14:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbiJMSaA (ORCPT ); Thu, 13 Oct 2022 14:30:00 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2061f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::61f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AE03182C78; Thu, 13 Oct 2022 11:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UF4abMpEEpJm3oc2xaX/CkOcuPFNXitfphtL4b0XTjqWawFbL/UfwW3puQD/uCFMCHApFKe6RXkKQH/DGTImouwRaPdRjtN+7mh85rPx7eojZUMB9L+iEQ3hyuv09F/bmzQH2oHEYiNAIl2Aa54ZQMyJ82XVH17M0jMMbnZ+J3/u0fLbBu5L2EN0gwZAByq7iy4XQ2vmoO0M/Qwlc9KPCz5FDcL/HN4QMZ725Q6krbEX0G/Ejc/k1RUD0EUb5ca9vH4ecPDARiDNtfQk2SKAT35fEzdTzLNcZ5xr59EmnH4AZbcKXQ6jTogp0r8/zVVQkjM4E0iJaOGdqGHd/uNy3A== 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=S3cy18Z3zPwKeR82/S2tMeEOQVTTzj1T9s1HDYRLS5g=; b=eC9ST6jx8qkMqnTOPN332cPFlK3atWcSX122ukVDTvpTWshb8eca3G/yruQKdyVnVkC+tr/cWFCZCEkc80mtUbXJxvmRLXzpdv2MrlFh6IXeXQSze2VY9r4QzF0RwH3fYQ52Fg1OoRwMFxZUoSxCcxi9WW6o+4dwlnFWKOmmjuZbrOqfL817MkDbrImSkdFf502xe+QrLBenRizVLo5Y4O5K0m2jjyJNvER7ODGS9FxcJHdvkXGyeG46scAp4KDZxF8Bsgvykw3eaiTv2efopsO8WCQD8SiBjqIfYE+zkUVq9ZF3gH89zR55EaOnmQgcLye+NTwSKUq0og2ju1AB7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S3cy18Z3zPwKeR82/S2tMeEOQVTTzj1T9s1HDYRLS5g=; b=hOdUDO1VLeaqAykWwCcq9e2GzAzinu5ZHk0JR+dNE/I4bDKlSQW/Jd+JJ8BMY9FAc+8UFdHX1ynGkNv7Tk24SOWaG3B540XBdERx7BNFxQKB/YeknYNg6BvpUyAQFy0FlAEghjtxQ+QRdkvTKorY//zg9LgL/qSaDVKurvERHdUuTMFbbfTkaYFh0OUHiGmRk3W5pFzskLIVTPJreYN94oDMWZNipWHtOOeBHCywq7ZKHxrx+MPP5xla1vuMTlUQL/FVtDVQhO0C5cR/aAbBojybmyEex3njsgLxQErAFnNZP0ESbQV2uiH6Lv/1Z/qQ5jCgyl8NbebVGXZ9CoL8Mw== Received: from MN2PR20CA0032.namprd20.prod.outlook.com (2603:10b6:208:e8::45) by SJ0PR12MB5662.namprd12.prod.outlook.com (2603:10b6:a03:429::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.22; Thu, 13 Oct 2022 18:18:48 +0000 Received: from BL02EPF0000C408.namprd05.prod.outlook.com (2603:10b6:208:e8:cafe::e1) by MN2PR20CA0032.outlook.office365.com (2603:10b6:208:e8::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.22 via Frontend Transport; Thu, 13 Oct 2022 18:18:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF0000C408.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Thu, 13 Oct 2022 18:18:47 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 13 Oct 2022 11:18:27 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 13 Oct 2022 11:18:27 -0700 Received: from vidyas-desktop.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Thu, 13 Oct 2022 11:18:23 -0700 From: Vidya Sagar To: , , , , , , , CC: , , , , , , , Subject: [PATCH V2 1/4] PCI: endpoint: Add core_deinit() callback support Date: Thu, 13 Oct 2022 23:48:12 +0530 Message-ID: <20221013181815.2133-2-vidyas@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221013181815.2133-1-vidyas@nvidia.com> References: <20221013181815.2133-1-vidyas@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C408:EE_|SJ0PR12MB5662:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f80a3fe-7389-45c7-b950-08daad475f03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xyfLdC1ghsCjwj2KttnmouswCn7SIO0rxAV3BQU75eEa+nbPgt8dKxv22FRPSgyJysE8JU4i8shTxhtUiUlD/FTYQnE0cn8in3gT0vOvnxzs7fp8m5D+9oAmmn1DyhNXZUqnk0LcMoqkOpHqcrEKfdgbVlyhD9fo3d0jCy+LNPHmsNYoqvJqiIUb1blz8Ga7M76DZbfy87CXRutJr1EgqewMyVSM2SQo11/G4AJTIZOqJ+F7CXQsI3Ly8IM00I52DLF8J7fodWdZXpzqv0LZ1IZe0P9GVrD50xY6ljj0uEraWXDeor1FFZdh1C8MYYZ0Qb6BhzVqgI+HdJHdtNre9DYSMWyLWp/33Dk6T4flMnVdN8JkxAY5RlhMgW0srQOe9qLqSJmT6KK8N6Tl030jfYOE7K85ezIan0h7Y5UyKm88ByOzcquh4TRVS/HqaWYa+E/DYDaS8M7XvheMuCQOJyu5Y8GvRRIWhR8HhQjx+oAE7TpPqof3XH1F9xDyz/vk4czlV7ePqbON52HiaxJBeW1Ff6EmzhPbB/KxVWevzJNxk0YJDjItQux5lM/3cJSHV5gb7QW9SQAkWgVlPq/fBFa1yRd8fst7B+p9kApg0MhO1E8Lor3hphD8TkAft5i6lEIwwnrAswEqAUlSLpDRt11C4wqkIOnEkPupTUtjSylkBQOBvvkvAY7OLld9Vww03d2/E1aCP4dMb84r/IxIZoiyfHPGpZIOU1lsTAUvIJ1IoJ/WwCXU/j2vEdtxFtqDP4Ni/WIQNWKTbmTPm59lyg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199015)(36840700001)(40470700004)(46966006)(478600001)(7696005)(26005)(70206006)(70586007)(82740400003)(8676002)(5660300002)(41300700001)(36756003)(54906003)(316002)(110136005)(86362001)(6666004)(4326008)(40460700003)(7636003)(47076005)(40480700001)(186003)(426003)(2616005)(36860700001)(83380400001)(1076003)(356005)(336012)(82310400005)(8936002)(7416002)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 18:18:47.2365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f80a3fe-7389-45c7-b950-08daad475f03 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0000C408.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5662 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The endpoint function driver should undo the things done in core_init() and stop hardware access before deinitializing the controller. Add core_deinit() callback support for function driver to do this cleanup. This core_deinit() callback should be invoked by the controller driver before deinitializing the controller. Signed-off-by: Vidya Sagar --- V2: * Reworded the commit message drivers/pci/endpoint/pci-epc-core.c | 26 ++++++++++++++++++++++++++ include/linux/pci-epc.h | 1 + include/linux/pci-epf.h | 2 ++ 3 files changed, 29 insertions(+) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 5dac1496cf16..689450f01f75 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -732,6 +732,32 @@ void pci_epc_init_notify(struct pci_epc *epc) } EXPORT_SYMBOL_GPL(pci_epc_init_notify); +/** + * pci_epc_deinit_notify() - Notify the EPF device that EPC device's core + * deinitialization is scheduled. + * @epc: the EPC device whose core deinitialization is scheduled + * + * Invoke to Notify the EPF device that the EPC device's deinitialization + * is scheduled. + */ +void pci_epc_deinit_notify(struct pci_epc *epc) +{ + struct pci_epf *epf; + + if (!epc || IS_ERR(epc)) + return; + + mutex_lock(&epc->list_lock); + list_for_each_entry(epf, &epc->pci_epf, list) { + mutex_lock(&epf->lock); + if (epf->event_ops->core_deinit) + epf->event_ops->core_deinit(epf); + mutex_unlock(&epf->lock); + } + mutex_unlock(&epc->list_lock); +} +EXPORT_SYMBOL_GPL(pci_epc_deinit_notify); + /** * pci_epc_destroy() - destroy the EPC device * @epc: the EPC device that has to be destroyed diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 301bb0e53707..b95dc4b3e302 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -204,6 +204,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf, enum pci_epc_interface_type type); void pci_epc_linkup(struct pci_epc *epc); void pci_epc_init_notify(struct pci_epc *epc); +void pci_epc_deinit_notify(struct pci_epc *epc); void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf, enum pci_epc_interface_type type); int pci_epc_write_header(struct pci_epc *epc, u8 func_no, u8 vfunc_no, diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index a215dc8ce693..fa51579951db 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -70,10 +70,12 @@ struct pci_epf_ops { /** * struct pci_epf_event_ops - Callbacks for capturing the EPC events * @core_init: Callback for the EPC initialization complete event + * @core_deinit: Callback for the EPC deinitialization schedule event * @link_up: Callback for the EPC link up event */ struct pci_epc_event_ops { int (*core_init)(struct pci_epf *epf); + int (*core_deinit)(struct pci_epf *epf); int (*link_up)(struct pci_epf *epf); }; -- 2.17.1