2010-10-24 20:46:19

by Serafeim Zanikolas

[permalink] [raw]
Subject: [PATCH] drivers: rtl818x: request DMA-able memory

Despite the indicated intention in comment, the kmalloc() call was not
explicitly requesting memory from ZONE_DMA.

Signed-off-by: Serafeim Zanikolas <[email protected]>
---
drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 38fa824..771794d 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);

/* allocate "DMA aware" buffer for register accesses */
- priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
+ priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
+ GFP_DMA | GFP_KERNEL);
if (!priv->io_dmabuf) {
err = -ENOMEM;
goto err_free_dev;
--
1.7.1



2010-10-25 17:47:57

by Serafeim Zanikolas

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory

On Mon, Oct 25, 2010 at 10:22:32AM -0400, John W. Linville wrote:
> On Mon, Oct 25, 2010 at 03:11:22PM +0100, Hin-Tak Leung wrote:
> >
> >
> > Larry Finger wrote:
> > >On 10/24/2010 03:32 PM, Serafeim Zanikolas wrote:
> > >>Despite the indicated intention in comment, the kmalloc() call was not
> > >>explicitly requesting memory from ZONE_DMA.
> > >>
> > >>Signed-off-by: Serafeim Zanikolas <[email protected]>
> > >>---
> > >> drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-
> > >> 1 files changed, 2 insertions(+), 1 deletions(-)
> > >>
> > >>diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> > >>index 38fa824..771794d 100644
> > >>--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
> > >>+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> > >>@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
> > >> priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
> > >> /* allocate "DMA aware" buffer for register accesses */
> > >>- priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
> > >>+ priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
> > >>+ GFP_DMA | GFP_KERNEL);
> > >> if (!priv->io_dmabuf) {
> > >> err = -ENOMEM;
> > >> goto err_free_dev;
> > >
> > >ACK.
> > >
> > >Larry
> >
> > Acked-by: Hin-Tak Leung <[email protected]>
> >
> > I had a quick look for similiar constructs and AFAIK only the
> > b43/b43legacy drivers uses DMA buffers. Seems to be a rare practice.
> > Is that something we should or should not do?
>
> It doesn't mean what you think it means. It is a relic of the past,
> used to indicate memory below 16MB so that ISA devices could do DMA.

Right. Sorry for the noise.

-S

2010-10-25 13:45:29

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory

On Sun, Oct 24, 2010 at 10:32:07PM +0200, Serafeim Zanikolas wrote:
> Despite the indicated intention in comment, the kmalloc() call was not
> explicitly requesting memory from ZONE_DMA.
>
> Signed-off-by: Serafeim Zanikolas <[email protected]>
> ---
> drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> index 38fa824..771794d 100644
> --- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
> +++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> @@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
> priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
>
> /* allocate "DMA aware" buffer for register accesses */
> - priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
> + priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
> + GFP_DMA | GFP_KERNEL);
> if (!priv->io_dmabuf) {
> err = -ENOMEM;
> goto err_free_dev;

Are you sure about this? Are there USB controllers out there with
the ISA 16MB limitation for DMA?

John
--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2010-10-25 13:24:35

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory

On 10/24/2010 03:32 PM, Serafeim Zanikolas wrote:
> Despite the indicated intention in comment, the kmalloc() call was not
> explicitly requesting memory from ZONE_DMA.
>
> Signed-off-by: Serafeim Zanikolas <[email protected]>
> ---
> drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> index 38fa824..771794d 100644
> --- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
> +++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> @@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
> priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
>
> /* allocate "DMA aware" buffer for register accesses */
> - priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
> + priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
> + GFP_DMA | GFP_KERNEL);
> if (!priv->io_dmabuf) {
> err = -ENOMEM;
> goto err_free_dev;

ACK.

Larry


2010-10-25 18:01:18

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory

On 10/25/2010 10:39 AM, Hin-Tak Leung wrote:
>
> okay - sorry about the confusion - I was grep'ing for GFP_DMA and only b43/b43lagacy have it and it is relatively rare. AFAIK none of the rtl8187 devices are non-USB... probably a NACK then, but I should ask Serafeim if there is a reason for him to submit this patch? (other than "it says dma"...)

There are some devices driven by b43/b43legacy that implement only 24-bit DMA.
For that reason, they need to allocate DMA buffers in the low 16 MB of RAM. For
rtl8187, that consideration does not apply.

Larry

2010-10-25 14:23:32

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory

On Mon, 2010-10-25 at 15:11 +0100, Hin-Tak Leung wrote:

> >> Despite the indicated intention in comment, the kmalloc() call was not
> >> explicitly requesting memory from ZONE_DMA.

> I had a quick look for similiar constructs and AFAIK only the b43/b43legacy
> drivers uses DMA buffers. Seems to be a rare practice. Is that something we
> should or should not do?

I think there's some confusion here about ZONE_DMA vs. DMA-able memory.
All memory you get with kmalloc can be used for DMA, GFP_DMA means using
ZONE_DMA which is a hack for ISA (and in b43 maybe PCMCIA/Cardbus)
devices to put memory into something they can address. I don't think the
latter is necessary for USB devices.

johannes


2010-10-25 14:30:13

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory

On Mon, Oct 25, 2010 at 03:11:22PM +0100, Hin-Tak Leung wrote:
>
>
> Larry Finger wrote:
> >On 10/24/2010 03:32 PM, Serafeim Zanikolas wrote:
> >>Despite the indicated intention in comment, the kmalloc() call was not
> >>explicitly requesting memory from ZONE_DMA.
> >>
> >>Signed-off-by: Serafeim Zanikolas <[email protected]>
> >>---
> >> drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-
> >> 1 files changed, 2 insertions(+), 1 deletions(-)
> >>
> >>diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> >>index 38fa824..771794d 100644
> >>--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
> >>+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> >>@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
> >> priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
> >> /* allocate "DMA aware" buffer for register accesses */
> >>- priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
> >>+ priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
> >>+ GFP_DMA | GFP_KERNEL);
> >> if (!priv->io_dmabuf) {
> >> err = -ENOMEM;
> >> goto err_free_dev;
> >
> >ACK.
> >
> >Larry
>
> Acked-by: Hin-Tak Leung <[email protected]>
>
> I had a quick look for similiar constructs and AFAIK only the
> b43/b43legacy drivers uses DMA buffers. Seems to be a rare practice.
> Is that something we should or should not do?

It doesn't mean what you think it means. It is a relic of the past,
used to indicate memory below 16MB so that ISA devices could do DMA.

John
--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2010-10-25 14:17:38

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory



Larry Finger wrote:
> On 10/24/2010 03:32 PM, Serafeim Zanikolas wrote:
>> Despite the indicated intention in comment, the kmalloc() call was not
>> explicitly requesting memory from ZONE_DMA.
>>
>> Signed-off-by: Serafeim Zanikolas <[email protected]>
>> ---
>> drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-
>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
>> index 38fa824..771794d 100644
>> --- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
>> +++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
>> @@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
>> priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
>>
>> /* allocate "DMA aware" buffer for register accesses */
>> - priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
>> + priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
>> + GFP_DMA | GFP_KERNEL);
>> if (!priv->io_dmabuf) {
>> err = -ENOMEM;
>> goto err_free_dev;
>
> ACK.
>
> Larry

Acked-by: Hin-Tak Leung <[email protected]>

I had a quick look for similiar constructs and AFAIK only the b43/b43legacy
drivers uses DMA buffers. Seems to be a rare practice. Is that something we
should or should not do?

Hin-Tak

2010-10-25 15:46:41

by Hin-Tak Leung

[permalink] [raw]
Subject: Re: [PATCH] drivers: rtl818x: request DMA-able memory


--- On Mon, 25/10/10, John W. Linville <[email protected]> wrote:

> > I had a quick look for similiar constructs and AFAIK
> only the
> > b43/b43legacy drivers uses DMA buffers. Seems to be a
> rare practice.
> > Is that something we should or should not do?
>
> It doesn't mean what you think it means.? It is a
> relic of the past,
> used to indicate memory below 16MB so that ISA devices
> could do DMA.

okay - sorry about the confusion - I was grep'ing for GFP_DMA and only b43/b43lagacy have it and it is relatively rare. AFAIK none of the rtl8187 devices are non-USB... probably a NACK then, but I should ask Serafeim if there is a reason for him to submit this patch? (other than "it says dma"...)

Hin-tak