Skip to content

Conversation

@opsiff
Copy link
Member

@opsiff opsiff commented Nov 7, 2025

fwnode: Fix kabi breakage due to reference count interface
deepin inclusion
category: kabi

Fixes: 12cd73c ("Add a property reference count interface for ACPI.")
Signed-off-by: Wentao Guan [email protected]

kABI: Fix kABI macros use COUNT_ARGS
deepin inclusion
category: bugfix

commit b229baa ("kernel.h: split out COUNT_ARGS() and CONCATENATE() to args.h")
move COUNT_ARGS to linux/args.h, it lead to make some headers not include it.
lead to strange build failed when use KABI_USE.
It can be reproduced in original rh_kabi.h(use centos 10) + upstream 6.6 in fwnode.h,
and commit 1dc05a2 ("device property: Replace custom implementation of COUNT_ARGS()")
include args.h, so it cannot be reproduced after v6.7 upstream.

Log:
In file included from ./include/linux/property.h:15,
from drivers/base/firmware_loader/fallback_platform.c:4:
./include/linux/fwnode.h:178:8: error: macro "_RH_KABI_REPLACE" requires 2 arguments, but only 1 given
178 | RH_KABI_USE(1, int b)
| ^ ~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/fwnode.h:130:
./include/linux/rh_kabi.h:441: note: macro "_RH_KABI_REPLACE" defined here
441 | # define _RH_KABI_REPLACE(_orig, _new)
|
./include/linux/rh_kabi.h:490:33: error: expected specifier-qualifier-list before ‘_RH_KABI_REPLACE’
490 | #define _RH_KABI_USE(...) _RH_KABI_REPLACE(VA_ARGS)
| ^~~~~~~~~~~~~~~~
./include/linux/rh_kabi.h:491:33: note: in expansion of macro ‘_RH_KABI_USE’
491 | #define RH_KABI_USE(n, ...) _RH_KABI_USE(__PASTE(_RH_KABI_USE, COUNT_ARGS(VA_ARGS))(n, VA_ARGS));
| ^~~~~~~~~~~~
./include/linux/fwnode.h:178:9: note: in expansion of macro ‘RH_KABI_USE’
178 | RH_KABI_USE(1, int b)

Fixes: 5083950 ("kABI: Introduce generic kABI macros to use for kABI workarounds")
Signed-off-by: Wentao Guan [email protected]

Summary by Sourcery

Fix build failures in the fwnode reference count interface by ensuring kABI macros have the required COUNT_ARGS definition and properly exposing the new operation slot.

Bug Fixes:

  • Include <linux/args.h> in deepin_kabi.h so COUNT_ARGS is available for kABI macros
  • Use DEEPIN_KABI_USE for property_count_reference_with_args in fwnode.h instead of reserving the slot to correctly apply the kABI replacement

deepin inclusion
category: bugfix

commit b229baa ("kernel.h: split out COUNT_ARGS() and CONCATENATE() to args.h")
move COUNT_ARGS to linux/args.h, it lead to make some headers not include it.
lead to strange build failed when use KABI_USE.
It can be reproduced in original rh_kabi.h(use centos 10) + upstream 6.6 in fwnode.h,
and commit 1dc05a2 ("device property: Replace custom implementation of COUNT_ARGS()")
include args.h, so it cannot be reproduced after v6.7 upstream.

Log:
In file included from ./include/linux/property.h:15,
                 from drivers/base/firmware_loader/fallback_platform.c:4:
./include/linux/fwnode.h:178:8: error: macro "_RH_KABI_REPLACE" requires 2 arguments, but only 1 given
  178 |         RH_KABI_USE(1, int b)
      | ^       ~~~~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/fwnode.h:130:
./include/linux/rh_kabi.h:441: note: macro "_RH_KABI_REPLACE" defined here
  441 | # define _RH_KABI_REPLACE(_orig, _new)                    \
      |
./include/linux/rh_kabi.h:490:33: error: expected specifier-qualifier-list before ‘_RH_KABI_REPLACE’
  490 | #define _RH_KABI_USE(...)       _RH_KABI_REPLACE(__VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~~~
./include/linux/rh_kabi.h:491:33: note: in expansion of macro ‘_RH_KABI_USE’
  491 | #define RH_KABI_USE(n, ...)     _RH_KABI_USE(__PASTE(_RH_KABI_USE, COUNT_ARGS(__VA_ARGS__))(n, __VA_ARGS__));
      |                                 ^~~~~~~~~~~~
./include/linux/fwnode.h:178:9: note: in expansion of macro ‘RH_KABI_USE’
  178 |         RH_KABI_USE(1, int b)

Fixes: 5083950 ("kABI: Introduce generic kABI macros to use for kABI workarounds")
Signed-off-by: Wentao Guan <[email protected]>
deepin inclusion
category: kabi

