linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] kernel-hacking: introduce CONFIG_NO_AUTO_INLINE
@ 2025-04-11 10:51 Chen Linxuan
  2025-04-11 10:54 ` [RFC PATCH 1/7] nvme: add __always_inline for nvme_pci_npages_prp Chen Linxuan
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
  0 siblings, 2 replies; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:51 UTC (permalink / raw)
  To: Masahiro Yamada, Nathan Chancellor, Nicolas Schier, Peter Huewe,
	Jarkko Sakkinen, Jason Gunthorpe, Jani Nikula, Joonas Lahtinen,
	Rodrigo Vivi, Tvrtko Ursulin, David Airlie, Simona Vetter,
	Chengchang Tang, Junxian Huang, Leon Romanovsky, Keith Busch,
	Jens Axboe, Christoph Hellwig, Sagi Grimberg, Yishai Hadas,
	Shameer Kolothum, Kevin Tian, Alex Williamson, Andrew Morton,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Chen Linxuan
  Cc: linux-kbuild, linux-kernel, linux-integrity, intel-gfx, dri-devel,
	linux-rdma, linux-nvme, kvm, virtualization, linux-mm, llvm

This series introduces a new kernel configuration option NO_AUTO_INLINE,
which can be used to disable the automatic inlining of functions.

This will allow the function tracer to trace more functions
because it only traces functions that the compiler has not inlined.

Previous discussions can be found here:
Link: https://lore.kernel.org/all/20181028130945.23581-3-changbin.du@gmail.com/

Chen Linxuan (2):
  drm/i915/pxp: fix undefined reference to
    `intel_pxp_gsccs_is_ready_for_sessions'
  RDMA/hns: initialize db in update_srq_db()

Winston Wen (5):
  nvme: add __always_inline for nvme_pci_npages_prp
  mm: add __always_inline for page_contains_unaccepted
  vfio/virtio: add __always_inline for virtiovf_get_device_config_size
  tpm: add __always_inline for tpm_is_hwrng_enabled
  lib/Kconfig.debug: introduce CONFIG_NO_AUTO_INLINE

 Makefile                                   |  6 ++++++
 drivers/char/tpm/tpm-chip.c                |  2 +-
 drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h |  8 ++++++--
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c |  2 +-
 drivers/nvme/host/pci.c                    |  2 +-
 drivers/vfio/pci/virtio/legacy_io.c        |  2 +-
 lib/Kconfig.debug                          | 15 +++++++++++++++
 mm/page_alloc.c                            |  2 +-
 8 files changed, 32 insertions(+), 7 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC PATCH 1/7] nvme: add __always_inline for nvme_pci_npages_prp
  2025-04-11 10:51 [RFC PATCH 0/7] kernel-hacking: introduce CONFIG_NO_AUTO_INLINE Chen Linxuan
@ 2025-04-11 10:54 ` Chen Linxuan
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
  1 sibling, 0 replies; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:54 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
  Cc: Winston Wen, Chen Linxuan, linux-nvme, linux-kernel

From: Winston Wen <wentao@uniontech.com>

On x86_64 with gcc version 13.3.0, I build drivers/nvme/host/pci.c
with:

  make defconfig
  ./scripts/kconfig/merge_config.sh .config <(
    echo CONFIG_BLK_DEV_NVME=m
  )
  make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once" \
    drivers/nvme/host/pci.o

Then I get a compile error:

    CALL    scripts/checksyscalls.sh
    DESCEND objtool
    INSTALL libsubcmd_headers
    CC      drivers/nvme/host/pci.o
  In file included from <command-line>:
  drivers/nvme/host/pci.c: In function 'nvme_init':
  ././include/linux/compiler_types.h:557:45: error: call to '__compiletime_assert_878' declared with attribute error: BUILD_BUG_ON failed: nvme_pci_npages_prp() > NVME_MAX_NR_ALLOCATIONS
    557 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
        |                                             ^
  ././include/linux/compiler_types.h:538:25: note: in definition of macro '__compiletime_assert'
    538 |                         prefix ## suffix();                             \
        |                         ^~~~~~
  ././include/linux/compiler_types.h:557:9: note: in expansion of macro '_compiletime_assert'
    557 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
        |         ^~~~~~~~~~~~~~~~~~~
  ./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
     39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
        |                                     ^~~~~~~~~~~~~~~~~~
  ./include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
        |         ^~~~~~~~~~~~~~~~
  drivers/nvme/host/pci.c:3804:9: note: in expansion of macro 'BUILD_BUG_ON'
   3804 |         BUILD_BUG_ON(nvme_pci_npages_prp() > NVME_MAX_NR_ALLOCATIONS);
        |         ^~~~~~~~~~~~

Signed-off-by: Winston Wen <wentao@uniontech.com>
Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
---
 drivers/nvme/host/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index b178d52eac1b..9ab070a9f037 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -390,7 +390,7 @@ static bool nvme_dbbuf_update_and_check_event(u16 value, __le32 *dbbuf_db,
  * as it only leads to a small amount of wasted memory for the lifetime of
  * the I/O.
  */
-static int nvme_pci_npages_prp(void)
+static __always_inline int nvme_pci_npages_prp(void)
 {
 	unsigned max_bytes = (NVME_MAX_KB_SZ * 1024) + NVME_CTRL_PAGE_SIZE;
 	unsigned nprps = DIV_ROUND_UP(max_bytes, NVME_CTRL_PAGE_SIZE);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 2/7] mm: add __always_inline for page_contains_unaccepted
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
@ 2025-04-11 10:54   ` Chen Linxuan
  2025-04-11 10:54   ` [RFC PATCH 3/7] vfio/virtio: add __always_inline for virtiovf_get_device_config_size Chen Linxuan
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:54 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Winston Wen, Chen Linxuan, linux-mm, linux-kernel

From: Winston Wen <wentao@uniontech.com>

On x86_64 with gcc version 13.3.0, I compile mm/page_alloc.c with:

  make defconfig
  make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once" \
    mm/page_alloc.o

Then I get a compile error:

    CALL    scripts/checksyscalls.sh
    DESCEND objtool
    INSTALL libsubcmd_headers
    CC      mm/page_alloc.o
  In file included from <command-line>:
  mm/page_alloc.c: In function '__free_unaccepted.isra':
  ././include/linux/compiler_types.h:557:45: error: call to '__compiletime_assert_1013' declared with attribute error: BUILD_BUG failed
    557 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
        |                                             ^
  ././include/linux/compiler_types.h:538:25: note: in definition of macro '__compiletime_assert'
    538 |                         prefix ## suffix();                             \
        |                         ^~~~~~
  ././include/linux/compiler_types.h:557:9: note: in expansion of macro '_compiletime_assert'
    557 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
        |         ^~~~~~~~~~~~~~~~~~~
  ./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
     39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
        |                                     ^~~~~~~~~~~~~~~~~~
  ./include/linux/build_bug.h:59:21: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
        |                     ^~~~~~~~~~~~~~~~
  mm/page_alloc.c:7301:9: note: in expansion of macro 'BUILD_BUG'
   7301 |         BUILD_BUG();
        |         ^~~~~~~~~

Signed-off-by: Winston Wen <wentao@uniontech.com>
Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fd6b865cb1ab..7c0934c818dd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7286,7 +7286,7 @@ static bool __free_unaccepted(struct page *page)
 
 #else
 
-static bool page_contains_unaccepted(struct page *page, unsigned int order)
+static __always_inline bool page_contains_unaccepted(struct page *page, unsigned int order)
 {
 	return false;
 }
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 3/7] vfio/virtio: add __always_inline for virtiovf_get_device_config_size
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
  2025-04-11 10:54   ` [RFC PATCH 2/7] mm: add __always_inline for page_contains_unaccepted Chen Linxuan
