From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 AD9E8445ADD for ; Thu, 20 Aug 2026 12:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787230104; cv=none; b=WGSjCxNZHT5S5biejaVgTsTlxyAGxqzK4ZFCrUCQYarFp+901jAFQBxj/IcFi9ALjQGdjJ6pePE5K7FcGSV4ZqfbRijf3f/yX6J3Yj1l27BnPiymsLAgRlvVtii+PUK7doaWaQluITFz87E5Wdi8PkEdi83lorvKDWRDXNhvOnc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787230104; c=relaxed/simple; bh=1rd0Xqdoh5avQQhT1vHHFyOkWivCJPvrHR0QlD3T3pQ=; h=Message-ID:Date:MIME-Version:From:Subject:To:References: In-Reply-To:Content-Type; b=TDNZjoxX9DaAXfpbl9VzAenqjKJIS3PibNNlz1F9o2UY3HF99yTj++eTVlFvxivLQzRiJUyqjwj1/CFYKF3TdN8OlS1uOFF2zJ168bDZ5WVuuWPBnHaLFxwuO16MIt+BJay0HgXq89YlZW6/XIDq+TB7MVEsLZXvDL98fydFiKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ep7YtsOA; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CzkKfwWm; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="ep7YtsOA"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CzkKfwWm" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67K8tHl33515455 for ; Thu, 20 Aug 2026 12:48:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= cSJ2JZNIVR5js1sCoMJ57s5g+nh89AyHHTrFjEK1jx0=; b=ep7YtsOAA2Ltdb+t wVM6/yqu1UlC3yR7EvP66TsZ/61Wbdhg3D8lL8roUo2a2DrDnTPjppHH3oi26CKi VW5AfzFmTdcJl16Zkpf3FAnCOAiUSCWGoA4uCfSt/GDYnAhn7AgBM11OFsc7vs9p bNphRBf26D7RcfP+TcM3c4OqxgkIuP8pckEgQIOUUjzks97SBOUdUTyxzcOIygOb antgdUcgDnclP1NcFebJwVv+yxNX8EaN2UR6dSZS4qcXW2cf5aEtMA5ug+Kep3Fa ktPWh4zN+XELh2D5j6m0fOjaOt6LU8/jfWGBTpuJoRq+gc4Y0E5BLGZ+3u3jWE2s Y26L7g== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g5xgc8v1t-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 20 Aug 2026 12:48:20 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93494cce712so286118885a.3 for ; Thu, 20 Aug 2026 05:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787230100; x=1787834900; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:to:subject:from:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to:content-type; bh=cSJ2JZNIVR5js1sCoMJ57s5g+nh89AyHHTrFjEK1jx0=; b=CzkKfwWmyJS1VWeLrY9R6ksoClREaQZnyqVvYaFbeDNChuCjt90BhtksINCkPxsqlw /9P3m+V+ce6XjKmKPTqNEX7++POv4rrhqx9FchuuqdG9NiNbhWv3zFlxBlsFcUKNo0fC M502P+kysoN8R0IFD7ewg3NAwR2mM6+uSNGEgLhxdEsnG4XlZvWpYXdhvnW+w3x+w2du 0S36uWSEL4yWcU7Q2+Roq4+HVZBKy2Gzna2ZBmE+Dg8E9n0fdQ8wTZybG/ARHi75gzw3 13DeaGenseR6tYYwSYqdpz8X/UmscLhWj7CaPg+VZJsPrixqko1r70ZWFN8QG88+LTb8 e1vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787230100; x=1787834900; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:to:subject:from:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=cSJ2JZNIVR5js1sCoMJ57s5g+nh89AyHHTrFjEK1jx0=; b=BShFEhLjySlYbUf+KaEBbImfVGPc3ZrAHqSaxjBgPvbesV9xO8Z45pfeHLmcS3g1gV wHJ1MrfRXONrcqs8Xf6/CkCZQm+dnAE90PkMipJsVXYmV6vpdgG6fZonQ1d+TCbEtYzi 8S2pSUOrjzp7e4aHmQGx2ejeTc7fcfgzULKK6bV2hcYEGf6PQtfVdKZxZvsbrVkLkuvm HFsNxzrrHmbYURQ669XhjtTeCD8X3nydG+Zm1EpygNNrVuNlAt6aM3rRNBaZHnhr/bkY SV7cgjFHyn4fwl0Alxui4pZTPcaaQC+oXHQ+eE2EBqTU+nz2BTAIcTog9+ml+kXLDezV SDFw== X-Forwarded-Encrypted: i=1; AHgh+RpmI3LUIl025LUjjClhhmVWrxrmHAVt0wE+caISankw7rkJZVYShELn/wRvsTy/pjihKx0q35Ng7BpX/aw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+K6DLrZHFZo90O7wjrT25itZkPJO/MyIFGCFA70WkBfwgXVoA AZFtX+e6xu0I86a1trEoru7yvlR9ldN3k8FsUmiOL99YGBAlO9Dil2ctMRUYLve5K5oVTTUURRn cWRgz1VcTV4yjzbQ5dhZ/r9GLe7ov0P6cZ1c+d9MTh/FwCJFzAhM9zo04Zgax3ewFUy8= X-Gm-Gg: AR+sD115HZ1ZY270IfOSPW8gVOHFud52oZ2a0nKFLONl6ChCfeOYRxJiAtOK1JWJE2n GtqvnYVtqw92r6t0RiW0t34Jmm//jizno5e2BjD1z61Hcs84WiVyEngemYHqnTfWnI5sX7RmSeC wCCCD/4PbKFVYFilpBOvjHtxEypGFGfZKwv7bEcFa3E10byzyOasQMFFhywjk1lRZzgvqwHEXJK 73PXw2Jul0ipqas7/YDFf2BtVCFDzzZ9GpcERRrNkEa2WofQk9+81W62jh70zCQRnUjnbVRiBz6 Qaja7INP0j9jLQjtpRG+v/NrVNR6+vZ4Stp5Zub9SuIlIskahq3SDAyytU5TdZDuN4J0AxkIaWm tesr2Lvk3etWE/T7BDYJ4AVzM+nIAfmMfAoNg5ZNSlTs68p0LJoK+RcBoaux6D10o38Ik3UQkgq YaJCGmjQ4pjQOjut04QExJT2hed4NVVxIRzQKCeTIPrQC5IRSan6/h6KmC0Am+RJAcYss= X-Received: by 2002:a05:620a:4111:b0:936:9525:e952 with SMTP id af79cd13be357-9371e66fa14mr1064202485a.41.1787230099542; Thu, 20 Aug 2026 05:48:19 -0700 (PDT) X-Received: by 2002:a05:620a:4111:b0:936:9525:e952 with SMTP id af79cd13be357-9371e66fa14mr1064198385a.41.1787230098962; Thu, 20 Aug 2026 05:48:18 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2458b648f9sm62823466b.28.2026.08.20.05.48.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Aug 2026 05:48:18 -0700 (PDT) Message-ID: <7ffe0c2e-0742-488a-ab6c-1dc2fabc049c@oss.qualcomm.com> Date: Thu, 20 Aug 2026 14:48:17 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Hans de Goede Subject: Re: [PATCH v2 3/4] Bluetooth: hci_h5: use device_schedule_reprobe() To: Daniel Golle , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Marcel Holtmann , Luiz Augusto von Dentz , Miri Korenblit , driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-wireless@vger.kernel.org References: <607f76ae7cbfb5e04260f69634cbd276a1c1240a.1787185594.git.daniel@makrotopia.org> Content-Language: en-US, nl In-Reply-To: <607f76ae7cbfb5e04260f69634cbd276a1c1240a.1787185594.git.daniel@makrotopia.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=GPM41ONK c=1 sm=1 tr=0 ts=6a86f794 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=VT4XjZGOAAAA:8 a=EUspDBNiAAAA:8 a=3ztaF3K77RXdcjtKaAIA:9 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 a=6CpsfURP9XNmmWg3j1mJ:22 X-Proofpoint-ORIG-GUID: lQSaj89h2N_TrdZ2pyVCbsaEu2i7H3XH X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIwMDA5NSBTYWx0ZWRfX9yDjs5ThLafb had9/SVOjpKT46estU8qmE4uk6XJx/gpLHfcPf73QQdzbYrsR0yQOboAcWwPJjNrmTTi+g3bSmw Jow9nvS2bysAFEHvAwB5xRIDX4Ib378iHDbGozldO8Q5XHtFrWapfCbH+uD1pWM8ugAaxheOHZp P9Wiy6+hNw81pGZgeJZ6jSoAD8eocMYdO6l9VdBagH6fXxzoiI2SZvwtyLIDhZz7EeLA8Ndflqb Rhw1OIj3dfJCF4rKRlK8FEK9qsryOsOcVw7kFw+MTENsJK9rvzKcFVSn1X420XZfXtsNydjrG55 tmkI+QVowtvVHqiOvTPySTSd5x3uzsRaAy5uN/0AmTMHz9S5U+XOjaTYLiTToN73J6MuszeyyBO H7bccdz7QF6XG63cN0TkZPNF4VBXHtjMaZGDgVibFME835lJniTejcdX/3OYdHhAan2uVIjigxD Hwm3e5+MhMDv3WQESLA== X-Proofpoint-GUID: lQSaj89h2N_TrdZ2pyVCbsaEu2i7H3XH X-Proofpoint-Spam-Info: AW1haW4tMjYwODIwMDA5NSBTYWx0ZWRfX/JMeBMNPeKPk 1QKnCh+pXFABiroRvOh0SvX4lpx1kOxesU+cd8fxDFqdB1qV76lqH+wOSjP8P0xYjQsOterKkfr yB0mto9/iiXx4dxuK29cbdnsY/g0e9o= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-19_06,2026-08-19_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608200095 Hi, On 20-Aug-26 02:32, Daniel Golle wrote: > h5_btrtl_resume() open-codes a deferred re-probe for RTL devices that > lose their firmware state over suspend: it takes a module reference, > allocates a work item, and the work function calls device_reprobe() > and then ends with put_device(); kfree(); module_put(THIS_MODULE); in > module text. That final module_put() is racy: once the reference > count is decremented a concurrent rmmod can free the module text > before the work function's epilogue has finished executing. The work > also does not synchronize against shutdown or unbind, so a stale > re-probe could undo an administrative unbind or detach a device whose > ->shutdown() callback has already run. > > Convert to the new device_schedule_reprobe() helper, whose work > function is builtin text and which skips the re-probe when the device > was removed, shutdown reached it, or it is no longer bound to the > driver that scheduled the re-probe. > > The old worker suppressed its error message for -EPROBE_DEFER; the > helper needs no equivalent because its attach half is > device_attach(), which folds probe deferral into the deferred-probe > machinery silently. > > Behavioral changes: > > - A pending re-probe no longer pins the module: rmmod with a re-probe > pending now succeeds immediately and the re-probe becomes a no-op, > instead of rmmod failing with EBUSY. > > - A re-probe scheduled before a system shutdown or before an > administrative unbind no longer detaches and rebinds the device > afterwards. > > - A re-probe racing the next suspend now detaches immediately while > the probe is deferred until the following resume by the > defer_all_probes machinery, instead of probing mid-suspend. > > Signed-off-by: Daniel Golle Thanks, this looks good to me and works as advertised on a device where this code path gets hit: Tested-by: Hans de Goede Reviewed-by: Hans de Goede Regards, Hans > --- > drivers/bluetooth/hci_h5.c | 43 ++++++-------------------------------- > 1 file changed, 6 insertions(+), 37 deletions(-) > > diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c > index 93cdde981840..68eaa03a2005 100644 > --- a/drivers/bluetooth/hci_h5.c > +++ b/drivers/bluetooth/hci_h5.c > @@ -990,7 +990,7 @@ static int h5_btrtl_setup(struct h5 *h5) > static void h5_btrtl_open(struct h5 *h5) > { > /* > - * Since h5_btrtl_resume() does a device_reprobe() the suspend handling > + * Since h5_btrtl_resume() schedules a device re-probe the suspend handling > * done by the hci_suspend_notifier is not necessary; it actually causes > * delays and a bunch of errors to get logged, so disable it. > */ > @@ -1047,46 +1047,15 @@ static int h5_btrtl_suspend(struct h5 *h5) > return 0; > } > > -struct h5_btrtl_reprobe { > - struct device *dev; > - struct work_struct work; > -}; > - > -static void h5_btrtl_reprobe_worker(struct work_struct *work) > -{ > - struct h5_btrtl_reprobe *reprobe = > - container_of(work, struct h5_btrtl_reprobe, work); > - int ret; > - > - ret = device_reprobe(reprobe->dev); > - if (ret && ret != -EPROBE_DEFER) > - dev_err(reprobe->dev, "Reprobe error %d\n", ret); > - > - put_device(reprobe->dev); > - kfree(reprobe); > - module_put(THIS_MODULE); > -} > - > static int h5_btrtl_resume(struct h5 *h5) > { > - if (test_bit(H5_WAKEUP_DISABLE, &h5->flags)) { > - struct h5_btrtl_reprobe *reprobe; > - > - reprobe = kzalloc_obj(*reprobe); > - if (!reprobe) > - return -ENOMEM; > - > - __module_get(THIS_MODULE); > + if (test_bit(H5_WAKEUP_DISABLE, &h5->flags)) > + return device_schedule_reprobe(&h5->hu->serdev->dev, 0); > > - INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker); > - reprobe->dev = get_device(&h5->hu->serdev->dev); > - queue_work(system_long_wq, &reprobe->work); > - } else { > - gpiod_set_value_cansleep(h5->device_wake_gpio, 1); > + gpiod_set_value_cansleep(h5->device_wake_gpio, 1); > > - if (test_bit(H5_HW_FLOW_CONTROL, &h5->flags)) > - serdev_device_set_flow_control(h5->hu->serdev, true); > - } > + if (test_bit(H5_HW_FLOW_CONTROL, &h5->flags)) > + serdev_device_set_flow_control(h5->hu->serdev, true); > > return 0; > }