diff mbox series

[net,v1,1/1] bnx2: Fix unused data compilation warning

Message ID 20250228100538.32029-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net,v1,1/1] bnx2: Fix unused data compilation warning | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-03-01--03-00 (tests: 893)

Commit Message

Andy Shevchenko Feb. 28, 2025, 10:05 a.m. UTC
In some configuration, compilation raises warnings related to unused
data. Indeed, depending on configuration, those data can be unused.

Mark those data as __maybe_unused to avoid compilation warnings.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/broadcom/bnx2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski March 4, 2025, 1:21 a.m. UTC | #1
On Fri, 28 Feb 2025 12:05:37 +0200 Andy Shevchenko wrote:
> In some configuration, compilation raises warnings related to unused
> data. Indeed, depending on configuration, those data can be unused.
> 
> Mark those data as __maybe_unused to avoid compilation warnings.

Will making dma_unmap_addr access the first argument instead of
pre-processing down to nothing not work?
Andy Shevchenko March 4, 2025, 10:56 a.m. UTC | #2
On Mon, Mar 03, 2025 at 05:21:14PM -0800, Jakub Kicinski wrote:
> On Fri, 28 Feb 2025 12:05:37 +0200 Andy Shevchenko wrote:
> > In some configuration, compilation raises warnings related to unused
> > data. Indeed, depending on configuration, those data can be unused.
> > 
> > Mark those data as __maybe_unused to avoid compilation warnings.
> 
> Will making dma_unmap_addr access the first argument instead of
> pre-processing down to nothing not work?

I looked at the implementation of those macros and I have no clue
how to do that in a least intrusive way. Otherwise it sounds to me
quite far from the scope of the small compilation error fix that
I presented here.
Paolo Abeni March 4, 2025, 11:39 a.m. UTC | #3
On 3/4/25 11:56 AM, Andy Shevchenko wrote:
> On Mon, Mar 03, 2025 at 05:21:14PM -0800, Jakub Kicinski wrote:
>> On Fri, 28 Feb 2025 12:05:37 +0200 Andy Shevchenko wrote:
>>> In some configuration, compilation raises warnings related to unused
>>> data. Indeed, depending on configuration, those data can be unused.
>>>
>>> Mark those data as __maybe_unused to avoid compilation warnings.
>>
>> Will making dma_unmap_addr access the first argument instead of
>> pre-processing down to nothing not work?
> 
> I looked at the implementation of those macros and I have no clue
> how to do that in a least intrusive way. Otherwise it sounds to me
> quite far from the scope of the small compilation error fix that
> I presented here.

I *think* Jakub is suggesting something alike:

