dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jani Nikula <jani.nikula@linux.intel.com>,
	Robert Tarasov <tutankhamen@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Dave Airlie <airlied@redhat.com>,
	Maling list - DRI developers <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/udl: Refactor edid retreiving in UDL driver
Date: Thu, 14 Mar 2019 11:46:25 +0100	[thread overview]
Message-ID: <3e4f46df-6a34-835b-6f57-d64aacc986d4@redhat.com> (raw)
In-Reply-To: <87ftrpixm8.fsf@intel.com>

Hi,

On 14-03-19 11:00, Jani Nikula wrote:
> On Wed, 13 Mar 2019, Robert Tarasov <tutankhamen@chromium.org> wrote:
>> On Wed, Mar 13, 2019 at 2:26 AM Jani Nikula <jani.nikula@linux.intel.com>
>> wrote:
>>   read_buff = kmalloc(2, GFP_KERNEL);
>>>
>>> A follow-up cleanup might be to switch to using "u8 read_buff[2];"
>>> instead of kmallocing it.
>>>
>>> I don't claim to understand how the usb stuff works, but otherwise the
>>> patch looks good to me. Nice refactoring!
>>>
>>>
>> "The buffer passed to usb_control_msg may end up in scatter-gather list,
>> and may thus not be on the stack. Having it on the stack usually works on
>> x86,   but not on other archs. "
> 
> Apparently you're referring to commit 242187b36255 ("udldrmfb:
> udl_get_edid: usb_control_msg buffer must not be on the stack"). Cc:
> Hans.

Right, that is correct, note this is enforced by the usb-core, having
the buffer on the stack will trigger a WARN_ONCE in drivers/usb/core/hcd.c:
usb_hcd_map_urb_for_dma() even on x86.

> Mind blows. Not a word on this anywhere in usb_control_msg()
> documentation. Nothing. I found this patch [1] that never go applied,
> which doesn't actually say anything about stack, only alignment and
> padding. Cc: Mauro.

I guess this is something everyone who works regularly on USB drivers
just learned once the hard way by triggering (and then fixing) the
WARN_ONCE. Note I'm not trying to make an excuse for the lacking docs
here, just trying to provide some background. I fully agree that the
docs should be updated to say that the buffer must be dma-able and
thus must not be on the stack. Maybe the docs should simply say
something along the lines of:

"the buffer should be dma-capable and properly aligned for dma,
it is advisable to use a dedictated kmalloc-ed buffer for this"

Regards,

Hans
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-03-14 10:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  1:04 [PATCH] drm/udl: Refactor edid retreiving in UDL driver Robert Tarasov
2019-03-13  9:27 ` Jani Nikula
2019-03-13 18:36   ` Robert Tarasov
2019-03-14 10:00     ` Jani Nikula
2019-03-14 10:46       ` Hans de Goede [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-03-13 18:38 Robert Tarasov
2019-03-15  2:04 ` Dave Airlie
2019-03-15  9:55   ` Jani Nikula

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=3e4f46df-6a34-835b-6f57-d64aacc986d4@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=mchehab+samsung@kernel.org \
    --cc=tutankhamen@chromium.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