All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
To: "Niklas Söderlund"
	<niklas.soderlund+renesas-1zkq55x86MTxsAP9Fp7wbw@public.gmane.org>
Cc: hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	arnd-r2nGTMty4D4@public.gmane.org,
	vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org,
	linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCHv9 6/6] dmaengine: rcar-dmac: add iommu support for slave transfers
Date: Mon, 02 Jan 2017 01:08:04 +0200	[thread overview]
Message-ID: <26490346.qhNpbOL6eO@avalon> (raw)
In-Reply-To: <6358234.jyTvyVnNF0@avalon>

Hi Niklas,

On Monday 05 Sep 2016 12:52:44 Laurent Pinchart wrote:
> On Wednesday 10 Aug 2016 13:22:19 Niklas Söderlund wrote:
> > Enable slave transfers to a device behind a IPMMU by mapping the slave
> > addresses using the dma-mapping API.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > drivers/dma/sh/rcar-dmac.c | 82 ++++++++++++++++++++++++++++++++++++-----
> > 1 file changed, 74 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> > index cf983a9..22a5e40 100644
> > --- a/drivers/dma/sh/rcar-dmac.c
> > +++ b/drivers/dma/sh/rcar-dmac.c

[snip]

> > +static int rcar_dmac_map_slave_addr(struct dma_chan *chan,
> > +				    enum dma_transfer_direction dir)
> > +{
> > +	struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
> > +	struct rcar_dmac_chan_map *map = &rchan->map;
> > +	phys_addr_t dev_addr;
> > +	size_t dev_size;
> > +	enum dma_data_direction dev_dir;
> > +
> > +	if (dir == DMA_DEV_TO_MEM) {
> > +		dev_addr = rchan->src.slave_addr;
> > +		dev_size = rchan->src.xfer_size;
> > +		dev_dir = DMA_TO_DEVICE;
> 
> Shouldn't this be DMA_FROM_DEVICE, and DMA_TO_DEVICE below ?

This comment can be ignored (thank you Robin for the explanation), but ...

> > +	} else {
> > +		dev_addr = rchan->dst.slave_addr;
> > +		dev_size = rchan->dst.xfer_size;
> > +		dev_dir = DMA_FROM_DEVICE;
> > +	}
> > +
> > +	/* Reuse current map if possible. */
> > +	if (dev_addr == map->slave.slave_addr &&
> > +	    dev_size == map->slave.xfer_size &&
> > +	    dev_dir == map->dir)
> > +		return 0;
> > +
> > +	/* Remove old mapping if present. */
> > +	if (map->slave.xfer_size)
> > +		dma_unmap_resource(chan->device->dev, map->addr,
> > +				   map->slave.xfer_size, map->dir, 0);
> 
> Unless I'm mistaken the resource will not be unmapped when freeing channel
> resources, will it ?

I believe this one still needs to be addressed.

> > +	map->slave.xfer_size = 0;
> > +
> > +	/* Create new slave address map. */
> > +	map->addr = dma_map_resource(chan->device->dev, dev_addr, dev_size,
> > +				     dev_dir, 0);
> > +
> > +	if (dma_mapping_error(chan->device->dev, map->addr)) {
> > +		dev_err(chan->device->dev,
> > +			"chan%u: failed to map %zx@%pap", rchan->index,
> > +			dev_size, &dev_addr);
> > +		return -EIO;
> > +	}
> > +
> > +	dev_dbg(chan->device->dev, "chan%u: map %zx@%pap to %pad dir: %s\n",
> > +		rchan->index, dev_size, &dev_addr, &map->addr,
> 
> > +		dev_dir == DMA_TO_DEVICE ? "DMA_TO_DEVICE" :
> "DMA_FROM_DEVICE");
> 
> > +
> > +	map->slave.slave_addr = dev_addr;
> > +	map->slave.xfer_size = dev_size;
> > +	map->dir = dev_dir;
> > +
> > +	return 0;
> > +}

[snip]

-- 
Regards,

Laurent Pinchart

WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: linux-renesas-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org,
	iommu@lists.linux-foundation.org, linux@armlinux.org.uk,
	hch@infradead.org, dan.j.williams@intel.com,
	vinod.koul@intel.com, robin.murphy@arm.com,
	linus.walleij@linaro.org, arnd@arndb.de
