mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.de>
To: Joe Perches <joe@perches.com>
Cc: "David Barksdale" <dbarksdale@uplogix.com>,
	"David Herrmann" <dh.herrmann@gmail.com>,
	"Jiri Kosina" <jkosina@suse.cz>,
	"Benjamin Tissoires" <benjamin.tissoires@redhat.com>,
	"Jakub Kákona" <kjakub@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] HID: New hid-cp2112 driver
Date: Thu, 30 Jan 2014 13:49:34 +0100	[thread overview]
Message-ID: <1391086174.16757.4.camel@linux-fkkt.site> (raw)
In-Reply-To: <1391075579.2422.53.camel@joe-AO722>

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




  reply	other threads:[~2014-01-30 12:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29 23:26 David Barksdale
2014-01-29 23:46 ` Joe Perches
2014-01-30  7:35   ` Oliver Neukum
2014-01-30  9:52     ` Joe Perches
2014-01-30 12:49       ` Oliver Neukum [this message]
2014-01-31 10:41 ` Jiri Kosina

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=1391086174.16757.4.camel@linux-fkkt.site \
    --to=oneukum@suse.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dbarksdale@uplogix.com \
    --cc=dh.herrmann@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=joe@perches.com \
    --cc=kjakub@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®