Skip to content

Apple drivers: allmodconfig sparse/W=1 warnings and checkpatch whitespace errors (no code change) - #2834

Open
RyanTheTide wants to merge 6 commits into
integration/aurorafrom
code-health/checkpatch-errors-20261123
Open

RyanTheTide wants to merge 6 commits into
integration/aurorafrom
code-health/checkpatch-errors-20261123

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

The first code-health pass (#2827) only built what the fleet config enables. An arm64 allmodconfig build (COMPILE_TEST, 4K pages) with W=1 and sparse over the Apple driver dirs turns up a few more warnings in code the fleet build never compiles that way:

  • apple-dart-dcp.h: apple_dart_host_lock()/apple_dart_host_unlock() raise -Wunused-function in every build without CONFIG_APPLE_DART_J713_DCP (APPLE_DART=m, 4K pages).
  • centauri Wi-Fi: the ring tail is polled as __le16 into a u16, and PCI_D0/PCI_D3hot are written into PCI_PM_CTRL without a __force cast (7 sparse warnings).
  • ATC PHY: sparse flags !!a | (!!b << 1) on bools as "dubious: !x | y".
  • AVD: the LSR address word truncation that sparse reports for constant test addresses.

There are also 166 checkpatch --strict ERRORs in the original scope. Most are whitespace.

Change

Six commits, none of which should change behaviour:

  1. wifi: apple: centauri: __le16 tail, (__force u16)PCI_D*.
  2. iommu/apple-dart: __maybe_unused on the two host-lock helpers. static inline also silences the warning, but it changed clang's inlining in apple-dart.o, so it isn't used.
  3. phy: apple: atc: drop the !! on bool lane flags.
  4. media: apple: avd: lower_32_bits() for the LSR address word.
  5. drm/apple: tabs for indentation, } else {, and paren spacing in DCP_FW_VERSION().
  6. media: apple: avd, soc: apple: tabs for indentation, bracket spacing in the AV1 CDF table declarations, and const char * / (type *) spacing.

The whitespace commits only touch lines that no open PR edits (checked against the hunks of every open PR, within 4 lines). Files that 10 or more open PRs touch are left alone.

Testing

  • The generated code is identical before and after for every object in drivers/{soc/apple,gpu/drm/apple,media/platform/apple,iommu,phy/apple,net/wireless/apple}. The comparison covers llvm-objdump -d text and llvm-nm -S function sizes in two configs: fleet79 (16K, J713 DCP on, 230/230 objects) and arm64 allmodconfig (253/253 objects).
  • allmodconfig W=1 + sparse: the targeted warnings go from 15 to 0, and nothing new appears.
  • checkpatch --strict ERRORs in the 19 touched files go from 101 to 52. What is left: AOM_CDF initializer-list macros (false positives), lines that open PRs touch, and one COMPLEX_MACRO.
  • checkpatch --strict on each patch: 0 errors. There is one warning (kzalloc_obj), and it is on a line this PR only re-indents.

Still to run

CI. No hardware rows are needed because the object code is identical.

Reviewer detail

Assisted-by: LLM (Claude:Opus 5.5)

…se types

sparse (C=1, allmodconfig) reports four "cast to restricted __le16" and
three "restricted pci_power_t degrades to integer" warnings here:

- The IPC send and hello paths poll a little-endian ring index with
  READ_ONCE() into a u16 and then pass that to le16_to_cpu(). Declare the
  local as __le16, which is what it holds. The conversion and the
  comparison are unchanged.
- PCI_D0 and PCI_D3hot are pci_power_t (__bitwise). Writing them into
  PCI_PM_CTRL needs a __force u16 cast, as drivers/pci/pci.c does.

No functional change: the generated code is identical.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
apple_dart_host_lock() and apple_dart_host_unlock() live in
apple-dart-dcp.h, but their only callers in apple-dart.c sit under
CONFIG_APPLE_DART_J713_DCP. Any build without that option (APPLE_DART=m,
4K pages, allmodconfig) gets two -Wunused-function warnings.

Mark them __maybe_unused. static inline would also silence the warning,
but it changes clang's inlining in apple-dart.o; __maybe_unused leaves
the generated code identical with CONFIG_APPLE_DART_J713_DCP=y.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
sparse warns "dubious: !x | y" on the DP lane mask. dp_lane[] is bool,
so the double negation does nothing; drop it. The generated code is
identical.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
On LSR variants push_address() pushes (addr >> 8) as a u32. When a KUnit
test passes a constant DMA address above 40 bits, sparse reports "cast
truncates bits from constant value". Only the low 32 bits of
(addr >> 8) go into the instruction word, so the truncation is
intended. Say so with lower_32_bits(). The generated code is identical.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Fix the checkpatch --strict ERRORs in drivers/gpu/drm/apple that are
whitespace only and that no open pull request touches:

- CODE_INDENT: indent with tabs (afk.h, audio.c, connector.c, dptxep.c,
  iomfb_internal.h, plane.c).
- ELSE_AFTER_BRACE: "} else {" in parser.c, with braces on both
  branches.
- SPACING: remove the inner spaces in DCP_FW_VERSION().

The generated code is identical. Files with many open PRs against them
(dcp.c, dcp-internal.h, iomfb.c, iomfb_template.c, apple_drv.c,
dcp-fabric.c) are left for later to avoid conflicts.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Fix the whitespace-only checkpatch --strict ERRORs and LEADING_SPACE
warnings in:

- avd-av1-entropymode.c: indent the CDF tables with tabs, drop the
  spaces inside the array bounds of the table declarations, and write
  one cast as "(type *)".
- avd.h: "const char *fw_name".
- soc/apple dockchannel.c, shim.h and mailbox-g17-test.h: indent with
  tabs.

The generated code is identical.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 537b04f.

I went through the whole diff, including with whitespace ignored, looking for anything that changes semantics. Nothing does.

  1. centauri __le16 tail (centauri_ipc.c:236/277, t6050/centauri_ipc.c:194/235): tail is only used as the READ_ONCE() target of an *(__le16 *) load and inside le16_to_cpu(tail). The bits and the comparison are unchanged.
  2. (__force u16)PCI_D0/PCI_D3hot (t6050/centauri_pci.c:404,1034,1046): the values are 0 and 3 and the expressions are already u16-wide, so the cast drops only the sparse annotation. There is no endianness question here; these are config-space words from pci_read/write_config_word().
  3. atc-j700-dp.h:486: dp_lane is bool dp_lane[2] (atc.c:670), so !! is a no-op.
  4. avd-inst.h:179: push() takes a u32, so lower_32_bits(addr >> 8) is the same truncation that already happened implicitly.
  5. __maybe_unused on the static DART host-lock helpers does not change linkage. The parser.c } else { braces wrap a single statement.
  6. With whitespace ignored, the remaining commits are empty. No string literal or format string changes. The #define DCP_FW_VERSION(x, y, z) name/paren spacing is unchanged, macro continuation backslashes are intact, and git diff --check is clean.

The size is fine (19 files, +75/-74, six commits split by subsystem). It does not need splitting.

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.

1 participant