Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle probe dependencies and hard errors better #6645

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

pelwell
Copy link
Contributor

@pelwell pelwell commented Feb 3, 2025

#6642 is a report of intermittent failures for the PIO driver to contact the firmware. These failures can be traced to the failure of PIO driver to distinguish hard errors and transient failures. The commits in this PR fix the PIO driver in this regard, but also improve the firmware driver to avoid pointless retries in the event that the firmware is not compatible.

platform_set_drvdata(pdev, fw);
} else {
kfree(fw);
platform_set_drvdata(pdev, ERR_PTR(-ENOENT));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do dereference this in rp1_firmware_remove (without a check).
I'm not sure if that can happen, but looks like a potential pitfall.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing the obvious fix has uncovered some deficiencies in the end-of-life code. Thank goodness for runtime overlays.

If the RP1 firmware has reported an error then return that from the PIO
probe function, otherwise defer the probing.

Link: raspberrypi#6642

Signed-off-by: Phil Elwell <[email protected]>
To avoid pointless retries, let the probe function succeed if the
firmware interface is configured correctly but the firmware is
incompatible. The value of the private drvdata field holds the outcome.

Link: raspberrypi#6642

Signed-off-by: Phil Elwell <[email protected]>
The of_xlate method saves the calculated event mask in the con_priv
field. It also rejects subsequent attempt to use that channel because
the mask is non-zero, which causes a repeated instantiation of a client
driver to fail.

The of_xlate method is not meant to be a point of resource acquisition.
Leave the con_priv initialisation, but drop the test that it was
previously zero.

Signed-off-by: Phil Elwell <[email protected]>
@pelwell
Copy link
Contributor Author

pelwell commented Feb 4, 2025

With the latest updates, the rp1 firmware driver and pio driver can be repeatedly instantiated and removed with no crashes or obvious leaks.

@pelwell pelwell merged commit 4d577c4 into raspberrypi:rpi-6.6.y Feb 4, 2025
12 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Feb 4, 2025
See: raspberrypi/linux#6636

kernel: misc: rp1-pio: SM_CONFIG_XFER32 = larger DMA bufs
See: raspberrypi/linux#6640

kernel: Handle probe dependencies and hard errors better
See: raspberrypi/linux#6645

kernel: spi: dw: Wait for idle after TX
See: raspberrypi/linux#6646
See: raspberrypi/linux#6649
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Feb 4, 2025
See: raspberrypi/linux#6636

kernel: misc: rp1-pio: SM_CONFIG_XFER32 = larger DMA bufs
See: raspberrypi/linux#6640

kernel: Handle probe dependencies and hard errors better
See: raspberrypi/linux#6645

kernel: spi: dw: Wait for idle after TX
See: raspberrypi/linux#6646
See: raspberrypi/linux#6649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants