From: Vignesh Raghavendra <vigneshr@ti.com>
To: Xiaoming Ni <nixiaoming@huawei.com>,
Miquel Raynal <miquel.raynal@bootlin.com>
Cc: wangle6@huawei.com, tudor.ambarus@microchip.com, richard@nod.at,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
linux-mtd@lists.infradead.org, gregkh@linuxfoundation.org,
tglx@linutronix.de
Subject: Re: ping // [PATCH] mtd:cfi_cmdset_0002: fix atomic sleep bug when CONFIG_MTD_XIP=y
Date: Mon, 14 Dec 2020 12:46:50 +0530 [thread overview]
Message-ID: <f14ccb94-cb53-f495-e95c-fe657122f16c@ti.com> (raw)
In-Reply-To: <b5c52547-b3cc-4217-cc69-067cee7d536f@huawei.com>
On 12/8/20 6:53 AM, Xiaoming Ni wrote:
> On 2020/12/8 2:59, Vignesh Raghavendra wrote:
>> Hi Xiaoming,
>>
[...]
>>>>> ---
>>>>> drivers/mtd/chips/cfi_cmdset_0002.c | 16 ++++++++++++++++
>>>>> 1 file changed, 16 insertions(+)
>>>>>
>>>>> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c
>>>>> b/drivers/mtd/chips/cfi_cmdset_0002.c
>>>>> index a1f3e1031c3d..12c3776f093a 100644
>>>>> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
>>>>> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
>>>>> @@ -1682,7 +1682,11 @@ static int __xipram
>>>>> do_write_oneword_once(struct map_info *map,
>>>>> set_current_state(TASK_UNINTERRUPTIBLE);
>>>>> add_wait_queue(&chip->wq, &wait);
>>>>> mutex_unlock(&chip->mutex);
>>>>> + if (IS_ENABLED(CONFIG_MTD_XIP))
>>>>> + local_irq_enable();
>>>>> schedule();
>>>>> + if (IS_ENABLED(CONFIG_MTD_XIP))
>>>>> + local_irq_disable();
>>>
>>> The fix really seems strange to me. I will let Vignesh decide but I
>>> think we should consider updating/fixing xip_disable instead.
>>
>> Agree with Miquel. Have you done any testing
>> or is this purely based on code inspection?
>>
> I don't have the corresponding device test environment.
> I found the problem through code review.
>
Sorry, I am not comfortable applying this patch without proper testing
that given the unknowns and legacy nature of the code.
>
>> What about comment before xip_disable() function:
>>
>> /*
>> * No interrupt what so ever can be serviced while the flash isn't in
>> array
>> * mode. This is ensured by the xip_disable() and xip_enable()
>> functions
>> * enclosing any code path where the flash is known not to be in
>> array mode.
>> * And within a XIP disabled code path, only functions marked with
>> __xipram
>> * may be called and nothing else (it's a good thing to inspect
>> generated
>> * assembly to make sure inline functions were actually inlined and
>> that gcc
>> * didn't emit calls to its own support functions). Also configuring
>> MTD CFI
>> * support to a single buswidth and a single interleave is also
>> recommended.
>> */
>>
>> So, I don't think the fix is as simple as this patch.
>>
> +xip_enable();
> schedule();
> +xip_disable();
>
> Do I need to change it to this?
>
This just narrows the window, but an IRQ is still possible just after
xip_enable() but before schedule().
Regards
Vignesh
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2020-12-14 7:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-27 13:07 [PATCH] mtd:cfi_cmdset_0002: fix atomic sleep bug when CONFIG_MTD_XIP=y Xiaoming Ni
2020-12-07 10:48 ` ping // " Xiaoming Ni
2020-12-07 10:53 ` Miquel Raynal
2020-12-07 18:59 ` Vignesh Raghavendra
2020-12-08 1:23 ` Xiaoming Ni
2020-12-14 7:16 ` Vignesh Raghavendra [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=f14ccb94-cb53-f495-e95c-fe657122f16c@ti.com \
--to=vigneshr@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=nixiaoming@huawei.com \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tudor.ambarus@microchip.com \
--cc=wangle6@huawei.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