@ 2025-04-11 10:54   ` Chen Linxuan
  2025-04-11 10:54   ` [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions' Chen Linxuan
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:54 UTC (permalink / raw)
  To: Yishai Hadas, Jason Gunthorpe, Shameer Kolothum, Kevin Tian,
	Alex Williamson
  Cc: Winston Wen, Chen Linxuan, kvm, virtualization, linux-kernel

From: Winston Wen <wentao@uniontech.com>

On x86_64 with gcc version 13.3.0, I compile
drivers/vfio/pci/virtio/legacy_io.c with:

  make defconfig
  ./scripts/kconfig/merge_config.sh .config <(
    echo CONFIG_VFIO=m
    echo CONFIG_VIRTIO_PCI=y
    echo CONFIG_VIRTIO_PCI_LIB_LEGACY=y
    echo CONFIG_VIRTIO_VFIO_PCI=m
    echo CONFIG_VIRTIO_VFIO_PCI_ADMIN_LEGACY=y
  )
  make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once" \
    drivers/vfio/pci/virtio/legacy_io.o

Then I get a compile error:

    CALL    scripts/checksyscalls.sh
    DESCEND objtool
    INSTALL libsubcmd_headers
    CC      drivers/vfio/pci/virtio/legacy_io.o
  In file included from <command-line>:
  drivers/vfio/pci/virtio/legacy_io.c: In function 'virtiovf_init_legacy_io':
  ././include/linux/compiler_types.h:557:45: error: call to '__compiletime_assert_889' declared with attribute error: BUILD_BUG_ON failed: !is_power_of_2(virtvdev->bar0_virtual_buf_size)
    557 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
        |                                             ^
  ././include/linux/compiler_types.h:538:25: note: in definition of macro '__compiletime_assert'
    538 |                         prefix ## suffix();                             \
        |                         ^~~~~~
  ././include/linux/compiler_types.h:557:9: note: in expansion of macro '_compiletime_assert'
    557 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
        |         ^~~~~~~~~~~~~~~~~~~
  ./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
     39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
        |                                     ^~~~~~~~~~~~~~~~~~
  ./include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
        |         ^~~~~~~~~~~~~~~~
  drivers/vfio/pci/virtio/legacy_io.c:401:9: note: in expansion of macro 'BUILD_BUG_ON'
    401 |         BUILD_BUG_ON(!is_power_of_2(virtvdev->bar0_virtual_buf_size));
        |         ^~~~~~~~~~~~

Signed-off-by: Winston Wen <wentao@uniontech.com>
Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
---
 drivers/vfio/pci/virtio/legacy_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/virtio/legacy_io.c b/drivers/vfio/pci/virtio/legacy_io.c
index 832af5ba267c..b6871d50b9f9 100644
--- a/drivers/vfio/pci/virtio/legacy_io.c
+++ b/drivers/vfio/pci/virtio/legacy_io.c
@@ -350,7 +350,7 @@ int virtiovf_open_legacy_io(struct virtiovf_pci_core_device *virtvdev)
 	return virtiovf_set_notify_addr(virtvdev);
 }
 
