linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Tianyang Zhang <zhangtianyang@loongson.cn>,
	chenhuacai@kernel.org, kernel@xen0n.name, corbet@lwn.net,
	alexs@kernel.org, si.yanteng@linux.dev, jiaxun.yang@flygoat.com,
	peterz@infradead.org, wangliupu@loongson.cn,
	lvjianmin@loongson.cn, maobibo@loongson.cn,
	siyanteng@cqsoftware.com.cn, gaosong@loongson.cn,
	yangtiezhu@loongson.cn
Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] irq/irq-loongarch-ir:Add Redirect irqchip support
Date: Mon, 23 Jun 2025 10:27:51 +0200	[thread overview]
Message-ID: <87v7omooag.ffs@tglx> (raw)
In-Reply-To: <9c60326b-f7bd-0b36-3bc5-0ad7d19690f1@loongson.cn>

On Mon, Jun 23 2025 at 10:45, Tianyang Zhang wrote:
> 在 2025/6/13 下午11:20, Thomas Gleixner 写道:
>> On Tue, Jun 10 2025 at 19:42, Tianyang Zhang wrote:
>>
>>> +	tail = (tail + 1) % INVALID_QUEUE_SIZE;
>> Why is this before the barrier? The barrier does not do anything about
>> this and you can simplify this. See below.
>>
>> And as there is no rmb() counterpart you want to explain that this is
>> serializing against the hardware.
>>> +	 */
>>> +	wmb();
>>> +
>>> +	write_queue_tail(rqueue->node, tail);
>> 	write_queue_tail(rqueue->node, (tail + 1) & INVALID_QUEUE_MASK);
>>
>> No?
>
> The reason fo coding here is that during testing, it was found that a
> barrier is needed between the update of temporary variable 'tail' and
> the operation of register with 'write_queue_tail' , otherwise
> write_queue_tail will probabilistically fail to obtain the correct
> value.

How so?

tail is the software managed part of the ringbuffer which is shared with
the hardware, right?

So even if the compiler would be allowed to reevalutate tail after the
barrier (it is NOT), then tail would still contain the same value as
before, no?

The wmb() is required to ensure that the hardware can observe the full
write of the command _before_ it can observe the update to the tail
index.

Anything else is voodoo.

Thanks,

        tglx

  reply	other threads:[~2025-06-23  8:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10 11:42 [PATCH v4 0/2] Loongarch irq-redirect supprot Tianyang Zhang
2025-06-10 11:42 ` [PATCH v4 1/2] Docs/LoongArch: Add Advanced Extended-Redirect IRQ model description Tianyang Zhang
2025-06-10 11:42 ` [PATCH v4 2/2] irq/irq-loongarch-ir:Add Redirect irqchip support Tianyang Zhang
2025-06-13 15:20   ` Thomas Gleixner
2025-06-23  2:45     ` Tianyang Zhang
2025-06-23  8:27       ` Thomas Gleixner [this message]
2025-06-23  9:33         ` Tianyang Zhang
2025-06-23 20:05           ` Thomas Gleixner
2025-06-24  1:39             ` Tianyang Zhang
2025-06-10 11:54 ` [PATCH v4 0/2] Loongarch irq-redirect supprot Huacai Chen
2025-06-10 12:07   ` Tianyang Zhang
2025-06-24  6:34   ` Tianyang Zhang
2025-06-13 14:02 ` Thomas Gleixner
2025-06-23  1:13   ` Tianyang Zhang

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=87v7omooag.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=alexs@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=corbet@lwn.net \
    --cc=gaosong@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=lvjianmin@loongson.cn \
    --cc=maobibo@loongson.cn \
    --cc=peterz@infradead.org \
    --cc=si.yanteng@linux.dev \
    --cc=siyanteng@cqsoftware.com.cn \
    --cc=wangliupu@loongson.cn \
    --cc=yangtiezhu@loongson.cn \
    --cc=zhangtianyang@loongson.cn \
    /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;
as well as URLs for NNTP newsgroup(s).