mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To: dan.j.williams@intel.com
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org,
	linux-kernel@vger.kernel.org, haavard.skinnemoen@atmel.com
Subject: Re: [PATCH 1/2] dmaengine: TXx9 Soc DMA Controller driver
Date: Fri, 13 Mar 2009 23:16:59 +0900 (JST)	[thread overview]
Message-ID: <20090313.231659.41197617.anemo@mba.ocn.ne.jp> (raw)
In-Reply-To: <20090313.011950.61509382.anemo@mba.ocn.ne.jp>

On Fri, 13 Mar 2009 01:19:50 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> Subject: dmaengine: Use chan_id provided by DMA device driver
> From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> 
> If chan_id was already given by the DMA device driver, use it.
> Otherwise assign an incremental number for each channels.
> 
> This allows the DMA device driver to reserve some channel ID numbers.
...
> @@ -663,7 +664,9 @@ int dma_async_device_register(struct dma_device *device)
>  			continue;
>  		}
>  
> -		chan->chan_id = chancnt++;
> +		if (!chan->chan_id)
> +			chan->chan_id = chan_id++;
> +		chancnt++;
>  		chan->dev->device.class = &dma_devclass;
>  		chan->dev->device.parent = device->dev;
>  		chan->dev->chan = chan;

This patch will fix another potential problem.  Some driver, for
example ipu, assumes chan_id is an index of its internal array.  But
dmaengine core does not guarantee it.

	/* represent channels in sysfs. Probably want devs too */
	list_for_each_entry(chan, &device->channels, device_node) {
		chan->local = alloc_percpu(typeof(*chan->local));
		if (chan->local == NULL)
			continue;
		chan->dev = kzalloc(sizeof(*chan->dev), GFP_KERNEL);
		if (chan->dev == NULL) {
			free_percpu(chan->local);
			continue;
		}

		chan->chan_id = chancnt++;
		...
	}
	device->chancnt = chancnt;

If alloc_percpu or kzalloc failed, chan_id does not match with its
position in device->channels list.


And above "continue" looks buggy anyway.  Keeping incomplete channels
in device->channels list looks very dangerous...

---
Atsushi Nemoto

  reply	other threads:[~2009-03-13 14:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-13 15:28 Atsushi Nemoto
2009-02-26  1:45 ` Dan Williams
2009-02-26 15:24   ` Atsushi Nemoto
2009-03-12 16:19     ` Atsushi Nemoto
2009-03-13 14:16       ` Atsushi Nemoto [this message]
2009-03-16 21:50         ` Dan Williams
2009-03-17  2:20           ` Atsushi Nemoto
2009-03-17  4:52             ` Dan Williams
2009-03-17 16:09               ` Atsushi Nemoto
2009-03-17 17:02                 ` Dan Williams
2009-03-18  0:49                   ` Atsushi Nemoto
2009-03-18  1:23                     ` Dan Williams
2009-03-18  2:01                       ` Atsushi Nemoto
2009-03-18 17:26                         ` Dan Williams
2009-03-21 12:29                           ` Atsushi Nemoto
2009-03-26 14:12                             ` Atsushi Nemoto
2009-03-31 19:34                               ` Dan Williams
2009-04-01 16:20                                 ` Atsushi Nemoto
2009-03-16 21:20     ` Dan Williams
2009-03-17  1:52       ` Atsushi Nemoto

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=20090313.231659.41197617.anemo@mba.ocn.ne.jp \
    --to=anemo@mba.ocn.ne.jp \
    --cc=dan.j.williams@intel.com \
    --cc=haavard.skinnemoen@atmel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®