Subject: Re: [PATCH wpan-next v2 10/11] net: mac802154: Add a warning in the hot path

From: Miquel Raynal <[email-masked]>
Date: Tue, 17 May 2022 16:52:59 +0200

[email-masked] wrote on Tue, 17 May 2022 15:36:55 +0200:

> [email-masked] wrote on Sun, 15 May 2022 18:30:15 -0400:
> 
> > Hi,
> > 
> > On Thu, May 12, 2022 at 10:34 AM Miquel Raynal
> > <[email-masked]> wrote:  
> > >
> > > We should never start a transmission after the queue has been stopped.
> > >
> > > But because it might work we don't kill the function here but rather
> > > warn loudly the user that something is wrong.
> > >
> > > Set an atomic when the queue will remain stopped. Reset this atomic when
> > > the queue actually gets restarded. Just check this atomic to know if the
> > > transmission is legitimate, warn if it is not.
> > >
> > > Signed-off-by: Miquel Raynal <[email-masked]>
> > > ---
> > >  include/net/cfg802154.h |  1 +
> > >  net/mac802154/tx.c      | 16 +++++++++++++++-
> > >  net/mac802154/util.c    |  1 +
> > >  3 files changed, 17 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> > > index 8b6326aa2d42..a1370e87233e 100644
> > > --- a/include/net/cfg802154.h
> > > +++ b/include/net/cfg802154.h
> > > @@ -218,6 +218,7 @@ struct wpan_phy {
> > >         struct mutex queue_lock;
> > >         atomic_t ongoing_txs;
> > >         atomic_t hold_txs;
> > > +       atomic_t queue_stopped;    
> > 
> > Maybe some test_bit()/set_bit() is better there?  
> 
> What do you mean? Shall I change the atomic_t type of queue_stopped?
> Isn't the atomic_t preferred in this situation?

Actually I re-read the doc and that's right, a regular unsigned long
used with test/set_bit might be preferred, I'll make the change.

Thanks,
Miquèl