Re: [PATCH v4 1/4] usb: dbc: early driver for xhci debug capability

From: Lu Baolu
Date: Thu Nov 10 2016 - 21:49:10 EST


Hi,

On 11/11/2016 10:24 AM, Lu Baolu wrote:
>> The only thing you can do to make this work is to prevent printing in NMI
>> > context:
>> >
>> > write()
>> > {
>> > if (in_nmi())
>> > return;
>> >
>> > raw_spinlock_irqsave(&lock, flags);
>> > ....
>> >
>> > That fully serializes the writes and just ignores NMI context printks. Not
>> > optimal, but I fear that's all you can do.
> Yes. But I want to add a bit more.
>
> write()
> {
> if (in_nmi() && raw_spin_is_locked(&lock)) {
> trace("... ...");
> return;
> }
>
> raw_spinlock_irqsave(&lock, flags);
> ....

Or...?

write()
{
if (in_nmi() && raw_spin_is_locked(&lock)) {
save_nmi_message_in_local_buf();
set_nmi_message_pending_flag();
return;
}

if (nmi_message_pending_flag_is_set()) {
write_nmi_message();
clear_nmi_message_pending_flag();
}

raw_spinlock_irqsave(&lock, flags);
....


Best regards,
Lu Baolu