Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1116380rdb; Fri, 2 Feb 2024 14:26:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcpNsNsUbkHlJ11LvptxvJ/QtN+DQXmTILY+tgI+0xskalxb8fQtNKtPCn++8dBfKE8Hgx X-Received: by 2002:a62:cd4f:0:b0:6de:1d05:580c with SMTP id o76-20020a62cd4f000000b006de1d05580cmr9229888pfg.29.1706912819552; Fri, 02 Feb 2024 14:26:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX71okkqWjdPncJmO/IdGJto65gittw3syDdIf1caww0rcoYoYEmZNfsAUtoL+70CeEJ3lyp0IaCPES0dnDVglaL+yefoY1g5KhOdAoWA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g9-20020a056a0023c900b006ddc2ac59c9si2171315pfc.391.2024.02.02.14.26.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:26:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50663-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=@amd.com header.s=selector1 header.b=walwakDk; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-50663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50663-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.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 DF0A628C20D for ; Fri, 2 Feb 2024 22:26:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5E0E126F1B; Fri, 2 Feb 2024 22:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="walwakDk" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) (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 CDBD68592F; Fri, 2 Feb 2024 22:26:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.49 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706912793; cv=fail; b=VKigvCkLCosAgfbhg6Wjsy4i3YSYpJqfoLMC6xaG8G15Ew+Vk1Ag1BLZFyvb12Yd8ULyx0+XV7ZkG9DUOlrjSwnjvVFG5cSJen6PwuOQIiN7t+zaHpttD2dbuk6CbrSxjlFNac5Z8hnHWgrSATpCmqHoef3J979lvKqd/kMYBVs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706912793; c=relaxed/simple; bh=2nImcPlmt9xNOtsWqOsA3Buzzzu54pf4Zkw7W9dQwgg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mBXZf6+fXwQOz076GZZut33LuJIe9bkaDUkVa1sUlJgzpUdjYUfbEDclWB9dnn/l9qCoCG2dO3LJPxEOsyav0IvYgqO9DX/6yoA55k4tCVF2M4qMEEk+9fyVlPHNSi6yDkaKeUor9IAXXimwmFwIMCNKeLA4cmb+oRHl1mgFHZk= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=walwakDk; arc=fail smtp.client-ip=40.107.223.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JH48bPkFBpkRMAosO3CaBCm5+0ZhqKXzVxNLjwzsIqrClbMfQ+J7uWojdNCstInLdEkLL6kkvQghHfDNRmldIWLZ9BUZFbHYhYiGVS4zJrB0ZDjCop3EW6dG3qwZJXI0RDK1rGUc5+8bcbGOyQWoTUUU7wzdgtI4ROB+RVQrPeNhhvvRhj9a99sFwnG69XELc6P89bH0dg2v1+7YvZnRHU96UEEVWz0IvtBjrBZL78PGuouvH0XRCFScYQ5EVOnRBcdCaMcmnzfG1B9wpZBichxVv+BzAv8LuWbVf8y1fyqXTCmlCFf3cLJJjugHwpUZUZTMYpInJO9B5WizXdScaw== 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=lOad2c9x0ubYcdKEEjzkb2ZBRugUJFx3v8GNWcCJl8A=; b=TD8kdGr6FWnKfzb1cvps6rr4Nsl+4Ys8CHgc4ArjhCGCcbkSfI8guARvgiJQ3g3JX3P5Kyc/yoGCe6wBIsHDQxp/avRy7Dp7f1JrwMGbPwLoMl9hgwmhhhqwcUcy0tfPpnV1dmMmAnTHblK9BSeB8DB2MiXVtRLROZnD0eH+4m88FHfsQGe9Zx/s43nzmAvrqUpHPlbXEfD/iU5mepsYfMKPhOS/Iosoan8pD4q3bn+EZZ/y5OVzIkTUxOwx3gkAQXf44koWIYvugiLfr7r8PufRRi8J0DpjBx38DLvdBVEKiTfl2oPFgSl5Vk7SfjWqkMRqwrN2hunlYx9ioY0JTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lOad2c9x0ubYcdKEEjzkb2ZBRugUJFx3v8GNWcCJl8A=; b=walwakDkrvt//Gbz8HOzYpA44MlcM1pL66SOe2ePu45a3FT4NqF9YbGNvIRs6xoAthIy9IQNOCFeXHfZ5zNOUcrZivv8IWLiqBdmAW1qE/OCG4fPcR5EpiigkwFp2VTaiHQB/9BbQE2EsZOsQWxx6ByVMGAtlbsJD87Onhej2pM= Received: from CYXPR02CA0022.namprd02.prod.outlook.com (2603:10b6:930:cf::26) by PH7PR12MB7844.namprd12.prod.outlook.com (2603:10b6:510:27b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.12; Fri, 2 Feb 2024 22:26:27 +0000 Received: from CY4PEPF0000EE33.namprd05.prod.outlook.com (2603:10b6:930:cf:cafe::e0) by CYXPR02CA0022.outlook.office365.com (2603:10b6:930:cf::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.31 via Frontend Transport; Fri, 2 Feb 2024 22:26:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE33.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Fri, 2 Feb 2024 22:26:27 +0000 Received: from hamza-pc.localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 2 Feb 2024 16:26:25 -0600 From: Hamza Mahfooz To: CC: Hamza Mahfooz , , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Bjorn Helgaas , Mario Limonciello , Lijo Lazar , "Srinivasan Shanmugam" , Le Ma , =?UTF-8?q?Andr=C3=A9=20Almeida?= , James Zhu , Aurabindo Pillai , "Jason Gunthorpe" , Wei Liu , Robin Murphy , , , Subject: [PATCH 2/3] PCI: introduce can_remove() Date: Fri, 2 Feb 2024 17:25:55 -0500 Message-ID: <20240202222603.141240-2-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202222603.141240-1-hamza.mahfooz@amd.com> References: <20240202222603.141240-1-hamza.mahfooz@amd.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 Content-Type: text/plain X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE33:EE_|PH7PR12MB7844:EE_ X-MS-Office365-Filtering-Correlation-Id: e3b87e87-a491-4be0-d07a-08dc243dff5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sXJhUV6PfcJj4doUDZppvQuCy8hb9iG9z+uk4Z5AVwIF9OoYzWGMZ9xtrPP44G0b4uj4gE7su4t6D5monmzWimqYQKhSX5v37CaXk70gr9fYKZzqB9HHh/OFGt7DkdbsUjk3ljzJCxpawrOpLzItNCdaaQb2AbPOPHiPTlgWeBLmCsA/J1U9sp19VypnWmSjzxSCz6P8CpsGXQR1bnVrgO4nLZIMYLMmgo9EpvjZB2cLD0dbZaai9vUMWoJGlHGgfRerugm+QjkYXEcKZzswgFWJvdRnsmZOVS3UjzlTVPu+x+TxWMiEhdM02vsTo1/iiYaikKToFaYeof4PntongHa0jALGOSMUVV/ZD0DPKvbFqguA3x/kPh0pGJrVtZgdf20usfLqDcYZdXecjehIH6N8chif0Mi9EwMaZPE+h6rWeZJugiuA+svnh/vMCgeDPo4JyzP8SJbneNRDLWPw4EyUHrtLuh9MO69j1ZZo1iehi0Ls4AU6k/H0FovZoQdFwQIWNshUeV48cLI4vGOi1ydsJitkRrnmOZeRBi8GSASIVSgklNag7zZHxctCQFi2zC5S5uPQFmGhtUxmDHK7/yetBo/9TTcf0by5A3IfE06iAZo1sYplYEs6Hk0rIMjeoM2HuTfFRuwQ999wTGlhi1ni+RP0g6x6ttWLgHmF7b+DORKQGWEpG6wAdpdPpeSgjUgQgvscozwFzZHsCG8pkSczbtn7/CMT3fql96ts/Stxl92hWRAdzu6IyML5AxEf37LELwoi66xBo8VVMF0e/7u6BGoF37TshlQbO2kRbjTVfi7+7UXMvXPQfqar1MM9 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(396003)(136003)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(82310400011)(40470700004)(46966006)(36840700001)(6666004)(26005)(16526019)(426003)(1076003)(2616005)(6916009)(4326008)(336012)(36756003)(8936002)(2906002)(316002)(54906003)(5660300002)(8676002)(70586007)(86362001)(44832011)(70206006)(7416002)(41300700001)(478600001)(81166007)(47076005)(356005)(82740400003)(83380400001)(36860700001)(40480700001)(40460700003)(36900700001)(16060500005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 22:26:27.4486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3b87e87-a491-4be0-d07a-08dc243dff5b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE33.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7844 Wire up the can_remove() callback, such that pci drivers can implement their own version of it. Cc: stable@vger.kernel.org Signed-off-by: Hamza Mahfooz --- drivers/pci/pci-driver.c | 12 ++++++++++++ include/linux/pci.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 51ec9e7e784f..8aae484c5494 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -466,6 +466,17 @@ static int pci_device_probe(struct device *dev) return error; } +static bool pci_device_can_remove(struct device *dev) +{ + struct pci_dev *pci_dev = to_pci_dev(dev); + struct pci_driver *drv = pci_dev->driver; + + if (drv->can_remove) + return drv->can_remove(pci_dev); + + return true; +} + static void pci_device_remove(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); @@ -1680,6 +1691,7 @@ struct bus_type pci_bus_type = { .match = pci_bus_match, .uevent = pci_uevent, .probe = pci_device_probe, + .can_remove = pci_device_can_remove, .remove = pci_device_remove, .shutdown = pci_device_shutdown, .dev_groups = pci_dev_groups, diff --git a/include/linux/pci.h b/include/linux/pci.h index add9368e6314..95276f44b23b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -902,6 +902,10 @@ struct module; * (negative number) otherwise. * The probe function always gets called from process * context, so it can sleep. + * @can_remove: The can_remove() function gets called during driver + * deregistration to determine if remove() can be called. + * The probe function always gets called from process + * context, so it can sleep. * @remove: The remove() function gets called whenever a device * being handled by this driver is removed (either during * deregistration of the driver or when it's manually @@ -943,6 +947,7 @@ struct pci_driver { const char *name; const struct pci_device_id *id_table; /* Must be non-NULL for probe to be called */ int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ + bool (*can_remove)(struct pci_dev *dev); void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ int (*suspend)(struct pci_dev *dev, pm_message_t state); /* Device suspended */ int (*resume)(struct pci_dev *dev); /* Device woken up */ -- 2.43.0