Re: [PATCH v7 08/11] misc: rp1: RaspberryPi RP1 misc driver

Andrea della Porta
2025-03-18T09:44:56Z

Hi Krzysztof,

On 17:37 Fri 14 Mar , Krzysztof Wilczynski wrote:
> Hello,
>
> Even though this is not for the PCI sub-system directly, I had a very brief
> look over the code. I hope you don't mind.

Highly appreciated, thanks!

>
> As such, a few nit picks, nothing blocking.
>
> > +# RaspberryPi RP1 misc device
>
> Would this be better if it matched the "tristate" description below?

Ack.

>
> > +config MISC_RP1
> > + tristate "RaspberryPi RP1 PCIe support"
> > + depends on OF_IRQ && OF_OVERLAY && PCI_MSI && PCI_QUIRKS
> > + select PCI_DYNAMIC_OF_NODES
> > + help
> > + Support the RP1 peripheral chip found on Raspberry Pi 5 board.
> > +
> > + This device supports several sub-devices including e.g. Ethernet
> > + controller, USB controller, I2C, SPI and UART.
> > +
> > + The driver is responsible for enabling the DT node once the PCIe
> > + endpoint has been configured, and handling interrupts.
> > +
> > + This driver uses an overlay to load other drivers to support for
> > + RP1 internal sub-devices.
>
> > +/* the dts overlay is included from the dts directory so
>
> /*
> * The dts overlay is included from the dts directory so
>
> To make the code comment match rest of the style.

Ack.

>
> > +/*
> > + * Copyright (c) 2018-24 Raspberry Pi Ltd.
> > + * All rights reserved.
>
> Copyright (c) 2018-2025 Raspberry Pi Ltd.
>
> To spell the current year fully, plus update it to 2025 already.
>
> I would also add an extra newline here to split the two apart a bit.

Ack.

>
> > + if (pci_resource_len(pdev, 1) <= 0x10000) {
> > + dev_err(&pdev->dev,
> > + "Not initialised - is the firmware running?\n");
> > + return -EINVAL;
> > + }
>
> The American spelling in the above might be better. But I don't have
> strong opinions here. It seems more popular in error messages.

I agree.

>
> > + err = pci_alloc_irq_vectors(pdev, RP1_INT_END, RP1_INT_END,
> > + PCI_IRQ_MSIX);
> > + if (err < 0) {
> > + return dev_err_probe(&pdev->dev, err,
> > + "pci_alloc_irq_vectors failed");
>
> Missing a new line at the end, but also...
>
> return dev_err_probe(&pdev->dev, err,
> "Failed to allocate MSI-X vectors\n");

Ack.

>
> Or, something like this over this the function name. Perhaps exposing
> error code could be useful to the end user? If so then something like this:
>
> return dev_err_probe(&pdev->dev, err,
> "Failed to allocate MSI-X vectors, err=%d\n", err);

dev_err_probe() should already print the err code, no need to add it.

>
> Here and other errors where appropriate.

I've changed dev_err() to dev_err_probe() in cases where the error code
is not evident (i.e. hardcoded) from the source.

>
> > + for (i = 0; i < RP1_INT_END; i++) {
> > + unsigned int irq = irq_create_mapping(rp1->domain, i);
> > +
> > + if (!irq) {
> > + dev_err(&pdev->dev, "failed to create irq mapping\n");
>
> dev_err(&pdev->dev, "Failed to create IRQ mapping\n");
>
> To make the error message capitalisation consistent.

Ack.

>
> > +static const struct pci_device_id dev_id_table[] = {
> > + { PCI_DEVICE(PCI_VENDOR_ID_RPI, PCI_DEVICE_ID_RPI_RP1_C0), },
> > + { 0, }
>
> { }
>
> Would probably be sufficient.

Ack.

>
> > +MODULE_AUTHOR("Phil Elwell <phil@raspberrypi.com>");
> > +MODULE_AUTHOR("Andrea della Porta <andrea.porta@suse.com>");
> > +MODULE_DESCRIPTION("RP1 wrapper");
>
> RaspberryPi RP1 misc device
>
> To match the Kconfig comment in the above description or the one from the
> "tristate" also in Kconfig.

Ack.

>
> Thank you for all the work here!

Thank you so much for your review!

Andrea

>
> Krzysztof