[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+sZ8B8-hsNXY-nFffvGMLJXmsAa9L+gnEK1ZdC7PztG1dd03Q@mail.gmail.com>
Date: Tue, 13 Sep 2022 18:52:12 +0200
From: Nam Cao <namcaov@...il.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: forest@...ttletooquiet.net, linux-kernel@...r.kernel.org,
linux-staging@...ts.linux.dev
Subject: Re: [PATCH v3 1/2] staging: vt6655: remove unnecessary volatile qualifier
On Sun, Sep 11, 2022 at 9:25 AM Greg KH <gregkh@...uxfoundation.org> wrote:
>
> On Sun, Sep 11, 2022 at 09:12:44AM +0200, Nam Cao wrote:
> > On Fri, Sep 9, 2022 at 8:03 PM Greg KH <gregkh@...uxfoundation.org> wrote:
> > >
> > > On Fri, Sep 09, 2022 at 02:17:55PM +0200, Nam Cao wrote:
> > > > Remove volatile qualifier for the member rd0 of struct vnt_rx_desc,
> > > > because there is no reason it must be volatile.
> > > >
> > > > Signed-off-by: Nam Cao <namcaov@...il.com>
> > > > ---
> > > > drivers/staging/vt6655/desc.h | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h
> > > > index 17a40c53b8ff..3f0f287b1693 100644
> > > > --- a/drivers/staging/vt6655/desc.h
> > > > +++ b/drivers/staging/vt6655/desc.h
> > > > @@ -182,7 +182,7 @@ struct vnt_rdes1 {
> > > >
> > > > /* Rx descriptor*/
> > > > struct vnt_rx_desc {
> > > > - volatile struct vnt_rdes0 rd0;
> > > > + struct vnt_rdes0 rd0;
> > >
> > > You can not just remove this without describing _WHY_ it is ok to do so.
> > >
> > > Have you properly determined why it is, or is not, ok to use volatile
> > > here?
> >
> > I did not carefully look at the volatile usage here. After looking at it
> > again, using volatile is actually valid: the structure resides on coherent
> > memory.
>
> Are you sure? That's a very odd thing for a driver to need. Looks like
> they are allocating some dma memory and then pointing structures on top
> of that memory. Why would you need to have "volatile" markings on a
> structure definition for that?
These structures are the ring buffer descriptors, which are dma-mapped and
their values may be changed by the hardware. For example, the field "owner" of
struct vnt_rdes0 is set to OWNED_BY_NIC by CPU, and then set to OWNED_BY_HOST
by hardware when new data arrives (at least that's why I can guess based on
the codes). So I think volatile is needed.
Please let me know if you think I'm wrong, because I have just recently
educated myself on DMA mapping.
Best regards,
Nam
Powered by blists - more mailing lists