From patchwork Tue Jan 10 17:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 41547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2879516wrt; Tue, 10 Jan 2023 09:36:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXvcEJDHpcCnypGtBL+Ch/pBQgV71lMfbQK2qWHRJsOFFLCMeNMQ83t6g4MrtrXLfrepvNjq X-Received: by 2002:a17:906:39d8:b0:847:410:ecff with SMTP id i24-20020a17090639d800b008470410ecffmr53273949eje.16.1673372205075; Tue, 10 Jan 2023 09:36:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673372205; cv=none; d=google.com; s=arc-20160816; b=T73YAl/F2D73FDWjxpoqhzNa855iMwO1BXdHyedY/MKw+7YKEYOD9tX6MiLVecr9fG 8zIF0tfn6XLNEWVcjg6lOnFQS17+4lhsaCEj4hfOgMy/2z2GzMy4fIGCEyR/1dGWHy14 sH9m42p1QHbLYkfKE6NmWDezbCN74jPVHpJNFkAlLUYpE1DpUsE4R84TpcdlwDq7lpxS z9pQJnKhSZLbF24GUdCd4q3XxFZZW0o0FmHnSG7cpVHlTCJgZt0SjuISSxPh0MlS4E6g 7hKxd6eVMlgSuCjakdKAHGFOp9ICxNH7W504zyUpJQPIwyDBM9Q9kYGDOUC1/Znz7n79 gKhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OtDNURmcpxSd4X5CvSSnrMvtckUZqJr40ZSleDNYRZs=; b=TyJhl5Fh+l36VrWgKeYihZmicurkKTrxSYEIP3/fH/5ziD3EwhyK/0CebyBEqwnbM4 tBr9y7oyF0x706GuNidLGnRtCo+cFplskNmHP/peUL9pITQ1av3M5VGwJl6Bx6hKkES3 FiAhNUDKioVacg2F7NQtUsgUcH5Osij0gyTNGCKeF8wyjRJ+sTmD7KV/E8WYGaI3+kaZ iDYLHlPL4Hvn39rzbeQxfRFxh7zhsXbAbxz5TiC24ZW13mJY3p+pXzHWjMsZKMLZMgYo QbUlZiR5dnHcjw/Na1+gYrwUrKgJfpTZ0fnnOlQnfhmIUPRquKw6EHMH/xsXjTiRVbTX egxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PSSbxEop; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd16-20020a170907969000b007ae127c6c80si13693128ejc.672.2023.01.10.09.36.21; Tue, 10 Jan 2023 09:36:45 -0800 (PST) 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=@chromium.org header.s=google header.b=PSSbxEop; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234304AbjAJRdF (ORCPT + 99 others); Tue, 10 Jan 2023 12:33:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234290AbjAJRc7 (ORCPT ); Tue, 10 Jan 2023 12:32:59 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69955B152 for ; Tue, 10 Jan 2023 09:32:57 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id r72so6469877iod.5 for ; Tue, 10 Jan 2023 09:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OtDNURmcpxSd4X5CvSSnrMvtckUZqJr40ZSleDNYRZs=; b=PSSbxEopop8onxh/vKdHAcgs4yAkwL1+Or4bv4hn/RAv/zJ7mJeuy4G8Fvq6/C6wFM qu8sY5piesWyr/yiuxpF39tJvv4fSSU9ne6kGhXfTFlbDTZ00kIXNjUuxI/flIJMuFx7 +MdlVzkigYOHg8dZS1mM/rlisjpzcf0ju5PBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OtDNURmcpxSd4X5CvSSnrMvtckUZqJr40ZSleDNYRZs=; b=5LGzrgzjCaednzc2hpzZSLhRuD913ntWVUlmUP+uHOvI/0hZa9+C4zGg53ldUYD2km coNg+q83/DEei1Wl/9uh0OQAXfggG4EQH0kD6VGOix3kCjrALIuClw+OqdroF7RaulZ/ u1QeUaiCj2zP0X9tE9Lfe0eHn18cGxKVgbHYmDJKkrN+l3Sr/8wZYds0n/jty31cMDBG 1qIEWESIHoVEq/uzHsFb3wvIeygJDJcwj3UPMkVa4a57QJxsmOly9cOT7dDLHp8dF0SL v0zAdGU/xxfw7UHjHXjHZtgGm9KPe7fitoT9hq1RBuMKdx6SGURo9xLZ5ZylaFfCV5qS otfQ== X-Gm-Message-State: AFqh2koEjkOfqMQJzuNajxXIEhRDGjJWMK/CiPON82vwXgMtuMuNcTPO VmGYA19hXzC4FsTZCd+qO+pFCA== X-Received: by 2002:a5e:8808:0:b0:6e2:af6e:3b58 with SMTP id l8-20020a5e8808000000b006e2af6e3b58mr46499475ioj.12.1673371977226; Tue, 10 Jan 2023 09:32:57 -0800 (PST) Received: from localhost (30.23.70.34.bc.googleusercontent.com. [34.70.23.30]) by smtp.gmail.com with UTF8SMTPSA id f3-20020a02a103000000b0039e91c28766sm1230804jag.167.2023.01.10.09.32.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Jan 2023 09:32:56 -0800 (PST) From: Matthias Kaehlcke To: Greg Kroah-Hartman Cc: Icenowy Zheng , stable@vger.kernel.org, Alexander Stein , linux-usb@vger.kernel.org, Johan Hovold , linux-kernel@vger.kernel.org, Stefan Wahren , Douglas Anderson , Matthias Kaehlcke , Ravi Chandra Sadineni Subject: [PATCH v2 1/2] usb: misc: onboard_hub: Invert driver registration order Date: Tue, 10 Jan 2023 17:32:52 +0000 Message-Id: <20230110172954.v2.1.I75494ebee7027a50235ce4b1e930fa73a578fbe2@changeid> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754657933785350010?= X-GMAIL-MSGID: =?utf-8?q?1754657933785350010?= The onboard_hub 'driver' consists of two drivers, a platform driver and a USB driver. Currently when the onboard hub driver is initialized it first registers the platform driver, then the USB driver. This results in a race condition when the 'attach' work is executed, which is scheduled when the platform device is probed. The purpose of fhe 'attach' work is to bind elegible USB hub devices to the onboard_hub USB driver. This fails if the work runs before the USB driver has been registered. Register the USB driver first, then the platform driver. This increases the chances that the onboard_hub USB devices are probed before their corresponding platform device, which the USB driver tries to locate in _probe(). The driver already handles this situation and defers probing if the onboard hub platform device doesn't exist yet. Cc: stable@vger.kernel.org Fixes: 8bc063641ceb ("usb: misc: Add onboard_usb_hub driver") Link: https://lore.kernel.org/lkml/Y6W00vQm3jfLflUJ@hovoldconsulting.com/T/#m0d64295f017942fd988f7c53425db302d61952b4 Reported-by: Alexander Stein Signed-off-by: Matthias Kaehlcke Tested-by: Stefan Wahren --- (no changes since v1) drivers/usb/misc/onboard_usb_hub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/misc/onboard_usb_hub.c b/drivers/usb/misc/onboard_usb_hub.c index 94e7966e199d..db0844b30bbd 100644 --- a/drivers/usb/misc/onboard_usb_hub.c +++ b/drivers/usb/misc/onboard_usb_hub.c @@ -433,13 +433,13 @@ static int __init onboard_hub_init(void) { int ret; - ret = platform_driver_register(&onboard_hub_driver); + ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE); if (ret) return ret; - ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE); + ret = platform_driver_register(&onboard_hub_driver); if (ret) - platform_driver_unregister(&onboard_hub_driver); + usb_deregister_device_driver(&onboard_hub_usbdev_driver); return ret; }