Skip to content

soc: apple: pmgr-misc: test the ioremap result with IS_ERR - #337

Merged
RyanTheTide merged 1 commit into
omacom:integration/aurorafrom
joshuaswarren:w73/pmgr-misc-iserr
Nov 17, 2026
Merged

RyanTheTide merged 1 commit into
omacom:integration/aurorafrom
joshuaswarren:w73/pmgr-misc-iserr

Conversation

@joshuaswarren

Copy link
Copy Markdown

[Joshua's agent] apple_pmgr_init_device() maps the fabric-ps and dcs-ps windows with devm_platform_ioremap_resource_byname() and then tests the result with if (!base). That function returns an ERR_PTR, never NULL, when the window is missing, so a device tree without one of the two windows goes on to readl_relaxed() through the error pointer.

The intent of the check is plain: a missing window means that system device is absent and apple_pmgr_init_device() returns false, so probe still succeeds with the other one. This changes the test to IS_ERR(base), which makes the code do that.

Checked by reading only: the one-line change, no other file. Not built and not booted; I have no device tree that lacks one of the windows to reproduce it, so the failing case is from the function's return contract, not from a crash I saw.

devm_platform_ioremap_resource_byname() returns an ERR_PTR, never NULL, when the named register window is missing. The driver tested for NULL, so a device tree without a fabric-ps or dcs-ps window went on to read through the error pointer. The intent of the check is that a missing window means the device is absent; test for the error pointer.

Signed-off-by: Joshua Warren <[email protected]>
@joshuaswarren

Copy link
Copy Markdown
Author

[Joshua's agent] Review result for this head, from an agent reviewer reading the diff and the kernel source:

GREEN on 237e806

devm_platform_ioremap_resource_byname() goes through devm_ioremap_resource(), which returns an IOMEM_ERR_PTR and never NULL, so IS_ERR is the right test. In apple_pmgr_misc_probe the return value starts at -ENODEV and becomes 0 if either apple_pmgr_init_device() call returns true, so returning false for a missing window is what the callers expect. No other check in the file tests this pointer for NULL: the other .base tests use misc->devices[i].base, which is zero from kzalloc or a valid mapping.

@scottjones scottjones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The change is right. In this tree devm_platform_ioremap_resource_byname() goes through devm_ioremap_resource(), which returns IOMEM_ERR_PTR() on every failure path and never NULL (drivers/base/platform.c:148, lib/devres.c:136). So the old !base test could never catch a missing window. With IS_ERR the function returns false, probe treats that as "absent" as intended, and base is stored only after the check, so the later .base NULL tests stay correct.

Built clean with W=1 on aarch64. Both in-tree DTs name fabric-ps and dcs-ps, so this is hardening rather than a crash anyone is hitting today.

Two small things, neither blocking:

  • A trailer would help anyone picking this up: Fixes: ae69cad ("soc: apple: Add driver for Apple PMGR misc controls"). That's the copy blame points to here (the same patch also landed as fa7e09c).
  • A missing window still logs "invalid resource (null)" at error level even though probe succeeds. If absence is meant to be normal, checking platform_get_resource_byname() for NULL first would keep it quiet. That can be a later change.

@joshuaswarren

Copy link
Copy Markdown
Author

Note

🤖 GPT-6.1 Terra responding on behalf of Joshua Warren

The current checks pass on 237e8065d3b5c35f7e8d10eb48802015b3958bdf. The missing-resource log remains unchanged in this patch.

Scott, could you merge this when ready?

@joshuaswarren

Copy link
Copy Markdown
Author

Note

anthropic/claude-opus-5-5 responding on behalf of joshuawarren

Scott, a short follow-up: this is still approved at head 237e8065d3b5, it is mergeable, and all 13 checks pass. Could you merge it when you have a moment? Thank you.

@RyanTheTide
RyanTheTide added this pull request to the merge queue Nov 17, 2026
Merged via the queue into omacom:integration/aurora with commit c20794c Nov 17, 2026
14 checks passed
@aronvandepol aronvandepol mentioned this pull request Nov 23, 2026
7 tasks done
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.

3 participants