-static int virtiovf_get_device_config_size(unsigned short device)
+static __always_inline int virtiovf_get_device_config_size(unsigned short device)
 {
 	/* Network card */
 	return offsetofend(struct virtio_net_config, status);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions'
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
  2025-04-11 10:54   ` [RFC PATCH 2/7] mm: add __always_inline for page_contains_unaccepted Chen Linxuan
  2025-04-11 10:54   ` [RFC PATCH 3/7] vfio/virtio: add __always_inline for virtiovf_get_device_config_size Chen Linxuan
@ 2025-04-11 10:54   ` Chen Linxuan
  2025-04-15  7:59     ` Jani Nikula
  2025-04-11 10:54   ` [RFC PATCH 5/7] RDMA/hns: initialize db in update_srq_db() Chen Linxuan
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:54 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter, Chen Linxuan
  Cc: intel-gfx, dri-devel, linux-kernel

On x86_64 with gcc version 13.3.0, I compile kernel with:

  make defconfig
  ./scripts/kconfig/merge_config.sh .config <(
    echo CONFIG_COMPILE_TEST=y
  )
  make KCFLAGS="-fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once"

Then I get a linker error:

  ld: vmlinux.o: in function `pxp_fw_dependencies_completed':
  kintel_pxp.c:(.text+0x95728f): undefined reference to `intel_pxp_gsccs_is_ready_for_sessions'

Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
---
 drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h b/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
index 9aae779c4da3..4969d3de2bac 100644
--- a/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
@@ -23,6 +23,7 @@ int intel_pxp_gsccs_init(struct intel_pxp *pxp);
 
 int intel_pxp_gsccs_create_session(struct intel_pxp *pxp, int arb_session_id);
 void intel_pxp_gsccs_end_arb_fw_session(struct intel_pxp *pxp, u32 arb_session_id);
+bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp);
 
 #else
 static inline void intel_pxp_gsccs_fini(struct intel_pxp *pxp)
@@ -34,8 +35,11 @@ static inline int intel_pxp_gsccs_init(struct intel_pxp *pxp)
 	return 0;
 }
 
-#endif
+static inline bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp)
+{
+	return false;
+}
 
-bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp);
+#endif
 
 #endif /*__INTEL_PXP_GSCCS_H__ */
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 5/7] RDMA/hns: initialize db in update_srq_db()
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
                     ` (2 preceding siblings ...)
  2025-04-11 10:54   ` [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions' Chen Linxuan
@ 2025-04-11 10:54   ` Chen Linxuan
  2025-04-11 18:01     ` Leon Romanovsky
  2025-04-11 10:54   ` [RFC PATCH 6/7] tpm: add __always_inline for tpm_is_hwrng_enabled Chen Linxuan
  2025-04-11 10:54   ` [RFC PATCH 7/7] lib/Kconfig.debug: introduce CONFIG_NO_AUTO_INLINE Chen Linxuan
  5 siblings, 1 reply; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:54 UTC (permalink / raw)
  To: Chengchang Tang, Junxian Huang, Jason Gunthorpe, Leon Romanovsky
  Cc: Chen Linxuan, Winston Wen, linux-rdma, linux-kernel

On x86_64 with gcc version 13.3.0, I compile
drivers/infiniband/hw/hns/hns_roce_hw_v2.c with:

  make defconfig
  ./scripts/kconfig/merge_config.sh .config <(
    echo CONFIG_COMPILE_TEST=y
    echo CONFIG_HNS3=m
    echo CONFIG_INFINIBAND=m
    echo CONFIG_INFINIBAND_HNS_HIP08=m
  )
  make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once" \
    drivers/infiniband/hw/hns/hns_roce_hw_v2.o

Then I get a compile error:

    CALL    scripts/checksyscalls.sh
    DESCEND objtool
    INSTALL libsubcmd_headers
    CC [M]  drivers/infiniband/hw/hns/hns_roce_hw_v2.o
  In file included from drivers/infiniband/hw/hns/hns_roce_hw_v2.c:47:
  drivers/infiniband/hw/hns/hns_roce_hw_v2.c: In function 'update_srq_db':
  drivers/infiniband/hw/hns/hns_roce_common.h:74:17: error: 'db' is used uninitialized [-Werror=uninitialized]
     74 |                 *((__le32 *)_ptr + (field_h) / 32) &=                          \
        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/infiniband/hw/hns/hns_roce_common.h:90:17: note: in expansion of macro '_hr_reg_clear'
     90 |                 _hr_reg_clear(ptr, field_type, field_h, field_l);              \
        |                 ^~~~~~~~~~~~~
  drivers/infiniband/hw/hns/hns_roce_common.h:95:39: note: in expansion of macro '_hr_reg_write'
     95 | #define hr_reg_write(ptr, field, val) _hr_reg_write(ptr, field, val)
        |                                       ^~~~~~~~~~~~~
  drivers/infiniband/hw/hns/hns_roce_hw_v2.c:948:9: note: in expansion of macro 'hr_reg_write'
    948 |         hr_reg_write(&db, DB_TAG, srq->srqn);
        |         ^~~~~~~~~~~~
  drivers/infiniband/hw/hns/hns_roce_hw_v2.c:946:31: note: 'db' declared here
    946 |         struct hns_roce_v2_db db;
        |                               ^~
  cc1: all warnings being treated as errors

Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
Co-Developed-by: Winston Wen <wentao@uniontech.com>
Signed-off-by: Winston Wen <wentao@uniontech.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 160e8927d364..7d6c0cfa1ded 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -943,7 +943,7 @@ static void fill_wqe_idx(struct hns_roce_srq *srq, unsigned int wqe_idx)
 static void update_srq_db(struct hns_roce_srq *srq)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device);
-	struct hns_roce_v2_db db;
+	struct hns_roce_v2_db db = { 0 };
 
 	hr_reg_write(&db, DB_TAG, srq->srqn);
 	hr_reg_write(&db, DB_CMD, HNS_ROCE_V2_SRQ_DB);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 6/7] tpm: add __always_inline for tpm_is_hwrng_enabled
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
                     ` (3 preceding siblings ...)
  2025-04-11 10:54   ` [RFC PATCH 5/7] RDMA/hns: initialize db in update_srq_db() Chen Linxuan
@ 2025-04-11 10:54   ` Chen Linxuan
  2025-04-12  0:47     ` Jarkko Sakkinen
  2025-04-11 10:54   ` [RFC PATCH 7/7] lib/Kconfig.debug: introduce CONFIG_NO_AUTO_INLINE Chen Linxuan
  5 siblings, 1 reply; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:54 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe
  Cc: Winston Wen, Chen Linxuan, linux-integrity, linux-kernel

From: Winston Wen <wentao@uniontech.com>

On x86_64 with gcc version 13.3.0, I compile kernel with:

  make defconfig
  ./scripts/kconfig/merge_config.sh .config <(
    echo CONFIG_TCG_TPM=y
    echo CONFIG_HW_RANDOM=m
  )
  make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once"

Then I get a link error:

  ld: vmlinux.o: in function `tpm_add_hwrng':
  tpm-chip.c:(.text+0x6c5924): undefined reference to `hwrng_register'
  ld: vmlinux.o: in function `tpm_chip_unregister':
  (.text+0x6c5bc9): undefined reference to `hwrng_unregister'
  ld: vmlinux.o: in function `tpm_chip_register':
  (.text+0x6c5c9b): undefined reference to `hwrng_unregister'

Signed-off-by: Winston Wen <wentao@uniontech.com>
Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
---
 drivers/char/tpm/tpm-chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index e25daf2396d3..48cc74d84247 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -534,7 +534,7 @@ static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 	return tpm_get_random(chip, data, max);
 }
 
