lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 21 Dec 2007 09:00:27 +0900
From:	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
To:	rusty@...tcorp.com.au
Cc:	davem@...emloft.net, fujita.tomonori@....ntt.co.jp,
	linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
	jens.axboe@...cle.com
Subject: Re: [PATCH 2/5] dma_map_sg_ring() helper

On Fri, 21 Dec 2007 09:58:56 +1100
Rusty Russell <rusty@...tcorp.com.au> wrote:

> On Thursday 20 December 2007 18:42:44 David Miller wrote:
> > From: FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
> > Date: Thu, 20 Dec 2007 16:06:31 +0900
> >
> > > On Thu, 20 Dec 2007 16:49:30 +1100
> > >
> > > Rusty Russell <rusty@...tcorp.com.au> wrote:
> > > > +/**
> > > > + * dma_map_sg_ring - Map an entire sg ring
> > > > + * @dev: Device to free noncoherent memory for
> > > > + * @sg: The sg_ring
> > > > + * @direction: DMA_TO_DEVICE, DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.
> > > > + *
> > > > + * This returns -ENOMEM if mapping fails.  It's not clear that telling
> > > > you + * it failed is useful though.
> > > > + */
> > > > +int dma_map_sg_ring(struct device *dev, struct sg_ring *sg,
> > > > +		     enum dma_data_direction direction)
> > > > +{
> > > > +	struct sg_ring *i;
> > > > +	unsigned int num;
> > > > +
> > > > +	for (i = sg; i; i = sg_ring_next(i, sg)) {
> > > > +		BUG_ON(i->num > i->max);
> > > > +		num = dma_map_sg(dev, i->sg, i->num, direction);
> > > > +		if (num == 0 && i->num != 0)
> > > > +			goto unmap;
> > > > +	}
> > > > +	return 0;
> > >
> > > I don't think that this works for IOMMUs that could merge sg entries.
> >
> > Right, it won't work at all.
> >
> > The caller has to be told how many DMA entries it really did use to
> > compose the mapping, and there has to be a way to properly iterate
> > over them.  The assumption that the IOMMU will map the SG entries
> > 1-to-1 is invalid.
> 
> Good catch.  Indeed, what's missing is one line:
> 
> 	i->num = num;
> 
> Of course, an arch-specific version of this could merge between sg_rings,
> too, but that's an optimization.

We need to pass the whole sg entries to the IOMMUs at a time.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