Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4714690ybv; Mon, 17 Feb 2020 04:33:53 -0800 (PST) X-Google-Smtp-Source: APXvYqznqoCo0r1QX88qHH0wf+14nWgBSUmf2SsopeiVSGf0LhSI6hdxC2b2YwfpI+eea/gL9YSc X-Received: by 2002:a05:6830:1e76:: with SMTP id m22mr6672881otr.295.1581942832909; Mon, 17 Feb 2020 04:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581942832; cv=none; d=google.com; s=arc-20160816; b=qGLkhVJKFZR4K9WY6b7pKA3eUhWdV7Xk3QJRqtfwwz0G7/lQTSUw4gek80bDRpoIJI N50qJ+bwARstJa42FTOn2h+Ep2iYaHNtL6179OK/i0a/4Q8y6BskbfXu4qNqnm0tIJ3o 6oePsjEN68qf8T0YGlX8hYYyEaQ4qKQYwUxhtBFEOwX1IEk1w1MYg8F+eT4z+sSBVLSu SWdSKUupmXWblgbJPgPscmC84WIvzHuPtwzXMWAMI9r2pSW8KQw1u2v2RKO5Vk/NN6Bd goKJ2h0nz0pCU6m3ttpU1KmRQzxGgrRvrKLnN6i3cnWiv4KQqGSUlaAq3S6fAOVvpX0m G92g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=aNTF4P1uqNQZVMGJLHo19kL7tQ6S3d+dIRhKOYS/9Fs=; b=VwmfnjEiT+SoMPOUqn1wjp2sTwmqOZKpqRHi1uI5CRaIWE9PpP4pPsU9rtp2sjPm3x VX4DMIH/HflpCj63QXGfRugWuIlsONfUCcnC6r/GF0uk/M7pY6Vtd4yVZzpPd5Mj0yYT XcUHa8GmsVMuoBwknqqnW37H9Qu5ZuOF6Wy5gu0t8E+oSfR1mzVt/z/9xFWmNGq7pFuu bJ+Yh/vG4vkPSQrTqBhPKaoUfF3FZzU3kK0Dlb2fQl2zDatrN9QlL54mYBoDDa8Wf9sG vzS4hnLY/ZjSAc2eBNWOYAZHmoJNDsmpYIzvJbSRd/SgQvhXjaaYonMgLGv1iyzAtCs0 mGZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si130716ota.299.2020.02.17.04.33.39; Mon, 17 Feb 2020 04:33:52 -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; 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 S1728097AbgBQLMt (ORCPT + 99 others); Mon, 17 Feb 2020 06:12:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:48004 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbgBQLMt (ORCPT ); Mon, 17 Feb 2020 06:12:49 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0CB5EB05D; Mon, 17 Feb 2020 11:12:45 +0000 (UTC) Message-ID: <9d3a870fdd71fd2ed5a4a5992b2dd39388eaedd5.camel@suse.de> Subject: Re: [PATCH] usb: xhci-pci: Raspberry Pi FW loader for VIA VL805 From: Nicolas Saenz Julienne To: Greg Kroah-Hartman 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 Date: Mon, 17 Feb 2020 12:12:42 +0100 In-Reply-To: <20200217103605.GA93732@kroah.com> References: <20200217100701.19949-1-nsaenzjulienne@suse.de> <20200217103605.GA93732@kroah.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-XZFCLbgsBknBnaLkhP22" User-Agent: Evolution 3.34.3 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-XZFCLbgsBknBnaLkhP22 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Greg, thanks for having a look at this. On Mon, 2020-02-17 at 11:36 +0100, Greg Kroah-Hartman wrote: [...] > > +#include >=20 > That feels really wrong :( I know, not that happy about it either, but I had to start with something := ) > > + > > #include "xhci.h" > > #include "xhci-trace.h" > > =20 > > @@ -308,6 +310,44 @@ static int xhci_pci_setup(struct usb_hcd *hcd) > > return xhci_pci_reinit(xhci, pdev); > > } > > =20 > > +/* > > + * On the Raspberry Pi 4, after a PCI reset, VL805's firmware may eith= er 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 >=20 > Can you just put #ifdefs in a .h file instead please? Yes, although... > > + struct device_node *fw_np; > > + struct rpi_firmware *fw; > > + u32 dev_addr; > > + int ret; > > + > > + fw_np =3D of_find_compatible_node(NULL, NULL, > > + "raspberrypi,bcm2835-firmware"); > > + if (!fw_np) > > + return 0; >=20 > So for non-rpi systems, this will work just fine, no need to #ifdef out > the whole function, right? ...you're right here, on non-rpi systems this will just return without erro= rs. On top of that, most VL805 users don't use device-tree, so it'll be fast. > > + > > + fw =3D rpi_firmware_get(fw_np); > > + of_node_put(fw_np); > > + if (!fw) > > + return -EPROBE_DEFER; > > + > > + dev_addr =3D pdev->bus->number << 20 | PCI_SLOT(pdev->devfn) << 15 | > > + PCI_FUNC(pdev->devfn) << 12; > > + > > + ret =3D 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? I think moving it into firmware/raspberrypi.c should be acceptable. That sa= id I'd still be on the loose regarding the include file, and the platform spec= ific function call in xhci_pci_probe(). Any suggestions? Note that it's important to us to be able to defer the probe as the firmwar= e inteface bringup might race with xHC's > > + > > /* > > * 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, con= st > > struct pci_device_id *id) > > =20 > > driver =3D (struct hc_driver *)id->driver_data; > > =20 > > + if (dev->vendor =3D=3D PCI_VENDOR_ID_VIA && dev->device =3D=3D 0x3483= ) { > > + retval =3D raspberrypi_load_vl805_fw(dev); > > + if (retval) { > > + if (retval !=3D -EPROBE_DEFER) > > + dev_err(&dev->dev, > > + "Failed to load VL805's firmware"); >=20 > Shouldn't the function print an error if there is one? Noted, I'll update that. Regards, Nicolas --=-XZFCLbgsBknBnaLkhP22 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl5KdSoACgkQlfZmHno8 x/6d/Af5AT5S0Pwl8xDlumP0TchdnzD/yXqk8Z3/Ysr8N+PeZKeXQpprFdma2otT z3axXIyIc2syYEscAQUqge9eKMfgHPBbsCSPICAEl00hQysxFxPmc1kJlhzxkN+F 6p3LRnzdUgVWGoc8ZMfym6EFVOlVcmQWqYKa4XaNhyhMIIMr0c5xfW2GSXpMFsNj ZtKXzOkDVUdeD7bAZKXELiQL/O3Kgqaut8Wm4F3ux9qTTxLv8WhWNk/dIOrwIpfm 4zy6GgZ2zmr+3rP0JNXqSujyjh9ZYj2cuJ75c/JeRzVa5r4b5ARhZ64F5ZpP+slW q5LpISI31g/y0STz1WxFgvLwttMljg== =QcVm -----END PGP SIGNATURE----- --=-XZFCLbgsBknBnaLkhP22--