From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Fabio Aiuto <fabioaiuto83@gmail.com>
Cc: outreachy-kernel@googlegroups.com, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [Outreachy kernel] [PATCH 1/2] staging: rtl8723bs: hal: Remove set but unused variables
Date: Thu, 29 Apr 2021 12:38:09 +0200 [thread overview]
Message-ID: <1870536.WTzYeaBcXf@linux.local> (raw)
In-Reply-To: <20210429102201.GF1409@agape.jhs>
On Thursday, April 29, 2021 12:22:02 PM CEST Fabio Aiuto wrote:
> On Thu, Apr 29, 2021 at 12:01:45PM +0200, Greg Kroah-Hartman wrote:
> > On Thu, Apr 29, 2021 at 10:25:53AM +0200, Fabio Aiuto wrote:
> > > On Thu, Apr 29, 2021 at 09:44:47AM +0200, Fabio M. De Francesco wrote:
> > > > On Thursday, April 29, 2021 9:26:20 AM CEST Fabio Aiuto wrote:
> > > > > Hi Fabio,
> > > > >
> > > > > On Wed, Apr 28, 2021 at 01:33:45PM +0200, Fabio M. De Francesco
wrote:
> > > > > > Removed four set but unused variables. Issue detected by gcc.
> > > > > >
> > > > > > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> > > > > > ---
> > > > > >
> > > > > > drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 5 -----
> > > > > > 1 file changed, 5 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
> > > > > > b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index
> > > >
> > > > 082448557b53..96cb4426a0f4
> > > >
> > > > > > 100644
> > > > > > --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
> > > > > > +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
> > > > > > @@ -3900,14 +3900,11 @@ u8 GetHalDefVar8723B(struct adapter
*padapter,
> > > >
> > > > enum
> > > >
> > > > > > hal_def_variable variable, v>
> > > > > >
> > > > > > u32 cmd;
> > > > > > u32 ra_info1, ra_info2;
> > > > > > u32 rate_mask1, rate_mask2;
> > > > > >
> > > > > > - u8 curr_tx_rate, curr_tx_sgi, hight_rate,
> > > >
> > > > lowest_rate;
> > > >
> > > > > > cmd = 0x40000100 | mac_id;
> > > > > > rtw_write32(padapter,
> > > >
> > > > REG_HMEBOX_DBG_2_8723B, cmd);
> > > >
> > > > > > msleep(10);
> > > > > > ra_info1 = rtw_read32(padapter, 0x2F0);
> > > > > >
> > > > > > - curr_tx_rate = ra_info1&0x7F;
> > > > > > - curr_tx_sgi = (ra_info1>>7)&0x01;
> > > > > >
> > > > > > cmd = 0x40000400 | mac_id;
> > > > > > rtw_write32(padapter,
> > > >
> > > > REG_HMEBOX_DBG_2_8723B, cmd);
> > > >
> > > > > > @@ -3916,8 +3913,6 @@ u8 GetHalDefVar8723B(struct adapter
*padapter, enum
> > > > > > hal_def_variable variable, v>
> > > > > >
> > > > > > ra_info2 = rtw_read32(padapter, 0x2F4);
> > > > > > rate_mask1 = rtw_read32(padapter, 0x2F8);
> > > > > > rate_mask2 = rtw_read32(padapter, 0x2FC);
> > > > > >
> > > > > > - hight_rate = ra_info2&0xFF;
> > > > > > - lowest_rate = (ra_info2>>8) & 0xFF;
> > > > > >
> > > > > > }
> > > > > > break;
> > > > >
> > > > > rate_mask{1,2} and ra_info{1,2} seems to be unused as well.
> > > > >
> > > > > thank you,
> > > > >
> > > > > fabio
> > > >
> > > > Hello Fabio,
> > > >
> > > > I'm not sure about it: rtw_read32 calls a pointer to a function. I'm
don't
> > > > know drivers programming, however that function looks like an
implementation
> > > > of a read() system call. So I wouldn't be so sure to remove those
calls.
> > > >
> > > > Could calling a (*read) method have side effects on subsequent read()?
I mean:
> > > > could it update some internal data structure? If not I can remove the
> > > > variables you mentioned above and the calls to read32.
> > > >
> > > > I'm looking forward to read your reply.
> > > >
> > > > Thanks,
> > > >
> > > > Fabio
> > >
> > > hi Fabio,
> > >
> > > rtw_read32 is a macro wrapping _rtw_read32() defined as follows (in
core/rtw_io.c):
> > >
> > > u32 _rtw_read32(struct adapter *adapter, u32 addr)
> > > {
> > >
> > > u32 r_val;
> > > /* struct io_queue *pio_queue = (struct io_queue
> > > *)adapter->pio_queue; */
> > > struct io_priv *pio_priv = &adapter->iopriv;
> > > struct intf_hdl *pintfhdl = &(pio_priv->intf);
> > > u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
> > >
> > > _read32 = pintfhdl->io_ops._read32;
> > >
> > > r_val = _read32(pintfhdl, addr);
> > > return rtw_le32_to_cpu(r_val);
> > >
> > > }
> > >
> > > the actual read seems to be performed by the handler contained in
> > >
> > > pintfhdl->io_ops._read32;
> > >
> > > so:
> > >
> > > $ grep -r '\b_read32' drivers/staging/rtl8723bs/
> > >
> > > drivers/staging/rtl8723bs/hal/sdio_ops.c: ops->_read32 =
&sdio_read32;
> > >
> > > this is the place where _read32 is stored with sdio_read32 reference...
> > >
> > > drivers/staging/rtl8723bs/core/rtw_io.c: u32 (*_read32)(struct
intf_hdl *pintfhdl,
> > > u32 addr); drivers/staging/rtl8723bs/core/rtw_io.c: _read32 =
> > > pintfhdl->io_ops._read32;
> > > ...
> > >
> > > if you check it in hal/sdio_ops.c, nothing is written, just reads are
> > > performed (and it's not odd, for a read function isn't supposed to write
> > > something under the hood ;)).
> >
> > Yes, but many types of hardware _REQUIRE_ reads to do something. So
> > "read that does nothing" is a requirement for some operations.
> >
> > As an example, a write is only guaranteed to have been finished if you
> > do a read of the same location back from it on some hardware busses.
> > The bus can reorder things, but a write/read of the same location can
> > not be reordered.
> >
> > Sometimes you have to do reads multiple times to get things to "stick".
> >
> > Other times reading from a location changes a state in the hardware
> > (horrid but HW designers aren't the brightest at times...)
> >
> > So you can NOT just remove reads without knowing that the hardware does
> > not require this. This is an issue where GCC "warnings" mean nothing as
> > gcc does not actually know what hardware does, or does not, do for many
> > things.
> >
> > thanks,
> >
> > greg k-h
>
> thank you for explanation, my hardware knowledge is poor:(
> Sorry for noise.
>
> fabio
>
I suspected that removing those variables could have been a source of troubles
(but I was thinking of possible side effects on internal kernel's data, not of
hardware related idiosyncrasies), however I think that you did well to point
it out because:
1) We learned something new from Greg;
2) I learned that, for the purpose of finding definitions, vim's ctrl-] is not
the right way to work out the problem.
If you have time, I'd appreciate some comments on the topic of line (2).
Thanks,
Fabio
next prev parent reply other threads:[~2021-04-29 10:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 11:33 [Outreachy kernel] [PATCH 0/2] Removed set but unused variables Fabio M. De Francesco
2021-04-28 11:33 ` [Outreachy kernel] [PATCH 1/2] staging: rtl8723bs: hal: Remove " Fabio M. De Francesco
2021-04-29 7:26 ` Fabio Aiuto
2021-04-29 7:44 ` Fabio M. De Francesco
2021-04-29 8:25 ` Fabio Aiuto
2021-04-29 9:16 ` Fabio M. De Francesco
2021-04-29 9:32 ` Fabio Aiuto
2021-04-29 9:53 ` Fabio M. De Francesco
2021-04-29 10:01 ` Greg Kroah-Hartman
2021-04-29 10:15 ` Fabio M. De Francesco
2021-04-29 11:21 ` Greg Kroah-Hartman
2021-04-29 10:22 ` Fabio Aiuto
2021-04-29 10:38 ` Fabio M. De Francesco [this message]
2021-04-29 12:07 ` Fabio Aiuto
2021-04-28 11:33 ` [Outreachy kernel] [PATCH 2/2] staging: rtl8723bs: core: Removed set but unused variable Fabio M. De Francesco
2021-04-29 14:35 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1870536.WTzYeaBcXf@linux.local \
--to=fmdefrancesco@gmail.com \
--cc=fabioaiuto83@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox