linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jorge.ramirez-ortiz@linaro.org (Jorge Ramirez-Ortiz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] drivers/tty: amba-pl011: defer driver probing if external dma is not ready.
Date: Wed, 25 Feb 2015 16:02:54 -0500	[thread overview]
Message-ID: <54EE387E.8040003@linaro.org> (raw)
In-Reply-To: <7759418.HHcBTFejZY@wuerfel>

On 02/25/2015 05:22 AM, Arnd Bergmann wrote:
> On Tuesday 24 February 2015 17:02:08 Jorge Ramirez-Ortiz wrote:
>> On 02/24/2015 02:32 PM, Jorge Ramirez-Ortiz wrote:
>>> On 02/24/2015 03:29 AM, Arnd Bergmann wrote:
>>>> On Monday 23 February 2015 22:46:53 Jorge Ramirez-Ortiz wrote:
>>>>> This patch addresses a race condition that happens when
>>>>> device_initcall(pl011_dma_initicall) is executed before all the devices have been
>>>>> probed - this issue was observed on an hisi_6220 SoC (HiKey board from Linaro).
>>>> How do you want to handle the case where there is a DMA channel in DT, but
>>>> no driver for it built into the kernel?
>>> In my view that should be fixed in the of-dma and the acpi-dma implementation
>>> (just don't return EPROBE_DEFER a second time since the driver wasn't found
>>> after the late_initcall associated to deferred probing). That would allow
>>> drivers that use the defer probing mechanism to wait for optional controllers to
>>> complete their probing sequence if those controllers don't become available.
>>>
>>> In any case, I can track the pending requests (up to twelve, one per UART) with
>>> a list in the driver.
>>> If a second request to probe fails with EPROBE_DEFER we can conclude that the
>>> driver is not present.
>>>
>>> I have tested such an implementation and it works as expected.
>>> would that be acceptable?
>> Something along these lines
>>
>> +struct dma_deferred {
>> +       struct list_head node;
>> +       struct device *dev;
>> +};
>> +
>> +static LIST_HEAD(dma_deferred_reqs);
>> +
>> +static int pl011_handle_dma_probe_defer(struct device *dev)
>> +{
>> +       struct list_head *node, *tmp;
>> +       struct dma_deferred *entry;
>> +
>> +       list_for_each_safe(node, tmp, &dma_deferred_reqs) {
>> +               entry = list_entry(node, struct dma_deferred, node);
>> +               if (entry->dev == dev) {
>> +                       dev_warn(dev, "DMA driver not present \n");
>> +                       list_del(node);
>> +                       kfree(entry);
>> +                       return -ENODEV;
>> +               }
>> +       }
> I don't see how this would help: Assume you probe the uart first, it defers
> because of missing DMA, then you probe DMA, which defers because of some
> other resource (clock, irq, ...), then probe the uart a second time and
> it fails, then you probe the DMA driver which succeeds because the resources
> are there. Another case would be the DMA driver being a loadable module
> that only gets loaded after all deferred probes from built-in drivers
> have completed.

yes you are right.
it is just as incomplete a solution as replacing the original device_initcall by
late_deviceinitcall (my first impulse)

>
> I don't think we can make any reasonable assumption about the number of
> times you need to defer the probing here.

agreed.

And even if we did, the current defer probing framework would not reliably
support it either, since it might stop sending deferred probes with requests
still queued in the deferred_probe_pending_list.So the wait could be eternal.

I believe this happens when all the in kernel drivers have been tried and the
list is now waiting for some module to successfuly load -which would trigger the
event that iterates through the list.

If not for this particular case, maybe there is some value in extending the
current defer driver probing behavior;
For example having two types of defer:
1. -EPROBE_DEFER (as per today, for ever)
2. -EPROBE_DEFERK (ie, defer until all the in-kernel devices have been handled
and the list is quiescent now waiting for modules)
On this second case we could flush the list probing the device with a flag in
struct device indicating this is indeed the last call under EPROBE_DEFERK.

I am not very sure myself if this would be of use to anybody (although I would
have probably used it on this case)

>
> Also, the UART is a rather central device, at least the one that is used
> for the console, and we probably want to use it as early as possible even
> if that means never attaching the dma engine.

yes, defer probing clearly does not fit here.

>
> A better solution might be to move the dma_request_slave_channel_reason()
> call out of the probe() function entirely and into the open() function:
> we use DMA if it is available by the time the device gets opened, otherwise
> we don't.

thanks! will do that.

>
> 	Arnd

  reply	other threads:[~2015-02-25 21:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Re: [PATCH] drivers/tty: amba-pl011: defer driver probing if external dma is not ready.>
2015-02-24  3:46 ` [PATCH v2] drivers/tty: amba-pl011: defer driver probing if external dma is not ready Jorge Ramirez-Ortiz
2015-02-24  3:46   ` [PATCH] " Jorge Ramirez-Ortiz
2015-02-24  8:29     ` Arnd Bergmann
2015-02-24 19:32       ` Jorge Ramirez-Ortiz
2015-02-24 22:02         ` Jorge Ramirez-Ortiz
2015-02-25 10:22           ` Arnd Bergmann
2015-02-25 21:02             ` Jorge Ramirez-Ortiz [this message]
2015-02-23 20:16 Jorge Ramirez-Ortiz
2015-02-23 20:58 ` Rob Herring
2015-02-24  3:33   ` Jorge Ramirez-Ortiz

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=54EE387E.8040003@linaro.org \
    --to=jorge.ramirez-ortiz@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).