From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A73DCC25B06 for ; Sat, 6 Aug 2022 16:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231904AbiHFQvf (ORCPT ); Sat, 6 Aug 2022 12:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbiHFQve (ORCPT ); Sat, 6 Aug 2022 12:51:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACC8DDEAB; Sat, 6 Aug 2022 09:51:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 66711B8060E; Sat, 6 Aug 2022 16:51:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17A1FC433C1; Sat, 6 Aug 2022 16:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659804691; bh=VnrvTUGe1dNVc7jCq++HzAzCuD0PNW0MzC6BQG5Rie0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vLeitvsKx6r79fikRlCnosNLcf8K9LipyoCIFpBtEP3Qqpm2Zvw5IGzmvNKQPsGXh fQTiU8aMGNwKqM+lHmg0Zgkxly4nHrNUtDLe+LDsZVl5ZIMWK0wW0FMnxgLzrgMZmO mh51bz3Z0a2G17zjqFcpwa/BciVvT5bW8rWpnuzaxmg0hhkE3dnfRlNAoyD0BeoEfT 5a+CD0lqpjvmOYXNQLkmHug5QaIopA4inT1xCWUciau5ZwQuEkMDtrbnUckFyA73MO HBzl3+Mlo+sMw/KvShy2YrywC0DTTxg9pZhUco0316sdtI5ryoDx5OmaO1ZcI+uE4s pPHKlLl34NhuQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oKN1p-0003Uh-Rx; Sat, 06 Aug 2022 18:51:58 +0200 Date: Sat, 6 Aug 2022 18:51:57 +0200 From: Johan Hovold To: Manivannan Sadhasivam Cc: Johan Hovold , Greg Kroah-Hartman , Felipe Balbi , Rob Herring , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Krishna Kurapati , Stephen Boyd , Doug Anderson , Matthias Kaehlcke , Pavankumar Kondeti , quic_ppratap@quicinc.com, quic_vpulyala@quicinc.com, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Randy Dunlap Subject: Re: [PATCH v2 3/9] usb: dwc3: qcom: fix gadget-only builds Message-ID: References: <20220804151001.23612-1-johan+linaro@kernel.org> <20220804151001.23612-4-johan+linaro@kernel.org> <20220806141536.GD14384@thinkpad> <20220806164250.GK14384@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220806164250.GK14384@thinkpad> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Sat, Aug 06, 2022 at 10:12:50PM +0530, Manivannan Sadhasivam wrote: > On Sat, Aug 06, 2022 at 06:04:21PM +0200, Johan Hovold wrote: > > On Sat, Aug 06, 2022 at 07:45:36PM +0530, Manivannan Sadhasivam wrote: > > > On Thu, Aug 04, 2022 at 05:09:55PM +0200, Johan Hovold wrote: > > > > A recent change added a dependency to the USB host stack and broke > > > > gadget-only builds of the driver. > > > > > > > > Fixes: 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend") > > > > Reported-by: Randy Dunlap > > > > Signed-off-by: Johan Hovold > > > > --`- > > > > > > > > Changes in v2 > > > > - new patch > > > > > > > > drivers/usb/dwc3/dwc3-qcom.c | 5 ++++- > > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c > > > > index be2e3dd36440..e9364141661b 100644 > > > > --- a/drivers/usb/dwc3/dwc3-qcom.c > > > > +++ b/drivers/usb/dwc3/dwc3-qcom.c > > > > @@ -310,8 +310,11 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom) > > > > * currently supports only 1 port per controller. So > > > > * this is sufficient. > > > > */ > > > > +#ifdef CONFIG_USB > > > > udev = usb_hub_find_child(hcd->self.root_hub, 1); > > > > - > > > > +#else > > > > + udev = NULL; > > > > +#endif > > > > > > Perhaps the check should be moved to the caller instead? This function still > > > references "usb_hcd" struct and I don't think that's intended for gadget only > > > mode. > > > > That wouldn't help with the build failure, which is what this patch is > > addressing. > > > > I should've put it clearly. You should guard the entire function and not just > usb_hub_find_child(). This way it becomes clear that this whole function depends > on the USB host functionality. Like, > > #ifdef CONFIG_USB > static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom) > { > ... > } > #elif > static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom) > { > return USB_SPEED_UNKNOWN > } > #endif Yeah, that's what Krishna suggested but I wanted to keep the ifdeffery minimal when fixing the build failure (we generally try to avoid adding stub functions to implementation files). Non-host mode was clearly never considered when adding the function in question as the code blows up otherwise regardless of whether CONFIG_USB is enabled or not (and a later patch in the series addresses that). But I'll revisit this too in a couple of weeks. Thanks for reviewing. Johan