Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4695414ybv; Mon, 17 Feb 2020 04:11:13 -0800 (PST) X-Google-Smtp-Source: APXvYqwhLEiB8+vvRpM6hJ9UF+3Lp3zZ0IHlusLDnYhbL13RBOgi6VAJWKJ4X7vwpuUCIfKpShCO X-Received: by 2002:aca:4e10:: with SMTP id c16mr9306104oib.6.1581941473268; Mon, 17 Feb 2020 04:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581941473; cv=none; d=google.com; s=arc-20160816; b=PFNqKp1cr1jeVV2DeEuW3QHXyGNtjqxX6dyzY2u/761jMjpwg2X+bzOmjqKo1jjQbo YVCp4RFFPg5ceKk6dKYJeOGUnKGwXp+9EP+e89W3bzNm2YRchaH3eYmFPzbKgofvoyO9 qfd8kZqcMi85zDJGvyJrzNOYwh1Mz6ZV106SgIOsDrFkntEFLLPny3myOshTq7R238gu FqYvInXkdp69ghJEb1p09V62/NGyb5jM4VnODHKmybK3QBgwuAb9FZF/EfCbs+JX17Hf +5S1g8JYtz5z4MV4TAzD7YNCIvVu915yRt+k0zjRvqZh5gk13tTc63I9Z7+iEybzw9Ut P2jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Oae4wkCR5IFn8j/CPv/ZmgCOb7r/a1QxA6EgTZQxYuQ=; b=yAXyLkzwX/+IX526ZcfzTgpB5GzKjnuN1VhSLPJs8uhycyZPMJqblsZLMtmMa7JWIt 5QSrP8kjhuinzzEUKHaMpmYIDLLBB6grUDUfxOhT5FVhMef1v6cl7Qd993vZhL0RM2S2 FSEyD5o113MbO7mFUDaFRx+5aoYyXwFIQvPQ+e9JfbAGi9tvV0stbZRKby/eznCKYzO/ xybouAvGB6fcjpXPm4h+12sk3TcldcOd9Xk/zN+CZmPyNx95cnxQ4iYgKkCIMK44ebOP Sg4/E4EaKgQdGoW/gWhqZLP9x/RHiilJey2sKnQNHpSvmD00bgxxaH+9F01kQYnTjpHX QR1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eYlTq6hf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si6291238oif.167.2020.02.17.04.10.21; Mon, 17 Feb 2020 04:11:13 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=eYlTq6hf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729217AbgBQKgI (ORCPT + 99 others); Mon, 17 Feb 2020 05:36:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:42250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbgBQKgI (ORCPT ); Mon, 17 Feb 2020 05:36:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB2D420725; Mon, 17 Feb 2020 10:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581935767; bh=60viLGKf79jXAYXHImdhwgxFlEuSkAt+HsIyxhV25lA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eYlTq6hflCJzX6XFC6jLt7AvBAgZw/8p1du/CYSw/mqOuHrhFtercBxM1Wi6zCe5m eQI8yyOD/oy5vnxuSOpYCuQ2gZNaYbD8fLHnV+lyHYSiZAhWLuWghe8Avhpb7BWE6G 3J5NZqs8bYpPR2a2GT0Hj/sZExxyxFG6CYA/ACYo= Date: Mon, 17 Feb 2020 11:36:05 +0100 From: Greg Kroah-Hartman To: Nicolas Saenz Julienne Cc: Mathias Nyman , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, oneukum@suse.com, phil@raspberrypi.com, tim.gover@raspberrypi.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] usb: xhci-pci: Raspberry Pi FW loader for VIA VL805 Message-ID: <20200217103605.GA93732@kroah.com> References: <20200217100701.19949-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200217100701.19949-1-nsaenzjulienne@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 17, 2020 at 11:07:00AM +0100, Nicolas Saenz Julienne wrote: > On the Raspberry Pi 4, after a PCI reset, VL805's firmware may either be > loaded directly from an EEPROM or, if not present, by the SoC's > VideCore. Inform VideCore that VL805 was just reset, or defer xhci's > probe if not yet joinable trough the mailbox interface. > > Based on Tim Gover's downstream implementation. > > Signed-off-by: Nicolas Saenz Julienne > --- > drivers/usb/host/xhci-pci.c | 50 ++++++++++++++++++++++ > include/soc/bcm2835/raspberrypi-firmware.h | 2 +- > 2 files changed, 51 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c > index 4917c5b033fa..eadace4a9339 100644 > --- a/drivers/usb/host/xhci-pci.c > +++ b/drivers/usb/host/xhci-pci.c > @@ -13,6 +13,8 @@ > #include > #include > > +#include That feels really wrong :( > + > #include "xhci.h" > #include "xhci-trace.h" > > @@ -308,6 +310,44 @@ static int xhci_pci_setup(struct usb_hcd *hcd) > return xhci_pci_reinit(xhci, pdev); > } > > +/* > + * On the Raspberry Pi 4, after a PCI reset, VL805's firmware may either be > + * loaded directly from an EEPROM or, if not present, by the SoC's VideCore. > + * Inform VideCore that VL805 was just reset, or defer xhci's probe if not yet > + * joinable trough the mailbox interface. > + */ > +static int raspberrypi_load_vl805_fw(struct pci_dev *pdev) > +{ > +#ifdef CONFIG_RASPBERRYPI_FIRMWARE Can you just put #ifdefs in a .h file instead please? > + struct device_node *fw_np; > + struct rpi_firmware *fw; > + u32 dev_addr; > + int ret; > + > + fw_np = of_find_compatible_node(NULL, NULL, > + "raspberrypi,bcm2835-firmware"); > + if (!fw_np) > + return 0; So for non-rpi systems, this will work just fine, no need to #ifdef out the whole function, right? > + > + fw = rpi_firmware_get(fw_np); > + of_node_put(fw_np); > + if (!fw) > + return -EPROBE_DEFER; > + > + dev_addr = pdev->bus->number << 20 | PCI_SLOT(pdev->devfn) << 15 | > + PCI_FUNC(pdev->devfn) << 12; > + > + ret = rpi_firmware_property(fw, RPI_FIRMWARE_NOTIFY_XHCI_RESET, > + &dev_addr, sizeof(dev_addr)); > + if (ret) > + return ret; > + > + dev_dbg(&pdev->dev, "loaded Raspberry Pi's VL805 firmware\n"); > + > +#endif > + return 0; > +} Why not put this whole function in some rpi-platform code? > + > /* > * We need to register our own PCI probe function (instead of the USB core's > * function) in order to create a second roothub under xHCI. > @@ -321,6 +361,16 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) > > driver = (struct hc_driver *)id->driver_data; > > + if (dev->vendor == PCI_VENDOR_ID_VIA && dev->device == 0x3483) { > + retval = raspberrypi_load_vl805_fw(dev); > + if (retval) { > + if (retval != -EPROBE_DEFER) > + dev_err(&dev->dev, > + "Failed to load VL805's firmware"); Shouldn't the function print an error if there is one? thanks, greg k-h