Received: by 10.192.165.156 with SMTP id m28csp369141imm; Tue, 10 Apr 2018 23:54:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/KJPxsPe2hoybyMxQRgQbWeTM6IKoQiK4SInak8S9vvhoGU/vRKAMYV8gIu/fiWRF91JQm X-Received: by 2002:a17:902:988d:: with SMTP id s13-v6mr3753859plp.30.1523429663631; Tue, 10 Apr 2018 23:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523429663; cv=none; d=google.com; s=arc-20160816; b=Emu/p4OcjCKu+Sde2/SVd6AyD8pITKiY234IeEx5KEEPT6kez8XJaBWDeRfV9NtuL8 I5CJITfhcIA8mmlSzP+nwaJ2P19ru41e/LZS/XqI2tXjkAsysz3AWx8KYHUeVUlHTJnu 1FeC9ByuVmtF8LgPlrqxXUH92F3afHzbL8Q1vp2+mmZBWTjNgBWJsPqMABJY/nZt1vuu K43aB/8+iR5Z9j0MiQU1A4KP6yukzouDRHH5nt1ciSIFCPv1vTHpOG+de3iuyRtGXveD i7c3IPDPjHWogW0+JEINE+LDD3fsU00HiBNpA1X3Sg8bjpZ/6hDXh8Rptf/uUoEQ17Mt MNow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=HxsIJSgkQqn61/I8mTpsX4WUF1E18VWmMJ+cm3rML6Y=; b=gT099iijbwyZ2mMhgcVcmYIZJNLYnNtpkSzmkpa6FqeIEa39c/xtlXdJFlQJEMCR/G WKZcMG0sSf43nOiqf8oF4UdYdVCa1Fi4g1VmJXUadvNGHco3cBa4m/nrL/Z2n9paF/5K WB1WRtiPY26oncNJFuB75U1KMLY3ErDrq8nS8oNrCEr29oa9+b0oqCrAEQ6wMqmL/zcL vYG59/xuP2lDZ6gLSJJqLyxQIbcCgEmAcRuYgeJFQZiSfjL9NlBQa/Mz5/zMrahg9jUV 9DJHvfPjJHQfAN9CQNzrwBYBhrE3qga6/JQaF9zU0+F+W6lNUJID+fVT941pIHbLZYug VG5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13-v6si481908plo.574.2018.04.10.23.53.44; Tue, 10 Apr 2018 23:54:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752370AbeDKGvB convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Apr 2018 02:51:01 -0400 Received: from smtprelay4.synopsys.com ([198.182.47.9]:49875 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbeDKGvA (ORCPT ); Wed, 11 Apr 2018 02:51:00 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 9F1E324E07B9; Tue, 10 Apr 2018 23:50:59 -0700 (PDT) Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id 187D5373A; Tue, 10 Apr 2018 23:50:59 -0700 (PDT) Received: from AM04WEHTCB.internal.synopsys.com (10.116.16.192) by us01wehtc1.internal.synopsys.com (10.12.239.231) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 10 Apr 2018 23:50:58 -0700 Received: from AM04WEMBXB.internal.synopsys.com ([fe80::1006:bcdd:1b7:579b]) by am04wehtcb.internal.synopsys.com ([::1]) with mapi id 14.03.0361.001; Wed, 11 Apr 2018 10:50:55 +0400 From: Minas Harutyunyan To: =?iso-8859-1?Q?Heiko_St=FCbner?= , Minas Harutyunyan CC: Tomeu Vizoso , "linux-kernel@vger.kernel.org" , Felipe Balbi , Amelie Delaunay , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" Subject: Re: [PATCH v4] usb: dwc2: dwc2_vbus_supply_init: fix error check Thread-Topic: [PATCH v4] usb: dwc2: dwc2_vbus_supply_init: fix error check Thread-Index: AQHTxOD8nEoVzOZ04EOGN7z3QZ1Kzw== Date: Wed, 11 Apr 2018 06:50:54 +0000 Message-ID: <410670D7E743164D87FA6160E7907A560113AE831F@am04wembxb.internal.synopsys.com> References: <20180322093943.49717-1-tomeu.vizoso@collabora.com> <4613360.AXT7q7Ng0i@phil> <410670D7E743164D87FA6160E7907A560113AE7E5C@am04wembxb.internal.synopsys.com> <41174786.HiOuqceMIB@diego> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.70.63] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Heiko, On 4/10/2018 7:37 PM, Heiko St?bner wrote: > Am Dienstag, 10. April 2018, 15:52:25 CEST schrieb Minas Harutyunyan: >> Hi Heiko, >> >> On 4/10/2018 4:28 PM, Heiko Stuebner wrote: >>> Am Montag, 26. M?rz 2018, 11:00:01 CEST schrieb Tomeu Vizoso: >>>> devm_regulator_get_optional returns -ENODEV if the regulator isn't >>>> there, so if that's the case we have to make sure not to leave -ENODEV >>>> in the regulator pointer. >>>> >>>> Also, make sure we return 0 in that case, but correctly propagate any >>>> other errors. Also propagate the error from _dwc2_hcd_start. >>>> >>>> Fixes: 531ef5ebea96 ("usb: dwc2: add support for host mode external vbus >>>> supply") Cc: Amelie Delaunay >>>> Signed-off-by: Tomeu Vizoso >>> >>> The patch that gets fixed here also breaks display-output on dwc2-based >>> Rockchip devices (likely even more), probably due to making the regulator >>> framework hickup. >> >> Could you please elaborate what mean "breaks display-output". >> On which Kernel version you apply this patch? > > I think I may have written that poorly. _Without_ this patch I get > display breakage on the most recent torvalds/master (merge-window) > where "usb: dwc2: add support for host mode external vbus supply" is > applied and this patch fixes the issue. > > "breaks display output" means both hdmi + edp output are missing > also including the backlight staying off. > > The patch we're fixing here, causes a null-pointer dereference in the > regulator framework, which seems to also cause issues when other > regulators are enabled, which I think is what I'm seeing here. > > Thank you for clarification. Earlier you added "reviewed" tag, this feedback can assumed as "tested" tag. Thanks, Minas > Heiko > >> >> Thanks, >> Minas >> >>> With this patch applied, apart from not seeing the NULL-ptr, I also get >>> display output on my rk3288-veycron Chromebook again, so >>> >>> Tested-by: Heiko Stuebner >>> >>>> v2: Only overwrite the error in the pointer after checking it (Heiko >>>> >>>> St?bner ) >>>> >>>> v3: Remove hunks that shouldn't be in this patch >>>> v4: Don't overwrite the error code before returning it (kbuild test >>>> >>>> robot ) >>>> >>>> --- >>>> >>>> drivers/usb/dwc2/hcd.c | 13 ++++++++----- >>>> 1 file changed, 8 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c >>>> index 190f95964000..c51b73b3e048 100644 >>>> --- a/drivers/usb/dwc2/hcd.c >>>> +++ b/drivers/usb/dwc2/hcd.c >>>> @@ -358,9 +358,14 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg >>>> *hsotg)>> >>>> static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg) >>>> { >>>> >>>> + int ret; >>>> + >>>> >>>> hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus"); >>>> >>>> - if (IS_ERR(hsotg->vbus_supply)) >>>> - return 0; >>>> + if (IS_ERR(hsotg->vbus_supply)) { >>>> + ret = PTR_ERR(hsotg->vbus_supply); >>>> + hsotg->vbus_supply = NULL; >>>> + return ret == -ENODEV ? 0 : ret; >>>> + } >>>> >>>> return regulator_enable(hsotg->vbus_supply); >>>> >>>> } >>>> >>>> @@ -4342,9 +4347,7 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd) >>>> >>>> spin_unlock_irqrestore(&hsotg->lock, flags); >>>> >>>> - dwc2_vbus_supply_init(hsotg); >>>> - >>>> - return 0; >>>> + return dwc2_vbus_supply_init(hsotg); >>>> >>>> } >>>> >>>> /* > > >