public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Maximilian Luz <luzmaximilian@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Mark Gross" <mgross@linux.intel.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rob Herring" <robh@kernel.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	"Len Brown" <lenb@kernel.org>, "Blaž Hrastnik" <blaz@mxxn.io>,
	"Dorian Stoll" <dorian.stoll@tmsp.io>,
	"Platform Driver" <platform-driver-x86@vger.kernel.org>,
	"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
	"ACPI Devel Maling List" <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH 1/9] platform/surface: Add Surface Aggregator subsystem
Date: Tue, 17 Nov 2020 07:05:13 +0100	[thread overview]
Message-ID: <596dd647-b874-29f5-5bbf-a02f9d6ac587@gmail.com> (raw)
In-Reply-To: <8768d422-15f1-9fa3-481f-53be8549c395@gmail.com>

On 11/16/20 6:03 PM, Maximilian Luz wrote:
> On 11/16/20 2:33 PM, Andy Shevchenko wrote:
>> On Sun, Nov 15, 2020 at 9:25 PM Maximilian Luz <luzmaximilian@gmail.com> wrote:

[...]

> READ_ONCE and WRITE_ONCE are used to ensure proper access to state that
> can be changed outside of the queue/pending locks (or under any one of
> them). In general, I have tried to document all critical access of such
> state with an explanation of why it is safe to do so.

I've looked at this again and noticed that I can guard the packet
timestamp by the pending lock and the packet priority by the queue lock
(after first submission). This makes reasoning about access to them
significantly easier and removes the need for WRITE_ONCE / READ_ONCE.

After that, READ_ONCE is used

- to access the controller state for smoke-testing to (hopefully) detect
   invalid request function usage (note that all other access to this
   state happens under the controller state lock)

- for the "safe counters", where access to the shared value is, after
   initialization, restricted to the increment function

- to update the timeout reaper, where access to the shared value
   (rtx_timeout.expires) is, after initialization, restricted to its
   modification function (ssh_ptl_timeout_reaper_mod() /
   ssh_rtl_timeout_reaper_mod()) and the timer function

- to access the request timestamp, which is, after initialization, only
   set once in the lifetime of a request (all other access is read-only)

- to access the 'ptl' reference of the packet, which, after
   initialization, is only set once, either at packet or request
   submission (all other access is read-only). Note due to this,
   READ_ONCE is only required for functions that can run concurrently
   with ssh_ptl_submit() and ssh_rtl_submit(), i.e. ssh_ptl_cancel() and
   ssh_rtl_cancel().

- to access request state outside of bit-ops when canceling

I'd argue that all of these cases can be checked and verified with a
reasonable amount of effort. Cancellation (last two points) is probably
the most complex one. Unfortunately, I don't see any way to simplify
that part without disallowing cancellation to run concurrently to
submission, which is something I'd like to support as this makes
implementing asynchronous requests in the future easier.

Regards,
Max

  reply	other threads:[~2020-11-17  6:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15 19:21 [PATCH 0/9] Add support for Microsoft Surface System Aggregator Module Maximilian Luz
2020-11-15 19:21 ` [PATCH 9/9] platform/surface: Add Surface ACPI Notify driver Maximilian Luz
2020-11-17 20:09   ` Randy Dunlap
2020-11-17 20:18     ` Maximilian Luz
     [not found] ` <20201115192143.21571-2-luzmaximilian@gmail.com>
2020-11-16 13:33   ` [PATCH 1/9] platform/surface: Add Surface Aggregator subsystem Andy Shevchenko
2020-11-16 17:03     ` Maximilian Luz
2020-11-17  6:05       ` Maximilian Luz [this message]
2020-11-18  0:28   ` Barnabás Pőcze
2020-11-18 23:06     ` Maximilian Luz
2020-11-19 15:54       ` Barnabás Pőcze
2020-11-19 17:35         ` Maximilian Luz
2020-11-24 11:59 ` [PATCH 0/9] Add support for Microsoft Surface System Aggregator Module Hans de Goede
2020-11-24 13:43   ` Maximilian Luz

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=596dd647-b874-29f5-5bbf-a02f9d6ac587@gmail.com \
    --to=luzmaximilian@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=blaz@mxxn.io \
    --cc=dorian.stoll@tmsp.io \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jirislaby@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=robh@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