From nobody Sun Feb 8 14:57:45 2026 Received: from sg-1-100.ptr.blmpb.com (sg-1-100.ptr.blmpb.com [118.26.132.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6DC436BCF6 for ; Wed, 7 Jan 2026 17:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767808630; cv=none; b=RLfxGxGBmX8Qs/JwZ/WrSLWZQ/+JRnGilH0v8rEzrtWB6NUqB9csWSkR5iLPUi/yzI9dDRhgMocfAVufbwN+nNmSl3yQYklQYccJuPV+hcN4A3HC0/U3oCj8Ahj6oPFOyDsyJo8n1nyClnlBNjqg7QzjyepR4KMQfZhynXW2oRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767808630; c=relaxed/simple; bh=ZYug4yNuU4av7KeoafX84stshFAma87Mg8qQ3P2JQKk=; h=References:Mime-Version:In-Reply-To:Cc:Message-Id:Content-Type: From:Subject:Date:To; b=Y7ZndCxubWfdwxVlArZb9Y1/Va9h4Cc9CNh1kPuqbUCOX4yJN9bTVDGOg+kPfxdEGdr+/cwy7FDW1ccX7ddYU7ojZK20DeE1H3DlB0U+qgSW717Xr8atEYrU+Q6MElitbbCa1Jss1ylgh8+LPzGSsBpDwE74sNbt+sw8BDi1pe8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=qfDtnwS+; arc=none smtp.client-ip=118.26.132.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="qfDtnwS+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1767808621; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=3lqZAckEjBHvH7t1Qq0KweacFxTKdPPI8/L7We/Rsrw=; b=qfDtnwS+ohbPccRDv/69ufj6qlXMhnB4FxeGzE8dVQWZJEA2A5Hl1kkFDfZwQQD6LiXGwk 44SxyfoPLaxN2zPsVI9ypKC/VlQxVeC+1t6FY5OWu7uCwLJfGc+DZqoCWtjT5C7K9NjR7n M8nLHtWXS9Vk6w3awho+dV63Vclqst2Yltp+pnW2HWEYK+wzGJNqQH4IM4ehx7saXrKixJ OhQE2e4a+6uExv0qrhcQ4YYlI+Qmb+RoGxKSiU6JcYdUMUQwhh0g2CvkmfSuyHa+ducLlR VjQw/1QdVCMdD4ANyBPk40HpC7Bz0WgR3RNQED4uuX6k58g/UHazRQg4gffuxQ== X-Lms-Return-Path: Content-Transfer-Encoding: quoted-printable References: <20260107175548.1792-1-guojinhui.liam@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260107175548.1792-1-guojinhui.liam@bytedance.com> Cc: , , Message-Id: <20260107175548.1792-2-guojinhui.liam@bytedance.com> From: "Jinhui Guo" Subject: [PATCH 1/3] driver core: Introduce helper function __device_attach_driver_scan() Date: Thu, 8 Jan 2026 01:55:46 +0800 X-Original-From: Jinhui Guo To: , , , , , , , , , Content-Type: text/plain; charset="utf-8" Introduce a helper to eliminate duplication between __device_attach() and __device_attach_async_helper(); a later patch will reuse it to add NUMA-node awareness to the synchronous probe path in __device_attach(). No functional changes. Signed-off-by: Jinhui Guo Reviewed-by: Danilo Krummrich --- drivers/base/dd.c | 71 ++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 349f31bedfa1..896f98add97d 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -962,6 +962,44 @@ static int __device_attach_driver(struct device_driver= *drv, void *_data) return ret =3D=3D 0; } =20 +static int __device_attach_driver_scan(struct device_attach_data *data, + bool *need_async) +{ + int ret =3D 0; + struct device *dev =3D data->dev; + + if (dev->parent) + pm_runtime_get_sync(dev->parent); + + ret =3D bus_for_each_drv(dev->bus, NULL, data, + __device_attach_driver); + /* + * When running in an async worker, a NULL need_async is passed + * since we are already in an async worker. + */ + if (need_async && !ret && data->check_async && data->have_async) { + /* + * If we could not find appropriate driver + * synchronously and we are allowed to do + * async probes and there are drivers that + * want to probe asynchronously, we'll + * try them. + */ + dev_dbg(dev, "scheduling asynchronous probe\n"); + get_device(dev); + *need_async =3D true; + } else { + if (!need_async) + dev_dbg(dev, "async probe completed\n"); + pm_request_idle(dev); + } + + if (dev->parent) + pm_runtime_put(dev->parent); + + return ret; +} + static void __device_attach_async_helper(void *_dev, async_cookie_t cookie) { struct device *dev =3D _dev; @@ -982,16 +1020,8 @@ static void __device_attach_async_helper(void *_dev, = async_cookie_t cookie) if (dev->p->dead || dev->driver) goto out_unlock; =20 - if (dev->parent) - pm_runtime_get_sync(dev->parent); + __device_attach_driver_scan(&data, NULL); =20 - bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver); - dev_dbg(dev, "async probe completed\n"); - - pm_request_idle(dev); - - if (dev->parent) - pm_runtime_put(dev->parent); out_unlock: device_unlock(dev); =20 @@ -1025,28 +1055,7 @@ static int __device_attach(struct device *dev, bool = allow_async) .want_async =3D false, }; =20 - if (dev->parent) - pm_runtime_get_sync(dev->parent); - - ret =3D bus_for_each_drv(dev->bus, NULL, &data, - __device_attach_driver); - if (!ret && allow_async && data.have_async) { - /* - * If we could not find appropriate driver - * synchronously and we are allowed to do - * async probes and there are drivers that - * want to probe asynchronously, we'll - * try them. - */ - dev_dbg(dev, "scheduling asynchronous probe\n"); - get_device(dev); - async =3D true; - } else { - pm_request_idle(dev); - } - - if (dev->parent) - pm_runtime_put(dev->parent); + ret =3D __device_attach_driver_scan(&data, &async); } out_unlock: device_unlock(dev); --=20 2.20.1 From nobody Sun Feb 8 14:57:45 2026 Received: from sg-1-104.ptr.blmpb.com (sg-1-104.ptr.blmpb.com [118.26.132.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AEE93876C2 for ; Wed, 7 Jan 2026 17:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.104 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767808657; cv=none; b=Rdc7v0Cf0YCttwRpkzaXe0plPkoglbf6vcVvv3Ui+mIK2s6vR/tNzlevUQxtFkXiQGU+Y24tFB8MzCijqherRuxt5uI57Zg7UW+9ErwJtq3fxG+sJLcUC5ymB1ELNAbCDtQ0O3brCxX2zPEHvVbYcugbqurljDCO8cq17zz8wbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767808657; c=relaxed/simple; bh=b+TZD4bsSQJ/2i+M96EFoDPZ1Q4PSbPM4m0GGIZsXkU=; h=To:In-Reply-To:Mime-Version:Message-Id:References:Content-Type:Cc: From:Subject:Date; b=kC5ppD4++gGyCX1Z63JbJ1NqnQCQfKdzjkEnHPJvsWO8vJSC2IhK7wzz8DKeV0rLB3sMnqw4x6whPnztjvhmW2Ck3BRN9DNnJkJ6X9kPitRD2PRLw7R1ljiyKJGMFYqSKNP/YeYL+nhop3hZOFQcbeiPqadetvXdadDB7Cuiibs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=oXBVpsYP; arc=none smtp.client-ip=118.26.132.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="oXBVpsYP" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1767808649; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=JTt8+yrsjnbVmvLy1n783Eg49SQZIHOAn/X1fUoS2Cg=; b=oXBVpsYPJ+oHwZ1aKQq7rPyrtrk8UKIj8XLI5oKChOguzx8X1tsm6ApeCjBBsFoPdCLvAg xrIeJrkcNcnZ1clT+0ULJToZfMxxZGIxU7lJDRIfGW70M6KP+BuS+rVfem3YDq+xH7D5V2 ze8Xy8HWTQMQKxrqn6LjUaJ0phpGifhtr1QoNsGeZjRn9ToCP+HUvj25ZwyFvQfsXyVeFX 21p6Yk7DzbwEi4Wffdg2I66L7UoMBybUVBTJDAhNQS6K5XpRXMswVH2d2Zwn8eDj/tkUoc pfHsA4Ps2IT5GEieZXOGeWv1jPF6Jjrt4duB6lm1kbGDmhFekfmI/0e50o4BcQ== To: , , , , , , , , , In-Reply-To: <20260107175548.1792-1-guojinhui.liam@bytedance.com> X-Original-From: Jinhui Guo Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <20260107175548.1792-3-guojinhui.liam@bytedance.com> X-Mailer: git-send-email 2.17.1 References: <20260107175548.1792-1-guojinhui.liam@bytedance.com> Cc: , , From: "Jinhui Guo" Subject: [PATCH 2/3] driver core: Add NUMA-node awareness to the synchronous probe path Date: Thu, 8 Jan 2026 01:55:47 +0800 X-Lms-Return-Path: Content-Type: text/plain; charset="utf-8" Introduce NUMA-node-aware synchronous probing: drivers can initialize and allocate memory on the device=E2=80=99s local node without scattering kmalloc_node() calls throughout the code. NUMA-aware probing was first added to PCI drivers by commit d42c69972b85 ("[PATCH] PCI: Run PCI driver initialization on local node") in 2005 and has benefited PCI drivers ever since. The asynchronous probe path already supports NUMA-node-aware probing via async_schedule_dev() in the driver core. Since NUMA affinity is orthogonal to sync/async probing, this patch adds NUMA-node-aware support to the synchronous probe path. Signed-off-by: Jinhui Guo --- drivers/base/dd.c | 104 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 3 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 896f98add97d..e1fb10ae2cc0 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -381,6 +381,92 @@ static void __exit deferred_probe_exit(void) } __exitcall(deferred_probe_exit); =20 +/* + * NUMA-node-aware synchronous probing: + * drivers can initialize and allocate memory on the device=E2=80=99s local + * node without scattering kmalloc_node() calls throughout the code. + */ + +/* Generic function pointer type */ +typedef int (*numa_func_t)(void *arg1, void *arg2); + +/* Context for NUMA execution */ +struct numa_work_ctx { + struct work_struct work; + numa_func_t func; + void *arg1; + void *arg2; + int result; +}; + +/* Worker function running on the target node */ +static void numa_work_func(struct work_struct *work) +{ + struct numa_work_ctx *ctx =3D container_of(work, struct numa_work_ctx, wo= rk); + + ctx->result =3D ctx->func(ctx->arg1, ctx->arg2); +} + +/* + * __exec_on_numa_node - Execute a function on a specific NUMA node synchr= onously + * @node: Target NUMA node ID + * @func: The wrapper function to execute + * @arg1: First argument (void *) + * @arg2: Second argument (void *) + * + * Returns the result of the function execution, or -ENODEV if initializat= ion fails. + * If the node is invalid or offline, it falls back to local execution. + */ +static int __exec_on_numa_node(int node, numa_func_t func, void *arg1, voi= d *arg2) +{ + struct numa_work_ctx ctx; + + /* Fallback to local execution if the node is invalid or offline */ + if (node < 0 || node >=3D MAX_NUMNODES || !node_online(node)) + return func(arg1, arg2); + + ctx.func =3D func; + ctx.arg1 =3D arg1; + ctx.arg2 =3D arg2; + ctx.result =3D -ENODEV; + INIT_WORK_ONSTACK(&ctx.work, numa_work_func); + + /* Use system_dfl_wq to allow execution on the specific node. */ + queue_work_node(node, system_dfl_wq, &ctx.work); + flush_work(&ctx.work); + destroy_work_on_stack(&ctx.work); + + return ctx.result; +} + +/* + * DEFINE_NUMA_WRAPPER - Generate a type-safe wrapper for a function + * @func_name: The name of the target function + * @type1: The type of the first argument + * @type2: The type of the second argument + * + * This macro generates a static function named __wrapper_ that + * casts void pointers back to their original types and calls the target f= unction. + */ +#define DEFINE_NUMA_WRAPPER(func_name, type1, type2) \ + static int __wrapper_##func_name(void *arg1, void *arg2) \ + { \ + return func_name((type1)arg1, (type2)arg2); \ + } + +/* + * EXEC_ON_NUMA_NODE - Execute a registered function on a NUMA node + * @node: Target NUMA node ID + * @func_name: The name of the target function (must be registered via DEF= INE_NUMA_WRAPPER) + * @arg1: First argument + * @arg2: Second argument + * + * This macro invokes the internal execution helper using the generated wr= apper. + */ +#define EXEC_ON_NUMA_NODE(node, func_name, arg1, arg2) \ + __exec_on_numa_node(node, __wrapper_##func_name, \ + (void *)(arg1), (void *)(arg2)) + /** * device_is_bound() - Check if device is bound to a driver * @dev: device to check @@ -808,6 +894,8 @@ static int __driver_probe_device(const struct device_dr= iver *drv, struct device return ret; } =20 +DEFINE_NUMA_WRAPPER(__driver_probe_device, const struct device_driver *, s= truct device *) + /** * driver_probe_device - attempt to bind device & driver together * @drv: driver to bind a device to @@ -844,6 +932,8 @@ static int driver_probe_device(const struct device_driv= er *drv, struct device *d return ret; } =20 +DEFINE_NUMA_WRAPPER(driver_probe_device, const struct device_driver *, str= uct device *) + static inline bool cmdline_requested_async_probing(const char *drv_name) { bool async_drv; @@ -1000,6 +1090,8 @@ static int __device_attach_driver_scan(struct device_= attach_data *data, return ret; } =20 +DEFINE_NUMA_WRAPPER(__device_attach_driver_scan, struct device_attach_data= *, bool *) + static void __device_attach_async_helper(void *_dev, async_cookie_t cookie) { struct device *dev =3D _dev; @@ -1055,7 +1147,9 @@ static int __device_attach(struct device *dev, bool a= llow_async) .want_async =3D false, }; =20 - ret =3D __device_attach_driver_scan(&data, &async); + ret =3D EXEC_ON_NUMA_NODE(dev_to_node(dev), + __device_attach_driver_scan, + &data, &async); } out_unlock: device_unlock(dev); @@ -1142,7 +1236,9 @@ int device_driver_attach(const struct device_driver *= drv, struct device *dev) int ret; =20 __device_driver_lock(dev, dev->parent); - ret =3D __driver_probe_device(drv, dev); + ret =3D EXEC_ON_NUMA_NODE(dev_to_node(dev), + __driver_probe_device, + drv, dev); __device_driver_unlock(dev, dev->parent); =20 /* also return probe errors as normal negative errnos */ @@ -1231,7 +1327,9 @@ static int __driver_attach(struct device *dev, void *= data) } =20 __device_driver_lock(dev, dev->parent); - driver_probe_device(drv, dev); + EXEC_ON_NUMA_NODE(dev_to_node(dev), + driver_probe_device, + drv, dev); __device_driver_unlock(dev, dev->parent); =20 return 0; --=20 2.20.1 From nobody Sun Feb 8 14:57:45 2026 Received: from sg-1-105.ptr.blmpb.com (sg-1-105.ptr.blmpb.com [118.26.132.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E202036C0D2 for ; Wed, 7 Jan 2026 17:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.105 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767808793; cv=none; b=QKi0v13Maej704NPMBvAQm4/iN/wI9wM71Eu1kzcFwUStXmJPeo4ab0+s6/+Oak2aKVS1Otk+81RlMSq0VCiBZa1NTn5u4GoNOsxK96tOl+YQsw0pmUlckOqUXqcvBwJfPTYe/cUumFGPG0clP+M5WHeeEDvXmbcbuglDm68kKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767808793; c=relaxed/simple; bh=euUvQ4Y+m1NwcCGrMBJ1nu9fJDEqdhilEPh8Wmv5G3M=; h=Cc:Date:Subject:References:In-Reply-To:Mime-Version:To:From: Message-Id:Content-Type; b=WhinmVdGa/Fy7QhtUnETPIVueWNLBiJsatwb4/LGmG6c1yA7hyw6myhXKx9Itk79k1s1SAAXqBn/yWZDb0ImzkX4RtUuRpoOlXVYmUmfgCqgaGDCMZkOKelx9Eq4drhsKqErSC0xw7sbQ3MWBs8W/z6pNDbAmRK2cQaJDj+Ulno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=UBDUJGEQ; arc=none smtp.client-ip=118.26.132.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="UBDUJGEQ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1767808672; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=tHAaPhycBRyZtfkz6/mgLYSwAX3tMag4G7w4Obd7jlY=; b=UBDUJGEQktMPWyxx/H1uRnRjCJKfDhb4AnLTNuAU7sAued9Bg8tm4g620Tb/6w/14igY1V CUn3GoR1JRWUq5oK3kNpEesvght9S0BkM/60yENr3Dnb95TROygXxgA8kfa4oYK9nXDu3X V3t1IRPptFYqC9NLqz1sMUi6vP5E+UWCtMhGZQGeng8vViNlQfNYhR7fbDSBjLh0BIgh4g IArWT3lpdZyXZP1fFB7I9s3YoBKleYSW0E9BXPdw67qaUA4aqFuDAlDzpmUJRhlki3exXC T3AqQfht/Ke5Yj9oH3sCtPB/j04a1m4Nf72z+hJl6tcOG8vZ9qM4nvnNg3zgFg== Cc: , , Date: Thu, 8 Jan 2026 01:55:48 +0800 Subject: [PATCH 3/3] PCI: Clean up NUMA-node awareness in pci_bus_type probe References: <20260107175548.1792-1-guojinhui.liam@bytedance.com> In-Reply-To: <20260107175548.1792-1-guojinhui.liam@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Original-From: Jinhui Guo X-Lms-Return-Path: Content-Transfer-Encoding: quoted-printable To: , , , , , , , , , From: "Jinhui Guo" Message-Id: <20260107175548.1792-4-guojinhui.liam@bytedance.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain; charset="utf-8" With NUMA-node-aware probing now handled by the driver core, the equivalent code in the PCI driver is redundant and can be removed. Dropping it speeds up asynchronous probe by 35%; the gain comes from eliminating the work_on_cpu() call in pci_call_probe() that previously pinned every worker to the same CPU, forcing serial probe of devices on the same NUMA node. Testing three NVMe devices on the same NUMA node of an AMD EPYC 9A64 2.4 GHz processor shows a 35% probe-time improvement with the patch: Before (all on CPU 0): nvme 0000:01:00.0: CPU: 0, COMM: kworker/0:1, cost: 52266334ns nvme 0000:02:00.0: CPU: 0, COMM: kworker/0:0, cost: 50787194ns nvme 0000:03:00.0: CPU: 0, COMM: kworker/0:2, cost: 50541584ns After (spread across CPUs 1, 2, 4): nvme 0000:01:00.0: CPU: 1, COMM: kworker/u1025:2, cost: 35399608ns nvme 0000:02:00.0: CPU: 2, COMM: kworker/u1025:3, cost: 35156157ns nvme 0000:03:00.0: CPU: 4, COMM: kworker/u1025:0, cost: 35322116ns The improvement grows with more PCI devices because fewer probes contend for the same CPU. Signed-off-by: Jinhui Guo --- drivers/pci/pci-driver.c | 83 ++++------------------------------------ include/linux/pci.h | 1 - 2 files changed, 8 insertions(+), 76 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 7c2d9d596258..683bc682e750 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -296,18 +296,9 @@ static struct attribute *pci_drv_attrs[] =3D { }; ATTRIBUTE_GROUPS(pci_drv); =20 -struct drv_dev_and_id { - struct pci_driver *drv; - struct pci_dev *dev; - const struct pci_device_id *id; -}; - -static long local_pci_probe(void *_ddi) +static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, + const struct pci_device_id *id) { - struct drv_dev_and_id *ddi =3D _ddi; - struct pci_dev *pci_dev =3D ddi->dev; - struct pci_driver *pci_drv =3D ddi->drv; - struct device *dev =3D &pci_dev->dev; int rc; =20 /* @@ -319,83 +310,25 @@ static long local_pci_probe(void *_ddi) * count, in its probe routine and pm_runtime_get_noresume() in * its remove routine. */ - pm_runtime_get_sync(dev); - pci_dev->driver =3D pci_drv; - rc =3D pci_drv->probe(pci_dev, ddi->id); + pm_runtime_get_sync(&dev->dev); + dev->driver =3D drv; + rc =3D drv->probe(dev, id); if (!rc) return rc; if (rc < 0) { - pci_dev->driver =3D NULL; - pm_runtime_put_sync(dev); + dev->driver =3D NULL; + pm_runtime_put_sync(&dev->dev); return rc; } /* * Probe function should return < 0 for failure, 0 for success * Treat values > 0 as success, but warn. */ - pci_warn(pci_dev, "Driver probe function unexpectedly returned %d\n", + pci_warn(dev, "Driver probe function unexpectedly returned %d\n", rc); return 0; } =20 -static bool pci_physfn_is_probed(struct pci_dev *dev) -{ -#ifdef CONFIG_PCI_IOV - return dev->is_virtfn && dev->physfn->is_probed; -#else - return false; -#endif -} - -static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, - const struct pci_device_id *id) -{ - int error, node, cpu; - struct drv_dev_and_id ddi =3D { drv, dev, id }; - - /* - * Execute driver initialization on node where the device is - * attached. This way the driver likely allocates its local memory - * on the right node. - */ - node =3D dev_to_node(&dev->dev); - dev->is_probed =3D 1; - - cpu_hotplug_disable(); - - /* - * Prevent nesting work_on_cpu() for the case where a Virtual Function - * device is probed from work_on_cpu() of the Physical device. - */ - if (node < 0 || node >=3D MAX_NUMNODES || !node_online(node) || - pci_physfn_is_probed(dev)) { - cpu =3D nr_cpu_ids; - } else { - cpumask_var_t wq_domain_mask; - - if (!zalloc_cpumask_var(&wq_domain_mask, GFP_KERNEL)) { - error =3D -ENOMEM; - goto out; - } - cpumask_and(wq_domain_mask, - housekeeping_cpumask(HK_TYPE_WQ), - housekeeping_cpumask(HK_TYPE_DOMAIN)); - - cpu =3D cpumask_any_and(cpumask_of_node(node), - wq_domain_mask); - free_cpumask_var(wq_domain_mask); - } - - if (cpu < nr_cpu_ids) - error =3D work_on_cpu(cpu, local_pci_probe, &ddi); - else - error =3D local_pci_probe(&ddi); -out: - dev->is_probed =3D 0; - cpu_hotplug_enable(); - return error; -} - /** * __pci_device_probe - check if a driver wants to claim a specific PCI de= vice * @drv: driver to call to check if it wants the PCI device diff --git a/include/linux/pci.h b/include/linux/pci.h index 864775651c6f..cbc0db2f2b84 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -481,7 +481,6 @@ struct pci_dev { unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */ unsigned int irq_managed:1; unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */ - unsigned int is_probed:1; /* Device probing in progress */ unsigned int link_active_reporting:1;/* Device capable of reporting link = active */ unsigned int no_vf_scan:1; /* Don't scan for VFs after IOV enablement */ unsigned int no_command_memory:1; /* No PCI_COMMAND_MEMORY */ --=20 2.20.1