Subject: Re: [PATCHv9 6/6] dmaengine: rcar-dmac: add iommu support for slave transfers
Date: Mon, 02 Jan 2017 01:08:04 +0200	[thread overview]
Message-ID: <26490346.qhNpbOL6eO@avalon> (raw)
In-Reply-To: <6358234.jyTvyVnNF0@avalon>

Hi Niklas,

On Monday 05 Sep 2016 12:52:44 Laurent Pinchart wrote:
> On Wednesday 10 Aug 2016 13:22:19 Niklas Söderlund wrote:
> > Enable slave transfers to a device behind a IPMMU by mapping the slave
> > addresses using the dma-mapping API.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > drivers/dma/sh/rcar-dmac.c | 82 ++++++++++++++++++++++++++++++++++++-----
> > 1 file changed, 74 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> > index cf983a9..22a5e40 100644
> > --- a/drivers/dma/sh/rcar-dmac.c
> > +++ b/drivers/dma/sh/rcar-dmac.c

[snip]

> > +static int rcar_dmac_map_slave_addr(struct dma_chan *chan,
> > +				    enum dma_transfer_direction dir)
> > +{
> > +	struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
> > +	struct rcar_dmac_chan_map *map = &rchan->map;
> > +	phys_addr_t dev_addr;
> > +	size_t dev_size;
> > +	enum dma_data_direction dev_dir;
> > +
> > +	if (dir == DMA_DEV_TO_MEM) {
> > +		dev_addr = rchan->src.slave_addr;
> > +		dev_size = rchan->src.xfer_size;
> > +		dev_dir = DMA_TO_DEVICE;
> 
> Shouldn't this be DMA_FROM_DEVICE, and DMA_TO_DEVICE below ?

This comment can be ignored (thank you Robin for the explanation), but ...

> > +	} else {
> > +		dev_addr = rchan->dst.slave_addr;
> > +		dev_size = rchan->dst.xfer_size;
> > +		dev_dir = DMA_FROM_DEVICE;
> > +	}
> > +
> > +	/* Reuse current map if possible. */
> > +	if (dev_addr == map->slave.slave_addr &&
> > +	    dev_size == map->slave.xfer_size &&
> > +	    dev_dir == map->dir)
> > +		return 0;
> > +
> > +	/* Remove old mapping if present. */
> > +	if (map->slave.xfer_size)
> > +		dma_unmap_resource(chan->device->dev, map->addr,
> > +				   map->slave.xfer_size, map->dir, 0);
> 
> Unless I'm mistaken the resource will not be unmapped when freeing channel
> resources, will it ?

I believe this one still needs to be addressed.

> > +	map->slave.xfer_size = 0;
> > +
> > +	/* Create new slave address map. */
> > +	map->addr = dma_map_resource(chan->device->dev, dev_addr, dev_size,
> > +				     dev_dir, 0);
> > +
> > +	if (dma_mapping_error(chan->device->dev, map->addr)) {
> > +		dev_err(chan->device->dev,
> > +			"chan%u: failed to map %zx@%pap", rchan->index,
> > +			dev_size, &dev_addr);
> > +		return -EIO;
> > +	}
> > +
> > +	dev_dbg(chan->device->dev, "chan%u: map %zx@%pap to %pad dir: %s\n",
> > +		rchan->index, dev_size, &dev_addr, &map->addr,
> 
> > +		dev_dir == DMA_TO_DEVICE ? "DMA_TO_DEVICE" :
> "DMA_FROM_DEVICE");
> 
> > +
> > +	map->slave.slave_addr = dev_addr;
> > +	map->slave.xfer_size = dev_size;
> > +	map->dir = dev_dir;
> > +
> > +	return 0;
> > +}

[snip]

-- 
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: [PATCHv9 6/6] dmaengine: rcar-dmac: add iommu support for slave transfers
Date: Mon, 02 Jan 2017 01:08:04 +0200	[thread overview]
Message-ID: <26490346.qhNpbOL6eO@avalon> (raw)
In-Reply-To: <6358234.jyTvyVnNF0@avalon>

Hi Niklas,

