Skip to contentSkip to conversation

pds_core: add stub macros for pdsc_debufs_* when ! CONFIG_DEBUG_FS

PATCH In review Tom Rix 3 participants 4 messages May 2, 2023 – May 3, 2023

Subsystems (3)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 pds_core: add stub macros for pdsc_debufs_* when ! CONFIG_DEBUG_FS

When CONFIG_DEBUG_FS is not defined there is this representative link error
ld: drivers/net/ethernet/amd/pds_core/main.o: in function `pdsc_remove':
main.c:(.text+0x35c): undefined reference to `pdsc_debugfs_del_dev

Avoid these link errors when CONFIG_DEBUG_FS is not defined by providing some empty macros.

---
 drivers/net/ethernet/amd/pds_core/core.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ethernet/amd/pds_core/core.h +12 -0
index e545fafc4819..0b39a6dc65c8 100644
@@ -261,6 +261,7 @@ int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
 
 void __iomem *pdsc_map_dbpage(struct pdsc *pdsc, int page_num);
 
+#ifdef CONFIG_DEBUG_FS
 void pdsc_debugfs_create(void);
 void pdsc_debugfs_destroy(void);
 void pdsc_debugfs_add_dev(struct pdsc *pdsc);
@@ -270,6 +271,17 @@ void pdsc_debugfs_add_viftype(struct pdsc *pdsc);
 void pdsc_debugfs_add_irqs(struct pdsc *pdsc);
 void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq);
 void pdsc_debugfs_del_qcq(struct pdsc_qcq *qcq);
+#else
+#define pdsc_debugfs_create()
+#define pdsc_debugfs_destroy()
+#define pdsc_debugfs_add_dev(pdsc)
+#define pdsc_debugfs_del_dev(pdsc)
+#define pdsc_debugfs_add_ident(pdsc)
+#define pdsc_debugfs_add_viftype(pdsc)
+#define pdsc_debugfs_add_irqs(pdsc)
+#define pdsc_debugfs_add_qcq(pdsc, qcq)
+#define pdsc_debugfs_del_qcq(qcq)
+#endif
 
 int pdsc_err_to_errno(enum pds_core_status_code code);
 bool pdsc_is_fw_running(struct pdsc *pdsc);
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 8 lines · Tom Rix

When CONFIG_DEBUG_FS is not defined there is this representative link error
ld: drivers/net/ethernet/amd/pds_core/main.o: in function `pdsc_remove':
main.c:(.text+0x35c): undefined reference to `pdsc_debugfs_del_dev

Avoid these link errors when CONFIG_DEBUG_FS is not defined by providing some empty macros.

There is already a patch pending on the same topic:

https://patchwork.kernel.org/user/todo/netdevbpf/?series=744165

and probably a different approach will be preferred:

https://lore.kernel.org/all/[email protected]/

Cheers,

Paolo

#2 lore raw
In reply to Tom Rix
Quoted 28 lines · Tue, May 02, 2023 at 04:52:20PM CEST, [email protected] wrote:

When CONFIG_DEBUG_FS is not defined there is this representative link error
ld: drivers/net/ethernet/amd/pds_core/main.o: in function `pdsc_remove':
main.c:(.text+0x35c): undefined reference to `pdsc_debugfs_del_dev

Avoid these link errors when CONFIG_DEBUG_FS is not defined by providing some empty macros.

---
drivers/net/ethernet/amd/pds_core/core.h | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/ethernet/amd/pds_core/core.h +1 -0
index e545fafc4819..0b39a6dc65c8 100644
@@ -261,6 +261,7 @@ int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
 
 void __iomem *pdsc_map_dbpage(struct pdsc *pdsc, int page_num);
 
+#ifdef CONFIG_DEBUG_FS
 void pdsc_debugfs_create(void);
 void pdsc_debugfs_destroy(void);
 void pdsc_debugfs_add_dev(struct pdsc *pdsc);
