All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 1/2] omap3: iovmm: Work around sg_alloc_table size limitation in IOMMU
Date: Mon, 6 Jun 2011 18:54:10 +0200	[thread overview]
Message-ID: <201106061854.10450.laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20110606164400.GA9456@n2100.arm.linux.org.uk>

Hi Russell,

On Monday 06 June 2011 18:44:00 Russell King - ARM Linux wrote:
> On Mon, Jun 06, 2011 at 06:23:18PM +0200, Laurent Pinchart wrote:
> > Hi Russell,
> > 
> > On Friday 03 June 2011 08:32:12 Russell King - ARM Linux wrote:
> > > SG chaining has _nothing_ to do with hardware.  It's all to do with
> > > software and hitting the SG table limit.
> > 
> > What's the reason for limiting the SG table size to one page then ?
> 
> As I say, it's got nothing to do with them ending up being passed to
> hardware.  Take a look at their definition:
> 
> struct scatterlist {
> #ifdef CONFIG_DEBUG_SG
>         unsigned long   sg_magic;
> #endif
>         unsigned long   page_link;
>         unsigned int    offset;
>         unsigned int    length;
>         dma_addr_t      dma_address;
> #ifdef CONFIG_NEED_SG_DMA_LENGTH
>         unsigned int    dma_length;
> #endif
> };
> 
> That clearly isn't hardware specific - hardware won't cope with
> CONFIG_DEBUG_SG being enabled or disabled, or whether the architecture
> supports the dma_length field, or that this structure has developed from
> being:
> 
> 	void *addr;
> 	unsigend int length;
> 	unsigned long dma_address;
> 
> to the above over the evolution of the kernel.  Or that we use the bottom
> two bits of page_link as our own flag bits?
> 
> So no, this struct goes nowhere near hardware of any kind.  It's merely
> used as a container to pass a list of scatter-gather locations in memory
> internally around within the kernel, especially to dma_map_sg()/
> dma_unmap_sg().
> 
> If you look at IDE or ATA code, or even SCSI code, you'll find the same
> pattern.  They're passed a scatterlist.  They map it for dma using
> dma_map_sg().  They then walk the scatterlist and extract the dma
> address and length using sg_dma_address() and sg_dma_length() and create
> the _hardware_ table from that information - and the hardware table very
> much depends on the hardware itself.  Once DMA is complete, they unmap
> the DMA region using dma_unmap_sg().
> 
> One very good reason that its limited to one page is because allocations
> larger than one page are prone to failure.  Would you want your company
> server failing to read/write data to its storage just because it couldn't
> get a contiguous 8K page for a 5K long scatterlist?  I think if Linux
> did that, it wouldn't have a future in the enterprise marketplace.

Of course not, but if the scatterlist is only touched by kernel code, it 
doesn't need to be contiguous in memory. It could be allocated with vmalloc().

-- 
Regards,

Laurent Pinchart

WARNING: multiple messages have this Message-ID (diff)
From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/2] omap3: iovmm: Work around sg_alloc_table size limitation in IOMMU
Date: Mon, 6 Jun 2011 18:54:10 +0200	[thread overview]
Message-ID: <201106061854.10450.laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20110606164400.GA9456@n2100.arm.linux.org.uk>

Hi Russell,

On Monday 06 June 2011 18:44:00 Russell King - ARM Linux wrote:
> On Mon, Jun 06, 2011 at 06:23:18PM +0200, Laurent Pinchart wrote:
> > Hi Russell,
> > 
> > On Friday 03 June 2011 08:32:12 Russell King - ARM Linux wrote:
> > > SG chaining has _nothing_ to do with hardware.  It's all to do with
> > > software and hitting the SG table limit.
> > 
> > What's the reason for limiting the SG table size to one page then ?
> 
> As I say, it's got nothing to do with them ending up being passed to
> hardware.  Take a look at their definition:
> 
> struct scatterlist {
> #ifdef CONFIG_DEBUG_SG
>         unsigned long   sg_magic;
> #endif
>         unsigned long   page_link;
>         unsigned int    offset;
>         unsigned int    length;
>         dma_addr_t      dma_address;
> #ifdef CONFIG_NEED_SG_DMA_LENGTH
>         unsigned int    dma_length;
> #endif
> };
> 
> That clearly isn't hardware specific - hardware won't cope with
> CONFIG_DEBUG_SG being enabled or disabled, or whether the architecture
> supports the dma_length field, or that this structure has developed from
> being:
> 
> 	void *addr;
> 	unsigend int length;
> 	unsigned long dma_address;
> 
> to the above over the evolution of the kernel.  Or that we use the bottom
> two bits of page_link as our own flag bits?
> 
> So no, this struct goes nowhere near hardware of any kind.  It's merely
> used as a container to pass a list of scatter-gather locations in memory
> internally around within the kernel, especially to dma_map_sg()/
> dma_unmap_sg().
> 
> If you look at IDE or ATA code, or even SCSI code, you'll find the same
> pattern.  They're passed a scatterlist.  They map it for dma using
> dma_map_sg().  They then walk the scatterlist and extract the dma
> address and length using sg_dma_address() and sg_dma_length() and create
> the _hardware_ table from that information - and the hardware table very
> much depends on the hardware itself.  Once DMA is complete, they unmap
> the DMA region using dma_unmap_sg().
> 
> One very good reason that its limited to one page is because allocations
> larger than one page are prone to failure.  Would you want your company
> server failing to read/write data to its storage just because it couldn't
> get a contiguous 8K page for a 5K long scatterlist?  I think if Linux
> did that, it wouldn't have a future in the enterprise marketplace.

