All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lina Iyer <ilina@codeaurora.org>
To: Stephen Boyd <swboyd@chromium.org>
Cc: Doug Anderson <dianders@chromium.org>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	"open list:ARM/QUALCOMM SUPPORT" <linux-soc@vger.kernel.org>,
	Rajendra Nayak <rnayak@codeaurora.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	mkshah@codeaurora.org
Subject: Re: [PATCH V2 2/4] drivers: qcom: rpmh-rsc: avoid locking in the interrupt handler
Date: Tue, 30 Jul 2019 11:29:35 -0600	[thread overview]
Message-ID: <20190730172935.GJ18620@codeaurora.org> (raw)
In-Reply-To: <5d3f5d6d.1c69fb81.4c1e2.5be6@mx.google.com>

On Mon, Jul 29 2019 at 14:56 -0600, Stephen Boyd wrote:
>Quoting Lina Iyer (2019-07-29 12:01:39)
>> On Thu, Jul 25 2019 at 09:44 -0600, Doug Anderson wrote:
>> >On Thu, Jul 25, 2019 at 8:18 AM Lina Iyer <ilina@codeaurora.org> wrote:
>> >>
>> >> On Wed, Jul 24 2019 at 17:28 -0600, Doug Anderson wrote:
>> >> >
>> >> >Jumping in without reading all the context, but I saw this fly by and
>> >> >it seemed odd.  If I'm way off base then please ignore...
>> >> >
>> >> >Can you give more details?  Why are these drivers in atomic contexts?
>> >> >If they are in atomic contexts because they are running in the context
>> >> >of an interrupt then your next patch in the series isn't so correct.
>> >> >
>> >> >Also: when people submit requests in atomic context are they always
>> >> >submitting an asynchronous request?  In that case we could
>> >> >(presumably) just use a spinlock to protect the queue of async
>> >> >requests and a mutex for everything else?
>> >> Yes, drivers only make async requests in interrupt contexts.
>> >
>> >So correct me if I'm off base, but you're saying that drivers make
>> >requests in interrupt contexts even after your whole series and that's
>> >why you're using spinlocks instead of mutexes.  ...but then in patch
>> >#3 in your series you say:
>> >
>> >> Switch over from using _irqsave/_irqrestore variants since we no longer
>> >> race with a lock from the interrupt handler.
>> >
>> >Those seem like contradictions.  What happens if someone is holding
>> >the lock, then an interrupt fires, then the interrupt routine wants to
>> >do an async request.  Boom, right?
>> >
>> The interrupt routine is handled by the driver and only completes the
>> waiting object (for sync requests). No other requests can be made from
>> our interrupt handler.
>
>The question is more if an interrupt handler for some consumer driver
>can call into this code and make an async request. Is that possible? If
>so, the concern is that the driver's interrupt handler can run and try
>to grab the lock on a CPU that already holds the lock in a non-irq
>disabled context. This would lead to a deadlock while the CPU servicing
>the interrupt waits for the lock held by another task that's been
>interrupted.
>
Hmm.. this patch will cause that issue, since we remove the irqsave
aspects of the locking. Let me give that a thought.
>>
>> >> They cannot
>> >> use the sync variants. The async and sync variants are streamlined into
>> >> the same code path. Hence the use of spinlocks instead of mutexes
>> >> through the critical path.
>> >
>> >I will perhaps defer to Stephen who was the one thinking that a mutex
>> >would be a big win here.  ...but if a mutex truly is a big win then it
>> >doesn't seem like it'd be that hard to have a linked list (protected
>> >by a spinlock) and then some type of async worker that:
>> >
>> >1. Grab the spinlock, pops one element off the linked list, release the spinlock
>> >2. Grab the mutex, send the one element, release the mutex
>> This would be a problem when the request is made from an irq handler. We
>> want to keep things simple and quick.
>>
>
>Is the problem that you want to use RPMh code from deep within the idle
>thread? As part of some sort of CPU idle driver for qcom platforms? The
>way this discussion is going it sounds like nothing is standing in the
>way of a design that use a kthread to pump messages off a queue of
>messages that is protected by a spinlock. The kthread would be woken up
>by the sync or async write to continue to pump messages out until the
>queue is empty.
>
While it is true that we want to use RPMH in cpuidle driver. Its just
that we had threads and all in our downstream 845 and it complicated the
whole setup a bit too much to our liking and did not help debug either.
I would rather not get all that back in the driver.

--Lina

  reply	other threads:[~2019-07-30 17:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22 21:53 [PATCH V2 1/4] drivers: qcom: rpmh-rsc: simplify TCS locking Lina Iyer
2019-07-22 21:53 ` [PATCH V2 2/4] drivers: qcom: rpmh-rsc: avoid locking in the interrupt handler Lina Iyer
2019-07-23 20:11   ` Stephen Boyd
2019-07-24 14:52     ` Lina Iyer
2019-07-24 19:37       ` Stephen Boyd
2019-07-24 20:36         ` Lina Iyer
2019-07-24 23:27           ` Doug Anderson
2019-07-25 15:18             ` Lina Iyer
2019-07-25 15:39               ` Doug Anderson
2019-07-29 19:01                 ` Lina Iyer
2019-07-29 20:56                   ` Stephen Boyd
2019-07-30 17:29                     ` Lina Iyer [this message]
2019-07-22 21:53 ` [PATCH V2 3/4] drivers: qcom: rpmh: switch over from spinlock irq variants Lina Iyer
2019-07-23 18:24   ` Stephen Boyd
2019-07-22 21:53 ` [PATCH V2 4/4] drivers: qcom: rpmh-rsc: remove redundant register access Lina Iyer
2019-07-23 18:22 ` [PATCH V2 1/4] drivers: qcom: rpmh-rsc: simplify TCS locking Stephen Boyd
2019-07-23 19:21   ` Lina Iyer
2019-07-23 20:18     ` Stephen Boyd
2019-07-24 14:54       ` Lina Iyer
2019-07-24 18:32         ` Stephen Boyd
2019-07-24 19:36           ` Lina Iyer

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=20190730172935.GJ18620@codeaurora.org \
    --to=ilina@codeaurora.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=dianders@chromium.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=mkshah@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=swboyd@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.