[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1391086174.16757.4.camel@linux-fkkt.site>
Date: Thu, 30 Jan 2014 13:49:34 +0100
From: Oliver Neukum <oneukum@...e.de>
To: Joe Perches <joe@...ches.com>
Cc: David Barksdale <dbarksdale@...ogix.com>,
David Herrmann <dh.herrmann@...il.com>,
Jiri Kosina <jkosina@...e.cz>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Jakub Kákona <kjakub@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] HID: New hid-cp2112 driver
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists