Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2476448pxj; Mon, 10 May 2021 04:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXsPECySOx4j+xMUt0PRC2okqRMHMq3JWb91yB2GFf8HkwewbdTMyv0P26yLFnv2FxkUNB X-Received: by 2002:a05:6e02:e0d:: with SMTP id a13mr21087895ilk.270.1620644575132; Mon, 10 May 2021 04:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644575; cv=none; d=google.com; s=arc-20160816; b=qlXOkY97Wz4QKl8oUUwDo6ttijNgPs1Y/fsSLfVw4RIbtvylLTcq/6H2XWzKpDdrlE s1qpGkKBcv3cMUgUjyAMp1oIFKy62ob/FfpcTVL+BKElspITho3ZBv+XU/6WNy4iEys7 tGBMpSvW4sqd2vuiSHfXNeH2K02UOTdTnaAQLjVa/uCwzs7+GQIx+6N5WU+SxZFTZRJW A9EDzDEltT3wIJVYht9mGytwPH8ysAL/cup2fywH2vW845kLy8Xy9R7iqw0phAVdU35D c1j3zKyZFUDfNe3gI+6Fybf7ecuesXZOu52NIsPdRVgozIqZQUgDY3NNV6ozR3/ZEV87 lOjw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pnkc3bVHJ44ZhlX2UHNPNK3hei2AXjG8LGcABU5tNFo=; b=1LyBDFHyI4jfMHWJ8Jiac0wwCG+1nrTV1whfBWZV8gYUw+xLTKWPitE9DzKGyY3DdW 5IgCTP05tGNTdQIhWA1Lyb1KLU6mbQ1gYJ3dQaRquhr+6bTZ408KzdEk3QgHV3kGmqFO DVxAU8YNKUFVyfyKLz4XF+fCksjpJav/RXn0A6geMM8IBNCcwyg02+UyId7rj14FWoXj JvC3x81tbBnhPs//bYE31ccHVM2lRrBiT9MY43GQKgyCcpuUanzJeYkNLwSoaD2dIQm+ t1LDnL24gXDXQEloquBt5fdLpSdmSCV7NzxRImXc/uPb/nzNpKTaTYgVCuLxwJzbDoTR PecQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aMTgkkv4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w12si15510332jap.71.2021.05.10.04.02.42; Mon, 10 May 2021 04:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aMTgkkv4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232050AbhEJK5z (ORCPT + 99 others); Mon, 10 May 2021 06:57:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:52050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233158AbhEJKpO (ORCPT ); Mon, 10 May 2021 06:45:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BC2261139; Mon, 10 May 2021 10:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642899; bh=ToYEWJBfBe7uy9FNJBzal6edEQ79xdeRGx54h0TVt9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMTgkkv4qs8xkQYOk6r7WfkH8dCSTVJPZOWn4GqRp1RdKlxiWJ/PlKThyFwr3Z/oc TYbe4/qyVguJAFT7/69mtGelX2+Di1M9UIozOuaTKMf3xVQGquM46R8BZEBbfC4pOR BVyLoVs/TfcJsNprfNByrUWyF+20f9j4psiGoxWk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felipe Balbi , Thinh Nguyen , Sasha Levin Subject: [PATCH 5.10 098/299] usb: dwc3: gadget: Check for disabled LPM quirk Date: Mon, 10 May 2021 12:18:15 +0200 Message-Id: <20210510102008.173563302@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thinh Nguyen [ Upstream commit 475e8be53d0496f9bc6159f4abb3ff5f9b90e8de ] If the device doesn't support LPM, make sure to disable the LPM capability and don't advertise to the host that it supports it. Acked-by: Felipe Balbi Signed-off-by: Thinh Nguyen Link: https://lore.kernel.org/r/9e68527ff932b1646f92a7593d4092a903754666.1618366071.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 4 +++- drivers/usb/dwc3/gadget.c | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3101f0dcf6ae..1ffeb00b9391 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1297,6 +1297,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,usb3_lpm_capable"); dwc->usb2_lpm_disable = device_property_read_bool(dev, "snps,usb2-lpm-disable"); + dwc->usb2_gadget_lpm_disable = device_property_read_bool(dev, + "snps,usb2-gadget-lpm-disable"); device_property_read_u8(dev, "snps,rx-thr-num-pkt-prd", &rx_thr_num_pkt_prd); device_property_read_u8(dev, "snps,rx-max-burst-prd", diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 1b241f937d8f..575a93b4f120 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1026,7 +1026,8 @@ struct dwc3_scratchpad_array { * @dis_start_transfer_quirk: set if start_transfer failure SW workaround is * not needed for DWC_usb31 version 1.70a-ea06 and below * @usb3_lpm_capable: set if hadrware supports Link Power Management - * @usb2_lpm_disable: set to disable usb2 lpm + * @usb2_lpm_disable: set to disable usb2 lpm for host + * @usb2_gadget_lpm_disable: set to disable usb2 lpm for gadget * @disable_scramble_quirk: set if we enable the disable scramble quirk * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk * @u2ss_inp3_quirk: set if we enable P3 OK for U2/SS Inactive quirk @@ -1227,6 +1228,7 @@ struct dwc3 { unsigned dis_start_transfer_quirk:1; unsigned usb3_lpm_capable:1; unsigned usb2_lpm_disable:1; + unsigned usb2_gadget_lpm_disable:1; unsigned disable_scramble_quirk:1; unsigned u2exit_lfps_quirk:1; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 5b5520286eff..0ffd2a4e6309 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3398,6 +3398,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) /* Enable USB2 LPM Capability */ if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A) && + !dwc->usb2_gadget_lpm_disable && (speed != DWC3_DSTS_SUPERSPEED) && (speed != DWC3_DSTS_SUPERSPEED_PLUS)) { reg = dwc3_readl(dwc->regs, DWC3_DCFG); @@ -3424,6 +3425,12 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) dwc3_gadget_dctl_write_safe(dwc, reg); } else { + if (dwc->usb2_gadget_lpm_disable) { + reg = dwc3_readl(dwc->regs, DWC3_DCFG); + reg &= ~DWC3_DCFG_LPM_CAP; + dwc3_writel(dwc->regs, DWC3_DCFG, reg); + } + reg = dwc3_readl(dwc->regs, DWC3_DCTL); reg &= ~DWC3_DCTL_HIRD_THRES_MASK; dwc3_gadget_dctl_write_safe(dwc, reg); @@ -3871,7 +3878,7 @@ int dwc3_gadget_init(struct dwc3 *dwc) dwc->gadget->speed = USB_SPEED_UNKNOWN; dwc->gadget->sg_supported = true; dwc->gadget->name = "dwc3-gadget"; - dwc->gadget->lpm_capable = true; + dwc->gadget->lpm_capable = !dwc->usb2_gadget_lpm_disable; /* * FIXME We might be setting max_speed to