On Monday 05 Sep 2016 12:52:44 Laurent Pinchart wrote:
> On Wednesday 10 Aug 2016 13:22:19 Niklas S?derlund wrote:
> > Enable slave transfers to a device behind a IPMMU by mapping the slave
> > addresses using the dma-mapping API.
> > 
> > Signed-off-by: Niklas S?derlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > drivers/dma/sh/rcar-dmac.c | 82 ++++++++++++++++++++++++++++++++++++-----
> > 1 file changed, 74 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> > index cf983a9..22a5e40 100644
> > --- a/drivers/dma/sh/rcar-dmac.c
> > +++ b/drivers/dma/sh/rcar-dmac.c

[snip]

> > +static int rcar_dmac_map_slave_addr(struct dma_chan *chan,
> > +				    enum dma_transfer_direction dir)
> > +{
> > +	struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
> > +	struct rcar_dmac_chan_map *map = &rchan->map;
> > +	phys_addr_t dev_addr;
> > +	size_t dev_size;
> > +	enum dma_data_direction dev_dir;
> > +
> > +	if (dir == DMA_DEV_TO_MEM) {
> > +		dev_addr = rchan->src.slave_addr;
> > +		dev_size = rchan->src.xfer_size;
> > +		dev_dir = DMA_TO_DEVICE;
> 
> Shouldn't this be DMA_FROM_DEVICE, and DMA_TO_DEVICE below ?

This comment can be ignored (thank you Robin for the explanation), but ...

> > +	} else {
> > +		dev_addr = rchan->dst.slave_addr;
> > +		dev_size = rchan->dst.xfer_size;
> > +		dev_dir = DMA_FROM_DEVICE;
> > +	}
> > +
> > +	/* Reuse current map if possible. */
> > +	if (dev_addr == map->slave.slave_addr &&
> > +	    dev_size == map->slave.xfer_size &&
> > +	    dev_dir == map->dir)
> > +		return 0;
> > +
> > +	/* Remove old mapping if present. */
> > +	if (map->slave.xfer_size)
> > +		dma_unmap_resource(chan->device->dev, map->addr,
> > +				   map->slave.xfer_size, map->dir, 0);
> 
> Unless I'm mistaken the resource will not be unmapped when freeing channel
> resources, will it ?

I believe this one still needs to be addressed.

> > +	map->slave.xfer_size = 0;
> > +
> > +	/* Create new slave address map. */
> > +	map->addr = dma_map_resource(chan->device->dev, dev_addr, dev_size,
> > +				     dev_dir, 0);
> > +
> > +	if (dma_mapping_error(chan->device->dev, map->addr)) {
> > +		dev_err(chan->device->dev,
> > +			"chan%u: failed to map %zx@%pap", rchan->index,
> > +			dev_size, &dev_addr);
> > +		return -EIO;
> > +	}
> > +
> > +	dev_dbg(chan->device->dev, "chan%u: map %zx@%pap to %pad dir: %s\n",
> > +		rchan->index, dev_size, &dev_addr, &map->addr,
> 
> > +		dev_dir == DMA_TO_DEVICE ? "DMA_TO_DEVICE" :
> "DMA_FROM_DEVICE");
> 
> > +
> > +	map->slave.slave_addr = dev_addr;
> > +	map->slave.xfer_size = dev_size;
> > +	map->dir = dev_dir;
> > +
> > +	return 0;
> > +}

[snip]

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2017-01-01 23:08 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10 11:22 [PATCHv9 0/6] dmaengine: rcar-dmac: add iommu support for slave transfers Niklas Söderlund
2016-08-10 11:22 ` Niklas Söderlund
2016-08-10 11:22 ` Niklas Söderlund
2016-08-10 11:22 ` [PATCHv9 1/6] dma-mapping: add {map,unmap}_resource to dma_map_ops Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22 ` [PATCHv9 2/6] dma-debug: add support for resource mappings Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-09-05  9:39   ` Laurent Pinchart
2016-09-05  9:39     ` Laurent Pinchart
2016-08-10 11:22 ` [PATCHv9 3/6] dma-mapping: add dma_{map,unmap}_resource Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
     [not found]   ` <20160810112219.17964-4-niklas.soderlund+renesas-1zkq55x86MTxsAP9Fp7wbw@public.gmane.org>
2016-09-05  9:46     ` Laurent Pinchart
2016-09-05  9:46       ` Laurent Pinchart
2016-09-05  9:46       ` Laurent Pinchart
2016-08-10 11:22 ` [PATCHv9 4/6] arm: dma-mapping: add {map, unmap}_resource for iommu ops Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22   ` [PATCHv9 4/6] arm: dma-mapping: add {map,unmap}_resource " Niklas Söderlund
     [not found]   ` <20160810112219.17964-5-niklas.soderlund+renesas-1zkq55x86MTxsAP9Fp7wbw@public.gmane.org>