---
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index b79925b1c433..927884f10b0f 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -629,7 +629,7 @@ static inline int dma_mmap_wc(struct device *dev,
 #else
 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
-#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
+#define dma_unmap_addr(PTR, ADDR_NAME)           (((PTR)->ADDR_NAME), 0)
 #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
 #define dma_unmap_len(PTR, LEN_NAME)             (0)
 #define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
---

Would that work?

Thanks,

Paolo
Andy Shevchenko March 4, 2025, 11:58 a.m. UTC | #4
+ Marek/Christoph (for the clarification/commenting on the below)

On Tue, Mar 04, 2025 at 12:39:40PM +0100, Paolo Abeni wrote:
> On 3/4/25 11:56 AM, Andy Shevchenko wrote:
> > On Mon, Mar 03, 2025 at 05:21:14PM -0800, Jakub Kicinski wrote:
> >> On Fri, 28 Feb 2025 12:05:37 +0200 Andy Shevchenko wrote:
> >>> In some configuration, compilation raises warnings related to unused
> >>> data. Indeed, depending on configuration, those data can be unused.
> >>>
> >>> Mark those data as __maybe_unused to avoid compilation warnings.
> >>
> >> Will making dma_unmap_addr access the first argument instead of
> >> pre-processing down to nothing not work?
> > 
> > I looked at the implementation of those macros and I have no clue
> > how to do that in a least intrusive way. Otherwise it sounds to me
> > quite far from the scope of the small compilation error fix that
> > I presented here.

> I *think* Jakub is suggesting something alike:

I see. Perhpas we need Marek's/Christoph's opinion on this...

> ---
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index b79925b1c433..927884f10b0f 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -629,7 +629,7 @@ static inline int dma_mmap_wc(struct device *dev,
>  #else
>  #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
>  #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
> -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
> +#define dma_unmap_addr(PTR, ADDR_NAME)           (((PTR)->ADDR_NAME), 0)
>  #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
>  #define dma_unmap_len(PTR, LEN_NAME)             (0)
>  #define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
> ---
> 
> Would that work?

I do not know. Not my area of expertise.
Andy Shevchenko March 4, 2025, 1:41 p.m. UTC | #5
On Tue, Mar 04, 2025 at 01:58:33PM +0200, Andy Shevchenko wrote:
> + Marek/Christoph (for the clarification/commenting on the below)
> 
> On Tue, Mar 04, 2025 at 12:39:40PM +0100, Paolo Abeni wrote:
> > On 3/4/25 11:56 AM, Andy Shevchenko wrote:
> > > On Mon, Mar 03, 2025 at 05:21:14PM -0800, Jakub Kicinski wrote:
> > >> On Fri, 28 Feb 2025 12:05:37 +0200 Andy Shevchenko wrote:
> > >>> In some configuration, compilation raises warnings related to unused
> > >>> data. Indeed, depending on configuration, those data can be unused.
> > >>>
> > >>> Mark those data as __maybe_unused to avoid compilation warnings.
> > >>
> > >> Will making dma_unmap_addr access the first argument instead of
> > >> pre-processing down to nothing not work?
> > > 
> > > I looked at the implementation of those macros and I have no clue
> > > how to do that in a least intrusive way. Otherwise it sounds to me
> > > quite far from the scope of the small compilation error fix that
> > > I presented here.
> 
> > I *think* Jakub is suggesting something alike:
> 
> I see. Perhpas we need Marek's/Christoph's opinion on this...
> 
> > ---
> > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > index b79925b1c433..927884f10b0f 100644
> > --- a/include/linux/dma-mapping.h
> > +++ b/include/linux/dma-mapping.h
> > @@ -629,7 +629,7 @@ static inline int dma_mmap_wc(struct device *dev,
> >  #else
> >  #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
> >  #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
> > -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
> > +#define dma_unmap_addr(PTR, ADDR_NAME)           (((PTR)->ADDR_NAME), 0)
> >  #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
> >  #define dma_unmap_len(PTR, LEN_NAME)             (0)
> >  #define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
> > ---
> > 
> > Would that work?

Actually it won't work because the variable is under the same ifdeffery.
What will work is to spreading the ifdeffery to the users, but it doesn't any
better than __maybe_unsused, which is compact hack (yes, I admit that it is not
the nicest solution, but it's spread enough in the kernel).

> I do not know. Not my area of expertise.
Jakub Kicinski March 4, 2025, 4:35 p.m. UTC | #6
On Tue, 4 Mar 2025 15:41:19 +0200 Andy Shevchenko wrote:
> > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > > index b79925b1c433..927884f10b0f 100644
> > > --- a/include/linux/dma-mapping.h
> > > +++ b/include/linux/dma-mapping.h
> > > @@ -629,7 +629,7 @@ static inline int dma_mmap_wc(struct device *dev,
> > >  #else
> > >  #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
> > >  #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
> > > -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
> > > +#define dma_unmap_addr(PTR, ADDR_NAME)           (((PTR)->ADDR_NAME), 0)
> > >  #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
> > >  #define dma_unmap_len(PTR, LEN_NAME)             (0)
> > >  #define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
> > > ---
> > > 
> > > Would that work?  
> 
> Actually it won't work because the variable is under the same ifdeffery.
> What will work is to spreading the ifdeffery to the users, but it doesn't any
> better than __maybe_unsused, which is compact hack (yes, I admit that it is not
> the nicest solution, but it's spread enough in the kernel).

I meant something more like (untested):

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index b79925b1c433..a7ebcede43f6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -629,10 +629,10 @@ static inline int dma_mmap_wc(struct device *dev,
 #else
 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
-#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
-#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
-#define dma_unmap_len(PTR, LEN_NAME)             (0)
-#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
+#define dma_unmap_addr(PTR, ADDR_NAME)           ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
+#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
+#define dma_unmap_len(PTR, LEN_NAME)             ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
+#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
 #endif
 
 #endif /* _LINUX_DMA_MAPPING_H */


I just don't know how much code out there depends on PTR not
existing if !CONFIG_NEED_DMA_MAP_STATE
Andy Shevchenko March 5, 2025, 10 a.m. UTC | #7
On Tue, Mar 04, 2025 at 08:35:24AM -0800, Jakub Kicinski wrote:
> On Tue, 4 Mar 2025 15:41:19 +0200 Andy Shevchenko wrote:

...

> > > > Would that work?  
> > 
> > Actually it won't work because the variable is under the same ifdeffery.
> > What will work is to spreading the ifdeffery to the users, but it doesn't any
> > better than __maybe_unsused, which is compact hack (yes, I admit that it is not
> > the nicest solution, but it's spread enough in the kernel).
> 
> I meant something more like (untested):

We are starving for the comment from the DMA mapping people.

> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index b79925b1c433..a7ebcede43f6 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -629,10 +629,10 @@ static inline int dma_mmap_wc(struct device *dev,
>  #else
>  #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
>  #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
> -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
> -#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
> -#define dma_unmap_len(PTR, LEN_NAME)             (0)
> -#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
> +#define dma_unmap_addr(PTR, ADDR_NAME)           ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
> +#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
> +#define dma_unmap_len(PTR, LEN_NAME)             ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
> +#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
>  #endif
>  
>  #endif /* _LINUX_DMA_MAPPING_H */
> 
> I just don't know how much code out there depends on PTR not
> existing if !CONFIG_NEED_DMA_MAP_STATE

Brief checking shows that only drivers/net/ethernet/chelsio/* comes
with ifdeffery, the rest most likely will fail in the same way
(note, overwhelming majority of the users is under the network realm):

$ git grep -lw dma_unmap_[al][de].*

drivers/infiniband/hw/cxgb4/cq.c
drivers/infiniband/hw/cxgb4/qp.c
drivers/infiniband/hw/mthca/mthca_allocator.c
drivers/infiniband/hw/mthca/mthca_eq.c
drivers/net/ethernet/alacritech/slicoss.c
drivers/net/ethernet/alteon/acenic.c
drivers/net/ethernet/amazon/ena/ena_netdev.c
drivers/net/ethernet/arc/emac_main.c
drivers/net/ethernet/atheros/alx/main.c
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
drivers/net/ethernet/broadcom/bcmsysport.c
drivers/net/ethernet/broadcom/bnx2.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/brocade/bna/bnad.c
drivers/net/ethernet/chelsio/cxgb/sge.c
drivers/net/ethernet/chelsio/cxgb3/sge.c
drivers/net/ethernet/emulex/benet/be_main.c
drivers/net/ethernet/engleder/tsnep_main.c
drivers/net/ethernet/google/gve/gve_tx.c
drivers/net/ethernet/google/gve/gve_tx_dqo.c
drivers/net/ethernet/intel/fm10k/fm10k_main.c
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40e/i40e_txrx.c
drivers/net/ethernet/intel/i40e/i40e_xsk.c
drivers/net/ethernet/intel/iavf/iavf_txrx.c
drivers/net/ethernet/intel/ice/ice_txrx.c
drivers/net/ethernet/intel/ice/ice_txrx_lib.c
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
drivers/net/ethernet/intel/idpf/idpf_txrx.c
drivers/net/ethernet/intel/igb/igb_ethtool.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igc/igc_dump.c
drivers/net/ethernet/intel/igc/igc_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
drivers/net/ethernet/marvell/skge.c
drivers/net/ethernet/marvell/sky2.c
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mscc/ocelot_fdma.c
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
drivers/net/ethernet/qlogic/qla3xxx.c
drivers/net/ethernet/rocker/rocker_main.c
drivers/net/ethernet/wangxun/libwx/wx_lib.c
drivers/net/wireless/intel/iwlegacy/3945-mac.c
drivers/net/wireless/intel/iwlegacy/3945.c
drivers/net/wireless/intel/iwlegacy/4965-mac.c
drivers/net/wireless/intel/iwlegacy/common.c
drivers/net/wireless/marvell/mwl8k.c

include/net/libeth/tx.h
Marek Szyprowski March 11, 2025, 12:51 p.m. UTC | #8
Hi Andy,

On 05.03.2025 11:00, Andy Shevchenko wrote:
> On Tue, Mar 04, 2025 at 08:35:24AM -0800, Jakub Kicinski wrote:
>> On Tue, 4 Mar 2025 15:41:19 +0200 Andy Shevchenko wrote:
> ...
>
>>>>> Would that work?
>>> Actually it won't work because the variable is under the same ifdeffery.
>>> What will work is to spreading the ifdeffery to the users, but it doesn't any
>>> better than __maybe_unsused, which is compact hack (yes, I admit that it is not
>>> the nicest solution, but it's spread enough in the kernel).
>> I meant something more like (untested):
> We are starving for the comment from the DMA mapping people.

I'm really sorry for this delay. Just got back to the everyday stuff 
after spending a week in bed recovering from flu...

>> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
>> index b79925b1c433..a7ebcede43f6 100644
>> --- a/include/linux/dma-mapping.h
>> +++ b/include/linux/dma-mapping.h
>> @@ -629,10 +629,10 @@ static inline int dma_mmap_wc(struct device *dev,
>>   #else
>>   #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
>>   #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
>> -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
>> -#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
>> -#define dma_unmap_len(PTR, LEN_NAME)             (0)
>> -#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
>> +#define dma_unmap_addr(PTR, ADDR_NAME)           ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
>> +#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
>> +#define dma_unmap_len(PTR, LEN_NAME)             ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
>> +#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
>>   #endif
>>   
>>   #endif /* _LINUX_DMA_MAPPING_H */
>>
>> I just don't know how much code out there depends on PTR not
>> existing if !CONFIG_NEED_DMA_MAP_STATE
> Brief checking shows that only drivers/net/ethernet/chelsio/* comes
> with ifdeffery, the rest most likely will fail in the same way
> (note, overwhelming majority of the users is under the network realm):

Frankly speaking I wasn't aware of this API till now.

If got it right the above proposal should work fine. The addr/len names 
can be optimized out, but the pointer to the container should exist.


> $ git grep -lw dma_unmap_[al][de].*
>
> drivers/infiniband/hw/cxgb4/cq.c
> drivers/infiniband/hw/cxgb4/qp.c
> drivers/infiniband/hw/mthca/mthca_allocator.c
> drivers/infiniband/hw/mthca/mthca_eq.c
> drivers/net/ethernet/alacritech/slicoss.c
> drivers/net/ethernet/alteon/acenic.c
> drivers/net/ethernet/amazon/ena/ena_netdev.c
> drivers/net/ethernet/arc/emac_main.c
> drivers/net/ethernet/atheros/alx/main.c
> drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
> drivers/net/ethernet/broadcom/bcmsysport.c
> drivers/net/ethernet/broadcom/bnx2.c
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
> drivers/net/ethernet/broadcom/bnxt/bnxt.c
> drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
> drivers/net/ethernet/broadcom/genet/bcmgenet.c
> drivers/net/ethernet/broadcom/tg3.c
> drivers/net/ethernet/brocade/bna/bnad.c
> drivers/net/ethernet/chelsio/cxgb/sge.c
> drivers/net/ethernet/chelsio/cxgb3/sge.c
> drivers/net/ethernet/emulex/benet/be_main.c
> drivers/net/ethernet/engleder/tsnep_main.c
> drivers/net/ethernet/google/gve/gve_tx.c
> drivers/net/ethernet/google/gve/gve_tx_dqo.c
> drivers/net/ethernet/intel/fm10k/fm10k_main.c
> drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
> drivers/net/ethernet/intel/i40e/i40e_main.c
> drivers/net/ethernet/intel/i40e/i40e_txrx.c
> drivers/net/ethernet/intel/i40e/i40e_xsk.c
> drivers/net/ethernet/intel/iavf/iavf_txrx.c
> drivers/net/ethernet/intel/ice/ice_txrx.c
> drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
> drivers/net/ethernet/intel/idpf/idpf_txrx.c
> drivers/net/ethernet/intel/igb/igb_ethtool.c
> drivers/net/ethernet/intel/igb/igb_main.c
> drivers/net/ethernet/intel/igc/igc_dump.c
> drivers/net/ethernet/intel/igc/igc_main.c
> drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> drivers/net/ethernet/marvell/skge.c
> drivers/net/ethernet/marvell/sky2.c
> drivers/net/ethernet/mediatek/mtk_eth_soc.c
> drivers/net/ethernet/mscc/ocelot_fdma.c
> drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> drivers/net/ethernet/qlogic/qla3xxx.c
> drivers/net/ethernet/rocker/rocker_main.c
> drivers/net/ethernet/wangxun/libwx/wx_lib.c
> drivers/net/wireless/intel/iwlegacy/3945-mac.c
> drivers/net/wireless/intel/iwlegacy/3945.c
> drivers/net/wireless/intel/iwlegacy/4965-mac.c
> drivers/net/wireless/intel/iwlegacy/common.c
> drivers/net/wireless/marvell/mwl8k.c
>
> include/net/libeth/tx.h
>
Best regards
Andy Shevchenko March 12, 2025, 4:20 p.m. UTC | #9
On Tue, Mar 11, 2025 at 01:51:21PM +0100, Marek Szyprowski wrote:
> On 05.03.2025 11:00, Andy Shevchenko wrote:
> > On Tue, Mar 04, 2025 at 08:35:24AM -0800, Jakub Kicinski wrote:
> >> On Tue, 4 Mar 2025 15:41:19 +0200 Andy Shevchenko wrote:

...

> >> I meant something more like (untested):
> > We are starving for the comment from the DMA mapping people.
> 
> I'm really sorry for this delay. Just got back to the everyday stuff 
> after spending a week in bed recovering from flu...

Oh, I hope you feel much better now!

...

> >>   #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
> >>   #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
> >> -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
> >> -#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
> >> -#define dma_unmap_len(PTR, LEN_NAME)             (0)
> >> -#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
> >> +#define dma_unmap_addr(PTR, ADDR_NAME)           ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
> >> +#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
> >> +#define dma_unmap_len(PTR, LEN_NAME)             ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
> >> +#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { typeof(PTR) __p __maybe_unused = PTR; } while (0)

> >> I just don't know how much code out there depends on PTR not
> >> existing if !CONFIG_NEED_DMA_MAP_STATE
> > Brief checking shows that only drivers/net/ethernet/chelsio/* comes
> > with ifdeffery, the rest most likely will fail in the same way
> > (note, overwhelming majority of the users is under the network realm):
> 
> Frankly speaking I wasn't aware of this API till now.
> 
> If got it right the above proposal should work fine. The addr/len names 
> can be optimized out, but the pointer to the container should exist.

Thanks for the reply, would you or Jakub will to send a formal patch?
I can test it on my configuration and build.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 6ec773e61182..a40ef3ec38b3 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -2887,7 +2887,7 @@  bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 		last = tx_buf->nr_frags;
 
 		for (i = 0; i < last; i++) {
-			struct bnx2_sw_tx_bd *tx_buf;
+			struct bnx2_sw_tx_bd *tx_buf __maybe_unused;
 
 			sw_cons = BNX2_NEXT_TX_BD(sw_cons);
 
@@ -2994,7 +2994,7 @@  static inline void
 bnx2_reuse_rx_data(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
 		   u8 *data, u16 cons, u16 prod)
 {
-	struct bnx2_sw_bd *cons_rx_buf, *prod_rx_buf;
+	struct bnx2_sw_bd *cons_rx_buf __maybe_unused, *prod_rx_buf;
 	struct bnx2_rx_bd *cons_bd, *prod_bd;
 
 	cons_rx_buf = &rxr->rx_buf_ring[cons];