Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2494945rwd; Wed, 17 May 2023 10:26:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MeEDRVE1e7ba9l5WWtDzMl5Q7xNGP56ET2FhAvKb0VCPgr0d9SxU0rxdmkgGjWd5DSjlM X-Received: by 2002:a17:902:f682:b0:1a6:db0a:8005 with SMTP id l2-20020a170902f68200b001a6db0a8005mr51242624plg.68.1684344415908; Wed, 17 May 2023 10:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684344415; cv=none; d=google.com; s=arc-20160816; b=d9uzviVMD7drpNQJsg9uq0DCTFByt+N+8i870VQqxtSoHMZy3Sbxni3h9mfWcJTEIs Wh+99awqLRLq76ksKM14H2qMg5cZpvJwA7PcMS4v+MBrx8USThCbWCKXrZQArDfyzs/B EbO8fbeVq85089+tkxrfW5BWAonzmffDH2d04BTzQIZmwCSRnh8wiMa+SYmQpXfi95gu MMNrJro45QKXCWRLT2IWA1afHol4NFxxfFPbMU6UlSgsFkKyxjCwNUe9zoBhvcEbeGKu A1fAv5FG9OL8w65s5BOTp+bCE/LbvWqEWfQ88DfY1DnMMBdmCQCokdA7mVYx9sI9CuJK DTdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gA4GEkw6Mvu6f7ZlzBV9HkqublrMhw+ZD7wnWlVurlY=; b=oOFnefNa7dAUA3mKaVabQe4nK9MASHtdVdGoRBo83E6OrR48IZidRfDKSSePZwcrB2 d65OyooS+8ZXM/AQ53BRVyVkkMp9JRzACRWkG+VoTkQa5EdeeKOO8B7kd61h+d0NPZmX g8iuSDsNUlPy91GWoYUekSPfkLKenLIWCxwwtxSojkg/eaGsopIrBrej0enq4SGCLIWL z2cSrGR7zPOHDv3iGhdZP5G09e6Ymv34fWHXVYptjd7HhKX6Af0z6cN3pantHz+UZIMz sA3p127K9CEqMA7GJ4VcOKcrVxnV/+zu2M3jTRCgQkMXEUBVCTxOJvq9qdXBNxdyi0uV oPOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Vn37ASA4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a17090301ca00b001acb38aa5a5si20689604plh.351.2023.05.17.10.26.43; Wed, 17 May 2023 10:26:55 -0700 (PDT) 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=@google.com header.s=20221208 header.b=Vn37ASA4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229471AbjEQRUH (ORCPT + 99 others); Wed, 17 May 2023 13:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjEQRUE (ORCPT ); Wed, 17 May 2023 13:20:04 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22F0A272B for ; Wed, 17 May 2023 10:20:03 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ae4e49727eso11741245ad.1 for ; Wed, 17 May 2023 10:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684344002; x=1686936002; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gA4GEkw6Mvu6f7ZlzBV9HkqublrMhw+ZD7wnWlVurlY=; b=Vn37ASA4fpooxlne/eIyFg3gzMwQTlgBd2XEo9pIoaSE1kWELMmWJq4+hNrPFq5v4P XUZ0qY668TiAm9nplrMPSMSmzuUkoGOEo1OXg2dG8GN3A/Sh05uEB+ffFit62kBsjnm6 a831OyGVKX4xUslo0UUanQtanXugGGLXr3xsTMuoGcPGT1UII2znsBRvCIoYHz2v/biC aJfB3gRszJSQJTBiawVNZ47wGDaVjf0PRN1kqaQtClOgyqRgUJkm+NlJYlE+sX9InNWh OrNTWhqq2rqt2nAdN6TOgN+55p2R/XVbOUXT9OjXQGREKkfqy/HEK7bTFhX3izQMpkSe r6Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684344002; x=1686936002; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gA4GEkw6Mvu6f7ZlzBV9HkqublrMhw+ZD7wnWlVurlY=; b=HomODkiRwGq5mW63qbU/2PZ2aKAX5+pirZSXSUupXJpFkrQaT/6Am3B1/68IqWDz+9 4h8hac3jEhiEEBzpnlAaihehu7i28srFQChDVl8yhNRy5dnh+msHKWPNc8oPFbqgX7Kh 3vqqtc0HjRQYSjB+Y9zPbYTZRMv5TUvCr5+15q1jwOzsRZT2VcP5+5JVbAmFK/wotFOy PUc/YSbUZ1qboVaonBY5yDqzLEh/XJHtaQ0l/NWosKy3Fi3OdEVzKZ6FDLeU2Gmqha0Q pZvScpWToJ512IBbnbX005iUNzjvCUM96nGcYVUWYIbtm52u6iVztaYxofJoz8ZPwpTA Pn0Q== X-Gm-Message-State: AC+VfDy4yhnOF08jQ3++7S2Q5nDCoA7SM3WKWX+8mgO50ezeaQAolIkp oLGgq3l5n7MwCc7y2smNnLWViS9KzvCL3PUeravwTA== X-Received: by 2002:a17:90a:be15:b0:23f:81c0:eadd with SMTP id a21-20020a17090abe1500b0023f81c0eaddmr335771pjs.47.1684344002532; Wed, 17 May 2023 10:20:02 -0700 (PDT) MIME-Version: 1.0 References: <20230517115955.1078339-1-badhri@google.com> In-Reply-To: From: Badhri Jagan Sridharan Date: Wed, 17 May 2023 10:19:25 -0700 Message-ID: Subject: Re: [PATCH v1] usb: gadget: udc: core: Offload usb_udc_vbus_handler processing To: Alan Stern Cc: gregkh@linuxfoundation.org, colin.i.king@gmail.com, xuetao09@huawei.com, quic_eserrao@quicinc.com, water.zhangjiantao@huawei.com, peter.chen@freescale.com, balbi@ti.com, francesco@dolcini.it, alistair@alistair23.me, stephan@gerhold.net, bagasdotme@gmail.com, luca@z3ntu.xyz, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Francesco Dolcini Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Wed, May 17, 2023 at 7:44=E2=80=AFAM Alan Stern wrote: > > On Wed, May 17, 2023 at 11:59:55AM +0000, Badhri Jagan Sridharan wrote: > > chipidea udc calls usb_udc_vbus_handler from udc_start gadget > > ops causing a deadlock. Avoid this by offloading usb_udc_vbus_handler > > processing. > > Surely that is the wrong approach. > > The real problem here is that usb_udc_vbus_handler() gets called from > within a udc_start routine. But this is totally unnecessary, because > the UDC core will call usb_udc_connect_control_locked() itself, later on > during gadget_bind_driver(). Hi Alan, usb_udc_vbus_handler sets the udc->vbus flag as well apart from calling usb_udc_connect_control_locked(). So, removing usb_udc_vbus_handle= r from chip specific start callback might prevent the controller from starting. void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status) { struct usb_udc *udc =3D gadget->udc; mutex_lock(&udc->connect_lock); if (udc) { udc->vbus =3D status; usb_udc_connect_control_locked(udc); Thanks, Badhri > > So a proper solution would be simply to remove the unnecessary > usb_udc_vbus_handler() call from the chipidea driver (and similarly for > the max3420_udc driver). > > Similar changes may be needed in these drivers' udc_stop routines. > > Alan Stern