linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.de>
To: Pavel Machek <pavel@ucw.cz>
Cc: Jiri Kosina <jkosina@suse.cz>, Lauri Kasanen <cand@gmx.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	ao2@ao2.it, AndrewD207@aol.com
Subject: Re: [PATCH] HID: sony: Enable Gasia third-party PS3 controllers
Date: Thu, 19 Mar 2015 11:29:15 +0100	[thread overview]
Message-ID: <1426760955.2814.9.camel@suse.de> (raw)
In-Reply-To: <20150319101203.GA22127@amd>

On Thu, 2015-03-19 at 11:12 +0100, Pavel Machek wrote:
> On Thu 2015-03-19 10:54:22, Oliver Neukum wrote:
> > On Thu, 2015-03-19 at 10:38 +0100, Pavel Machek wrote:
> > > On Thu 2015-03-19 10:14:21, Oliver Neukum wrote:
> > > > On Mon, 2015-03-16 at 22:37 +0100, Jiri Kosina wrote:
> > 
> > > > > Are you sure CONFIG_DMA_API_DEBUG wouldn't warn here?
> > > > 
> > > > As far as I can tell, it will not warn. The problem is not in the
> > > > mapping itself. That is usually legitimate. The problem arises
> > > > because the buffer doesn't have a cacheline of its own. Thus the
> > > > memory corruption happens after the IO operation has started.
> > > 
> > > Nasty. Would WARN_ON(buffer & CACHELINE_SIZE-1) do at least part of
> > 
> > No. It is perfectly legitimate to put your buffer at an offset
> > or to combine buffers provided you don't use them at the same
> > time.
> 
> Legitimate: yes. Is anyone doing it? And will not they see exactly the

For this particular function probably not. In the general case, yes.
That's how you continue after an error.

> same data corruption with the aliasing data?

No, the error happens by touching another part of the cacheline
from the CPU thus loading stale content into the cache.
You can even have simultaneous DMA to two buffers in the same cacheline
provided you touch neither until the last DMA has finished.

> > > Alternatively, we could create "allocate_for_usb" function, and only
> > > take pointers allocated by that function in usb functions. That would
> > > also teach people the problem exists...
> > 
> > No, this problem is not limited to USB.
> 
> Well.. Recognize that just because you have a pointer does not mean
> you can pass it to certain functions.
> 
> Maybe those functions should not be taking pointers in the first
> place....

What else would it take? Should we force people to allocate a new
buffer every time? That would make the API for reading and writing
asymmetric.

	Regards
		Oliver

      reply	other threads:[~2015-03-19 10:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-07 13:48 [PATCH] HID: sony: Enable Gasia third-party PS3 controllers Lauri Kasanen
2015-02-07 15:56 ` Benjamin Tissoires
2015-02-07 16:31   ` Antonio Ospite
2015-02-07 21:48     ` Lauri Kasanen
2015-03-19 10:26       ` David Herrmann
2015-02-09 10:08 ` Oliver Neukum
2015-02-09 18:44   ` Lauri Kasanen
2015-02-10  8:14     ` Oliver Neukum
2015-03-16 21:10       ` Pavel Machek
2015-03-16 21:37         ` Jiri Kosina
2015-03-19  9:14           ` Oliver Neukum
2015-03-19  9:38             ` Pavel Machek
2015-03-19  9:54               ` Oliver Neukum
2015-03-19 10:12                 ` Pavel Machek
2015-03-19 10:29                   ` Oliver Neukum [this message]

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=1426760955.2814.9.camel@suse.de \
    --to=oneukum@suse.de \
    --cc=AndrewD207@aol.com \
    --cc=ao2@ao2.it \
    --cc=cand@gmx.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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;
as well as URLs for NNTP newsgroup(s).