All of lore.kernel.org
 help / color / mirror / Atom feed
From: "xuqiang (M)" <xuqiang36@huawei.com>
To: Marc Zyngier <maz@kernel.org>
Cc: <tglx@linutronix.de>, <linux-kernel@vger.kernel.org>,
	<rui.xiang@huawei.com>
Subject: Re: [PATCH -next] irq-chip/gic-v3-its: Fixed an issue where the ITS executes the residual commands in the queue again when the ITS wakes up from sleep mode.
Date: Fri, 6 Nov 2020 18:05:36 +0800	[thread overview]
Message-ID: <bd9acf43-d97b-3a11-bca2-b82f71467d2f@huawei.com> (raw)
In-Reply-To: <42a66989326ff73fd01318dc8fbceffc@kernel.org>


在 2020/11/5 22:24, Marc Zyngier 写道:
> On 2020-11-05 14:06, xuqiang (M) wrote:
>> 在 2020/11/5 21:12, Marc Zyngier 写道:
>>> Please don't top-post.
>>>
>>> On 2020-11-05 11:54, xuqiang (M) wrote:
>>>> The kernel sends three commands in the following sequence:
>>>>
>>>> 1.mapd(deviceA, ITT_addr1, valid:1)
>>>>
>>>> 2.mapti(deviceA):ITS write ITT_addr1 memory;
>>>>
>>>> 3.mapd(deviceA, ITT_addr1, valid:0) and kfree(ITT_addr1);
>>>>
>>>> 4.mapd(deviceA, ITT_addr2, valid:1);
>>>>
>>>> 5.mapti(deviceA):ITS write ITT_addr2 memory;
>>>>
>>>> In this case, the processor enters the sleep mode. After the kernel
>>>> performs the suspend operation, the firmware performs the store
>>>> operation and saves GITS_CBASER and GITS_CWRITER registers.
>>>>
>>>> Then, the processor is woken up, and the firmware restores GITS_CBASER
>>>> and GITS_CWRITER registers. Because GITS_CWRITER register is not 0,
>>>> ITS will read the above command sequence execution from the command
>>>> queue, causing ITT_addr1 memory to be trampled.
>>>
>>> This cannot work. By doing a memset on the command queue, you are
>>> only feeding crap to the ITS (command 0 simply does not exist).
>>> Consider yourself lucky that it doesn't just lock-up.
>>>
>>> What needs to happen is the restore sequence that is already in the
>>> driver, so that the command queue is in a sane state before re-enabling
>>> the ITS.
>>>
>>>         M.
>>
>>
>> On my platform, ITS_FLAGS_SAVE_SUSPEND_STATE is not set, thus
>> the first if condition in its_save_disable under list_for_each_entry 
>> goes
>> to the continue, however, I want to set the GITS_CWRITER to 0 at the
>> end of list_for_each_entry.
>>
>> Do you have any suggestions about how to do this?
>
> That's pretty much dropping the checks for ITS_FLAGS_SAVE_SUSPEND_STATE,
> isn't it? But I assume your ITS is already enabled by the time you 
> reenter
> the kernel? If so, I bet your firmware is doing more than just writing
> to CBASER and CWRITER...
>
>         M.

Yes, you are right.My firmware stores GITS_CTRL,GITS_CBASER,GITS_CWRITER

and GITS_BASER<n> in the suspend, and restores these registers in the 
resume.

So I will drop the checks for ITS_FLAGS_SAVE_SUSPEND_STATE. In the case 
of ITS disabled,

set the GITS_CWRITER to 0.

Thanks

              Xu.


  reply	other threads:[~2020-11-06 10:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03  8:11 [PATCH -next] irq-chip/gic-v3-its: Fixed an issue where the ITS executes the residual commands in the queue again when the ITS wakes up from sleep mode Xu Qiang
2020-11-03 18:19 ` Marc Zyngier
2020-11-05 11:54   ` xuqiang (M)
2020-11-05 13:12     ` Marc Zyngier
2020-11-05 14:06       ` xuqiang (M)
2020-11-05 14:24         ` Marc Zyngier
2020-11-06 10:05           ` xuqiang (M) [this message]
2020-11-07 10:42 Xu Qiang
2020-11-07 16:54 ` Marc Zyngier
2020-11-09  3:05   ` xuqiang (M)
2020-11-09 10:43     ` Marc Zyngier
2020-11-10  9:09       ` xuqiang (M)
2020-11-17 13:37         ` xuqiang (M)
2020-11-22 12:47 ` Marc Zyngier

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=bd9acf43-d97b-3a11-bca2-b82f71467d2f@huawei.com \
    --to=xuqiang36@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=rui.xiang@huawei.com \
    --cc=tglx@linutronix.de \
    /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.