From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 01FFB3B52F4 for ; Wed, 29 Jul 2026 05:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785303635; cv=none; b=Ej1EJYaW5YiGmCzb8GCsO64GJigG0egklolXUSxQqbxPYQ6BcPN+6ZQeb+ZEzzZ7PxAPVrQMxsifw9I7LJcil3kwgI1LijbN65/kQNyIA8B+hNLF7GBeDmmxHr/2TbEttTT5ETAD1wq+4iu7hyMUDzM8tfE4e8cLBq9BM2iPpyg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785303635; c=relaxed/simple; bh=jL0RiLOugXkaYKuBva15zd1DJur+LW1Pqs6+Liy3JIs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TR9S2AgRRfoCHcCvx7Vm7xzKu9sCjPNCBflEIKBUgW4gYclohvIWUfa93eP1w5HlUYIYrRm4OTHahBf7Ep6eEi40gBH0T7njzB6JLufoRnZcUgaX8+/frHKbXXB7OruQclh300lru/m0REfHbNKAMMrRM9Nz1545xiCwk/gYThM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i3vY6wr6; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i3vY6wr6" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3810c5d691bso504695a91.1 for ; Tue, 28 Jul 2026 22:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785303633; x=1785908433; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=rkOHM5geNPJAHsEz68m3kayrwcdycw0DphXnanl0CQc=; b=i3vY6wr6M6Unxfj1OH7lpnuDJmc+wUj+hu5M+Zmwcifq842rDL2Ibh7nQODYP8yMBU +WFPodwnRmOSaC/LmWu8MwfumbI2oRd+rqz11/lce6/+eiiCSrDFg/HrTXOulSLAoJmc 3GJHvy7tu07rXaefYGzeEePeF+u6XqeyVVqTIykGanJle3S6yFXoLEQtXlilCknhJbuz aBQph/W2rMxgq4aMfgs4WcMhicxbjuZEIDIag5ZV+376dv2soI8JgTj5BSUNtc54gIqe J/J9RaEDQyKGIUonpDa30qgvSU5SEPV5LnZj9YY0ZHJBXrh7SEBL4s0jqjAHBs+F2Exc FZXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785303633; x=1785908433; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rkOHM5geNPJAHsEz68m3kayrwcdycw0DphXnanl0CQc=; b=WRX0LZFaHaIq3Vv7dVIS4RChyusCuxK6wuJpCW14vyoFS5fWCMMcnamMg9L6/m8CrA 0mMeHJ72kveah+n2sIiz6KP8QZFtNEKT8XXTUL4y5Fqk/KL/ubD7tFfwz02aA6vbLBTZ KOe2W+04S02FIt7pMvWKLMVUuXPG5xQHWwbbDyD3qCCpYwnBPcGLAxQLPXFuWDlQmzc7 652FOOC2l+1mfSHUZcMj/V4UKX+N/o7D8pPU1bRJ6DXQ9+3eD6ADQl8oyxxKCuWlDpWu D21/NwAlPaxrCNlsFi9rm4XRa4z250AfqYYT3Nu7inrOS3Avl+vsYZ3pLxV19Q747ycS xQAQ== X-Forwarded-Encrypted: i=1; AHgh+RrYQIjSPmW8VO5qRLGH4yPfGEwsqD4XvUVjfCzWDqbHmjjM9rlN2f6cZ2mZa8MoPIQ6x1E6hC9LtM1p6Tw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz4UT+ZiwpVe1h8vYcJeZbipwpNbYDPuXf9CQ/FiLPhbBbpvz+G z9sEVB2dOXBcMyOIZmn869s5kITXMrO8yFmc5T2txlUb8umr/KKr1/8CNDU8tQ== X-Gm-Gg: AR+sD13rS8pE5NX2cKh0W4hn81EtvtQ69eUeC8+Tyt11h2vyRl2IT7knILDavYdplPH 6o29sUVUB+B9PJABeP6zhKabk6ZhnPq1VRfluZUMnU7JEHJt/klwred4IE5VqD8phjtPFoMsQnl PTzdIrTrVA8NOY3sv8PPalIwf2S6xhRvshl948NMrd5YtagNkdWaLjh46jg3DC/ICUze3zpe825 BmcNMsm5GdDJ8upBmYgvra0bUHDs2MBOlWLXk0eRG84nhmo9UwfhOzWgHUWqgijDw/dACStd/uI SIlsUNT9rI9ixpPhdVyS9SLq8KAGrX8bdTDLVk/X/beIG4aA91XMIsippiTYop0oNhHFVkBG/nX BEG2OOsjK4mbIAiG9sZTn2SjwpscaBG0tEJF9pVATwkpcsMpvFfRrk0s+J8xy3d1wg9OAOMwc36 HvpSVSBx83wS8m3OVYmwJoVdPWKnA3lguUlufVmTZ2rbDNZv67XoJH2/SYGseX10AlMxD6LANev tiTGeDzm+o9XjOU8TyElby3yuzosg== X-Received: by 2002:a17:90b:584f:b0:38f:1e1a:5141 with SMTP id 98e67ed59e1d1-38f6a45f896mr5868893a91.28.1785303633084; Tue, 28 Jul 2026 22:40:33 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:3062:3727:f62a:314c]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13e72643a12sm8093503c88.5.2026.07.28.22.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 22:40:32 -0700 (PDT) Date: Tue, 28 Jul 2026 22:40:29 -0700 From: Dmitry Torokhov To: Greg Kroah-Hartman Cc: Danilo Krummrich , "Rafael J. Wysocki" , driver-core@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] driver core: introduce PROBE_FORCE_ASYNCHRONOUS Message-ID: References: <2026072729-driller-leggings-e530@gregkh> <2026072717-amicably-tray-4a8b@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2026072717-amicably-tray-4a8b@gregkh> On Mon, Jul 27, 2026 at 08:25:51AM +0200, Greg Kroah-Hartman wrote: > On Sun, Jul 26, 2026 at 10:54:54PM -0700, Dmitry Torokhov wrote: > > On Mon, Jul 27, 2026 at 07:40:57AM +0200, Greg Kroah-Hartman wrote: > > > On Sun, Jul 26, 2026 at 10:31:41PM -0700, Dmitry Torokhov wrote: > > > > Add PROBE_FORCE_ASYNCHRONOUS probe type enum and update > > > > driver_allows_async_probing() to allow asynchronous probing for drivers > > > > marked with this type. > > > > > > > > While PROBE_PREFER_ASYNCHRONOUS exists, it represents a temporary opt-in > > > > preference. Subsystems that require asynchronous probing (such as slow > > > > legacy buses) need a dedicated probe type to guarantee asynchronous > > > > execution. > > > > > > > > Assisted-by: Antigravity:gemini-3.5-flash > > > > Signed-off-by: Dmitry Torokhov > > > > --- > > > > > > > > I am planning to rework serio and gameport subsystems to rely on > > > > asynchronous probing instead of rolling their own implementations. > > > > > > What do you mean? Why doesn't the PROBE_PREFER_ASYNCHRONOUS work for > > > you for those subsystems? > > > > It shows the intent. It is not "preference" anymore, it is a "must". If > > we ever introduce switch to make probing synchronous for some reason it > > should not affect drivers that must be probed asynchronously. > > I'm sorry, but I don't understand. PROBE_PREFER_ASYNCHRONOUS says that the driver prefers to be probe asynchronously but it can also be probed synchronously if needed. PROBE_FORCE_ASYNCHRONOUS indicates that the driver *must* be probed asynchronously, or the kernel will break. Currently there is no difference in behavior, but it documents the intent. > And as there's no users for this, we > really can't take it until we see those users at the same time :) I am planning to use it in serio and gameport bus implementations that currently roll their own asynchronous registration which is quite ugly. Because we have nested serio ports probing *must* be done asynchronously or it will deadlock. I would like to merge the new constant early so that I do not have dependency when I am ready to merge input changes. Below is how it will look like (just a small part of a WIP series). Thanks. -- Dmitry Input: serio - use PROBE_FORCE_ASYNCHRONOUS and make port registration synchronous From: Dmitry Torokhov Mark serio drivers as using PROBE_FORCE_ASYNCHRONOUS instead of PROBE_PREFER_ASYNCHRONOUS during registration. At the same time, rework __serio_register_port() to run synchronously under serio_mutex instead of queuing a SERIO_REGISTER_PORT event to kseriod. This ensures port registration happens synchronously while driver probing is handled asynchronously by the driver core. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Dmitry Torokhov --- drivers/input/serio/serio.c | 46 +++++-------------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index dd53c2b7a39d..f47d90f0507b 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -124,7 +124,6 @@ enum serio_event_type { SERIO_RESCAN_PORT, SERIO_RECONNECT_PORT, SERIO_RECONNECT_SUBTREE, - SERIO_REGISTER_PORT, }; struct serio_event { @@ -190,11 +189,6 @@ static void serio_handle_event(struct work_struct *work) while ((event = serio_get_event())) { switch (event->type) { - - case SERIO_REGISTER_PORT: - serio_add_port(event->object); - break; - case SERIO_RECONNECT_PORT: serio_reconnect_port(event->object); break; @@ -279,30 +273,6 @@ static void serio_remove_pending_events(void *object) } } -/* - * Locate child serio port (if any) that has not been fully registered yet. - * - * Children are registered by driver's connect() handler so there can't be a - * grandchild pending registration together with a child. - */ -static struct serio *serio_get_pending_child(struct serio *parent) -{ - struct serio_event *event; - struct serio *serio; - - guard(spinlock_irqsave)(&serio_event_lock); - - list_for_each_entry(event, &serio_event_list, node) { - if (event->type == SERIO_REGISTER_PORT) { - serio = event->object; - if (serio->parent == parent) - return serio; - } - } - - return NULL; -} - /* * Serio port operations */ @@ -516,13 +486,6 @@ static void serio_add_port(struct serio *serio) */ static void serio_destroy_port(struct serio *serio) { - struct serio *child; - - while ((child = serio_get_pending_child(serio)) != NULL) { - serio_remove_pending_events(child); - put_device(&child->dev); - } - if (serio->stop) serio->stop(serio); @@ -653,13 +616,14 @@ void serio_reconnect(struct serio *serio) EXPORT_SYMBOL(serio_reconnect); /* - * Submits register request to kseriod for subsequent execution. - * Note that port registration is always asynchronous. + * Synchronously registers serio port. */ int __serio_register_port(struct serio *serio, struct module *owner) { serio_init_port(serio); - serio_queue_event(serio, owner, SERIO_REGISTER_PORT); + + guard(mutex)(&serio_mutex); + serio_add_port(serio); return 0; } @@ -778,7 +742,7 @@ int __serio_register_driver(struct serio_driver *drv, struct module *owner, cons * Mark all serio drivers as using asynchronous probe because serio * devices are slow and their probing takes long time. */ - drv->driver.probe_type = PROBE_PREFER_ASYNCHRONOUS; + drv->driver.probe_type = PROBE_FORCE_ASYNCHRONOUS; error = driver_register(&drv->driver); if (error) {