Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3421117rdh; Mon, 27 Nov 2023 14:01:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNkS0w8AlyI4WhMqPkT5TwuPdNTWnGsN/iTn6sIOH/adLyoivysKkJvF9g9pC0AwM6xqiw X-Received: by 2002:a05:6808:159b:b0:3b8:3ce0:a03 with SMTP id t27-20020a056808159b00b003b83ce00a03mr8849076oiw.4.1701122464948; Mon, 27 Nov 2023 14:01:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701122464; cv=none; d=google.com; s=arc-20160816; b=mwrPutYb18arJTwI9UwImxOT6h9G/OVg9PtohUBJr98gDAB80SDAbtXzB4uA50hCBo kqHqwBPt6JnaLqV+RC2uW7kR/UGggwMKYC68PTiSWg539HHNdyiPf/ywVmbhXQ35cOM9 D/RQovrbMJWHRBVQ4hWvNwluRCTdb0Z8NgyHtlg+0FrCpnfDEOcoyrbItcgeahW4AHcY Lcdnd1CQgItA/zBcg9T00kLmpDwklL50Ft135DXLOV9+Pp7cCNCC8Yglo8s0o0G3XfgU YsNP0fbv0N1xPxljLQ5CRmKDFhM/gCSTHL+u7KYxOJBO04rQCicWunf/AeC8SSQEUn7P z3sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:message-id:mime-version:date :dkim-signature; bh=fTNvGVxIFnvSGPtP4qlnkK9J/w0WE03mzYNhzIBqHiA=; fh=WZ2ETSVoamtIHZcWmX4XMM7qBsNjVN+v+TmKM7+I35Q=; b=GexQIqhc7RyaperQ8a7I3fVBEjNDHWR+vntwkej8FgYLSsjjdVgPi4kP34nmW9J39K kI3FDuys1wPkaRVwHIY2gGmEHqGbt/AxF4oo3KLBM/OD/Uwa32u5tPnAPRfhdq5HzO6M V+ZMvpfbl9rq7huS+wt71DdUXINWAacWFCMKbv7psBv9BInHZCFZfeF74J6PdQGegnuY 3bamelC5h3trk+ayYVtbjtVBtfRXECw1UJQ3dglda8gzdYxYw6jkm3LYR8VdV1pAK9mx jTNaf06J0kS2Y87wcrQFK6mi2mizlkTkg1/vHUYD9OcGZkpToXDxfWqBd5O5khBUy0sS tFdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dSBw1aIJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h22-20020aca1816000000b003ae1cd58ba0si3819082oih.124.2023.11.27.14.01.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:01:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dSBw1aIJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E52ED8096BA4; Mon, 27 Nov 2023 14:00:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232683AbjK0WAq (ORCPT + 99 others); Mon, 27 Nov 2023 17:00:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233355AbjK0WAo (ORCPT ); Mon, 27 Nov 2023 17:00:44 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D491A5 for ; Mon, 27 Nov 2023 14:00:50 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cfe0b63eeeso24403337b3.0 for ; Mon, 27 Nov 2023 14:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701122450; x=1701727250; darn=vger.kernel.org; h=to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=fTNvGVxIFnvSGPtP4qlnkK9J/w0WE03mzYNhzIBqHiA=; b=dSBw1aIJkIfaJ45FqI7HnpDSRyNOXMy52Pf5+BqIOj047Y/euEW8PM0r1Q+at212K/ IMdqZaeV6/mjfaaOOOOOxqmqGm0s4QUlq1nUUhlGvnjQSatTRndJH5gN0c7MxfdHKvid 1X1JAs9gvxCVCDPesw6UtRLK5GuaGrXScawU9eACEX35Zjt9fZQRAdugc8oBDY0Gg89I o8c0eWFALe79laCS9N/GzEeNzbs1bN2l8/srTz6iE6R7TGcqvHZsaZYNIbOqv1StxeJL /nykYmPQ8aGKiInIeFCCM8zOY4W4Q4wYzkJG6hzakNcaVyRoTqnorNvgQ6/KzcOh0sUx z5yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701122450; x=1701727250; h=to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fTNvGVxIFnvSGPtP4qlnkK9J/w0WE03mzYNhzIBqHiA=; b=YbA/mRTPutSZx0V2Ntt/v07nkHrwSfVLF6SdYEuC3lh6Bywcwq663vK6JG6y8IYU9T J9m9q+FPRqNm++fdj3dGbbDVs0sTvZ0GomkcpHrQk4OrAASXEukd+IUJ03NEHDRkU55O rrTx87ljpPJu3effsB/bTZoo9RmOkGGsr76bv9eYiccumAQDC8X+XcECTckVjJFm39NO nJuo3IjoXrGKAo1eEFH4tXFcDB3Kvz6XdyNB/6ggRrA9Iyo9Dbp+lZMSLJcQYNP6nHET 5jUG8j+pHygZz75mQACu/rQezX+kqx/VOd6SzcKJq2SIenF2YAtC3/ACaDsHbmuZaGbu h/GQ== X-Gm-Message-State: AOJu0Ywpbg+4rwJio4f/EzrXsjui4IyCE07WLAIN9dHTWxC8EyQkCg+w XiB00fPQYBvWfmljWpj7EhPpaL/x2aQ= X-Received: from royluo-cloudtop0.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:bb8]) (user=royluo job=sendgmr) by 2002:a05:690c:470e:b0:5cb:d80c:3d34 with SMTP id gz14-20020a05690c470e00b005cbd80c3d34mr263835ywb.8.1701122450148; Mon, 27 Nov 2023 14:00:50 -0800 (PST) Date: Mon, 27 Nov 2023 22:00:47 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Message-ID: <20231127220047.2199234-1-royluo@google.com> Subject: [PATCH v2] USB: gadget: core: adjust uevent timing on gadget unbind From: Roy Luo To: royluo@google.com, gregkh@linuxfoundation.org, stern@rowland.harvard.edu, badhri@google.com, quic_kriskura@quicinc.com, francesco.dolcini@toradex.com, quic_eserrao@quicinc.com, ivan.orlov0322@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:00:59 -0800 (PST) The KOBJ_CHANGE uevent is sent before gadget unbind is actually executed, resulting in inaccurate uevent emitted at incorrect timing (the uevent would have USB_UDC_DRIVER variable set while it would soon be removed). Move the KOBJ_CHANGE uevent to the end of the unbind function so that uevent is sent only after the change has been made. Fixes: 2ccea03a8f7e ("usb: gadget: introduce UDC Class") Signed-off-by: Roy Luo --- Changes since v1: add Fixes tag --- drivers/usb/gadget/udc/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index ded9531f141b..d59f94464b87 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -1646,8 +1646,6 @@ static void gadget_unbind_driver(struct device *dev) dev_dbg(&udc->dev, "unbinding gadget driver [%s]\n", driver->function); - kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); - udc->allow_connect = false; cancel_work_sync(&udc->vbus_work); mutex_lock(&udc->connect_lock); @@ -1667,6 +1665,8 @@ static void gadget_unbind_driver(struct device *dev) driver->is_bound = false; udc->driver = NULL; mutex_unlock(&udc_lock); + + kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); } /* ------------------------------------------------------------------------- */ base-commit: 9b6de136b5f0158c60844f85286a593cb70fb364 -- 2.43.0.rc1.413.gea7ed67945-goog