lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9d3a870fdd71fd2ed5a4a5992b2dd39388eaedd5.camel@suse.de>
Date:   Mon, 17 Feb 2020 12:12:42 +0100
From:   Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Mathias Nyman <mathias.nyman@...el.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Ray Jui <rjui@...adcom.com>,
        Scott Branden <sbranden@...adcom.com>,
        bcm-kernel-feedback-list@...adcom.com, oneukum@...e.com,
        phil@...pberrypi.com, tim.gover@...pberrypi.org,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-rpi-kernel@...ts.infradead.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH] usb: xhci-pci: Raspberry Pi FW loader for VIA VL805

Hi Greg, thanks for having a look at this.

On Mon, 2020-02-17 at 11:36 +0100, Greg Kroah-Hartman wrote:

[...]

> > +#include <soc/bcm2835/raspberrypi-firmware.h>
> 
> 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"
> >  
> > @@ -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?

Yes, although...

> > +	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?

...you're right here, on non-rpi systems this will just return without errors.
On top of that, most VL805 users don't use device-tree, so it'll be fast.

> > +
> > +	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?

I think moving it into firmware/raspberrypi.c should be acceptable. That said
I'd still be on the loose regarding the include file, and the platform specific
function call in xhci_pci_probe(). Any suggestions?
Note that it's important to us to be able to defer the probe as the firmware
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, 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?

Noted, I'll update that.

Regards,
Nicolas


Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