lkml.org 
[lkml]   [2014]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4] HID: New hid-cp2112 driver
From
Date
On Thu, 2014-01-30 at 01:52 -0800, Joe Perches wrote:
> On Thu, 2014-01-30 at 08:35 +0100, Oliver Neukum wrote:
> > On Wed, 2014-01-29 at 15:46 -0800, Joe Perches wrote:
> >
> > > > +static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number,
> > > > + u8 *data, size_t count, unsigned char report_type)
> > > > +{
> > > > + u8 *buf;
> > > > + int ret;
> > > > +
> > > > + buf = kmalloc(count, GFP_KERNEL);
> > > > + if (!buf)
> > > > + return -ENOMEM;
> > > > +
> > > > + ret = hdev->hid_get_raw_report(hdev, report_number, buf, count,
> > > > + report_type);
> > > > + memcpy(data, buf, count);
> > > > + kfree(buf);
> > > > + return ret;
> > >
> > > if the data is going to be copied in data,
> > > why not just use data in hid_get_raw_report
> > > and avoid the malloc?
> >
> > He must not. It would violate the DMA rules. This function is passed
> > pointers to parts of structures. Access to the structures may race
> > with a DMA to/from the buffer. That violates the DMA rules.
>
> If this is going to be used to DMA, doesn't
> the alloc need to be GFP_KERNEL | GFP_DMA ?

No. GFP_DMA is needed only for DMA to the ISA bus.

Regards
Oliver





\
 
 \ /
  Last update: 2014-01-30 14:01    [W:0.039 / U:0.736 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site