Fixes: 12cd73c ("Add a property reference count interface for ACPI.")
Signed-off-by: Wentao Guan <[email protected]>
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 7, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This patch restores kABI compatibility by refactoring the fwnode reference-count callback to use the DEEPIN_KABI_USE macro and adds the missing COUNT_ARGS definition via an args.h include in deepin_kabi.h.

Class diagram for updated fwnode_operations structure

classDiagram
class fwnode_operations {
    +void __iomem *iomap(struct fwnode_handle *fwnode, int index)
    +int irq_get(const struct fwnode_handle *fwnode, unsigned int index)
    +int add_links(struct fwnode_handle *fwnode)
    +DEEPIN_KABI_USE(1, int (*property_count_reference_with_args)(const struct fwnode_handle *fwnode, const char *list_name, const char *cells_name))
    +DEEPIN_KABI_RESERVE(2)
    +DEEPIN_KABI_RESERVE(3)
    +DEEPIN_KABI_RESERVE(4)
}
Loading

Class diagram for deepin_kabi.h include changes

classDiagram
class deepin_kabi_h {
    +#include <linux/args.h>
    +#include <linux/kconfig.h>
    +#include <linux/compiler.h>
    +#include <linux/stringify.h>
}
Loading

File-Level Changes

Change Details Files
Refactor fwnode Operations struct to use DEEPIN_KABI_USE for property_count_reference_with_args
  • Remove standalone property_count_reference_with_args pointer declaration
  • Replace DEEPIN_KABI_RESERVE(1) with DEEPIN_KABI_USE wrapping the function signature
  • Retain remaining DEEPIN_KABI_RESERVE slots
include/linux/fwnode.h
Add missing args header to supply COUNT_ARGS for kABI macros
  • Insert include <linux/args.h> at the top of deepin_kabi.h
include/linux/deepin_kabi.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link

deepin pr auto review

我来帮你分析这个 git diff 的修改内容:

  1. 代码变更概述:
  • 在 deepin_kabi.h 中添加了新的头文件包含 linux/args.h
  • 在 fwnode.h 中修改了 fwnode_operations 结构体的定义,使用 DEEPIN_KABI_USE 宏替换了原来的函数指针定义
  1. 代码质量分析:
    优点:
  • 使用了 KABI (Kernel Application Binary Interface) 机制来保证内核接口的稳定性
  • 通过宏定义的方式管理接口变更,便于版本控制和兼容性管理

潜在问题:

  • 新增的 linux/args.h 头文件包含需要确保在所有使用 deepin_kabi.h 的地方都是必要的
  • DEEPIN_KABI_USE 宏的使用需要确保其定义正确且与 DEEPIN_KABI_RESERVE 宏协调工作
  1. 安全性分析:
  • 修改主要涉及接口定义,没有直接的安全风险
  • 但是需要确保 DEEPIN_KABI_USE 宏的实现是安全的,不会引入内存访问问题
  1. 性能影响:
  • 修改主要是接口层面的,不会直接影响运行时性能
  • 通过宏定义的方式管理接口,编译时处理,对性能影响最小

改进建议:

  1. 对于 deepin_kabi.h:
#ifndef _LINUX_DEEPIN_KABI_H
#define _LINUX_DEEPIN_KABI_H

// 建议添加注释说明新增头文件的用途
#include <linux/args.h>  /* 用于参数处理相关宏定义 */
#include <linux/kconfig.h>
#include <linux/compiler.h>
#include <linux/stringify.h>
  1. 对于 fwnode.h:
struct fwnode_operations {
    // ... 其他成员 ...

    // 建议添加注释说明这个变更的目的
    /* 
     * 使用 KABI 机制管理 property_count_reference_with_args 函数指针,
     * 确保接口向后兼容性
     */
    DEEPIN_KABI_USE(1, int (*property_count_reference_with_args)(
        const struct fwnode_handle *fwnode, const char *list_name,
        const char *cells_name))
    
    // 建议为每个保留位添加注释说明未来可能的用途
    DEEPIN_KABI_RESERVE(2)  /* 保留用于未来扩展 */
    DEEPIN_KABI_RESERVE(3)  /* 保留用于未来扩展 */
    DEEPIN_KABI_RESERVE(4)  /* 保留用于未来扩展 */
  1. 其他建议:
  • 确保 DEEPIN_KABI_USE 和 DEEPIN_KABI_RESERVE 宏的定义是线程安全的
  • 考虑添加编译时检查,确保 DEEPIN_KABI_USE 的编号不会重复
  • 建议在相关文档中记录这些接口变更,便于其他开发者理解和使用

这些修改主要是为了更好地管理内核接口的兼容性,整体设计是合理的。只要确保宏定义的正确实现和适当的文档说明,这些变更是可以接受的。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shy129
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@opsiff opsiff merged commit 19a90fb into deepin-community:linux-6.6.y Nov 11, 2025
12 checks passed
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