-static bool tpm_is_hwrng_enabled(struct tpm_chip *chip)
+static __always_inline bool tpm_is_hwrng_enabled(struct tpm_chip *chip)
 {
 	if (!IS_ENABLED(CONFIG_HW_RANDOM_TPM))
 		return false;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 7/7] lib/Kconfig.debug: introduce CONFIG_NO_AUTO_INLINE
       [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
                     ` (4 preceding siblings ...)
  2025-04-11 10:54   ` [RFC PATCH 6/7] tpm: add __always_inline for tpm_is_hwrng_enabled Chen Linxuan
@ 2025-04-11 10:54   ` Chen Linxuan
  2025-04-15  7:13     ` Chen Linxuan
  5 siblings, 1 reply; 15+ messages in thread
From: Chen Linxuan @ 2025-04-11 10:54 UTC (permalink / raw)
  To: Masahiro Yamada, Nathan Chancellor, Nicolas Schier, Andrew Morton,
	Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: Winston Wen, Changbin Du, Masahiro Yamada, Chen Linxuan,
	linux-kbuild, linux-kernel, llvm

From: Winston Wen <wentao@uniontech.com>

Add a new kernel hacking option CONFIG_NO_AUTO_INLINE that prevents the
compiler from auto-inlining functions not explicitly marked with the
'inline' keyword.

This enhancement improves function tracer capabilities as it can only
trace functions that haven't been inlined by the compiler.

Previous discussions:
Link: https://lore.kernel.org/all/20181028130945.23581-3-changbin.du@gmail.com/

This patch is modified from 917fad29febd ("kernel hacking: add a config
option to disable compiler auto-inlining") which can be founded in
linux-next-history:
Link: https://web.git.kernel.org/pub/scm/linux/kernel/git/next/linux-next-history.git/commit/?id=917fad29febd

Unlike the original implementation, this patch:

1. Make it depends on CC_IS_GCC,
   as Clang 18.1.3 break test_bitmap_const_eval() in lib/test_bitmap.c

2. Make it depends on X86_64,
   as I haven't test other architectures

3. Removes unnecessary cc-option checks per 7d73c3e9c514 ("Makefile:
   remove stale cc-option checks").

4. Update help information.

Cc: Changbin Du <changbin.du@gmail.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Winston Wen <wentao@uniontech.com>
Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
---
 Makefile          |  6 ++++++
 lib/Kconfig.debug | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/Makefile b/Makefile
index f42418556507..0a9bf33ce75f 100644
--- a/Makefile
+++ b/Makefile
@@ -1071,6 +1071,12 @@ endif
 # Ensure compilers do not transform certain loops into calls to wcslen()
 KBUILD_CFLAGS += -fno-builtin-wcslen
 
+ifdef CONFIG_NO_AUTO_INLINE
+KBUILD_CFLAGS   += -fno-inline-functions \
+		   -fno-inline-small-functions \
+		   -fno-inline-functions-called-once
+endif
+
 # change __FILE__ to the relative path to the source directory
 ifdef building_out_of_srctree
 KBUILD_CPPFLAGS += $(call cc-option,-ffile-prefix-map=$(srcroot)/=)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 9fe4d8dfe578..2ebb4802886a 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -436,8 +436,23 @@ config GDB_SCRIPTS
 	  instance. See Documentation/process/debugging/gdb-kernel-debugging.rst
 	  for further details.
 
+
 endif # DEBUG_INFO
 
+config NO_AUTO_INLINE
+	bool "Disable compiler auto-inline optimizations (EXPERIMENTAL)"
+	default n
+	depends on CC_IS_GCC && (X86 || LOONGARCH)
+	help
+	  This will prevent the compiler from optimizing the kernel by
+	  auto-inlining functions not marked with the inline keyword.
+	  With this option, only functions explicitly marked with
+	  "inline" will be inlined. This will allow the function tracer
+	  to trace more functions because it only traces functions that
+	  the compiler has not inlined.
+
+	  If unsure, select N.
+
 config FRAME_WARN
 	int "Warn for stack frames larger than"
 	range 0 8192
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 5/7] RDMA/hns: initialize db in update_srq_db()
  2025-04-11 10:54   ` [RFC PATCH 5/7] RDMA/hns: initialize db in update_srq_db() Chen Linxuan
@ 2025-04-11 18:01     ` Leon Romanovsky
  0 siblings, 0 replies; 15+ messages in thread
From: Leon Romanovsky @ 2025-04-11 18:01 UTC (permalink / raw)
  To: Chen Linxuan
  Cc: Chengchang Tang, Junxian Huang, Jason Gunthorpe, Winston Wen,
	linux-rdma, linux-kernel

On Fri, Apr 11, 2025 at 06:54:53PM +0800, Chen Linxuan wrote:
> On x86_64 with gcc version 13.3.0, I compile
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c with:
> 
>   make defconfig
>   ./scripts/kconfig/merge_config.sh .config <(
>     echo CONFIG_COMPILE_TEST=y
>     echo CONFIG_HNS3=m
>     echo CONFIG_INFINIBAND=m
>     echo CONFIG_INFINIBAND_HNS_HIP08=m
>   )
>   make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once" \
>     drivers/infiniband/hw/hns/hns_roce_hw_v2.o
> 
> Then I get a compile error:
> 
>     CALL    scripts/checksyscalls.sh
>     DESCEND objtool
>     INSTALL libsubcmd_headers
>     CC [M]  drivers/infiniband/hw/hns/hns_roce_hw_v2.o
>   In file included from drivers/infiniband/hw/hns/hns_roce_hw_v2.c:47:
>   drivers/infiniband/hw/hns/hns_roce_hw_v2.c: In function 'update_srq_db':
>   drivers/infiniband/hw/hns/hns_roce_common.h:74:17: error: 'db' is used uninitialized [-Werror=uninitialized]
>      74 |                 *((__le32 *)_ptr + (field_h) / 32) &=                          \
>         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   drivers/infiniband/hw/hns/hns_roce_common.h:90:17: note: in expansion of macro '_hr_reg_clear'
>      90 |                 _hr_reg_clear(ptr, field_type, field_h, field_l);              \
>         |                 ^~~~~~~~~~~~~
>   drivers/infiniband/hw/hns/hns_roce_common.h:95:39: note: in expansion of macro '_hr_reg_write'
>      95 | #define hr_reg_write(ptr, field, val) _hr_reg_write(ptr, field, val)
>         |                                       ^~~~~~~~~~~~~
>   drivers/infiniband/hw/hns/hns_roce_hw_v2.c:948:9: note: in expansion of macro 'hr_reg_write'
>     948 |         hr_reg_write(&db, DB_TAG, srq->srqn);
>         |         ^~~~~~~~~~~~
>   drivers/infiniband/hw/hns/hns_roce_hw_v2.c:946:31: note: 'db' declared here
>     946 |         struct hns_roce_v2_db db;
>         |                               ^~
>   cc1: all warnings being treated as errors
> 
> Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> Co-Developed-by: Winston Wen <wentao@uniontech.com>
> Signed-off-by: Winston Wen <wentao@uniontech.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to rdma-next.

Thanks

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 6/7] tpm: add __always_inline for tpm_is_hwrng_enabled
  2025-04-11 10:54   ` [RFC PATCH 6/7] tpm: add __always_inline for tpm_is_hwrng_enabled Chen Linxuan
@ 2025-04-12  0:47     ` Jarkko Sakkinen
  2025-04-15  2:28       ` Chen Linxuan
  0 siblings, 1 reply; 15+ messages in thread
From: Jarkko Sakkinen @ 2025-04-12  0:47 UTC (permalink / raw)
  To: Chen Linxuan
  Cc: Peter Huewe, Jason Gunthorpe, Winston Wen, linux-integrity,
	linux-kernel

On Fri, Apr 11, 2025 at 06:54:54PM +0800, Chen Linxuan wrote:
> From: Winston Wen <wentao@uniontech.com>
> 
> On x86_64 with gcc version 13.3.0, I compile kernel with:

Use passive:

"Presume that kernel is compiled for x86_64 with gcc version 13.3.0:"

> 
>   make defconfig
>   ./scripts/kconfig/merge_config.sh .config <(
>     echo CONFIG_TCG_TPM=y
>     echo CONFIG_HW_RANDOM=m
>   )
>   make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once"
> 
> Then I get a link error:

"This results a link error:"

> 
>   ld: vmlinux.o: in function `tpm_add_hwrng':
>   tpm-chip.c:(.text+0x6c5924): undefined reference to `hwrng_register'
>   ld: vmlinux.o: in function `tpm_chip_unregister':
>   (.text+0x6c5bc9): undefined reference to `hwrng_unregister'
>   ld: vmlinux.o: in function `tpm_chip_register':
>   (.text+0x6c5c9b): undefined reference to `hwrng_unregister'

The resolution is lacking i.e., why adding __always_inline addresses
the linking problem.

> 
> Signed-off-by: Winston Wen <wentao@uniontech.com>
> Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
> Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> ---
>  drivers/char/tpm/tpm-chip.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index e25daf2396d3..48cc74d84247 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -534,7 +534,7 @@ static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
>  	return tpm_get_random(chip, data, max);
>  }
>  
> -static bool tpm_is_hwrng_enabled(struct tpm_chip *chip)
> +static __always_inline bool tpm_is_hwrng_enabled(struct tpm_chip *chip)
>  {
>  	if (!IS_ENABLED(CONFIG_HW_RANDOM_TPM))
>  		return false;
> -- 
> 2.48.1
> 

BR, Jarkko

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 6/7] tpm: add __always_inline for tpm_is_hwrng_enabled
  2025-04-12  0:47     ` Jarkko Sakkinen
@ 2025-04-15  2:28       ` Chen Linxuan
  0 siblings, 0 replies; 15+ messages in thread
From: Chen Linxuan @ 2025-04-15  2:28 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: Chen Linxuan, Peter Huewe, Jason Gunthorpe, Winston Wen,
	linux-integrity, linux-kernel

Jarkko Sakkinen <jarkko@kernel.org> 于2025年4月12日周六 08:47写道:
>
> On Fri, Apr 11, 2025 at 06:54:54PM +0800, Chen Linxuan wrote:
> > From: Winston Wen <wentao@uniontech.com>
> >
> > On x86_64 with gcc version 13.3.0, I compile kernel with:
>
> Use passive:
>
> "Presume that kernel is compiled for x86_64 with gcc version 13.3.0:"
>
> >
> >   make defconfig
> >   ./scripts/kconfig/merge_config.sh .config <(
> >     echo CONFIG_TCG_TPM=y
> >     echo CONFIG_HW_RANDOM=m
> >   )
> >   make KCFLAGS="-fno-inline-small-functions -fno-inline-functions-called-once"
> >
> > Then I get a link error:
>
> "This results a link error:"
>

I will update commit message when I send v2.

> >
> >   ld: vmlinux.o: in function `tpm_add_hwrng':
> >   tpm-chip.c:(.text+0x6c5924): undefined reference to `hwrng_register'
> >   ld: vmlinux.o: in function `tpm_chip_unregister':
> >   (.text+0x6c5bc9): undefined reference to `hwrng_unregister'
> >   ld: vmlinux.o: in function `tpm_chip_register':
> >   (.text+0x6c5c9b): undefined reference to `hwrng_unregister'
>
> The resolution is lacking i.e., why adding __always_inline addresses
> the linking problem.

Regarding your comment about the resolution,
here’s a detailed explanation of
 why adding the `__always_inline` attribute addresses the linking issue:

With `CONFIG_TCG_TPM=y` and `CONFIG_HW_RANDOM=m`,
the functions `tpm_add_hwrng`, `tpm_chip_unregister`, and
`tpm_chip_register` are compiled into `vmlinux.o`
and reference the symbols `hwrng_register` and `hwrng_unregister`.
These symbols, however, are compiled into `rng-core.ko`, which results
in the linking error.

I am not sure but I think this weird linking error only arises when
auto inlining is disabled because of some dead code elimination.

`CONFIG_TCG_TPM=y` and `CONFIG_HW_RANDOM=m` set `CONFIG_HW_RANDOM_TPM=n`.
This causes the function `tpm_is_hwrng_enabled` to always return
`false`, as shown below:

```c
static bool tpm_is_hwrng_enabled(struct tpm_chip *chip)
{
    if (!IS_ENABLED(CONFIG_HW_RANDOM_TPM))
        return false;
    if (tpm_is_firmware_upgrade(chip))
        return false;
    if (chip->flags & TPM_CHIP_FLAG_HWRNG_DISABLED)
        return false;
    return true;
}
```

When `tpm_is_hwrng_enabled` is inlined, dead code elimination
optimizations are applied and the reference to the `hwrng_*` functions
will been removed.
For instance, in the `tpm_chip_unregister` function:

```c
void tpm_chip_unregister(struct tpm_chip *chip)
{
#ifdef CONFIG_TCG_TPM2_HMAC
    int rc;

    rc = tpm_try_get_ops(chip);
    if (!rc) {
        tpm2_end_auth_session(chip);
        tpm_put_ops(chip);
    }
#endif

    tpm_del_legacy_sysfs(chip);
    if (tpm_is_hwrng_enabled(chip))
        hwrng_unregister(&chip->hwrng);
    tpm_bios_log_teardown(chip);
    if (chip->flags & TPM_CHIP_FLAG_TPM2 && !tpm_is_firmware_upgrade(chip))
        tpm_devs_remove(chip);
    tpm_del_char_device(chip);
}
```

When `tpm_is_hwrng_enabled` is inlined and always returns `false`,
the call to `hwrng_unregister` is effectively part of a `if (false)` block,
which I guess that will be then optimized out.

However, when the `-fno-inline-small-functions` and
`-fno-inline-functions-called-once` flags are used,
tpm_is_hwrng_enabled is not inline.

And this optimization some how cannot occur,
leading to the undefined reference errors during linking.

Adding the `__always_inline` attribute ensures that
`tpm_is_hwrng_enabled` is inlined regardless of the compiler flags.
This allows the dead code elimination to proceed as expected,
resolving the linking issue.

There might be better ways to fix this.
But it is directly caused by adding `-fno-inline-small-functions` and
`-fno-inline-functions-called-once` flags,
I think add `__always_inline` is good enough.

>
> >
> > Signed-off-by: Winston Wen <wentao@uniontech.com>
> > Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
> > Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> > ---
> >  drivers/char/tpm/tpm-chip.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> > index e25daf2396d3..48cc74d84247 100644
> > --- a/drivers/char/tpm/tpm-chip.c
> > +++ b/drivers/char/tpm/tpm-chip.c
> > @@ -534,7 +534,7 @@ static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
> >       return tpm_get_random(chip, data, max);
> >  }
> >
> > -static bool tpm_is_hwrng_enabled(struct tpm_chip *chip)
> > +static __always_inline bool tpm_is_hwrng_enabled(struct tpm_chip *chip)
> >  {
> >       if (!IS_ENABLED(CONFIG_HW_RANDOM_TPM))
> >               return false;
> > --
> > 2.48.1
> >
>
> BR, Jarkko
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 7/7] lib/Kconfig.debug: introduce CONFIG_NO_AUTO_INLINE
  2025-04-11 10:54   ` [RFC PATCH 7/7] lib/Kconfig.debug: introduce CONFIG_NO_AUTO_INLINE Chen Linxuan
@ 2025-04-15  7:13     ` Chen Linxuan
  0 siblings, 0 replies; 15+ messages in thread
From: Chen Linxuan @ 2025-04-15  7:13 UTC (permalink / raw)
  To: Chen Linxuan
  Cc: Masahiro Yamada, Nathan Chancellor, Nicolas Schier, Andrew Morton,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Winston Wen,
	Changbin Du, Masahiro Yamada, linux-kbuild, linux-kernel, llvm

Chen Linxuan <chenlinxuan@uniontech.com> 于2025年4月11日周五 18:56写道:
>
> From: Winston Wen <wentao@uniontech.com>
>
> Add a new kernel hacking option CONFIG_NO_AUTO_INLINE that prevents the
> compiler from auto-inlining functions not explicitly marked with the
> 'inline' keyword.
>
> This enhancement improves function tracer capabilities as it can only
> trace functions that haven't been inlined by the compiler.
>
> Previous discussions:
> Link: https://lore.kernel.org/all/20181028130945.23581-3-changbin.du@gmail.com/
>
> This patch is modified from 917fad29febd ("kernel hacking: add a config
> option to disable compiler auto-inlining") which can be founded in
> linux-next-history:
> Link: https://web.git.kernel.org/pub/scm/linux/kernel/git/next/linux-next-history.git/commit/?id=917fad29febd
>
> Unlike the original implementation, this patch:
>
> 1. Make it depends on CC_IS_GCC,
>    as Clang 18.1.3 break test_bitmap_const_eval() in lib/test_bitmap.c
>
> 2. Make it depends on X86_64,
>    as I haven't test other architectures

LOONGARCH has been tested, too.

>
> 3. Removes unnecessary cc-option checks per 7d73c3e9c514 ("Makefile:
>    remove stale cc-option checks").
>
> 4. Update help information.
>
> Cc: Changbin Du <changbin.du@gmail.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Winston Wen <wentao@uniontech.com>
> Co-Developed-by: Chen Linxuan <chenlinxuan@uniontech.com>
> Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> ---
>  Makefile          |  6 ++++++
>  lib/Kconfig.debug | 15 +++++++++++++++
>  2 files changed, 21 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index f42418556507..0a9bf33ce75f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1071,6 +1071,12 @@ endif
>  # Ensure compilers do not transform certain loops into calls to wcslen()
>  KBUILD_CFLAGS += -fno-builtin-wcslen
>
> +ifdef CONFIG_NO_AUTO_INLINE
> +KBUILD_CFLAGS   += -fno-inline-functions \
> +                  -fno-inline-small-functions \
> +                  -fno-inline-functions-called-once
> +endif
> +
>  # change __FILE__ to the relative path to the source directory
>  ifdef building_out_of_srctree
>  KBUILD_CPPFLAGS += $(call cc-option,-ffile-prefix-map=$(srcroot)/=)
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 9fe4d8dfe578..2ebb4802886a 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -436,8 +436,23 @@ config GDB_SCRIPTS
>           instance. See Documentation/process/debugging/gdb-kernel-debugging.rst
>           for further details.
>
> +
>  endif # DEBUG_INFO
>
> +config NO_AUTO_INLINE
> +       bool "Disable compiler auto-inline optimizations (EXPERIMENTAL)"
> +       default n
> +       depends on CC_IS_GCC && (X86 || LOONGARCH)
> +       help
> +         This will prevent the compiler from optimizing the kernel by
> +         auto-inlining functions not marked with the inline keyword.
> +         With this option, only functions explicitly marked with
> +         "inline" will be inlined. This will allow the function tracer
> +         to trace more functions because it only traces functions that
> +         the compiler has not inlined.
> +
> +         If unsure, select N.
> +
>  config FRAME_WARN
>         int "Warn for stack frames larger than"
>         range 0 8192
> --
> 2.48.1
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions'
  2025-04-11 10:54   ` [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions' Chen Linxuan
@ 2025-04-15  7:59     ` Jani Nikula
  2025-04-15  8:09       ` Chen Linxuan
  0 siblings, 1 reply; 15+ messages in thread
From: Jani Nikula @ 2025-04-15  7:59 UTC (permalink / raw)
  To: Chen Linxuan, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter, Chen Linxuan
  Cc: intel-gfx, dri-devel, linux-kernel, Alan Previn,
	Daniele Ceraolo Spurio, Radhakrishna Sripada

On Fri, 11 Apr 2025, Chen Linxuan <chenlinxuan@uniontech.com> wrote:
> On x86_64 with gcc version 13.3.0, I compile kernel with:
>
>   make defconfig
>   ./scripts/kconfig/merge_config.sh .config <(
>     echo CONFIG_COMPILE_TEST=y
>   )
>   make KCFLAGS="-fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once"

The change looks good, but I'm guessing the real explanation is that you
have CONFIG_DRM_I915_PXP=n and that appears to be broken.

Fixes: 99afb7cc8c44 ("drm/i915/pxp: Add ARB session creation and cleanup")
Reviewed-by: Jani Nikula <jani.nikula@intel.com>

But how do you want this merged?


BR,
Jani.

>
> Then I get a linker error:
>
>   ld: vmlinux.o: in function `pxp_fw_dependencies_completed':
>   kintel_pxp.c:(.text+0x95728f): undefined reference to `intel_pxp_gsccs_is_ready_for_sessions'
>
> Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> ---
>  drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h b/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
> index 9aae779c4da3..4969d3de2bac 100644
> --- a/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
> @@ -23,6 +23,7 @@ int intel_pxp_gsccs_init(struct intel_pxp *pxp);
>  
>  int intel_pxp_gsccs_create_session(struct intel_pxp *pxp, int arb_session_id);
>  void intel_pxp_gsccs_end_arb_fw_session(struct intel_pxp *pxp, u32 arb_session_id);
> +bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp);
>  
>  #else
>  static inline void intel_pxp_gsccs_fini(struct intel_pxp *pxp)
> @@ -34,8 +35,11 @@ static inline int intel_pxp_gsccs_init(struct intel_pxp *pxp)
>  	return 0;
>  }
>  
> -#endif
> +static inline bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp)
> +{
> +	return false;
> +}
>  
> -bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp);
> +#endif
>  
>  #endif /*__INTEL_PXP_GSCCS_H__ */

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions'
  2025-04-15  7:59     ` Jani Nikula
@ 2025-04-15  8:09       ` Chen Linxuan
  2025-04-15  9:07         ` Jani Nikula
  0 siblings, 1 reply; 15+ messages in thread
From: Chen Linxuan @ 2025-04-15  8:09 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Chen Linxuan, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter, intel-gfx, dri-devel, linux-kernel,
	Alan Previn, Daniele Ceraolo Spurio, Radhakrishna Sripada

Jani Nikula <jani.nikula@linux.intel.com> 于2025年4月15日周二 15:59写道:
>
> On Fri, 11 Apr 2025, Chen Linxuan <chenlinxuan@uniontech.com> wrote:
> > On x86_64 with gcc version 13.3.0, I compile kernel with:
> >
> >   make defconfig
> >   ./scripts/kconfig/merge_config.sh .config <(
> >     echo CONFIG_COMPILE_TEST=y
> >   )
> >   make KCFLAGS="-fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once"
>
> The change looks good, but I'm guessing the real explanation is that you
> have CONFIG_DRM_I915_PXP=n and that appears to be broken.
>
> Fixes: 99afb7cc8c44 ("drm/i915/pxp: Add ARB session creation and cleanup")
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
> But how do you want this merged?
>

As patch 5 has been merged into rdma-next, I think it's OK to merge
this single patch into your tree.

>
> BR,
> Jani.
>
> >
> > Then I get a linker error:
> >
> >   ld: vmlinux.o: in function `pxp_fw_dependencies_completed':
> >   kintel_pxp.c:(.text+0x95728f): undefined reference to `intel_pxp_gsccs_is_ready_for_sessions'
> >
> > Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
> > ---
> >  drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h b/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
> > index 9aae779c4da3..4969d3de2bac 100644
> > --- a/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
> > +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.h
> > @@ -23,6 +23,7 @@ int intel_pxp_gsccs_init(struct intel_pxp *pxp);
> >
> >  int intel_pxp_gsccs_create_session(struct intel_pxp *pxp, int arb_session_id);
> >  void intel_pxp_gsccs_end_arb_fw_session(struct intel_pxp *pxp, u32 arb_session_id);
> > +bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp);
> >
> >  #else
> >  static inline void intel_pxp_gsccs_fini(struct intel_pxp *pxp)
> > @@ -34,8 +35,11 @@ static inline int intel_pxp_gsccs_init(struct intel_pxp *pxp)
> >       return 0;
> >  }
> >
> > -#endif
> > +static inline bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp)
> > +{
> > +     return false;
> > +}
> >
> > -bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp);
> > +#endif
> >
> >  #endif /*__INTEL_PXP_GSCCS_H__ */
>
> --
> Jani Nikula, Intel
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions'
  2025-04-15  8:09       ` Chen Linxuan