2016-08-23 15:31     ` Niklas Söderlund
2016-08-23 15:31       ` Niklas Söderlund
2016-08-23 15:31       ` Niklas Söderlund
2016-09-05  9:54       ` Laurent Pinchart
2016-09-05  9:54         ` [PATCHv9 4/6] arm: dma-mapping: add {map, unmap}_resource " Laurent Pinchart
2016-08-10 11:22 ` [PATCHv9 5/6] dmaengine: rcar-dmac: group slave configuration Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22 ` [PATCHv9 6/6] dmaengine: rcar-dmac: add iommu support for slave transfers Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-08-10 11:22   ` Niklas Söderlund
2016-09-05  9:52   ` Laurent Pinchart
2016-09-05  9:52     ` Laurent Pinchart
2016-09-05 10:37     ` Robin Murphy
2016-09-05 10:37       ` Robin Murphy
2016-09-05 10:37       ` Robin Murphy
2017-01-01 23:08     ` Laurent Pinchart [this message]
2017-01-01 23:08       ` Laurent Pinchart
2017-01-01 23:08       ` Laurent Pinchart
2017-01-09 15:42       ` Niklas Söderlund
2017-01-09 15:42         ` Niklas Söderlund
2017-01-09 15:42         ` Niklas Söderlund
     [not found] ` <20160810112219.17964-1-niklas.soderlund+renesas-1zkq55x86MTxsAP9Fp7wbw@public.gmane.org>
2016-08-10 17:37   ` [PATCHv9 0/6] " Vinod Koul
2016-08-10 17:37     ` Vinod Koul
2016-08-10 17:37     ` Vinod Koul
2016-09-15 16:26     ` Vinod Koul
2016-09-15 16:26       ` Vinod Koul
2016-09-15 16:26       ` Vinod Koul
2016-09-16  9:07       ` Arnd Bergmann
2016-09-16  9:07         ` Arnd Bergmann
2016-09-16  9:07         ` Arnd Bergmann
2016-09-16  9:48         ` Laurent Pinchart
2016-09-16  9:48           ` Laurent Pinchart
2016-09-16 10:36           ` Robin Murphy
2016-09-16 10:36             ` Robin Murphy
2016-09-16 10:36             ` Robin Murphy
2016-09-16 12:05             ` Laurent Pinchart
2016-09-16 12:05               ` Laurent Pinchart
2016-09-16 12:49               ` Robin Murphy
2016-09-16 12:49                 ` Robin Murphy
2016-09-16 12:49                 ` Robin Murphy
     [not found]                 ` <cea119f1-18d5-675d-ee33-c22b0c8e7693-5wv7dgnIgG8@public.gmane.org>
2016-09-16 13:01                   ` Laurent Pinchart
2016-09-16 13:01                     ` Laurent Pinchart
2016-09-16 13:01                     ` Laurent Pinchart
2016-09-16 12:02           ` Arnd Bergmann
2016-09-16 12:02             ` Arnd Bergmann
2016-09-16 12:02             ` Arnd Bergmann
2016-09-16 12:09             ` Laurent Pinchart
2016-09-16 12:09               ` Laurent Pinchart
2016-09-16 12:22               ` Arnd Bergmann
2016-09-16 12:22                 ` Arnd Bergmann
2016-09-16 12:58                 ` Laurent Pinchart
2016-09-16 12:58                   ` Laurent Pinchart
2016-09-23  7:25       ` Niklas Söderlund
2016-09-23  7:25         ` Niklas Söderlund
2016-09-23  7:25         ` Niklas Söderlund
2016-08-29 13:11   ` Haggai Eran
2016-09-26 16:47 ` Vinod Koul
2016-09-26 16:47   ` Vinod Koul
2016-09-26 16:47   ` Vinod Koul

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=26490346.qhNpbOL6eO@avalon \
    --to=laurent.pinchart-rylnwiuwjnjg/c1bvhzhaw@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=niklas.soderlund+renesas-1zkq55x86MTxsAP9Fp7wbw@public.gmane.org \
    --cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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.