Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp300083pxb; Thu, 26 Aug 2021 03:33:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXl/fwfpunUSmbQCR1rEWoB/QgyKPt069oCNaHaXLGhAVsVyZykNkVxB12QUTWpukVYucI X-Received: by 2002:a17:906:32cf:: with SMTP id k15mr3560078ejk.68.1629973985248; Thu, 26 Aug 2021 03:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629973985; cv=none; d=google.com; s=arc-20160816; b=NSgNTLygA5dAalVi/qXMh5Sl6Wxi3x816uVqTrK5Q3R3TlUYT8fFpoa+72xwGbEP7T iKtiDwuAzhkDZQBJHdoUG0qSKM12uElVM23kutfaXyN9mfABAKS5H1TP6cQIzPP4HFIe DyZv40d7X29p8i88l9A444SuCyXdN0rvXqFth6W4+DzGJSxiFbXP2X2uAcxJjgQ3Kmm6 XrC/47Bm4j0zBPgqSchFWL9XHNk08eidG/cecJ9XetT+5SWMsuORNNjP/lXLdew4CtOX FRDqhgtWzBikREYEtoFZjftC+fmgmN/KB/W748nRu1g4z4hglRDq+O/qmlZ3nN2yeMO4 tC7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=XzBXd5sld1gb9KLHCgzTUhnEwnOeZ3mfViFaHGsejfY=; b=rnVk6aHTLkMKktuLNZkg3yqzsROXoM1Y6S6Q75xp8tdkuKpLIIgr1YtRaELnMzPARJ /hjKJyaOoSI4a1zW9W3wHHC+0j3pPJwFBP126BIkoQl6r6NjfL9jb3LU8ZFnrSwHgqI8 YZF+xKywbPFIyDPdtCS6Tk1L6TOXdzWjLR5zXfJVnNyM78DUOeBcSQfi8V0R7VUg/cEZ mxPFU4O7f2sxrG7aISZqJ3aoxVUEn/HXGHkjc9bURBL77SebOpIbmDERHcE7fyLfbTVE tJhp9f8flSkMnSawyDccjsRrJfYazbUZxRL4P1tSg9EVs/AcxvWW6aDylFlHBuPqDhNI SJQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HAwngu+K; dkim=neutral (no key) header.i=@suse.de header.b="aS3IL/lV"; 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=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o2si2761691eds.325.2021.08.26.03.32.34; Thu, 26 Aug 2021 03:33:05 -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=@suse.de header.s=susede2_rsa header.b=HAwngu+K; dkim=neutral (no key) header.i=@suse.de header.b="aS3IL/lV"; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241456AbhHZK3L (ORCPT + 99 others); Thu, 26 Aug 2021 06:29:11 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:57274 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241435AbhHZK3K (ORCPT ); Thu, 26 Aug 2021 06:29:10 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0D20920182; Thu, 26 Aug 2021 10:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629973702; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XzBXd5sld1gb9KLHCgzTUhnEwnOeZ3mfViFaHGsejfY=; b=HAwngu+KyX5F7ARhejfbHtj+zY3kMllb6QgXqxJI+c41Zx2AHbRpbvHCWwHorM5uHG0hFp NWH+91zx8koTloM2ifa+7MvYzlYbxeVjKM8ijggbPQYdcYE/pm/KCH4jP/RMjnOw45T9TD aOLTpiaUhCIgTpF4J/QgwanANoEuq2A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629973702; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XzBXd5sld1gb9KLHCgzTUhnEwnOeZ3mfViFaHGsejfY=; b=aS3IL/lVrgLEHPlIZbQ1xq4qtRBXuFjb/IRPHM14qorYa/3Jbn8nlkt3qbHRYt9uWPfS7j q7yqRo410Q1ycTAg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 01602A3B89; Thu, 26 Aug 2021 10:28:21 +0000 (UTC) Date: Thu, 26 Aug 2021 12:28:21 +0200 Message-ID: From: Takashi Iwai To: Mathias Nyman Cc: Greg Kroah-Hartman , Moritz Fischer , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: renesas-xhci: Prefer firmware loading on unknown ROM state In-Reply-To: <20210819113427.1166-1-tiwai@suse.de> References: <20210819113427.1166-1-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Aug 2021 13:34:27 +0200, Takashi Iwai wrote: > > The recent attempt to handle an unknown ROM state in the commit > d143825baf15 ("usb: renesas-xhci: Fix handling of unknown ROM state") > resulted in a regression and reverted later by the commit 44cf53602f5a > ("Revert "usb: renesas-xhci: Fix handling of unknown ROM state""). > The problem of the former fix was that it treated the failure of > firmware loading as a fatal error. Since the firmware files aren't > included in the standard linux-firmware tree, most users don't have > them, hence they got the non-working system after that. The revert > fixed the regression, but also it didn't make the firmware loading > triggered even on the devices that do need it. So we need still a fix > for them. > > This is another attempt to handle the unknown ROM state. Like the > previous fix, this also tries to load the firmware when ROM shows > unknown state. In this patch, however, the failure of a firmware > loading (such as a missing firmware file) isn't handled as a fatal > error any longer when ROM has been already detected, but it falls back > to the ROM mode like before. The error is returned only when no ROM > is detected and the firmware loading failed. > > Along with it, for simplifying the code flow, the detection and the > check of ROM is factored out from renesas_fw_check_running() and done > in the caller side, renesas_xhci_check_request_fw(). It avoids the > redundant ROM checks. > > The patch was tested on Lenovo Thinkpad T14 gen (BIOS 1.34). Also it > was confirmed that no regression is seen on another Thinkpad T14 > machine that has worked without the patch, too. > > Fixes: 44cf53602f5a ("Revert "usb: renesas-xhci: Fix handling of unknown ROM state"") > BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1189207 > Signed-off-by: Takashi Iwai A gentle ping to confirm whether this gets a review or not. thanks, Takashi > --- > drivers/usb/host/xhci-pci-renesas.c | 35 +++++++++++++++++++---------- > 1 file changed, 23 insertions(+), 12 deletions(-) > > diff --git a/drivers/usb/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c > index aa88e57649a9..52599d96634f 100644 > --- a/drivers/usb/host/xhci-pci-renesas.c > +++ b/drivers/usb/host/xhci-pci-renesas.c > @@ -207,7 +207,8 @@ static int renesas_check_rom_state(struct pci_dev *pdev) > return 0; > > case RENESAS_ROM_STATUS_NO_RESULT: /* No result yet */ > - return 0; > + dev_dbg(&pdev->dev, "Unknown ROM status ...\n"); > + return -ENOENT; > > case RENESAS_ROM_STATUS_ERROR: /* Error State */ > default: /* All other states are marked as "Reserved states" */ > @@ -224,14 +225,6 @@ static int renesas_fw_check_running(struct pci_dev *pdev) > u8 fw_state; > int err; > > - /* Check if device has ROM and loaded, if so skip everything */ > - err = renesas_check_rom(pdev); > - if (err) { /* we have rom */ > - err = renesas_check_rom_state(pdev); > - if (!err) > - return err; > - } > - > /* > * Test if the device is actually needing the firmware. As most > * BIOSes will initialize the device for us. If the device is > @@ -591,21 +584,39 @@ int renesas_xhci_check_request_fw(struct pci_dev *pdev, > (struct xhci_driver_data *)id->driver_data; > const char *fw_name = driver_data->firmware; > const struct firmware *fw; > + bool has_rom; > int err; > > + /* Check if device has ROM and loaded, if so skip everything */ > + has_rom = renesas_check_rom(pdev); > + if (has_rom) { > + err = renesas_check_rom_state(pdev); > + if (!err) > + return 0; > + else if (err != -ENOENT) > + has_rom = false; > + } > + > err = renesas_fw_check_running(pdev); > /* Continue ahead, if the firmware is already running. */ > if (!err) > return 0; > > + /* no firmware interface available */ > if (err != 1) > - return err; > + return has_rom ? 0 : err; > > pci_dev_get(pdev); > - err = request_firmware(&fw, fw_name, &pdev->dev); > + err = firmware_request_nowarn(&fw, fw_name, &pdev->dev); > pci_dev_put(pdev); > if (err) { > - dev_err(&pdev->dev, "request_firmware failed: %d\n", err); > + if (has_rom) { > + dev_info(&pdev->dev, "failed to load firmware %s, fallback to ROM\n", > + fw_name); > + return 0; > + } > + dev_err(&pdev->dev, "failed to load firmware %s: %d\n", > + fw_name, err); > return err; > } > > -- > 2.26.2 >