@ 2025-04-15  9:07         ` Jani Nikula
  0 siblings, 0 replies; 15+ messages in thread
From: Jani Nikula @ 2025-04-15  9:07 UTC (permalink / raw)
  To: Chen Linxuan
  Cc: Chen Linxuan, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter, intel-gfx, dri-devel, linux-kernel,
	Alan Previn, Daniele Ceraolo Spurio

On Tue, 15 Apr 2025, Chen Linxuan <chenlinxuan@uniontech.com> wrote:
> Jani Nikula <jani.nikula@linux.intel.com> 于2025年4月15日周二 15:59写道:
>>
>> On Fri, 11 Apr 2025, Chen Linxuan <chenlinxuan@uniontech.com> wrote:
>> > On x86_64 with gcc version 13.3.0, I compile kernel with:
>> >
>> >   make defconfig
>> >   ./scripts/kconfig/merge_config.sh .config <(
>> >     echo CONFIG_COMPILE_TEST=y
>> >   )
>> >   make KCFLAGS="-fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once"
>>
>> The change looks good, but I'm guessing the real explanation is that you
>> have CONFIG_DRM_I915_PXP=n and that appears to be broken.
>>
>> Fixes: 99afb7cc8c44 ("drm/i915/pxp: Add ARB session creation and cleanup")
>> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>>
>> But how do you want this merged?
>>
>
> As patch 5 has been merged into rdma-next, I think it's OK to merge
> this single patch into your tree.

Thanks. I amended the commit message a little, and resent this to
intel-gfx [1], and will merge it via drm-intel-next.

BR,
Jani.



[1] https://lore.kernel.org/r/20250415090616.2649889-1-jani.nikula@intel.com



-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-04-15  9:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 10:51 [RFC PATCH 0/7] kernel-hacking: introduce CONFIG_NO_AUTO_INLINE Chen Linxuan
2025-04-11 10:54 ` [RFC PATCH 1/7] nvme: add __always_inline for nvme_pci_npages_prp Chen Linxuan
     [not found] ` <20250411105459.90782-1-chenlinxuan@uniontech.com>
2025-04-11 10:54   ` [RFC PATCH 2/7] mm: add __always_inline for page_contains_unaccepted Chen Linxuan
2025-04-11 10:54   ` [RFC PATCH 3/7] vfio/virtio: add __always_inline for virtiovf_get_device_config_size Chen Linxuan
2025-04-11 10:54   ` [RFC PATCH 4/7] drm/i915/pxp: fix undefined reference to `intel_pxp_gsccs_is_ready_for_sessions' Chen Linxuan
2025-04-15  7:59     ` Jani Nikula
2025-04-15  8:09       ` Chen Linxuan
2025-04-15  9:07         ` Jani Nikula
2025-04-11 10:54   ` [RFC PATCH 5/7] RDMA/hns: initialize db in update_srq_db() Chen Linxuan
2025-04-11 18:01     ` Leon Romanovsky
2025-04-11 10:54   ` [RFC PATCH 6/7] tpm: add __always_inline for tpm_is_hwrng_enabled Chen Linxuan
2025-04-12  0:47     ` Jarkko Sakkinen
2025-04-15  2:28       ` Chen Linxuan
2025-04-11 10:54   ` [RFC PATCH 7/7] lib/Kconfig.debug: introduce CONFIG_NO_AUTO_INLINE Chen Linxuan
2025-04-15  7:13     ` Chen Linxuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).