From: Grant Grundler <iod00d@hp.com>
To: Jesse Barnes <jbarnes@engr.sgi.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org, tony.luck@intel.com,
linux-ia64@vger.kernel.org
Subject: Re: [PATCH] I/O space write barrier
Date: Fri, 22 Oct 2004 01:01:50 +0000 [thread overview]
Message-ID: <20041022010150.GH3878@cup.hp.com> (raw)
In-Reply-To: <200410211613.19601.jbarnes@engr.sgi.com>
On Thu, Oct 21, 2004 at 04:13:19PM -0700, Jesse Barnes wrote:
> This patch adds a mmiowb() call to deal with this sort of situation, and
> adds some documentation describing I/O ordering issues to deviceiobook.tmpl.
Jesse,
This looks overall pretty good. Just a few nits.
> The idea is to mirror the regular, cacheable memory barrier operation, wmb.
> Example of the problem this new macro solves:
>
> CPU A: spin_lock_irqsave(&dev_lock, flags)
> CPU A: ...
> CPU A: writel(newval, ring_ptr);
> CPU A: spin_unlock_irqrestore(&dev_lock, flags)
> ...
> CPU B: spin_lock_irqsave(&dev_lock, flags)
> CPU B: writel(newval2, ring_ptr);
> CPU B: ...
> CPU B: spin_unlock_irqrestore(&dev_lock, flags)
>
> In this case, newval2 could be written to ring_ptr before newval. Fixing it
> is easy though:
>
> CPU A: spin_lock_irqsave(&dev_lock, flags)
> CPU A: ...
> CPU A: writel(newval, ring_ptr);
> CPU A: mmiowb(); /* ensure no other writes beat us to the device */
> CPU A: spin_unlock_irqrestore(&dev_lock, flags)
> ...
> CPU B: spin_lock_irqsave(&dev_lock, flags)
> CPU B: writel(newval2, ring_ptr);
> CPU B: ...
> CPU B: mmiowb();
> CPU B: spin_unlock_irqrestore(&dev_lock, flags)
This is a great example and should be used instead of the qla1280 code
snippet that you used. Please just point at the source file that contains
the code and name the register usage this example represents.
Ie make it easy to find the example in real code without using
line numbers.
> I've tried to describe how mmiowb() differs from PCI posted
> write flushing in the patch to deviceiobook.tmpl.
Yes - I think this is alot clearer than the previous documents - thanks!
...
> +<programlisting>
> + sp->flags |= SRB_SENT;
> + ha->actthreads++;
> + WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index);
> +
> + /*
> + * A Memory Mapped I/O Write Barrier is needed to ensure that this write
> + * of the request queue in register is ordered ahead of writes issued
> + * after this one by other CPUs. Access to the register is protected
> + * by the host_lock. Without the mmiowb, however, it is possible for
> + * this CPU to release the host lock, another CPU acquire the host lock,
> + * and write to the request queue in, and have the second write make it
> + * to the chip first.
> + */
> + mmiowb(); /* posted write ordering */
> +</programlisting>
This is the example code I'd like to see replaced with your
synthetic example above.
thanks,
grant
WARNING: multiple messages have this Message-ID (diff)
From: Grant Grundler <iod00d@hp.com>
To: Jesse Barnes <jbarnes@engr.sgi.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org, tony.luck@intel.com,
linux-ia64@vger.kernel.org
Subject: Re: [PATCH] I/O space write barrier
Date: Thu, 21 Oct 2004 18:01:50 -0700 [thread overview]
Message-ID: <20041022010150.GH3878@cup.hp.com> (raw)
In-Reply-To: <200410211613.19601.jbarnes@engr.sgi.com>
On Thu, Oct 21, 2004 at 04:13:19PM -0700, Jesse Barnes wrote:
> This patch adds a mmiowb() call to deal with this sort of situation, and
> adds some documentation describing I/O ordering issues to deviceiobook.tmpl.
Jesse,
This looks overall pretty good. Just a few nits.
> The idea is to mirror the regular, cacheable memory barrier operation, wmb.
> Example of the problem this new macro solves:
>
> CPU A: spin_lock_irqsave(&dev_lock, flags)
> CPU A: ...
> CPU A: writel(newval, ring_ptr);
> CPU A: spin_unlock_irqrestore(&dev_lock, flags)
> ...
> CPU B: spin_lock_irqsave(&dev_lock, flags)
> CPU B: writel(newval2, ring_ptr);
> CPU B: ...
> CPU B: spin_unlock_irqrestore(&dev_lock, flags)
>
> In this case, newval2 could be written to ring_ptr before newval. Fixing it
> is easy though:
>
> CPU A: spin_lock_irqsave(&dev_lock, flags)
> CPU A: ...
> CPU A: writel(newval, ring_ptr);
> CPU A: mmiowb(); /* ensure no other writes beat us to the device */
> CPU A: spin_unlock_irqrestore(&dev_lock, flags)
> ...
> CPU B: spin_lock_irqsave(&dev_lock, flags)
> CPU B: writel(newval2, ring_ptr);
> CPU B: ...
> CPU B: mmiowb();
> CPU B: spin_unlock_irqrestore(&dev_lock, flags)
This is a great example and should be used instead of the qla1280 code
snippet that you used. Please just point at the source file that contains
the code and name the register usage this example represents.
Ie make it easy to find the example in real code without using
line numbers.
> I've tried to describe how mmiowb() differs from PCI posted
> write flushing in the patch to deviceiobook.tmpl.
Yes - I think this is alot clearer than the previous documents - thanks!
...
> +<programlisting>
> + sp->flags |= SRB_SENT;
> + ha->actthreads++;
> + WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index);
> +
> + /*
> + * A Memory Mapped I/O Write Barrier is needed to ensure that this write
> + * of the request queue in register is ordered ahead of writes issued
> + * after this one by other CPUs. Access to the register is protected
> + * by the host_lock. Without the mmiowb, however, it is possible for
> + * this CPU to release the host lock, another CPU acquire the host lock,
> + * and write to the request queue in, and have the second write make it
> + * to the chip first.
> + */
> + mmiowb(); /* posted write ordering */
> +</programlisting>
This is the example code I'd like to see replaced with your
synthetic example above.
thanks,
grant
next prev parent reply other threads:[~2004-10-22 1:01 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-21 23:13 [PATCH] I/O space write barrier Jesse Barnes
2004-10-21 23:13 ` Jesse Barnes
2004-10-21 23:17 ` [PATCH] use mmiowb in qla1280.c Jesse Barnes
2004-10-22 9:53 ` Jes Sorensen
2004-10-24 16:20 ` James Bottomley
2004-10-25 16:18 ` Jesse Barnes
2004-10-25 19:02 ` Andrew Morton
2004-10-25 19:33 ` Jesse Barnes
2004-10-21 23:28 ` [PATCH] use mmiowb in tg3.c Jesse Barnes
2004-10-21 23:40 ` David S. Miller
2004-10-22 1:16 ` Benjamin Herrenschmidt
2004-10-22 1:33 ` akepner
2004-10-22 2:07 ` Benjamin Herrenschmidt
2004-10-22 3:01 ` Jesse Barnes
2004-10-22 4:00 ` Paul Mackerras
2004-10-22 20:51 ` [PATCH] use mmiowb in tg3_poll akepner
2005-05-28 23:12 ` Lennert Buytenhek
2005-05-30 16:30 ` Arthur Kepner
2005-05-31 12:53 ` jamal
2005-05-31 16:45 ` Jesse Barnes
2004-10-22 1:01 ` Grant Grundler [this message]
2004-10-22 1:01 ` [PATCH] I/O space write barrier Grant Grundler
2004-10-22 3:05 ` Jesse Barnes
2004-10-22 3:05 ` Jesse Barnes
2004-10-22 4:26 ` Greg Banks
2004-10-22 4:26 ` Greg Banks
2004-10-22 15:26 ` Grant Grundler
2004-10-22 15:26 ` Grant Grundler
-- strict thread matches above, loose matches on Subject: below --
2004-10-05 22:38 Jesse Barnes
2004-10-04 20:39 Albert Cahalan
2004-10-04 21:20 ` Jesse Barnes
2004-10-05 0:32 ` Albert Cahalan
2004-10-05 1:22 ` Benjamin Herrenschmidt
2004-10-05 2:26 ` Jesse Barnes
2004-10-05 3:04 ` Benjamin Herrenschmidt
2004-10-05 15:33 ` Jesse Barnes
2004-10-05 22:41 ` Benjamin Herrenschmidt
2004-10-05 23:09 ` Jesse Barnes
2004-10-05 23:57 ` Roland Dreier
2004-10-06 1:45 ` Benjamin Herrenschmidt
2004-10-05 2:33 ` Jesse Barnes
2004-09-27 18:03 Jesse Barnes
2004-09-29 10:36 ` Greg Banks
2004-09-29 20:35 ` David S. Miller
2004-09-29 20:43 ` Jesse Barnes
2004-09-29 20:50 ` David S. Miller
2004-09-30 2:23 ` Greg Banks
2004-09-29 22:55 ` Jesse Barnes
2004-09-30 7:15 ` Jeremy Higdon
2004-09-30 21:21 ` Guennadi Liakhovetski
2004-10-16 0:38 ` Jeremy Higdon
2004-10-16 3:20 ` Matthew Wilcox
2004-10-16 3:31 ` Jeremy Higdon
2004-09-23 18:48 Jesse Barnes
2004-09-23 19:03 ` James Bottomley
2004-09-23 19:07 ` Jesse Barnes
2004-09-23 19:27 ` James Bottomley
2004-09-23 19:41 ` Jesse Barnes
2004-09-23 19:57 ` Jeremy Higdon
2004-09-23 22:22 ` Jeremy Higdon
2004-09-23 23:36 ` James Bottomley
2004-09-24 5:03 ` Jeremy Higdon
2004-09-23 19:55 ` Jeremy Higdon
2004-09-23 20:09 ` Jesse Barnes
2004-09-27 0:45 ` Benjamin Herrenschmidt
2004-09-27 15:41 ` Jesse Barnes
2004-09-22 15:45 Jesse Barnes
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=20041022010150.GH3878@cup.hp.com \
--to=iod00d@hp.com \
--cc=akpm@osdl.org \
--cc=jbarnes@engr.sgi.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.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 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.