Of course not, but if the scatterlist is only touched by kernel code, it 
doesn't need to be contiguous in memory. It could be allocated with vmalloc().

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2011-06-06 16:53 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-30 12:47 [PATCH 0/2] OMAP3 IOMMU fixes Laurent Pinchart
2011-05-30 12:47 ` [PATCH 1/2] omap3: iovmm: Work around sg_alloc_table size limitation in IOMMU Laurent Pinchart
2011-05-31 13:22   ` Tony Lindgren
2011-06-01 12:25     ` [PATCH v2 " Laurent Pinchart
2011-06-01 13:11       ` Tony Lindgren
2011-06-01 12:25     ` [PATCH v2 2/2] omap3: iovmm: Support non page-aligned buffers in iommu_vmap Laurent Pinchart
2011-06-01 12:50       ` Tony Lindgren
2011-06-01 13:09         ` Laurent Pinchart
2011-06-01 13:10           ` Tony Lindgren
2011-06-01 13:17             ` Tony Lindgren
2011-06-01 13:30               ` [PATCH v3 1/2] omap3: iovmm: Work around sg_alloc_table size limitation in IOMMU Laurent Pinchart
2011-06-01 13:30                 ` Laurent Pinchart
2011-06-01 13:43                 ` Russell King - ARM Linux
2011-06-01 13:43                   ` Russell King - ARM Linux
2011-06-01 13:50                   ` Laurent Pinchart
2011-06-01 13:50                     ` Laurent Pinchart
2011-06-01 14:03                     ` Russell King - ARM Linux
2011-06-01 14:03                       ` Russell King - ARM Linux
2011-06-03  0:12                       ` Laurent Pinchart
2011-06-03  0:12                         ` Laurent Pinchart
2011-06-03  6:32                         ` Russell King - ARM Linux
2011-06-03  6:32                           ` Russell King - ARM Linux
2011-06-06 16:23                           ` Laurent Pinchart
2011-06-06 16:23                             ` Laurent Pinchart
2011-06-06 16:44                             ` Russell King - ARM Linux
2011-06-06 16:44                               ` Russell King - ARM Linux
2011-06-06 16:54                               ` Laurent Pinchart [this message]
2011-06-06 16:54                                 ` Laurent Pinchart
2011-06-06 18:00                                 ` Russell King - ARM Linux
2011-06-06 18:00                                   ` Russell King - ARM Linux
2011-06-08 10:33                                   ` Laurent Pinchart
2011-06-08 10:33                                     ` Laurent Pinchart
2011-06-03  9:39                         ` Felipe Contreras
2011-06-03  9:39                           ` Felipe Contreras
2011-06-01 13:30               ` [PATCH v3 2/2] omap3: iovmm: Support non page-aligned buffers in iommu_vmap Laurent Pinchart
2011-06-01 13:30                 ` Laurent Pinchart
2011-05-30 12:47 ` [PATCH " Laurent Pinchart
2011-05-30 13:16 ` [PATCH 0/2] OMAP3 IOMMU fixes Hiroshi DOYU
2011-06-08 10:48 ` Laurent Pinchart
2011-06-13 13:40   ` Tony Lindgren
2011-06-13 16:41     ` Laurent Pinchart
2011-06-13 19:34       ` Ohad Ben-Cohen

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=201106061854.10450.laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /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.