Platform-driver-x86 archive mirror
 help / color / mirror / Atom feed
From: Maximilian Luz <luzmaximilian@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>,
	Weifeng Liu <weifeng.liu.z@gmail.com>,
	platform-driver-x86@vger.kernel.org,
	linux-serial@vger.kernel.org
Subject: Re: [RFC PATCH 0/2] Defer probing of SAM if serdev device is not ready
Date: Thu, 2 May 2024 22:03:14 +0200	[thread overview]
Message-ID: <259aca16-6875-43d9-96a1-6b2e35688ea6@gmail.com> (raw)
In-Reply-To: <b08a6155-0701-403a-9c33-b1e24fd99e42@redhat.com>

Hi,

On 5/2/24 10:38 AM, Hans de Goede wrote:
> Hi Weifeng,
> 
> On 5/2/24 6:02 AM, Weifeng Liu wrote:
>> Greetings,
>>
>> This series is intended to remedy a race condition where surface
>> aggregator module (SAM) which is a serdev driver could fail to probe if
>> the underlying UART port is not ready to open.  In such circumstance,
>> invoking serdev_device_open() gets errno -ENXIO, leading to failure in
>> probing of SAM.  However, if the probe is retried in a short delay,
>> serdev_device_open() would work as expected and everything just goes
>> fine.  As a workaround, adding the serial driver (8250_dw) into
>> initramfs or building it into the kernel image significantly mitigates
>> the likelihood of encountering this race condition, as in this way the
>> serial device would be initialized much earlier than probing of SAM.
>>
>> However, IMO we should reliably avoid this sort of race condition.  A
>> good way is returning -EPROBE_DEFER when serdev_device_open returns
>> -ENXIO so that the kernel will be able to retry the probing later.  This
>> is what the first patch tries to do.
>>
>> Though this solution might be a good enough solution for this specific
>> issue, I am wondering why this kind of race condition could ever happen,
>> i.e., why a serdes device could be not ready yet at the moment the
>> serdev driver gets called and tries to bind it.  And even if this is an
>> expected behavior how serdev driver works, I do feel it a little bit
>> weird that we need to identify serdev_device_open() returning -ENXIO as
>> non-fatal error and thus return -EPROBE_DEFER manually in such case, as
>> I don't see this sort of behavior in other serdev driver.  Maximilian
>> and Hans suggested discussing the root cause of the race condition here.
>> I will be grateful if you could provide some reasoning and insights on
>> this.
> 
> Ack, I have no objection against the changes and if Maximilian is ok with
> it I can merge these right away as an interim fix, but I would really
> like to know why the serdev core / tty code is registering a serdev
> device for a serial port before it is ready to have serdev_device_open()
> called on it. To me it seems that the root cause is in somewhere in
> the 8250_dw code or the serdev core code.

I'm fine with this being merged as an interim fix once Andy's comments
have been addressed. Weifeng, in that case you can then also add

Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>

However, I too would like to see this fixed properly on the serdev side.

> Resources sometimes not being ready is sometimes which drivers generally
> speaking need to handle, but in this case the resource which is not
> ready is the device the driver is binding to, so it seems that
> the device is registered too soon.
> 
> If someone familiar with the serial / serdev code can provide some
> insight here that would be great.

I will be away for the remainder of the month starting end of next week,
but I could try to look into this after that, provided no one else did by
then.

Best regards,
Max

      reply	other threads:[~2024-05-02 20:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02  4:02 [RFC PATCH 0/2] Defer probing of SAM if serdev device is not ready Weifeng Liu
2024-05-02  4:02 ` [RFC PATCH 1/2] platform/surface: aggregator: Defer probing when serdev " Weifeng Liu
2024-05-02 15:19   ` Andy Shevchenko
2024-05-02  4:02 ` [RFC PATCH 2/2] platform/surface: aggregator: Log critical errors during SAM probing Weifeng Liu
2024-05-02 15:15   ` Andy Shevchenko
2024-05-02  8:38 ` [RFC PATCH 0/2] Defer probing of SAM if serdev device is not ready Hans de Goede
2024-05-02 20:03   ` Maximilian Luz [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=259aca16-6875-43d9-96a1-6b2e35688ea6@gmail.com \
    --to=luzmaximilian@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=weifeng.liu.z@gmail.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).