All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sowmini Varadhan <sowmini.varadhan@oracle.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: aik@au1.ibm.com, anton@au1.ibm.com, paulus@samba.org,
	sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	davem@davemloft.net
Subject: Re: [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock
Date: Thu, 2 Apr 2015 17:43:43 -0400	[thread overview]
Message-ID: <20150402214343.GA15680@oracle.com> (raw)
In-Reply-To: <1428008044.20500.272.camel@kernel.crashing.org>

On (04/03/15 07:54), Benjamin Herrenschmidt wrote:
> > +	limit = pool->end;
> > +
> > +	/* The case below can happen if we have a small segment appended
> > +	 * to a large, or when the previous alloc was at the very end of
> > +	 * the available space. If so, go back to the beginning and flush.
> > +	 */
> > +	if (start >= limit) {
> > +		start = pool->start;
> > +		if (!large_pool && iommu->lazy_flush != NULL)
> > +			iommu->lazy_flush(iommu);
> 
> Add need_flush = false;

A few clarifications, while I parse the rest of your comments:

Not sure I follow- need_flush is initialized to true at the start of the function?

> I only just noticed too, you completely dropped the code to honor
> the dma mask. Why that ? Some devices rely on this.

so that's an interesting question: the existing iommu_range_alloc() in
arch/sparc/kernel/iommu.c does not use the mask at all. I based most of
the code  on this (except for the lock fragmentation part). 
I dont know if this is arch specific.

> 
> > +	if (dev)
> > +		boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
> > +				      1 << iommu->table_shift);
> > +	else
> > +		boundary_size = ALIGN(1UL << 32, 1 << iommu->table_shift);
> > +
> > +	shift = iommu->table_map_base >> iommu->table_shift;
> > +	boundary_size = boundary_size >> iommu->table_shift;
> > +	/*
> > +	 * if the skip_span_boundary_check had been set during init, we set
> > +	 * things up so that iommu_is_span_boundary() merely checks if the
> > +	 * (index + npages) < num_tsb_entries
> > +	 */
> > +	if ((iommu->flags & IOMMU_NO_SPAN_BOUND) != 0) {
> > +		shift = 0;
> > +		boundary_size = iommu->poolsize * iommu->nr_pools;
> > +	}
> > +	n = iommu_area_alloc(iommu->map, limit, start, npages, shift,
> > +			     boundary_size, 0);
> 
> You have completely dropped the alignment support. This will break
> drivers. There are cases (especially with consistent allocations) where

Again, not sure I follow? are you referring to the IOMMU_NO_SPAN_BOUND case?
That's very specific to LDC (sparc ldoms virtualization infra). The default
is to not have IOMMU_NO_SPAN_BOUND set. 
For the rest of the drivers, the code that sets up boundary_size aligns things
in the same way as the ppc code.


> the driver have alignment constraints on the address, those must be
> preserved.
> 

--Sowmini

WARNING: multiple messages have this Message-ID (diff)
From: Sowmini Varadhan <sowmini.varadhan@oracle.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: aik@au1.ibm.com, anton@au1.ibm.com, paulus@samba.org,
	sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	davem@davemloft.net
Subject: Re: [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l
Date: Thu, 02 Apr 2015 21:43:43 +0000	[thread overview]
Message-ID: <20150402214343.GA15680@oracle.com> (raw)
In-Reply-To: <1428008044.20500.272.camel@kernel.crashing.org>

On (04/03/15 07:54), Benjamin Herrenschmidt wrote:
> > +	limit = pool->end;
> > +
> > +	/* The case below can happen if we have a small segment appended
> > +	 * to a large, or when the previous alloc was at the very end of
> > +	 * the available space. If so, go back to the beginning and flush.
> > +	 */
> > +	if (start >= limit) {
> > +		start = pool->start;
> > +		if (!large_pool && iommu->lazy_flush != NULL)
> > +			iommu->lazy_flush(iommu);
> 
> Add need_flush = false;

A few clarifications, while I parse the rest of your comments:

Not sure I follow- need_flush is initialized to true at the start of the function?

> I only just noticed too, you completely dropped the code to honor
> the dma mask. Why that ? Some devices rely on this.

so that's an interesting question: the existing iommu_range_alloc() in
arch/sparc/kernel/iommu.c does not use the mask at all. I based most of
the code  on this (except for the lock fragmentation part). 
I dont know if this is arch specific.

> 
> > +	if (dev)
> > +		boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
> > +				      1 << iommu->table_shift);
> > +	else
> > +		boundary_size = ALIGN(1UL << 32, 1 << iommu->table_shift);
> > +
> > +	shift = iommu->table_map_base >> iommu->table_shift;
> > +	boundary_size = boundary_size >> iommu->table_shift;
> > +	/*
> > +	 * if the skip_span_boundary_check had been set during init, we set
> > +	 * things up so that iommu_is_span_boundary() merely checks if the
> > +	 * (index + npages) < num_tsb_entries
> > +	 */
> > +	if ((iommu->flags & IOMMU_NO_SPAN_BOUND) != 0) {
> > +		shift = 0;
> > +		boundary_size = iommu->poolsize * iommu->nr_pools;
> > +	}
> > +	n = iommu_area_alloc(iommu->map, limit, start, npages, shift,
> > +			     boundary_size, 0);
> 
> You have completely dropped the alignment support. This will break
> drivers. There are cases (especially with consistent allocations) where

Again, not sure I follow? are you referring to the IOMMU_NO_SPAN_BOUND case?
That's very specific to LDC (sparc ldoms virtualization infra). The default
is to not have IOMMU_NO_SPAN_BOUND set. 
For the rest of the drivers, the code that sets up boundary_size aligns things
in the same way as the ppc code.


> the driver have alignment constraints on the address, those must be
> preserved.
> 

--Sowmini

  reply	other threads:[~2015-04-02 21:43 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 14:40 [PATCH v8 RFC 0/3] Generic IOMMU pooled allocator Sowmini Varadhan
2015-03-31 14:40 ` Sowmini Varadhan
2015-03-31 14:40 ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Sowmini Varadhan
2015-03-31 14:40   ` Sowmini Varadhan
2015-03-31 15:15   ` David Laight
2015-03-31 15:15     ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l David Laight
2015-03-31 15:25     ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Sowmini Varadhan
2015-03-31 15:25       ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Sowmini Varadhan
2015-04-02 20:54   ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-02 20:54     ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-04-02 21:43     ` Sowmini Varadhan [this message]
2015-04-02 21:43       ` Sowmini Varadhan
2015-04-02 21:57       ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-02 21:57         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-04-02 22:01         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-02 22:01           ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-04-02 22:02           ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-02 22:02             ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-04-02 22:15         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Sowmini Varadhan
2015-04-02 22:15           ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Sowmini Varadhan
2015-04-02 22:19           ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-02 22:19             ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-04-02 21:54     ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Sowmini Varadhan
2015-04-02 21:54       ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Sowmini Varadhan
2015-04-02 22:08       ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-02 22:08         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-04-03  0:42       ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock David Miller
2015-04-03  0:42         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l David Miller
2015-04-03 18:28     ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Sowmini Varadhan
2015-04-03 18:28       ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Sowmini Varadhan
2015-04-03 21:06       ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-03 21:06         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-04-03 21:51         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Sowmini Varadhan
2015-04-03 21:51           ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Sowmini Varadhan
2015-04-04 11:27         ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Sowmini Varadhan
2015-04-04 11:27           ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Sowmini Varadhan
2015-04-04 13:33           ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and lock Benjamin Herrenschmidt
2015-04-04 13:33             ` [PATCH v8 RFC 1/3] sparc: Break up monolithic iommu table/lock into finer graularity pools and l Benjamin Herrenschmidt
2015-03-31 14:40 ` [PATCH v8 RFC 2/3] sparc: Make sparc64 use scalable lib/iommu-common.c functions Sowmini Varadhan
2015-03-31 14:40   ` Sowmini Varadhan
2015-03-31 14:40 ` [PATCH v8 RFC 3/3] sparc: Make LDC use common iommu poll management functions Sowmini Varadhan
2015-03-31 14:40   ` Sowmini Varadhan
2015-03-31 18:06 ` [PATCH v8 RFC 0/3] Generic IOMMU pooled allocator Sowmini Varadhan
2015-03-31 18:06   ` Sowmini Varadhan
2015-03-31 18:08   ` David Miller
2015-03-31 18:08     ` David Miller
2015-04-01  1:01   ` Benjamin Herrenschmidt
2015-04-01  1:01     ` Benjamin Herrenschmidt
2015-04-01  1:08     ` Sowmini Varadhan
2015-04-01  1:08       ` Sowmini Varadhan
2015-04-01  3:12       ` David Miller
2015-04-01  3:12         ` David Miller
2015-04-02 12:51         ` Sowmini Varadhan
2015-04-02 12:51           ` Sowmini Varadhan
2015-04-02 16:21           ` David Miller
2015-04-02 16:21             ` David Miller
2015-04-02 20:22             ` Benjamin Herrenschmidt
2015-04-02 20:22               ` Benjamin Herrenschmidt
2015-04-02 20:52               ` Benjamin Herrenschmidt
2015-04-02 20:52                 ` Benjamin Herrenschmidt

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=20150402214343.GA15680@oracle.com \
    --to=sowmini.varadhan@oracle.com \
    --cc=aik@au1.ibm.com \
    --cc=anton@au1.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=sparclinux@vger.kernel.org \
    /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.