@@ -270,6 +271,17 @@ void pdsc_debugfs_add_viftype(struct pdsc *pdsc);
 void pdsc_debugfs_add_irqs(struct pdsc *pdsc);
 void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq);
 void pdsc_debugfs_del_qcq(struct pdsc_qcq *qcq);

drivers/net/ethernet/amd/pds_core/core.h void pdsc_debugfs_add_viftype(struct pdsc *pdsc); · line 283

Quoted 10 lines
drivers/net/ethernet/amd/pds_core/core.h +10 -0
+#else
+#define pdsc_debugfs_create()
+#define pdsc_debugfs_destroy()
+#define pdsc_debugfs_add_dev(pdsc)
+#define pdsc_debugfs_del_dev(pdsc)
+#define pdsc_debugfs_add_ident(pdsc)
+#define pdsc_debugfs_add_viftype(pdsc)
+#define pdsc_debugfs_add_irqs(pdsc)
+#define pdsc_debugfs_add_qcq(pdsc, qcq)
+#define pdsc_debugfs_del_qcq(qcq)

Usually this is done using static inline stub functions. Any reason to not to do it in the same way?

Quoted 7 lines
drivers/net/ethernet/amd/pds_core/core.h +1 -0
+#endif
 
 int pdsc_err_to_errno(enum pds_core_status_code code);
 bool pdsc_is_fw_running(struct pdsc *pdsc);
Signature · 1 line
2.27.0
author
#3 lore raw
Quoted 33 lines · Jiri Pirko
Quoted 32 lines · Tue, May 02, 2023 at 04:52:20PM CEST, [email protected] wrote:

When CONFIG_DEBUG_FS is not defined there is this representative link error
ld: drivers/net/ethernet/amd/pds_core/main.o: in function `pdsc_remove':
main.c:(.text+0x35c): undefined reference to `pdsc_debugfs_del_dev

Avoid these link errors when CONFIG_DEBUG_FS is not defined by providing some empty macros.

---
drivers/net/ethernet/amd/pds_core/core.h | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/net/ethernet/amd/pds_core/core.h +5 -0
index e545fafc4819..0b39a6dc65c8 100644
@@ -261,6 +261,7 @@ int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
 
 void __iomem *pdsc_map_dbpage(struct pdsc *pdsc, int page_num);
 
+#ifdef CONFIG_DEBUG_FS
 void pdsc_debugfs_create(void);
 void pdsc_debugfs_destroy(void);
 void pdsc_debugfs_add_dev(struct pdsc *pdsc);
@@ -270,6 +271,17 @@ void pdsc_debugfs_add_viftype(struct pdsc *pdsc);
 void pdsc_debugfs_add_irqs(struct pdsc *pdsc);
 void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq);
 void pdsc_debugfs_del_qcq(struct pdsc_qcq *qcq);
+#else
+#define pdsc_debugfs_create()
+#define pdsc_debugfs_destroy()
+#define pdsc_debugfs_add_dev(pdsc)
Quoted 8 lines

drivers/net/ethernet/amd/pds_core/core.h void pdsc_debugfs_add_viftype(struct pdsc *pdsc); · line 283

Quoted 6 lines
drivers/net/ethernet/amd/pds_core/core.h +6 -0
+#define pdsc_debugfs_del_dev(pdsc)
+#define pdsc_debugfs_add_ident(pdsc)
+#define pdsc_debugfs_add_viftype(pdsc)
+#define pdsc_debugfs_add_irqs(pdsc)
+#define pdsc_debugfs_add_qcq(pdsc, qcq)
+#define pdsc_debugfs_del_qcq(qcq)

Usually this is done using static inline stub functions. Any reason to not to do it in the same way?

I do not mind changing the patch if that is what is required.

However I believe Paolo said the change was being handled by another patch.

Tom

Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/amd/pds_core/core.h +1 -0
+#endif
 
 int pdsc_err_to_errno(enum pds_core_status_code code);
 bool pdsc_is_fw_running(struct pdsc *pdsc);
Signature · 1 line
2.27.0