[PATCH] lib/genalloc: change return type to unsigned long for bitmap_set_ll

2021-01-04 Thread Huang Shijie
Just as bitmap_clear_ll(), change return type to unsigned long
for bitmap_set_ll to avoid the possible overflow in future.

Signed-off-by: Huang Shijie 
---
 This patch is not a bug fix.
 I missed to change it in previous patch.

---
 lib/genalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index dab97bb69df6..5dcf9cdcbc46 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -81,7 +81,8 @@ static int clear_bits_ll(unsigned long *addr, unsigned long 
mask_to_clear)
  * users set the same bit, one user will return remain bits, otherwise
  * return 0.
  */
-static int bitmap_set_ll(unsigned long *map, unsigned long start, unsigned 
long nr)
+static unsigned long
+bitmap_set_ll(unsigned long *map, unsigned long start, unsigned long nr)
 {
unsigned long *p = map + BIT_WORD(start);
const unsigned long size = start + nr;
-- 
2.17.1



[PATCH] sizes.h: Add SZ_8G/SZ_16G/SZ_32G macros

2020-12-28 Thread Huang Shijie
Add these macros, since we can use them in drivers.

Signed-off-by: Huang Shijie 
---
 include/linux/sizes.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/sizes.h b/include/linux/sizes.h
index 9874f6f67537..1ac79bcee2bb 100644
--- a/include/linux/sizes.h
+++ b/include/linux/sizes.h
@@ -44,6 +44,9 @@
 #define SZ_2G  0x8000
 
 #define SZ_4G  _AC(0x1, ULL)
+#define SZ_8G  _AC(0x2, ULL)
+#define SZ_16G _AC(0x4, ULL)
+#define SZ_32G _AC(0x8, ULL)
 #define SZ_64T _AC(0x4000, ULL)
 
 #endif /* __LINUX_SIZES_H__ */
-- 
2.17.1



[PATCH] lib/genalloc: fix the overflow when size is too big

2020-12-28 Thread Huang Shijie
Some graphic card has very big memory on chip, such as 32G bytes.

In the following case, it will cause overflow:
  
  pool = gen_pool_create(PAGE_SHIFT, NUMA_NO_NODE);
  ret = gen_pool_add(pool, 0x100, SZ_32G, NUMA_NO_NODE);

  va = gen_pool_alloc(pool, SZ_4G);
  

The overflow occurs in gen_pool_alloc_algo_owner():

  

size = nbits << order;

  

The @nbits is "int" type, so it will overflow.
Then the gen_pool_avail() will return the wrong value.

This patch converts some "int" to "unsigned long", and
changes the compare code in while.

Reported-by: Shi Jiasheng 
Signed-off-by: Huang Shijie 
---
 lib/genalloc.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 7f1244b5294a..dab97bb69df6 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -81,14 +81,14 @@ static int clear_bits_ll(unsigned long *addr, unsigned long 
mask_to_clear)
  * users set the same bit, one user will return remain bits, otherwise
  * return 0.
  */
-static int bitmap_set_ll(unsigned long *map, int start, int nr)
+static int bitmap_set_ll(unsigned long *map, unsigned long start, unsigned 
long nr)
 {
unsigned long *p = map + BIT_WORD(start);
-   const int size = start + nr;
+   const unsigned long size = start + nr;
int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
 
-   while (nr - bits_to_set >= 0) {
+   while (nr >= bits_to_set) {
if (set_bits_ll(p, mask_to_set))
return nr;
nr -= bits_to_set;
@@ -116,14 +116,15 @@ static int bitmap_set_ll(unsigned long *map, int start, 
int nr)
  * users clear the same bit, one user will return remain bits,
  * otherwise return 0.
  */
-static int bitmap_clear_ll(unsigned long *map, int start, int nr)
+static unsigned long
+bitmap_clear_ll(unsigned long *map, unsigned long start, unsigned long nr)
 {
unsigned long *p = map + BIT_WORD(start);
-   const int size = start + nr;
+   const unsigned long size = start + nr;
int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
 
-   while (nr - bits_to_clear >= 0) {
+   while (nr >= bits_to_clear) {
if (clear_bits_ll(p, mask_to_clear))
return nr;
nr -= bits_to_clear;
@@ -183,8 +184,8 @@ int gen_pool_add_owner(struct gen_pool *pool, unsigned long 
virt, phys_addr_t ph
 size_t size, int nid, void *owner)
 {
struct gen_pool_chunk *chunk;
-   int nbits = size >> pool->min_alloc_order;
-   int nbytes = sizeof(struct gen_pool_chunk) +
+   unsigned long nbits = size >> pool->min_alloc_order;
+   unsigned long nbytes = sizeof(struct gen_pool_chunk) +
BITS_TO_LONGS(nbits) * sizeof(long);
 
chunk = vzalloc_node(nbytes, nid);
@@ -242,7 +243,7 @@ void gen_pool_destroy(struct gen_pool *pool)
struct list_head *_chunk, *_next_chunk;
struct gen_pool_chunk *chunk;
int order = pool->min_alloc_order;
-   int bit, end_bit;
+   unsigned long bit, end_bit;
 
list_for_each_safe(_chunk, _next_chunk, >chunks) {
chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
@@ -278,7 +279,7 @@ unsigned long gen_pool_alloc_algo_owner(struct gen_pool 
*pool, size_t size,
struct gen_pool_chunk *chunk;
unsigned long addr = 0;
int order = pool->min_alloc_order;
-   int nbits, start_bit, end_bit, remain;
+   unsigned long nbits, start_bit, end_bit, remain;
 
 #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
BUG_ON(in_nmi());
@@ -487,7 +488,7 @@ void gen_pool_free_owner(struct gen_pool *pool, unsigned 
long addr, size_t size,
 {
struct gen_pool_chunk *chunk;
int order = pool->min_alloc_order;
-   int start_bit, nbits, remain;
+   unsigned long start_bit, nbits, remain;
 
 #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
BUG_ON(in_nmi());
@@ -755,7 +756,7 @@ unsigned long gen_pool_best_fit(unsigned long *map, 
unsigned long size,
index = bitmap_find_next_zero_area(map, size, start, nr, 0);
 
while (index < size) {
-   int next_bit = find_next_bit(map, size, index + nr);
+   unsigned long next_bit = find_next_bit(map, size, index + nr);
if ((next_bit - index) < len) {
len = next_bit - index;
start_bit = index;
-- 
2.17.1



[PATCH] lockdep: fix the typo

2020-11-15 Thread Huang Shijie
Fix the 'signle' to 'single".

Signed-off-by: Huang Shijie 
---
 include/linux/lockdep_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/lockdep_types.h b/include/linux/lockdep_types.h
index 9a1fd49df17f..1989017d663f 100644
--- a/include/linux/lockdep_types.h
+++ b/include/linux/lockdep_types.h
@@ -46,7 +46,7 @@ enum lockdep_wait_type {
  * NR_LOCKDEP_CACHING_CLASSES ... Number of classes
  * cached in the instance of lockdep_map
  *
- * Currently main class (subclass == 0) and signle depth subclass
+ * Currently main class (subclass == 0) and single depth subclass
  * are cached in lockdep_map. This optimization is mainly targeting
  * on rq->lock. double_rq_lock() acquires this highly competitive with
  * single depth.
-- 
2.17.1



[tip: locking/urgent] Documentation/locking/locktypes: Fix a typo

2020-08-13 Thread tip-bot2 for Huang Shijie
The following commit has been merged into the locking/urgent branch of tip:

Commit-ID: cb75c95c5262328bd4da3dd334f6826a3a34a979
Gitweb:
https://git.kernel.org/tip/cb75c95c5262328bd4da3dd334f6826a3a34a979
Author:Huang Shijie 
AuthorDate:Thu, 13 Aug 2020 14:02:20 +08:00
Committer: Ingo Molnar 
CommitterDate: Thu, 13 Aug 2020 20:59:06 +02:00

Documentation/locking/locktypes: Fix a typo

We have three categories locks, not two.

Signed-off-by: Huang Shijie 
Signed-off-by: Ingo Molnar 
Acked-by: Will Deacon 
Link: https://lore.kernel.org/r/20200813060220.18199-1-sjhu...@iluvatar.ai
---
 Documentation/locking/locktypes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/locking/locktypes.rst 
b/Documentation/locking/locktypes.rst
index 1b577a8..4cefed8 100644
--- a/Documentation/locking/locktypes.rst
+++ b/Documentation/locking/locktypes.rst
@@ -10,7 +10,7 @@ Introduction
 
 
 The kernel provides a variety of locking primitives which can be divided
-into two categories:
+into three categories:
 
  - Sleeping locks
  - CPU local locks


[PATCH] Documentation/locking/locktypes: fix the typo

2020-08-13 Thread Huang Shijie
We have three categories locks, not two.

Signed-off-by: Huang Shijie 
---
 Documentation/locking/locktypes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/locking/locktypes.rst 
b/Documentation/locking/locktypes.rst
index 1b577a8bf982..4cefed8048ca 100644
--- a/Documentation/locking/locktypes.rst
+++ b/Documentation/locking/locktypes.rst
@@ -10,7 +10,7 @@ Introduction
 
 
 The kernel provides a variety of locking primitives which can be divided
-into two categories:
+into three categories:
 
  - Sleeping locks
  - CPU local locks
-- 
2.17.1



Re: [PATCH 1/2] mm/gup.c: fix the wrong comments

2019-04-09 Thread Huang Shijie
On Tue, Apr 09, 2019 at 02:55:31PM +, Weiny, Ira wrote:
> > On Tue, Apr 09, 2019 at 11:04:18AM +0800, Huang Shijie wrote:
> > > On Mon, Apr 08, 2019 at 07:49:29PM -0700, Matthew Wilcox wrote:
> > > > On Tue, Apr 09, 2019 at 09:08:33AM +0800, Huang Shijie wrote:
> > > > > On Mon, Apr 08, 2019 at 07:13:13AM -0700, Matthew Wilcox wrote:
> > > > > > On Mon, Apr 08, 2019 at 10:37:45AM +0800, Huang Shijie wrote:
> > > > > > > The root cause is that sg_alloc_table_from_pages() requires
> > > > > > > the page order to keep the same as it used in the user space,
> > > > > > > but
> > > > > > > get_user_pages_fast() will mess it up.
> > > > > >
> > > > > > I don't understand how get_user_pages_fast() can return the
> > > > > > pages in a different order in the array from the order they appear 
> > > > > > in
> > userspace.
> > > > > > Can you explain?
> > > > > Please see the code in gup.c:
> > > > >
> > > > >   int get_user_pages_fast(unsigned long start, int nr_pages,
> > > > >   unsigned int gup_flags, struct page 
> > > > > **pages)
> > > > >   {
> > > > >   ...
> > > > >   if (gup_fast_permitted(start, nr_pages)) {
> > > > >   local_irq_disable();
> > > > >   gup_pgd_range(addr, end, gup_flags, pages, );
> > // The @pages array maybe filled at the first time.
> > > >
> > > > Right ... but if it's not filled entirely, it will be filled
> > > > part-way, and then we stop.
> > > >
> > > > >   local_irq_enable();
> > > > >   ret = nr;
> > > > >   }
> > > > >   ...
> > > > >   if (nr < nr_pages) {
> > > > >   /* Try to get the remaining pages with
> > get_user_pages */
> > > > >   start += nr << PAGE_SHIFT;
> > > > >   pages += nr;
> > > > >   // The
> > @pages is moved forward.
> > > >
> > > > Yes, to the point where gup_pgd_range() stopped.
> > > >
> > > > >   if (gup_flags & FOLL_LONGTERM) {
> > > > >   down_read(>mm->mmap_sem);
> > > > >   ret = __gup_longterm_locked(current,
> > current->mm,  // The @pages maybe filled at the second time
> > > >
> > > > Right.
> > > >
> > > > >   /*
> > > > >* retain FAULT_FOLL_ALLOW_RETRY
> > optimization if
> > > > >* possible
> > > > >*/
> > > > >   ret = get_user_pages_unlocked(start,
> > nr_pages - nr,// The @pages maybe filled at the second time.
> > > > > pages, 
> > > > > gup_flags);
> > > >
> > > > Yes.  But they'll be in the same order.
> > > >
> > > > > BTW, I do not know why we mess up the page order. It maybe used in
> > some special case.
> > > >
> > > > I'm not discounting the possibility that you've found a bug.
> > > > But documenting that a bug exists is not the solution; the solution
> > > > is fixing the bug.
> > > I do not think it is a bug :)
> > >
> > > If we use the get_user_pages_unlocked(), DMA is okay, such as:
> > >  
> > >get_user_pages_unlocked()
> > >sg_alloc_table_from_pages()
> > >.
> > >
> > > I think the comment is not accurate enough. So just add more comments,
> > > and tell the driver users how to use the GUPs.
> > 
> > gup_fast() and gup_unlocked() should return the pages in the same order.
> > If they do not, then it is a bug.
> 
> Is there a reproducer for this?  Or do you have some debug output which shows 
> this problem?
Is Matthew right?

 " gup_fast() and gup_unlocked() should return the pages in the same order.
 If they do not, then it is a bug."

If Matthew is right,
I need more time to debug the DMA issue...


Thanks
Huang Shijie
 

> 
> Ira
> 


Re: [PATCH 1/2] mm/gup.c: fix the wrong comments

2019-04-09 Thread Huang Shijie
On Tue, Apr 09, 2019 at 01:23:16PM -0700, Ira Weiny wrote:
> On Tue, Apr 09, 2019 at 09:08:33AM +0800, Huang Shijie wrote:
> > On Mon, Apr 08, 2019 at 07:13:13AM -0700, Matthew Wilcox wrote:
> > > On Mon, Apr 08, 2019 at 10:37:45AM +0800, Huang Shijie wrote:
> > > > When CONFIG_HAVE_GENERIC_GUP is defined, the kernel will use its own
> > > > get_user_pages_fast().
> > > > 
> > > > In the following scenario, we will may meet the bug in the DMA case:
> > > > .
> > > > get_user_pages_fast(start,,, pages);
> > > > ..
> > > > sg_alloc_table_from_pages(, pages, ...);
> > > > .
> > > > 
> > > > The root cause is that sg_alloc_table_from_pages() requires the
> > > > page order to keep the same as it used in the user space, but
> > > > get_user_pages_fast() will mess it up.
> > > 
> > > I don't understand how get_user_pages_fast() can return the pages in a
> > > different order in the array from the order they appear in userspace.
> > > Can you explain?
> > Please see the code in gup.c:
> > 
> > int get_user_pages_fast(unsigned long start, int nr_pages,
> > unsigned int gup_flags, struct page **pages)
> > {
> > ...
> > if (gup_fast_permitted(start, nr_pages)) {
> > local_irq_disable();
> > gup_pgd_range(addr, end, gup_flags, pages, );
> >// The @pages array maybe filled at the first time.
> > local_irq_enable();
> > ret = nr;
> > }
> > ...
> > if (nr < nr_pages) {
> > /* Try to get the remaining pages with get_user_pages */
> > start += nr << PAGE_SHIFT;
> > pages += nr;
> >   // The @pages is moved forward.
> > 
> > if (gup_flags & FOLL_LONGTERM) {
> > down_read(>mm->mmap_sem);
> > ret = __gup_longterm_locked(current, 
> > current->mm,  // The @pages maybe filled at the second time
> >
> 
> Neither this nor the get_user_pages_unlocked is filling the pages a second
The get_user_pages_unlocked() will call the handle_mm_fault which will allocate 
a
new page for the empty PTE, and save the new page into the @pages array.


> time.  It is adding to the page array having moved start and the page array
> forward.

Yes. This will mess up the page order.

I will read the code again to check if I am wrong :)

> 
> Are you doing a FOLL_LONGTERM GUP?  Or are you in the else clause below when
> you get this bug?
I do not use FOLL_LONGTERM, I just use the FOLL_WRITE.

So it seems it runs into the else clause below.

Thanks
Huang Shijie

> 
> Ira
> 
> > start, nr_pages - 
> > nr,
> > pages, NULL, 
> > gup_flags);
> > up_read(>mm->mmap_sem);
> > } else {
> > /*
> >  * retain FAULT_FOLL_ALLOW_RETRY optimization if
> >  * possible
> >  */
> > ret = get_user_pages_unlocked(start, nr_pages - 
> > nr,// The @pages maybe filled at the second time.
> >   pages, gup_flags);
> > }
> > }
> > 
> > 


Re: [PATCH 1/2] mm/gup.c: fix the wrong comments

2019-04-08 Thread Huang Shijie
On Mon, Apr 08, 2019 at 07:49:29PM -0700, Matthew Wilcox wrote:
> On Tue, Apr 09, 2019 at 09:08:33AM +0800, Huang Shijie wrote:
> > On Mon, Apr 08, 2019 at 07:13:13AM -0700, Matthew Wilcox wrote:
> > > On Mon, Apr 08, 2019 at 10:37:45AM +0800, Huang Shijie wrote:
> > > > The root cause is that sg_alloc_table_from_pages() requires the
> > > > page order to keep the same as it used in the user space, but
> > > > get_user_pages_fast() will mess it up.
> > > 
> > > I don't understand how get_user_pages_fast() can return the pages in a
> > > different order in the array from the order they appear in userspace.
> > > Can you explain?
> > Please see the code in gup.c:
> > 
> > int get_user_pages_fast(unsigned long start, int nr_pages,
> > unsigned int gup_flags, struct page **pages)
> > {
> > ...
> > if (gup_fast_permitted(start, nr_pages)) {
> > local_irq_disable();
> > gup_pgd_range(addr, end, gup_flags, pages, );
> >// The @pages array maybe filled at the first time.
> 
> Right ... but if it's not filled entirely, it will be filled part-way,
> and then we stop.
> 
> > local_irq_enable();
> > ret = nr;
> > }
> > ...
> > if (nr < nr_pages) {
> > /* Try to get the remaining pages with get_user_pages */
> > start += nr << PAGE_SHIFT;
> > pages += nr;
> >   // The @pages is moved forward.
> 
> Yes, to the point where gup_pgd_range() stopped.
> 
> > if (gup_flags & FOLL_LONGTERM) {
> > down_read(>mm->mmap_sem);
> > ret = __gup_longterm_locked(current, 
> > current->mm,  // The @pages maybe filled at the second time
> 
> Right.
> 
> > /*
> >  * retain FAULT_FOLL_ALLOW_RETRY optimization if
> >  * possible
> >  */
> > ret = get_user_pages_unlocked(start, nr_pages - 
> > nr,// The @pages maybe filled at the second time.
> >   pages, gup_flags);
> 
> Yes.  But they'll be in the same order.
> 
> > BTW, I do not know why we mess up the page order. It maybe used in some 
> > special case.
> 
> I'm not discounting the possibility that you've found a bug.
> But documenting that a bug exists is not the solution; the solution is
> fixing the bug.
I do not think it is a bug :)

If we use the get_user_pages_unlocked(), DMA is okay, such as:
 
 get_user_pages_unlocked()
 sg_alloc_table_from_pages()
 .

I think the comment is not accurate enough. So just add more comments, and tell 
the driver
users how to use the GUPs.

Thanks
Huang Shijie


Re: [PATCH 1/2] mm/gup.c: fix the wrong comments

2019-04-08 Thread Huang Shijie
On Mon, Apr 08, 2019 at 07:13:13AM -0700, Matthew Wilcox wrote:
> On Mon, Apr 08, 2019 at 10:37:45AM +0800, Huang Shijie wrote:
> > When CONFIG_HAVE_GENERIC_GUP is defined, the kernel will use its own
> > get_user_pages_fast().
> > 
> > In the following scenario, we will may meet the bug in the DMA case:
> > .
> > get_user_pages_fast(start,,, pages);
> > ..
> > sg_alloc_table_from_pages(, pages, ...);
> > .
> > 
> > The root cause is that sg_alloc_table_from_pages() requires the
> > page order to keep the same as it used in the user space, but
> > get_user_pages_fast() will mess it up.
> 
> I don't understand how get_user_pages_fast() can return the pages in a
> different order in the array from the order they appear in userspace.
> Can you explain?
Please see the code in gup.c:

int get_user_pages_fast(unsigned long start, int nr_pages,
unsigned int gup_flags, struct page **pages)
{
...
if (gup_fast_permitted(start, nr_pages)) {
local_irq_disable();
gup_pgd_range(addr, end, gup_flags, pages, );
   // The @pages array maybe filled at the first time.
local_irq_enable();
ret = nr;
}
...
if (nr < nr_pages) {
/* Try to get the remaining pages with get_user_pages */
start += nr << PAGE_SHIFT;
pages += nr;
  // The @pages is moved forward.

if (gup_flags & FOLL_LONGTERM) {
down_read(>mm->mmap_sem);
ret = __gup_longterm_locked(current, 
current->mm,  // The @pages maybe filled at the second time
start, nr_pages - 
nr,
pages, NULL, 
gup_flags);
up_read(>mm->mmap_sem);
} else {
/*
 * retain FAULT_FOLL_ALLOW_RETRY optimization if
 * possible
 */
ret = get_user_pages_unlocked(start, nr_pages - 
nr,// The @pages maybe filled at the second time.
  pages, gup_flags);
}
}


    .....

BTW, I do not know why we mess up the page order. It maybe used in some special 
case.

Thanks
Huang Shijie


[PATCH 2/2] lib/scatterlist.c: add more commit for sg_alloc_table_from_pages

2019-04-07 Thread Huang Shijie
The get_user_pages_fast() may mess up the page order in @pages array,
We will get the wrong DMA results in this case.

Add more commit to clarify it.

Signed-off-by: Huang Shijie 
---
 lib/scatterlist.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 739dc9fe2c55..c170afb1a25e 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -450,6 +450,9 @@ EXPORT_SYMBOL(__sg_alloc_table_from_pages);
  *specified by the page array. The returned sg table is released by
  *sg_free_table.
  *
+ * Note: Do not use get_user_pages_fast() to pin the pages for @pages array,
+ *   it may mess up the page order, and we will get the wrong DMA results.
+
  * Returns:
  *   0 on success, negative error on failure
  */
-- 
2.17.1



[PATCH 1/2] mm/gup.c: fix the wrong comments

2019-04-07 Thread Huang Shijie
When CONFIG_HAVE_GENERIC_GUP is defined, the kernel will use its own
get_user_pages_fast().

In the following scenario, we will may meet the bug in the DMA case:
.
get_user_pages_fast(start,,, pages);
..
sg_alloc_table_from_pages(, pages, ...);
.

The root cause is that sg_alloc_table_from_pages() requires the
page order to keep the same as it used in the user space, but
get_user_pages_fast() will mess it up.

So change the comments, and make it more clear for the driver
users.

Signed-off-by: Huang Shijie 
---
 mm/gup.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 22acdd0f79ff..fb11ff90ba3b 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1129,10 +1129,6 @@ EXPORT_SYMBOL(get_user_pages_locked);
  *  with:
  *
  *  get_user_pages_unlocked(tsk, mm, ..., pages);
- *
- * It is functionally equivalent to get_user_pages_fast so
- * get_user_pages_fast should be used instead if specific gup_flags
- * (e.g. FOLL_FORCE) are not required.
  */
 long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
 struct page **pages, unsigned int gup_flags)
@@ -2147,6 +2143,10 @@ int __get_user_pages_fast(unsigned long start, int 
nr_pages, int write,
  * If not successful, it will fall back to taking the lock and
  * calling get_user_pages().
  *
+ * Note this routine may fill the pages array with entries in a
+ * different order than get_user_pages_unlocked(), which may cause
+ * issues for callers expecting the routines to be equivalent.
+ *
  * Returns number of pages pinned. This may be fewer than the number
  * requested. If nr_pages is 0 or negative, returns 0. If no pages
  * were pinned, returns -errno.
-- 
2.17.1



Re: [PATCH] mm/gup.c: fix the wrong comments

2019-04-07 Thread Huang Shijie
On Thu, Apr 04, 2019 at 09:50:47AM -0700, Ira Weiny wrote:
> On Thu, Apr 04, 2019 at 03:23:47PM +0800, Huang Shijie wrote:
> > When CONFIG_HAVE_GENERIC_GUP is defined, the kernel will use its own
> > get_user_pages_fast().
> > 
> > In the following scenario, we will may meet the bug in the DMA case:
> > .
> > get_user_pages_fast(start,,, pages);
> > ..
> > sg_alloc_table_from_pages(, pages, ...);
> > .
> > 
> > The root cause is that sg_alloc_table_from_pages() requires the
> > page order to keep the same as it used in the user space, but
> > get_user_pages_fast() will mess it up.
> 
> I wonder if there is something we can do to change sg_alloc_table_from_pages()
> to work?  Reading the comment for it there is no indication of this 
> limitation.
The sg_alloc_table_from_pages() cannot work if the page order is wrong...

> So should we update that comment as well?
Okay.

I will create a DMA patch to add more comment for sg_alloc_table_from_pages().

Thanks
Huang Shijie


[PATCH] mm/gup.c: fix the wrong comments

2019-04-04 Thread Huang Shijie
When CONFIG_HAVE_GENERIC_GUP is defined, the kernel will use its own
get_user_pages_fast().

In the following scenario, we will may meet the bug in the DMA case:
.
get_user_pages_fast(start,,, pages);
..
sg_alloc_table_from_pages(, pages, ...);
.

The root cause is that sg_alloc_table_from_pages() requires the
page order to keep the same as it used in the user space, but
get_user_pages_fast() will mess it up.

So change the comments, and make it more clear for the driver
users.

Signed-off-by: Huang Shijie 
---
 mm/gup.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 22acdd0f79ff..b810d15d4db9 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1129,10 +1129,6 @@ EXPORT_SYMBOL(get_user_pages_locked);
  *  with:
  *
  *  get_user_pages_unlocked(tsk, mm, ..., pages);
- *
- * It is functionally equivalent to get_user_pages_fast so
- * get_user_pages_fast should be used instead if specific gup_flags
- * (e.g. FOLL_FORCE) are not required.
  */
 long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
 struct page **pages, unsigned int gup_flags)
@@ -2147,6 +2143,10 @@ int __get_user_pages_fast(unsigned long start, int 
nr_pages, int write,
  * If not successful, it will fall back to taking the lock and
  * calling get_user_pages().
  *
+ * This function is different from the get_user_pages_unlocked():
+ *  The @pages may has different page order with the result
+ *  got by get_user_pages_unlocked().
+ *
  * Returns number of pages pinned. This may be fewer than the number
  * requested. If nr_pages is 0 or negative, returns 0. If no pages
  * were pinned, returns -errno.
-- 
2.17.1



Re: [PATCH] trace/page_ref: print out the page migratetype name

2019-03-27 Thread Huang Shijie
On Wed, Mar 27, 2019 at 09:24:22AM -0400, Steven Rostedt wrote:
> On Wed, 27 Mar 2019 13:09:37 +0800
> Huang Shijie  wrote:
> 
> > Print out the page migratetype name which is more readable.
> 
> Except that it breaks perf and trace-cmd, as they wont know what a
> migratetype_names array contains.
> 
> See how writeback does it. Which would be something like this for you.
> 
> /* enums need to be exported to user space */
Thanks for pointing this...

I did not notice that it will breaks the perf and trace-cmd.

So please just ignore this patch.

Thanks
Huang Shijie


[PATCH] trace/page_ref: print out the page migratetype name

2019-03-26 Thread Huang Shijie
Print out the page migratetype name which is more readable.

Signed-off-by: Huang Shijie 
---
 include/trace/events/page_ref.h | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/trace/events/page_ref.h b/include/trace/events/page_ref.h
index 5d2ea93956ce..94df979c2d6b 100644
--- a/include/trace/events/page_ref.h
+++ b/include/trace/events/page_ref.h
@@ -36,11 +36,12 @@ DECLARE_EVENT_CLASS(page_ref_mod_template,
__entry->val = v;
),
 
-   TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%d 
val=%d",
+   TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%s 
val=%d",
__entry->pfn,
show_page_flags(__entry->flags & ((1UL << NR_PAGEFLAGS) - 1)),
__entry->count,
-   __entry->mapcount, __entry->mapping, __entry->mt,
+   __entry->mapcount, __entry->mapping,
+   migratetype_names[__entry->mt],
__entry->val)
 );
 
@@ -86,11 +87,12 @@ DECLARE_EVENT_CLASS(page_ref_mod_and_test_template,
__entry->ret = ret;
),
 
-   TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%d 
val=%d ret=%d",
+   TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%s 
val=%d ret=%d",
__entry->pfn,
show_page_flags(__entry->flags & ((1UL << NR_PAGEFLAGS) - 1)),
__entry->count,
-   __entry->mapcount, __entry->mapping, __entry->mt,
+   __entry->mapcount, __entry->mapping,
+   migratetype_names[__entry->mt],
__entry->val, __entry->ret)
 );
 
-- 
2.17.1



Re: [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool

2019-01-03 Thread Huang Shijie
On Wed, Jan 02, 2019 at 11:55:50PM -0800, Christoph Hellwig wrote:
> On Mon, Dec 24, 2018 at 03:06:22PM +0800, Huang Shijie wrote:
> > We may use the addr_in_gen_pool() in the driver module.
> > So export the addr_in_gen_pool for the compiling.
> 
> Please send this along with the driver that plans to use it.
The driver is still under develop with the FPGA, and our hardware chip maybe
tape out at next year.

Thanks
Huang Shijie




[PATCH] Documentation: rename addr_in_gen_pool to gen_pool_has_addr

2018-12-28 Thread Huang Shijie
Update the document, since we have renamed addr_in_gen_pool to
gen_pool_has_addr.

Signed-off-by: Huang Shijie 
---

Sorry, I missed to update this document...

---
 Documentation/core-api/genalloc.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/core-api/genalloc.rst 
b/Documentation/core-api/genalloc.rst
index 6b38a39fab24..a534cc7ebd05 100644
--- a/Documentation/core-api/genalloc.rst
+++ b/Documentation/core-api/genalloc.rst
@@ -129,7 +129,7 @@ writing of special-purpose memory allocators in the future.
:functions: gen_pool_for_each_chunk
 
 .. kernel-doc:: lib/genalloc.c
-   :functions: addr_in_gen_pool
+   :functions: gen_pool_has_addr
 
 .. kernel-doc:: lib/genalloc.c
:functions: gen_pool_avail
-- 
2.17.1



Re: [PATCH] lib/genalloc.c: rename addr_in_gen_pool to gen_pool_has_addr

2018-12-28 Thread Huang Shijie
On Fri, Dec 28, 2018 at 09:48:34AM +0100, Christoph Hellwig wrote:
> On Fri, Dec 28, 2018 at 04:39:50PM +0800, Huang Shijie wrote:
> > Follow the kernel conventions, rename addr_in_gen_pool to
> > gen_pool_has_addr.
> 
> Which convention?  The old name certainly looks more sensible to me.
I submitted a patch to export the symbol, addr_in_gen_pool.
But most the exported symbols are named like gen_pool_*.

What about I add a macro in the header genalloc.h, such as:

#define addr_in_gen_poolgen_pool_has_addr

> 
> If we really want to change anything about this function I'd suggest
> to drop the size argument, as the address itself should describe the
> region good enough.

Maybe others need the @size argument. I am not sure if it is right to remove
the size argument...

Thanks
Huang Shijie


[PATCH] lib/genalloc.c: rename addr_in_gen_pool to gen_pool_has_addr

2018-12-28 Thread Huang Shijie
Follow the kernel conventions, rename addr_in_gen_pool to
gen_pool_has_addr.

Signed-off-by: Huang Shijie 
---
 arch/arm/mm/dma-mapping.c | 2 +-
 drivers/misc/sram-exec.c  | 2 +-
 include/linux/genalloc.h  | 2 +-
 kernel/dma/remap.c| 2 +-
 lib/genalloc.c| 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index f1e2922e447c..a876101a0f82 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -563,7 +563,7 @@ static void *__alloc_from_pool(size_t size, struct page 
**ret_page)
 
 static bool __in_atomic_pool(void *start, size_t size)
 {
-   return addr_in_gen_pool(atomic_pool, (unsigned long)start, size);
+   return gen_pool_has_addr(atomic_pool, (unsigned long)start, size);
 }
 
 static int __free_from_pool(void *start, size_t size)
diff --git a/drivers/misc/sram-exec.c b/drivers/misc/sram-exec.c
index 426ad912b441..d054e2842a5f 100644
--- a/drivers/misc/sram-exec.c
+++ b/drivers/misc/sram-exec.c
@@ -96,7 +96,7 @@ void *sram_exec_copy(struct gen_pool *pool, void *dst, void 
*src,
if (!part)
return NULL;
 
-   if (!addr_in_gen_pool(pool, (unsigned long)dst, size))
+   if (!gen_pool_has_addr(pool, (unsigned long)dst, size))
return NULL;
 
base = (unsigned long)part->base;
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index dd0a452373e7..c5e5bed82fbc 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -156,7 +156,7 @@ extern struct gen_pool *devm_gen_pool_create(struct device 
*dev,
int min_alloc_order, int nid, const char *name);
 extern struct gen_pool *gen_pool_get(struct device *dev, const char *name);
 
-bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
+extern bool gen_pool_has_addr(struct gen_pool *pool, unsigned long start,
size_t size);
 
 #ifdef CONFIG_OF
diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c
index 18cc09fc27b9..5022b904d7bc 100644
--- a/kernel/dma/remap.c
+++ b/kernel/dma/remap.c
@@ -158,7 +158,7 @@ int __init dma_atomic_pool_init(gfp_t gfp, pgprot_t prot)
 
 bool dma_in_atomic_pool(void *start, size_t size)
 {
-   return addr_in_gen_pool(atomic_pool, (unsigned long)start, size);
+   return gen_pool_has_addr(atomic_pool, (unsigned long)start, size);
 }
 
 void *dma_alloc_from_pool(size_t size, struct page **ret_page, gfp_t flags)
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 96b6f478d275..946bbeefec81 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -423,7 +423,7 @@ void gen_pool_for_each_chunk(struct gen_pool *pool,
 EXPORT_SYMBOL(gen_pool_for_each_chunk);
 
 /**
- * addr_in_gen_pool - checks if an address falls within the range of a pool
+ * gen_pool_has_addr - checks if an address falls within the range of a pool
  * @pool:  the generic memory pool
  * @start: start address
  * @size:  size of the region
@@ -431,7 +431,7 @@ EXPORT_SYMBOL(gen_pool_for_each_chunk);
  * Check if the range of addresses falls within the specified pool. Returns
  * true if the entire range is contained in the pool and false otherwise.
  */
-bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
+bool gen_pool_has_addr(struct gen_pool *pool, unsigned long start,
size_t size)
 {
bool found = false;
@@ -450,7 +450,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned long 
start,
rcu_read_unlock();
return found;
 }
-EXPORT_SYMBOL(addr_in_gen_pool);
+EXPORT_SYMBOL(gen_pool_has_addr);
 
 /**
  * gen_pool_avail - get available free space of the pool
-- 
2.17.1



Re: [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool

2018-12-27 Thread Huang Shijie
On Thu, Dec 27, 2018 at 09:49:29PM -0800, Andrew Morton wrote:
> On Mon, 24 Dec 2018 15:06:22 +0800 Huang Shijie  wrote:
> 
> > We may use the addr_in_gen_pool() in the driver module.
> > So export the addr_in_gen_pool for the compiling.
> > 
> > ...
> >
> > --- a/lib/genalloc.c
> > +++ b/lib/genalloc.c
> > @@ -450,6 +450,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned 
> > long start,
> > rcu_read_unlock();
> > return found;
> >  }
> > +EXPORT_SYMBOL(addr_in_gen_pool);
> >  
> >  /**
> >   * gen_pool_avail - get available free space of the pool
> 
> OK, but...  The name is poor.
> 
> q:/usr/src/25> grep EXPORT_SYMBOL lib/genalloc.c
> EXPORT_SYMBOL(gen_pool_create);
> EXPORT_SYMBOL(gen_pool_add_virt);
> EXPORT_SYMBOL(gen_pool_virt_to_phys);
> EXPORT_SYMBOL(gen_pool_destroy);
> EXPORT_SYMBOL(gen_pool_alloc);
> EXPORT_SYMBOL(gen_pool_alloc_algo);
> EXPORT_SYMBOL(gen_pool_dma_alloc);
> EXPORT_SYMBOL(gen_pool_free);
> EXPORT_SYMBOL(gen_pool_for_each_chunk);
> EXPORT_SYMBOL_GPL(gen_pool_avail);
> EXPORT_SYMBOL_GPL(gen_pool_size);
> EXPORT_SYMBOL(gen_pool_set_algo);
> EXPORT_SYMBOL(gen_pool_first_fit);
> EXPORT_SYMBOL(gen_pool_first_fit_align);
> EXPORT_SYMBOL(gen_pool_fixed_alloc);
> EXPORT_SYMBOL(gen_pool_first_fit_order_align);
> EXPORT_SYMBOL(gen_pool_best_fit);
> EXPORT_SYMBOL_GPL(gen_pool_get);
> EXPORT_SYMBOL(devm_gen_pool_create);
> EXPORT_SYMBOL_GPL(of_gen_pool_get);
> 
> See?  Almost everything is called gen_pool_foo.  Which is correct as
> per kernel conventions.  We should globally rename this to
> gen_pool_has_addr or similar.
okay, I will do it right now..

Thanks
Huang Shijie


[PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap.

2018-12-24 Thread Huang Shijie
Some devices may have big memory on chip, such as over 1G.
In some cases, the nbytes maybe bigger then 4M which is the bounday of
the memory buddy system (4K default).

So use vzalloc_node() to allocate the bitmap.
Also use vfree to free the it.

Signed-off-by: Huang Shijie 
---
The v1 did not free the memory with vfree.
This patch fixes it.

---
 lib/genalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 5deb25c40a5a..f365d71cdc77 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -187,7 +187,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long 
virt, phys_addr_t phy
int nbytes = sizeof(struct gen_pool_chunk) +
BITS_TO_LONGS(nbits) * sizeof(long);
 
-   chunk = kzalloc_node(nbytes, GFP_KERNEL, nid);
+   chunk = vzalloc_node(nbytes, nid);
if (unlikely(chunk == NULL))
return -ENOMEM;
 
@@ -251,7 +251,7 @@ void gen_pool_destroy(struct gen_pool *pool)
bit = find_next_bit(chunk->bits, end_bit, 0);
BUG_ON(bit < end_bit);
 
-   kfree(chunk);
+   vfree(chunk);
}
kfree_const(pool->name);
kfree(pool);
-- 
2.17.1



[PATCH 1/2] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap.

2018-12-23 Thread Huang Shijie
Some devices may have over 1G memory on chip.
In some cases, the nbytes may big then 4M which is the bounday of
the memory buddy system. So use vzalloc_node() to allocate the bitmap.

Signed-off-by: Huang Shijie 
---
 lib/genalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 5deb25c40a5a..0d0ff9f0483f 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -187,7 +187,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long 
virt, phys_addr_t phy
int nbytes = sizeof(struct gen_pool_chunk) +
BITS_TO_LONGS(nbits) * sizeof(long);
 
-   chunk = kzalloc_node(nbytes, GFP_KERNEL, nid);
+   chunk = vzalloc_node(nbytes, nid);
if (unlikely(chunk == NULL))
return -ENOMEM;
 
-- 
2.17.1



[PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool

2018-12-23 Thread Huang Shijie
We may use the addr_in_gen_pool() in the driver module.
So export the addr_in_gen_pool for the compiling.

Signed-off-by: Huang Shijie 
---
 lib/genalloc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 0d0ff9f0483f..9da91a16046f 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -450,6 +450,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned long 
start,
rcu_read_unlock();
return found;
 }
+EXPORT_SYMBOL(addr_in_gen_pool);
 
 /**
  * gen_pool_avail - get available free space of the pool
-- 
2.17.1



[PATCH v2] dma: mic_x100_dma: use devm_kzalloc to fix an issue

2018-08-21 Thread Huang Shijie
The following patch introduced an issue.
commit f6206f00d8c5 ("dmaengine: mic_x100_dma: use the new helper to 
simplify the code")

This issue is :

kfree(mic_dma_dev)
.
dma_async_device_unregister(mic_dma_dev->device);

Free the memory, and use it again.

So use devm_kzalloc to allocate mic_dma_dev to fix it.

When the Devres try to release the resources, it will call release at the
following order:

dma_async_device_unregister(mic_dma_dev->device);
.
kfree(mic_dma_dev)

Fixes: f6206f00d8c5 ("dmaengine: mic_x100_dma: use the new helper to simplify 
the code")
Signed-off-by: Huang Shijie 
---
v1 --> v2:
 Change the commit message and title
---
 drivers/dma/mic_x100_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
index b76cb17d879c..adfd316db1a8 100644
--- a/drivers/dma/mic_x100_dma.c
+++ b/drivers/dma/mic_x100_dma.c
@@ -639,7 +639,7 @@ static struct mic_dma_device *mic_dma_dev_reg(struct 
mbus_device *mbdev,
int ret;
struct device *dev = >dev;
 
-   mic_dma_dev = kzalloc(sizeof(*mic_dma_dev), GFP_KERNEL);
+   mic_dma_dev = devm_kzalloc(dev, sizeof(*mic_dma_dev), GFP_KERNEL);
if (!mic_dma_dev) {
ret = -ENOMEM;
goto alloc_error;
@@ -664,7 +664,6 @@ static struct mic_dma_device *mic_dma_dev_reg(struct 
mbus_device *mbdev,
 reg_error:
mic_dma_uninit(mic_dma_dev);
 init_error:
-   kfree(mic_dma_dev);
mic_dma_dev = NULL;
 alloc_error:
dev_err(dev, "Error at %s %d ret=%d\n", __func__, __LINE__, ret);
@@ -674,7 +673,6 @@ static struct mic_dma_device *mic_dma_dev_reg(struct 
mbus_device *mbdev,
 static void mic_dma_dev_unreg(struct mic_dma_device *mic_dma_dev)
 {
mic_dma_uninit(mic_dma_dev);
-   kfree(mic_dma_dev);
 }
 
 /* DEBUGFS CODE */
-- 
2.17.1



[PATCH v2] dma: mic_x100_dma: use devm_kzalloc to fix an issue

2018-08-21 Thread Huang Shijie
The following patch introduced an issue.
commit f6206f00d8c5 ("dmaengine: mic_x100_dma: use the new helper to 
simplify the code")

This issue is :

kfree(mic_dma_dev)
.
dma_async_device_unregister(mic_dma_dev->device);

Free the memory, and use it again.

So use devm_kzalloc to allocate mic_dma_dev to fix it.

When the Devres try to release the resources, it will call release at the
following order:

dma_async_device_unregister(mic_dma_dev->device);
.
kfree(mic_dma_dev)

Fixes: f6206f00d8c5 ("dmaengine: mic_x100_dma: use the new helper to simplify 
the code")
Signed-off-by: Huang Shijie 
---
v1 --> v2:
 Change the commit message and title
---
 drivers/dma/mic_x100_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
index b76cb17d879c..adfd316db1a8 100644
--- a/drivers/dma/mic_x100_dma.c
+++ b/drivers/dma/mic_x100_dma.c
@@ -639,7 +639,7 @@ static struct mic_dma_device *mic_dma_dev_reg(struct 
mbus_device *mbdev,
int ret;
struct device *dev = >dev;
 
-   mic_dma_dev = kzalloc(sizeof(*mic_dma_dev), GFP_KERNEL);
+   mic_dma_dev = devm_kzalloc(dev, sizeof(*mic_dma_dev), GFP_KERNEL);
if (!mic_dma_dev) {
ret = -ENOMEM;
goto alloc_error;
@@ -664,7 +664,6 @@ static struct mic_dma_device *mic_dma_dev_reg(struct 
mbus_device *mbdev,
 reg_error:
mic_dma_uninit(mic_dma_dev);
 init_error:
-   kfree(mic_dma_dev);
mic_dma_dev = NULL;
 alloc_error:
dev_err(dev, "Error at %s %d ret=%d\n", __func__, __LINE__, ret);
@@ -674,7 +673,6 @@ static struct mic_dma_device *mic_dma_dev_reg(struct 
mbus_device *mbdev,
 static void mic_dma_dev_unreg(struct mic_dma_device *mic_dma_dev)
 {
mic_dma_uninit(mic_dma_dev);
-   kfree(mic_dma_dev);
 }
 
 /* DEBUGFS CODE */
-- 
2.17.1



Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code

2018-08-07 Thread Huang Shijie
On Tue, Aug 07, 2018 at 10:01:47AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-06 06:28, Huang Shijie wrote:
> It might be only me, but I like to keep the resource teardown in a
> reverse order of their creation. If everything is devm then it is granted.
Yes.

If everything is devm then it is granted..

> 
> In case of cppi4 it looks safe after reading in to the DMAengine core,
> module core and platform core code.
> 
> But does the removed three lines worth over the clarity of how the
> module removal is proceeding?
Please keep the driver as it is if you like the traditional way. :)

The DMA driver's maintainer has the right to decide whether
to use the dmaenginem_async_device_register or not.

Thanks
Huang Shijie


Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code

2018-08-07 Thread Huang Shijie
On Tue, Aug 07, 2018 at 10:01:47AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-06 06:28, Huang Shijie wrote:
> It might be only me, but I like to keep the resource teardown in a
> reverse order of their creation. If everything is devm then it is granted.
Yes.

If everything is devm then it is granted..

> 
> In case of cppi4 it looks safe after reading in to the DMAengine core,
> module core and platform core code.
> 
> But does the removed three lines worth over the clarity of how the
> module removal is proceeding?
Please keep the driver as it is if you like the traditional way. :)

The DMA driver's maintainer has the right to decide whether
to use the dmaenginem_async_device_register or not.

Thanks
Huang Shijie


Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code

2018-08-05 Thread Huang Shijie
On Fri, Aug 03, 2018 at 10:55:25AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie 
> > ---
> >  drivers/dma/ti/cppi41.c | 7 ++-
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
> > index 1497da367710..d2998a19ed2e 100644
> > --- a/drivers/dma/ti/cppi41.c
> > +++ b/drivers/dma/ti/cppi41.c
> > @@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device 
> > *pdev)
> > goto err_chans;
> > cdd->irq = irq;
> >  
> > -   ret = dma_async_device_register(>ddev);
> > +   ret = dmaenginem_async_device_register(>ddev);
> > if (ret)
> > goto err_chans;
> >  
> > ret = of_dma_controller_register(dev->of_node,
> > cppi41_dma_xlate, _dma_info);
> > if (ret)
> > -   goto err_of;
> > +   goto err_chans;
> >  
> > pm_runtime_mark_last_busy(dev);
> > pm_runtime_put_autosuspend(dev);
> >  
> > return 0;
> > -err_of:
> > -   dma_async_device_unregister(>ddev);
> >  err_chans:
> > deinit_cppi41(dev, cdd);
> >  err_init_cppi:
> > @@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device 
> > *pdev)
> > dev_err(>dev, "%s could not pm_runtime_get: %i\n",
> > __func__, error);
> > of_dma_controller_free(pdev->dev.of_node);
> > -   dma_async_device_unregister(>ddev);
> 
> If I read the code right then this is not safe.
I read the code again, and find it is okay.

> We would have deinitalized cppi41 driver which is not functional, but we
> will still have the dma device registered and if a channel is requested
> we will have kernel crash.
We cannot succeed to request a channel when the drv->remove() is called.

Please see __device_release_driver:
  -
if (dev->bus && dev->bus->remove)
dev->bus->remove(dev);
else if (drv->remove)
drv->remove(dev);

device_links_driver_cleanup(dev);
dma_deconfigure(dev);

devres_release_all(dev);> Devres release
  -

For the DMA engine driver, there is only one case which will calls 
drv->remove():
Use the rmmod(or modprobe -r).

We do not use the device_link_add API for DMA engines.
And we not manually call the device_release_driver() for DMA engines.

But when we use the rmmod, the module state will be MODULE_STATE_GOING.
In the find_candidate(), dma_chan_get() will fail.
And we cannot get a channel.

Please correct me if I am wrong :)

Thanks
Huang Shijie


Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code

2018-08-05 Thread Huang Shijie
On Fri, Aug 03, 2018 at 10:55:25AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie 
> > ---
> >  drivers/dma/ti/cppi41.c | 7 ++-
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
> > index 1497da367710..d2998a19ed2e 100644
> > --- a/drivers/dma/ti/cppi41.c
> > +++ b/drivers/dma/ti/cppi41.c
> > @@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device 
> > *pdev)
> > goto err_chans;
> > cdd->irq = irq;
> >  
> > -   ret = dma_async_device_register(>ddev);
> > +   ret = dmaenginem_async_device_register(>ddev);
> > if (ret)
> > goto err_chans;
> >  
> > ret = of_dma_controller_register(dev->of_node,
> > cppi41_dma_xlate, _dma_info);
> > if (ret)
> > -   goto err_of;
> > +   goto err_chans;
> >  
> > pm_runtime_mark_last_busy(dev);
> > pm_runtime_put_autosuspend(dev);
> >  
> > return 0;
> > -err_of:
> > -   dma_async_device_unregister(>ddev);
> >  err_chans:
> > deinit_cppi41(dev, cdd);
> >  err_init_cppi:
> > @@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device 
> > *pdev)
> > dev_err(>dev, "%s could not pm_runtime_get: %i\n",
> > __func__, error);
> > of_dma_controller_free(pdev->dev.of_node);
> > -   dma_async_device_unregister(>ddev);
> 
> If I read the code right then this is not safe.
I read the code again, and find it is okay.

> We would have deinitalized cppi41 driver which is not functional, but we
> will still have the dma device registered and if a channel is requested
> we will have kernel crash.
We cannot succeed to request a channel when the drv->remove() is called.

Please see __device_release_driver:
  -
if (dev->bus && dev->bus->remove)
dev->bus->remove(dev);
else if (drv->remove)
drv->remove(dev);

device_links_driver_cleanup(dev);
dma_deconfigure(dev);

devres_release_all(dev);> Devres release
  -

For the DMA engine driver, there is only one case which will calls 
drv->remove():
Use the rmmod(or modprobe -r).

We do not use the device_link_add API for DMA engines.
And we not manually call the device_release_driver() for DMA engines.

But when we use the rmmod, the module state will be MODULE_STATE_GOING.
In the find_candidate(), dma_chan_get() will fail.
And we cannot get a channel.

Please correct me if I am wrong :)

Thanks
Huang Shijie


Re: [PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-04 Thread Huang Shijie
On Fri, Aug 03, 2018 at 11:20:49AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > All the patches are using dmaenginem_async_device_register to simplify code
> > except the last one:
> >   dmaengine: add COMPILE_TEST for the drivers
> > 
> > I use the last one to do the compiler test.  
> > There are still 20 drivers which do not use the 
> > dmaenginem_async_device_register.
> > Let me take a rest, if this patch set is accepted, I will do the rest.
> 
> I think for most of the drivers this series is going to open a race
> which is essentially:
> 
> prior:
> _remove()
> {
> ...
>   dma_async_device_register()
>   /* Free resources, disable HW, etc */

If these resources are managed by the devm_* APIs.
We can use the dmaenginem_async_device_register().

The Devres will release all the things in the following order:
   
dma_async_device_unregister()
/* Free resources, disable HW, etc */
   


Thanks
Huang Shijie


Re: [PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-04 Thread Huang Shijie
On Fri, Aug 03, 2018 at 11:20:49AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > All the patches are using dmaenginem_async_device_register to simplify code
> > except the last one:
> >   dmaengine: add COMPILE_TEST for the drivers
> > 
> > I use the last one to do the compiler test.  
> > There are still 20 drivers which do not use the 
> > dmaenginem_async_device_register.
> > Let me take a rest, if this patch set is accepted, I will do the rest.
> 
> I think for most of the drivers this series is going to open a race
> which is essentially:
> 
> prior:
> _remove()
> {
> ...
>   dma_async_device_register()
>   /* Free resources, disable HW, etc */

If these resources are managed by the devm_* APIs.
We can use the dmaenginem_async_device_register().

The Devres will release all the things in the following order:
   
dma_async_device_unregister()
/* Free resources, disable HW, etc */
   


Thanks
Huang Shijie


Re: [PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 11:20:49AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > All the patches are using dmaenginem_async_device_register to simplify code
> > except the last one:
> >   dmaengine: add COMPILE_TEST for the drivers
> > 
> > I use the last one to do the compiler test.  
> > There are still 20 drivers which do not use the 
> > dmaenginem_async_device_register.
> > Let me take a rest, if this patch set is accepted, I will do the rest.
> 
> I think for most of the drivers this series is going to open a race
> which is essentially:
> 
> prior:
> _remove()
> {
> ...
>   dma_async_device_register()
>   /* Free resources, disable HW, etc */
>   return 0;
> }
> 
> after:
> _remove()
> {
> ...
>   /* Free resources, disable HW, etc */
>   /*
>* The dma device is still registered and a channel can be
>* requested
>*/
> 
>   dma_async_device_register()
>   return 0;
> }
> 
> It might be theoretical, but conversion to managed device resources is
> not straight forward in some cases. 
Yes. 

okay, let me think again..

@Vinod, please just ignore this patch set.

Thanks
Huang Shijie


Re: [PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 11:20:49AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > All the patches are using dmaenginem_async_device_register to simplify code
> > except the last one:
> >   dmaengine: add COMPILE_TEST for the drivers
> > 
> > I use the last one to do the compiler test.  
> > There are still 20 drivers which do not use the 
> > dmaenginem_async_device_register.
> > Let me take a rest, if this patch set is accepted, I will do the rest.
> 
> I think for most of the drivers this series is going to open a race
> which is essentially:
> 
> prior:
> _remove()
> {
> ...
>   dma_async_device_register()
>   /* Free resources, disable HW, etc */
>   return 0;
> }
> 
> after:
> _remove()
> {
> ...
>   /* Free resources, disable HW, etc */
>   /*
>* The dma device is still registered and a channel can be
>* requested
>*/
> 
>   dma_async_device_register()
>   return 0;
> }
> 
> It might be theoretical, but conversion to managed device resources is
> not straight forward in some cases. 
Yes. 

okay, let me think again..

@Vinod, please just ignore this patch set.

Thanks
Huang Shijie


Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie




在 2018年08月03日 15:55, Peter Ujfalusi 写道:


On 2018-08-03 10:19, Huang Shijie wrote:

Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
  drivers/dma/ti/cppi41.c | 7 ++-
  1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
index 1497da367710..d2998a19ed2e 100644
--- a/drivers/dma/ti/cppi41.c
+++ b/drivers/dma/ti/cppi41.c
@@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device 
*pdev)
goto err_chans;
cdd->irq = irq;
  
-	ret = dma_async_device_register(>ddev);

+   ret = dmaenginem_async_device_register(>ddev);
if (ret)
goto err_chans;
  
  	ret = of_dma_controller_register(dev->of_node,

cppi41_dma_xlate, _dma_info);
if (ret)
-   goto err_of;
+   goto err_chans;
  
  	pm_runtime_mark_last_busy(dev);

pm_runtime_put_autosuspend(dev);
  
  	return 0;

-err_of:
-   dma_async_device_unregister(>ddev);
  err_chans:
deinit_cppi41(dev, cdd);
  err_init_cppi:
@@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
dev_err(>dev, "%s could not pm_runtime_get: %i\n",
__func__, error);
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>ddev);

If I read the code right then this is not safe.
We would have deinitalized cppi41 driver which is not functional, but we
will still have the dma device registered and if a channel is requested
we will have kernel crash.

It falls in the same case as omap-dma, edma.

Thanks for pointing this, we can drop the patches for omap-dma, edma.

Huang Shijie



Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie




在 2018年08月03日 15:55, Peter Ujfalusi 写道:


On 2018-08-03 10:19, Huang Shijie wrote:

Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
  drivers/dma/ti/cppi41.c | 7 ++-
  1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
index 1497da367710..d2998a19ed2e 100644
--- a/drivers/dma/ti/cppi41.c
+++ b/drivers/dma/ti/cppi41.c
@@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device 
*pdev)
goto err_chans;
cdd->irq = irq;
  
-	ret = dma_async_device_register(>ddev);

+   ret = dmaenginem_async_device_register(>ddev);
if (ret)
goto err_chans;
  
  	ret = of_dma_controller_register(dev->of_node,

cppi41_dma_xlate, _dma_info);
if (ret)
-   goto err_of;
+   goto err_chans;
  
  	pm_runtime_mark_last_busy(dev);

pm_runtime_put_autosuspend(dev);
  
  	return 0;

-err_of:
-   dma_async_device_unregister(>ddev);
  err_chans:
deinit_cppi41(dev, cdd);
  err_init_cppi:
@@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
dev_err(>dev, "%s could not pm_runtime_get: %i\n",
__func__, error);
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>ddev);

If I read the code right then this is not safe.
We would have deinitalized cppi41 driver which is not functional, but we
will still have the dma device registered and if a channel is requested
we will have kernel crash.

It falls in the same case as omap-dma, edma.

Thanks for pointing this, we can drop the patches for omap-dma, edma.

Huang Shijie



Re: [PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 09:51:43AM +0200, Lars-Peter Clausen wrote:
> On 08/03/2018 09:19 AM, Huang Shijie wrote:
> > All the patches are using dmaenginem_async_device_register to simplify code
> > except the last one:
> >   dmaengine: add COMPILE_TEST for the drivers
> > 
> > I use the last one to do the compiler test.  
> > There are still 20 drivers which do not use the 
> > dmaenginem_async_device_register.
> > Let me take a rest, if this patch set is accepted, I will do the rest.
> 
> Lots of race conditions in this series. The DMA device needs to be removed
> before any of the resources it uses are disabled/released.
> 
> As a rule of thumb you can only convert something to a managed
> allocation/reregistration if it is the last action in remove.
Yes. Agree.

I am collecting the DMA maintainers opinions now..
If the managed unregistration is not the last action, we can drop the patch.

Thanks
Huang Shijie



Re: [PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 09:51:43AM +0200, Lars-Peter Clausen wrote:
> On 08/03/2018 09:19 AM, Huang Shijie wrote:
> > All the patches are using dmaenginem_async_device_register to simplify code
> > except the last one:
> >   dmaengine: add COMPILE_TEST for the drivers
> > 
> > I use the last one to do the compiler test.  
> > There are still 20 drivers which do not use the 
> > dmaenginem_async_device_register.
> > Let me take a rest, if this patch set is accepted, I will do the rest.
> 
> Lots of race conditions in this series. The DMA device needs to be removed
> before any of the resources it uses are disabled/released.
> 
> As a rule of thumb you can only convert something to a managed
> allocation/reregistration if it is the last action in remove.
Yes. Agree.

I am collecting the DMA maintainers opinions now..
If the managed unregistration is not the last action, we can drop the patch.

Thanks
Huang Shijie



Re: [PATCH 08/46] dmaengine: edma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 10:50:13AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie 
> > ---
> >  drivers/dma/ti/edma.c | 8 ++--
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
> > index ceabdea40ae0..28ba1e722c47 100644
> > --- a/drivers/dma/ti/edma.c
> > +++ b/drivers/dma/ti/edma.c
> > @@ -2388,18 +2388,17 @@ static int edma_probe(struct platform_device *pdev)
> > ecc->dma_slave.filter.mapcnt = info->slavecnt;
> > ecc->dma_slave.filter.fn = edma_filter_fn;
> >  
> > -   ret = dma_async_device_register(>dma_slave);
> > +   ret = dmaenginem_async_device_register(>dma_slave);
> > if (ret) {
> > dev_err(dev, "slave ddev registration failed (%d)\n", ret);
> > goto err_reg1;
> > }
> >  
> > if (ecc->dma_memcpy) {
> > -   ret = dma_async_device_register(ecc->dma_memcpy);
> > +   ret = dmaenginem_async_device_register(ecc->dma_memcpy);
> > if (ret) {
> > dev_err(dev, "memcpy ddev registration failed (%d)\n",
> > ret);
> > -   dma_async_device_unregister(>dma_slave);
> > goto err_reg1;
> > }
> > }
> > @@ -2439,9 +2438,6 @@ static int edma_remove(struct platform_device *pdev)
> >  
> > if (dev->of_node)
> > of_dma_controller_free(dev->of_node);
> > -   dma_async_device_unregister(>dma_slave);
> > -   if (ecc->dma_memcpy)
> > -   dma_async_device_unregister(ecc->dma_memcpy);
> 
> I'm afraid this is not safe either, we need to free the dummy_slot
> _after_ the dma device is unregistered.
> 
Thanks for pointing this.

I will drop this patch ...

Thanks
Huang Shijie


Re: [PATCH 08/46] dmaengine: edma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 10:50:13AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie 
> > ---
> >  drivers/dma/ti/edma.c | 8 ++--
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
> > index ceabdea40ae0..28ba1e722c47 100644
> > --- a/drivers/dma/ti/edma.c
> > +++ b/drivers/dma/ti/edma.c
> > @@ -2388,18 +2388,17 @@ static int edma_probe(struct platform_device *pdev)
> > ecc->dma_slave.filter.mapcnt = info->slavecnt;
> > ecc->dma_slave.filter.fn = edma_filter_fn;
> >  
> > -   ret = dma_async_device_register(>dma_slave);
> > +   ret = dmaenginem_async_device_register(>dma_slave);
> > if (ret) {
> > dev_err(dev, "slave ddev registration failed (%d)\n", ret);
> > goto err_reg1;
> > }
> >  
> > if (ecc->dma_memcpy) {
> > -   ret = dma_async_device_register(ecc->dma_memcpy);
> > +   ret = dmaenginem_async_device_register(ecc->dma_memcpy);
> > if (ret) {
> > dev_err(dev, "memcpy ddev registration failed (%d)\n",
> > ret);
> > -   dma_async_device_unregister(>dma_slave);
> > goto err_reg1;
> > }
> > }
> > @@ -2439,9 +2438,6 @@ static int edma_remove(struct platform_device *pdev)
> >  
> > if (dev->of_node)
> > of_dma_controller_free(dev->of_node);
> > -   dma_async_device_unregister(>dma_slave);
> > -   if (ecc->dma_memcpy)
> > -   dma_async_device_unregister(ecc->dma_memcpy);
> 
> I'm afraid this is not safe either, we need to free the dummy_slot
> _after_ the dma device is unregistered.
> 
Thanks for pointing this.

I will drop this patch ...

Thanks
Huang Shijie


Re: [PATCH 07/46] dmaengine: omap-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 10:47:30AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie 
> > ---
> >  drivers/dma/ti/omap-dma.c | 5 +
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
> > index a4a931ddf6f6..085748c6eb67 100644
> > --- a/drivers/dma/ti/omap-dma.c
> > +++ b/drivers/dma/ti/omap-dma.c
> > @@ -1566,7 +1566,7 @@ static int omap_dma_probe(struct platform_device 
> > *pdev)
> > }
> > }
> >  
> > -   rc = dma_async_device_register(>ddev);
> > +   rc = dmaenginem_async_device_register(>ddev);
> 
> Why it is dmaenginem_async_device_register() and not aligned other
> resource managed functions (devm_* dmam_*), like
> devm_dma_async_device_register()
Vinod prefer the this dmaenginem_async_device_register..
> 
> and in dmaenginem_async_device_register() what is the 'm' in dmaenginem ?
> DMAengine Managed?
Yes.
> 
> > if (rc) {
> > pr_warn("OMAP-DMA: failed to register slave DMA engine device: 
> > %d\n",
> > rc);
> > @@ -1584,7 +1584,6 @@ static int omap_dma_probe(struct platform_device 
> > *pdev)
> > of_dma_simple_xlate, _dma_info);
> > if (rc) {
> > pr_warn("OMAP-DMA: failed to register DMA 
> > controller\n");
> > -   dma_async_device_unregister(>ddev);
> > omap_dma_free(od);
> > }
> > }
> > @@ -1606,8 +1605,6 @@ static int omap_dma_remove(struct platform_device 
> > *pdev)
> > irq = platform_get_irq(pdev, 1);
> > devm_free_irq(>dev, irq, od);
> >  
> > -   dma_async_device_unregister(>ddev);
> > -
> 
> I think this is a bad idea in general.
> We need to unregister the dma-device before we clean up and free resources.
okay, thanks for pointing here.
We can drop this patch now...

> 
> > if (!od->legacy) {
> > /* Disable all interrupts */
> > omap_dma_glbl_write(od, IRQENABLE_L0, 0);
> > 
> 
> I'm sorry to say, but it is a NACK from me.
No problem.

Thanks
Huang Shijie


Re: [PATCH 07/46] dmaengine: omap-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
On Fri, Aug 03, 2018 at 10:47:30AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie 
> > ---
> >  drivers/dma/ti/omap-dma.c | 5 +
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
> > index a4a931ddf6f6..085748c6eb67 100644
> > --- a/drivers/dma/ti/omap-dma.c
> > +++ b/drivers/dma/ti/omap-dma.c
> > @@ -1566,7 +1566,7 @@ static int omap_dma_probe(struct platform_device 
> > *pdev)
> > }
> > }
> >  
> > -   rc = dma_async_device_register(>ddev);
> > +   rc = dmaenginem_async_device_register(>ddev);
> 
> Why it is dmaenginem_async_device_register() and not aligned other
> resource managed functions (devm_* dmam_*), like
> devm_dma_async_device_register()
Vinod prefer the this dmaenginem_async_device_register..
> 
> and in dmaenginem_async_device_register() what is the 'm' in dmaenginem ?
> DMAengine Managed?
Yes.
> 
> > if (rc) {
> > pr_warn("OMAP-DMA: failed to register slave DMA engine device: 
> > %d\n",
> > rc);
> > @@ -1584,7 +1584,6 @@ static int omap_dma_probe(struct platform_device 
> > *pdev)
> > of_dma_simple_xlate, _dma_info);
> > if (rc) {
> > pr_warn("OMAP-DMA: failed to register DMA 
> > controller\n");
> > -   dma_async_device_unregister(>ddev);
> > omap_dma_free(od);
> > }
> > }
> > @@ -1606,8 +1605,6 @@ static int omap_dma_remove(struct platform_device 
> > *pdev)
> > irq = platform_get_irq(pdev, 1);
> > devm_free_irq(>dev, irq, od);
> >  
> > -   dma_async_device_unregister(>ddev);
> > -
> 
> I think this is a bad idea in general.
> We need to unregister the dma-device before we clean up and free resources.
okay, thanks for pointing here.
We can drop this patch now...

> 
> > if (!od->legacy) {
> > /* Disable all interrupts */
> > omap_dma_glbl_write(od, IRQENABLE_L0, 0);
> > 
> 
> I'm sorry to say, but it is a NACK from me.
No problem.

Thanks
Huang Shijie


[PATCH 01/46] dmaengine: zx_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register() to simplify the code.
Remove the code calling dma_async_device_unregister().

Signed-off-by: Huang Shijie 
---
 drivers/dma/zx_dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
index 2571bc7693df..7febd20113ef 100644
--- a/drivers/dma/zx_dma.c
+++ b/drivers/dma/zx_dma.c
@@ -861,20 +861,18 @@ static int zx_dma_probe(struct platform_device *op)
INIT_LIST_HEAD(>chan_pending);
platform_set_drvdata(op, d);
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret)
goto clk_dis;
 
ret = of_dma_controller_register((>dev)->of_node,
 zx_of_dma_simple_xlate, d);
if (ret)
-   goto of_dma_register_fail;
+   goto clk_dis;
 
dev_info(>dev, "initialized\n");
return 0;
 
-of_dma_register_fail:
-   dma_async_device_unregister(>slave);
 clk_dis:
clk_disable_unprepare(d->clk);
 zx_dma_out:
@@ -889,7 +887,6 @@ static int zx_dma_remove(struct platform_device *op)
/* explictly free the irq */
devm_free_irq(>dev, d->irq, d);
 
-   dma_async_device_unregister(>slave);
of_dma_controller_free((>dev)->of_node);
 
list_for_each_entry_safe(c, cn, >slave.channels,
-- 
2.17.1



[PATCH 01/46] dmaengine: zx_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register() to simplify the code.
Remove the code calling dma_async_device_unregister().

Signed-off-by: Huang Shijie 
---
 drivers/dma/zx_dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
index 2571bc7693df..7febd20113ef 100644
--- a/drivers/dma/zx_dma.c
+++ b/drivers/dma/zx_dma.c
@@ -861,20 +861,18 @@ static int zx_dma_probe(struct platform_device *op)
INIT_LIST_HEAD(>chan_pending);
platform_set_drvdata(op, d);
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret)
goto clk_dis;
 
ret = of_dma_controller_register((>dev)->of_node,
 zx_of_dma_simple_xlate, d);
if (ret)
-   goto of_dma_register_fail;
+   goto clk_dis;
 
dev_info(>dev, "initialized\n");
return 0;
 
-of_dma_register_fail:
-   dma_async_device_unregister(>slave);
 clk_dis:
clk_disable_unprepare(d->clk);
 zx_dma_out:
@@ -889,7 +887,6 @@ static int zx_dma_remove(struct platform_device *op)
/* explictly free the irq */
devm_free_irq(>dev, d->irq, d);
 
-   dma_async_device_unregister(>slave);
of_dma_controller_free((>dev)->of_node);
 
list_for_each_entry_safe(c, cn, >slave.channels,
-- 
2.17.1



[PATCH 11/46] dmaengine: tegra20-apb-dma: use helper dmaenginem_async_device_register

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister
   remove the label err_unregister_dma_dev

Signed-off-by: Huang Shijie 
---
 drivers/dma/tegra20-apb-dma.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 9a558e30c461..9f6f51abbeef 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -1444,7 +1444,7 @@ static int tegra_dma_probe(struct platform_device *pdev)
tdma->dma_dev.device_tx_status = tegra_dma_tx_status;
tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending;
 
-   ret = dma_async_device_register(>dma_dev);
+   ret = dmaenginem_async_device_register(>dma_dev);
if (ret < 0) {
dev_err(>dev,
"Tegra20 APB DMA driver registration failed %d\n", ret);
@@ -1456,15 +1456,13 @@ static int tegra_dma_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(>dev,
"Tegra20 APB DMA OF registration failed %d\n", ret);
-   goto err_unregister_dma_dev;
+   goto err_irq;
}
 
dev_info(>dev, "Tegra20 APB DMA driver register %d channels\n",
cdata->nr_channels);
return 0;
 
-err_unregister_dma_dev:
-   dma_async_device_unregister(>dma_dev);
 err_irq:
while (--i >= 0) {
struct tegra_dma_channel *tdc = >channels[i];
@@ -1485,8 +1483,6 @@ static int tegra_dma_remove(struct platform_device *pdev)
int i;
struct tegra_dma_channel *tdc;
 
-   dma_async_device_unregister(>dma_dev);
-
for (i = 0; i < tdma->chip_data->nr_channels; ++i) {
tdc = >channels[i];
free_irq(tdc->irq, tdc);
-- 
2.17.1



[PATCH 04/46] dmaengine: xgene-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove xgene_dma_async_register
   remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/xgene-dma.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/xgene-dma.c b/drivers/dma/xgene-dma.c
index 1d5988849aa6..192322bbdc29 100644
--- a/drivers/dma/xgene-dma.c
+++ b/drivers/dma/xgene-dma.c
@@ -1564,7 +1564,7 @@ static int xgene_dma_async_register(struct xgene_dma 
*pdma, int id)
list_add_tail(>dma_chan.device_node, _dev->channels);
 
/* Register with Linux async DMA framework*/
-   ret = dma_async_device_register(dma_dev);
+   ret = dmaenginem_async_device_register(dma_dev);
if (ret) {
chan_err(chan, "Failed to register async device %d", ret);
tasklet_kill(>tasklet);
@@ -1588,10 +1588,8 @@ static int xgene_dma_init_async(struct xgene_dma *pdma)
for (i = 0; i < XGENE_DMA_MAX_CHANNEL ; i++) {
ret = xgene_dma_async_register(pdma, i);
if (ret) {
-   for (j = 0; j < i; j++) {
-   dma_async_device_unregister(>dma_dev[j]);
+   for (j = 0; j < i; j++)
tasklet_kill(>chan[j].tasklet);
-   }
 
return ret;
}
@@ -1600,14 +1598,6 @@ static int xgene_dma_init_async(struct xgene_dma *pdma)
return ret;
 }
 
-static void xgene_dma_async_unregister(struct xgene_dma *pdma)
-{
-   int i;
-
-   for (i = 0; i < XGENE_DMA_MAX_CHANNEL; i++)
-   dma_async_device_unregister(>dma_dev[i]);
-}
-
 static void xgene_dma_init_channels(struct xgene_dma *pdma)
 {
struct xgene_dma_chan *chan;
@@ -1796,8 +1786,6 @@ static int xgene_dma_remove(struct platform_device *pdev)
struct xgene_dma_chan *chan;
int i;
 
-   xgene_dma_async_unregister(pdma);
-
/* Mask interrupts and disable DMA engine */
xgene_dma_mask_interrupts(pdma);
xgene_dma_disable(pdma);
-- 
2.17.1



[PATCH 02/46] dmaengine: zynqmp_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code,
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/xilinx/zynqmp_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index c74a88b65039..acfc74b68717 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -1085,13 +1085,12 @@ static int zynqmp_dma_probe(struct platform_device 
*pdev)
p->dst_addr_widths = BIT(zdev->chan->bus_width / 8);
p->src_addr_widths = BIT(zdev->chan->bus_width / 8);
 
-   dma_async_device_register(>common);
+   dmaenginem_async_device_register(>common);
 
ret = of_dma_controller_register(pdev->dev.of_node,
 of_zynqmp_dma_xlate, zdev);
if (ret) {
dev_err(>dev, "Unable to register DMA to DT\n");
-   dma_async_device_unregister(>common);
goto free_chan_resources;
}
 
@@ -1122,7 +1121,6 @@ static int zynqmp_dma_remove(struct platform_device *pdev)
struct zynqmp_dma_device *zdev = platform_get_drvdata(pdev);
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>common);
 
zynqmp_dma_chan_remove(zdev->chan);
pm_runtime_disable(zdev->dev);
-- 
2.17.1



[PATCH 06/46] dmaengine: timb_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/timb_dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index 395c698edb4d..39e1ba2347db 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -723,7 +723,7 @@ static int td_probe(struct platform_device *pdev)
list_add_tail(_chan->chan.device_node, >dma.channels);
}
 
-   err = dma_async_device_register(>dma);
+   err = dmaenginem_async_device_register(>dma);
if (err) {
dev_err(>dev, "Failed to register async device\n");
goto err_free_irq;
@@ -754,7 +754,6 @@ static int td_remove(struct platform_device *pdev)
struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int irq = platform_get_irq(pdev, 0);
 
-   dma_async_device_unregister(>dma);
free_irq(irq, td);
tasklet_kill(>tasklet);
iounmap(td->membase);
-- 
2.17.1



[PATCH 14/46] dmaengine: coh901318: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister
   remove label err_register_of_dma,err_register_memcpy

Signed-off-by: Huang Shijie 
---
 drivers/dma/coh901318.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index da74fd74636b..ff29f2f6ce3b 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -2690,7 +2690,7 @@ static int __init coh901318_probe(struct platform_device 
*pdev)
base->dma_slave.device_terminate_all = coh901318_terminate_all;
base->dma_slave.dev = >dev;
 
-   err = dma_async_device_register(>dma_slave);
+   err = dmaenginem_async_device_register(>dma_slave);
 
if (err)
goto err_register_slave;
@@ -2717,15 +2717,15 @@ static int __init coh901318_probe(struct 
platform_device *pdev)
 * i.e. 2^2
 */
base->dma_memcpy.copy_align = DMAENGINE_ALIGN_4_BYTES;
-   err = dma_async_device_register(>dma_memcpy);
+   err = dmaenginem_async_device_register(>dma_memcpy);
 
if (err)
-   goto err_register_memcpy;
+   goto err_register_slave;
 
err = of_dma_controller_register(pdev->dev.of_node, coh901318_xlate,
 base);
if (err)
-   goto err_register_of_dma;
+   goto err_register_slave;
 
platform_set_drvdata(pdev, base);
dev_info(>dev, "Initialized COH901318 DMA on virtual base 0x%p\n",
@@ -2733,10 +2733,6 @@ static int __init coh901318_probe(struct platform_device 
*pdev)
 
return err;
 
- err_register_of_dma:
-   dma_async_device_unregister(>dma_memcpy);
- err_register_memcpy:
-   dma_async_device_unregister(>dma_slave);
  err_register_slave:
coh901318_pool_destroy(>pool);
return err;
@@ -2767,8 +2763,6 @@ static int coh901318_remove(struct platform_device *pdev)
coh901318_base_remove(base, dma_memcpy_channels);
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma_memcpy);
-   dma_async_device_unregister(>dma_slave);
coh901318_pool_destroy(>pool);
return 0;
 }
-- 
2.17.1



[PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-03 Thread Huang Shijie
All the patches are using dmaenginem_async_device_register to simplify code
except the last one:
  dmaengine: add COMPILE_TEST for the drivers

I use the last one to do the compiler test.  
There are still 20 drivers which do not use the 
dmaenginem_async_device_register.
Let me take a rest, if this patch set is accepted, I will do the rest.

Huang Shijie (46):
  dmaengine: zx_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: zynqmp_dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: xilinx_dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: xgene-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: txx9dmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: timb_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: omap-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: edma: use dmaenginem_async_device_register to simplify the
code
  dmaengine: cppi41: use dmaenginem_async_device_register to simplify
the code
  dmaengine: tegra210-adma: use helper dmaenginem_async_device_register
  dmaengine: tegra20-apb-dma: use helper
dmaenginem_async_device_register
  dmaengine: sun6i-dma: use helper dmaenginem_async_device_register
  dmaengine: sun4i-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: coh901318: use dmaenginem_async_device_register to simplify
the code
  dmaengine: s3c24xx-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: ste_dma40: use dmaenginem_async_device_register to simplify
the code
  dmaengine: stm32-mdma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: stm32-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sprd-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sirf-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: bam_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sudmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sa11x0-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: nbpfaxi: use dmaenginem_async_device_register to simplify
the code
  dmaengine: mmp_tdma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: shdmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: usb-dmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: rcar-dmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: hidma: use dmaenginem_async_device_register to simplify the
code
  dmaengine: pxa_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: moxart-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: pl330: use dmaenginem_async_device_register to simplify the
code
  dmaengine: pch_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: mxs-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: mtk-hsdma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: k3dma: use dmaenginem_async_device_register to simplify the
code
  dmaengine: imx-sdma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: imx-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: img-mdc-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: fsl-edma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: at_hdmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: at_xdmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: dma-jz4780: use dmaenginem_async_device_register to
simplify the code
  dmaengine: dma-jz4740: use dmaenginem_async_device_register to
simplify the code
  dmaengine: dma-axi-dmac: use dmaenginem_async_device_register to
simplify the code
  dmaengine: add COMPILE_TEST for the drivers

 drivers/dma/Kconfig  | 24 
 drivers/dma/at_hdmac.c   |  4 +---
 drivers/dma/at_xdmac.c   |  7 ++-
 drivers/dma/coh901318.c  | 14 --
 drivers/dma/dma-axi-dmac.c   |  7 ++-
 drivers/dma/dma-jz4740.c |  7 ++-
 drivers/dma/dma-jz4780.c |  8 ++--
 drivers/dma/fsl-edma.c   |  4 +---
 drivers/dma/img-mdc-dma.c|  7 ++-
 drivers/dma/imx-dma.c|  8 ++--
 drivers/dma/imx-sdma.c   |  7 ++-
 drivers/dma/k3dma.c  |  7 ++-
 drivers/dma/mediatek/mtk-hsdma.c |  4 +---
 drivers/dma/mmp_tdma.c   |  7 ++-
 drivers/dma/moxart-dma.c |  5 +
 drivers/dma/mxs-dma.c|  3 +--
 drivers/dma/nbpfaxi.c

[PATCH 14/46] dmaengine: coh901318: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister
   remove label err_register_of_dma,err_register_memcpy

Signed-off-by: Huang Shijie 
---
 drivers/dma/coh901318.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index da74fd74636b..ff29f2f6ce3b 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -2690,7 +2690,7 @@ static int __init coh901318_probe(struct platform_device 
*pdev)
base->dma_slave.device_terminate_all = coh901318_terminate_all;
base->dma_slave.dev = >dev;
 
-   err = dma_async_device_register(>dma_slave);
+   err = dmaenginem_async_device_register(>dma_slave);
 
if (err)
goto err_register_slave;
@@ -2717,15 +2717,15 @@ static int __init coh901318_probe(struct 
platform_device *pdev)
 * i.e. 2^2
 */
base->dma_memcpy.copy_align = DMAENGINE_ALIGN_4_BYTES;
-   err = dma_async_device_register(>dma_memcpy);
+   err = dmaenginem_async_device_register(>dma_memcpy);
 
if (err)
-   goto err_register_memcpy;
+   goto err_register_slave;
 
err = of_dma_controller_register(pdev->dev.of_node, coh901318_xlate,
 base);
if (err)
-   goto err_register_of_dma;
+   goto err_register_slave;
 
platform_set_drvdata(pdev, base);
dev_info(>dev, "Initialized COH901318 DMA on virtual base 0x%p\n",
@@ -2733,10 +2733,6 @@ static int __init coh901318_probe(struct platform_device 
*pdev)
 
return err;
 
- err_register_of_dma:
-   dma_async_device_unregister(>dma_memcpy);
- err_register_memcpy:
-   dma_async_device_unregister(>dma_slave);
  err_register_slave:
coh901318_pool_destroy(>pool);
return err;
@@ -2767,8 +2763,6 @@ static int coh901318_remove(struct platform_device *pdev)
coh901318_base_remove(base, dma_memcpy_channels);
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma_memcpy);
-   dma_async_device_unregister(>dma_slave);
coh901318_pool_destroy(>pool);
return 0;
 }
-- 
2.17.1



[PATCH 00/46] Use dmaenginem_async_device_register to simplify code

2018-08-03 Thread Huang Shijie
All the patches are using dmaenginem_async_device_register to simplify code
except the last one:
  dmaengine: add COMPILE_TEST for the drivers

I use the last one to do the compiler test.  
There are still 20 drivers which do not use the 
dmaenginem_async_device_register.
Let me take a rest, if this patch set is accepted, I will do the rest.

Huang Shijie (46):
  dmaengine: zx_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: zynqmp_dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: xilinx_dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: xgene-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: txx9dmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: timb_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: omap-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: edma: use dmaenginem_async_device_register to simplify the
code
  dmaengine: cppi41: use dmaenginem_async_device_register to simplify
the code
  dmaengine: tegra210-adma: use helper dmaenginem_async_device_register
  dmaengine: tegra20-apb-dma: use helper
dmaenginem_async_device_register
  dmaengine: sun6i-dma: use helper dmaenginem_async_device_register
  dmaengine: sun4i-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: coh901318: use dmaenginem_async_device_register to simplify
the code
  dmaengine: s3c24xx-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: ste_dma40: use dmaenginem_async_device_register to simplify
the code
  dmaengine: stm32-mdma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: stm32-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sprd-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sirf-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: bam_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sudmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: sa11x0-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: nbpfaxi: use dmaenginem_async_device_register to simplify
the code
  dmaengine: mmp_tdma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: shdmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: usb-dmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: rcar-dmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: hidma: use dmaenginem_async_device_register to simplify the
code
  dmaengine: pxa_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: moxart-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: pl330: use dmaenginem_async_device_register to simplify the
code
  dmaengine: pch_dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: mxs-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: mtk-hsdma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: k3dma: use dmaenginem_async_device_register to simplify the
code
  dmaengine: imx-sdma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: imx-dma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: img-mdc-dma: use dmaenginem_async_device_register to
simplify the code
  dmaengine: fsl-edma: use dmaenginem_async_device_register to simplify
the code
  dmaengine: at_hdmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: at_xdmac: use dmaenginem_async_device_register to simplify
the code
  dmaengine: dma-jz4780: use dmaenginem_async_device_register to
simplify the code
  dmaengine: dma-jz4740: use dmaenginem_async_device_register to
simplify the code
  dmaengine: dma-axi-dmac: use dmaenginem_async_device_register to
simplify the code
  dmaengine: add COMPILE_TEST for the drivers

 drivers/dma/Kconfig  | 24 
 drivers/dma/at_hdmac.c   |  4 +---
 drivers/dma/at_xdmac.c   |  7 ++-
 drivers/dma/coh901318.c  | 14 --
 drivers/dma/dma-axi-dmac.c   |  7 ++-
 drivers/dma/dma-jz4740.c |  7 ++-
 drivers/dma/dma-jz4780.c |  8 ++--
 drivers/dma/fsl-edma.c   |  4 +---
 drivers/dma/img-mdc-dma.c|  7 ++-
 drivers/dma/imx-dma.c|  8 ++--
 drivers/dma/imx-sdma.c   |  7 ++-
 drivers/dma/k3dma.c  |  7 ++-
 drivers/dma/mediatek/mtk-hsdma.c |  4 +---
 drivers/dma/mmp_tdma.c   |  7 ++-
 drivers/dma/moxart-dma.c |  5 +
 drivers/dma/mxs-dma.c|  3 +--
 drivers/dma/nbpfaxi.c

[PATCH 04/46] dmaengine: xgene-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove xgene_dma_async_register
   remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/xgene-dma.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/xgene-dma.c b/drivers/dma/xgene-dma.c
index 1d5988849aa6..192322bbdc29 100644
--- a/drivers/dma/xgene-dma.c
+++ b/drivers/dma/xgene-dma.c
@@ -1564,7 +1564,7 @@ static int xgene_dma_async_register(struct xgene_dma 
*pdma, int id)
list_add_tail(>dma_chan.device_node, _dev->channels);
 
/* Register with Linux async DMA framework*/
-   ret = dma_async_device_register(dma_dev);
+   ret = dmaenginem_async_device_register(dma_dev);
if (ret) {
chan_err(chan, "Failed to register async device %d", ret);
tasklet_kill(>tasklet);
@@ -1588,10 +1588,8 @@ static int xgene_dma_init_async(struct xgene_dma *pdma)
for (i = 0; i < XGENE_DMA_MAX_CHANNEL ; i++) {
ret = xgene_dma_async_register(pdma, i);
if (ret) {
-   for (j = 0; j < i; j++) {
-   dma_async_device_unregister(>dma_dev[j]);
+   for (j = 0; j < i; j++)
tasklet_kill(>chan[j].tasklet);
-   }
 
return ret;
}
@@ -1600,14 +1598,6 @@ static int xgene_dma_init_async(struct xgene_dma *pdma)
return ret;
 }
 
-static void xgene_dma_async_unregister(struct xgene_dma *pdma)
-{
-   int i;
-
-   for (i = 0; i < XGENE_DMA_MAX_CHANNEL; i++)
-   dma_async_device_unregister(>dma_dev[i]);
-}
-
 static void xgene_dma_init_channels(struct xgene_dma *pdma)
 {
struct xgene_dma_chan *chan;
@@ -1796,8 +1786,6 @@ static int xgene_dma_remove(struct platform_device *pdev)
struct xgene_dma_chan *chan;
int i;
 
-   xgene_dma_async_unregister(pdma);
-
/* Mask interrupts and disable DMA engine */
xgene_dma_mask_interrupts(pdma);
xgene_dma_disable(pdma);
-- 
2.17.1



[PATCH 02/46] dmaengine: zynqmp_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code,
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/xilinx/zynqmp_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index c74a88b65039..acfc74b68717 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -1085,13 +1085,12 @@ static int zynqmp_dma_probe(struct platform_device 
*pdev)
p->dst_addr_widths = BIT(zdev->chan->bus_width / 8);
p->src_addr_widths = BIT(zdev->chan->bus_width / 8);
 
-   dma_async_device_register(>common);
+   dmaenginem_async_device_register(>common);
 
ret = of_dma_controller_register(pdev->dev.of_node,
 of_zynqmp_dma_xlate, zdev);
if (ret) {
dev_err(>dev, "Unable to register DMA to DT\n");
-   dma_async_device_unregister(>common);
goto free_chan_resources;
}
 
@@ -1122,7 +1121,6 @@ static int zynqmp_dma_remove(struct platform_device *pdev)
struct zynqmp_dma_device *zdev = platform_get_drvdata(pdev);
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>common);
 
zynqmp_dma_chan_remove(zdev->chan);
pm_runtime_disable(zdev->dev);
-- 
2.17.1



[PATCH 06/46] dmaengine: timb_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/timb_dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index 395c698edb4d..39e1ba2347db 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -723,7 +723,7 @@ static int td_probe(struct platform_device *pdev)
list_add_tail(_chan->chan.device_node, >dma.channels);
}
 
-   err = dma_async_device_register(>dma);
+   err = dmaenginem_async_device_register(>dma);
if (err) {
dev_err(>dev, "Failed to register async device\n");
goto err_free_irq;
@@ -754,7 +754,6 @@ static int td_remove(struct platform_device *pdev)
struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int irq = platform_get_irq(pdev, 0);
 
-   dma_async_device_unregister(>dma);
free_irq(irq, td);
tasklet_kill(>tasklet);
iounmap(td->membase);
-- 
2.17.1



[PATCH 11/46] dmaengine: tegra20-apb-dma: use helper dmaenginem_async_device_register

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister
   remove the label err_unregister_dma_dev

Signed-off-by: Huang Shijie 
---
 drivers/dma/tegra20-apb-dma.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 9a558e30c461..9f6f51abbeef 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -1444,7 +1444,7 @@ static int tegra_dma_probe(struct platform_device *pdev)
tdma->dma_dev.device_tx_status = tegra_dma_tx_status;
tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending;
 
-   ret = dma_async_device_register(>dma_dev);
+   ret = dmaenginem_async_device_register(>dma_dev);
if (ret < 0) {
dev_err(>dev,
"Tegra20 APB DMA driver registration failed %d\n", ret);
@@ -1456,15 +1456,13 @@ static int tegra_dma_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(>dev,
"Tegra20 APB DMA OF registration failed %d\n", ret);
-   goto err_unregister_dma_dev;
+   goto err_irq;
}
 
dev_info(>dev, "Tegra20 APB DMA driver register %d channels\n",
cdata->nr_channels);
return 0;
 
-err_unregister_dma_dev:
-   dma_async_device_unregister(>dma_dev);
 err_irq:
while (--i >= 0) {
struct tegra_dma_channel *tdc = >channels[i];
@@ -1485,8 +1483,6 @@ static int tegra_dma_remove(struct platform_device *pdev)
int i;
struct tegra_dma_channel *tdc;
 
-   dma_async_device_unregister(>dma_dev);
-
for (i = 0; i < tdma->chip_data->nr_channels; ++i) {
tdc = >channels[i];
free_irq(tdc->irq, tdc);
-- 
2.17.1



[PATCH 27/46] dmaengine: usb-dmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/sh/usb-dmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index 1bb1a8e09025..c09d7c65c2c5 100644
--- a/drivers/dma/sh/usb-dmac.c
+++ b/drivers/dma/sh/usb-dmac.c
@@ -849,7 +849,7 @@ static int usb_dmac_probe(struct platform_device *pdev)
engine->device_tx_status = usb_dmac_tx_status;
engine->device_issue_pending = usb_dmac_issue_pending;
 
-   ret = dma_async_device_register(engine);
+   ret = dmaenginem_async_device_register(engine);
if (ret < 0)
goto error;
 
@@ -879,7 +879,6 @@ static int usb_dmac_remove(struct platform_device *pdev)
for (i = 0; i < dmac->n_channels; ++i)
usb_dmac_chan_remove(dmac, >channels[i]);
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>engine);
 
pm_runtime_disable(>dev);
 
-- 
2.17.1



[PATCH 13/46] dmaengine: sun4i-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister
   remove label err_dma_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/sun4i-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c
index f4ed3f17607c..c80a59c1fc38 100644
--- a/drivers/dma/sun4i-dma.c
+++ b/drivers/dma/sun4i-dma.c
@@ -1228,7 +1228,7 @@ static int sun4i_dma_probe(struct platform_device *pdev)
goto err_clk_disable;
}
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret) {
dev_warn(>dev, "Failed to register DMA engine device\n");
goto err_clk_disable;
@@ -1238,15 +1238,13 @@ static int sun4i_dma_probe(struct platform_device *pdev)
 priv);
if (ret) {
dev_err(>dev, "of_dma_controller_register failed\n");
-   goto err_dma_unregister;
+   goto err_clk_disable;
}
 
dev_dbg(>dev, "Successfully probed SUN4I_DMA\n");
 
return 0;
 
-err_dma_unregister:
-   dma_async_device_unregister(>slave);
 err_clk_disable:
clk_disable_unprepare(priv->clk);
return ret;
@@ -1260,7 +1258,6 @@ static int sun4i_dma_remove(struct platform_device *pdev)
disable_irq(priv->irq);
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>slave);
 
clk_disable_unprepare(priv->clk);
 
-- 
2.17.1



[PATCH 23/46] dmaengine: sa11x0-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/sa11x0-dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/sa11x0-dma.c b/drivers/dma/sa11x0-dma.c
index b31d07c7d93c..9181d6048f43 100644
--- a/drivers/dma/sa11x0-dma.c
+++ b/drivers/dma/sa11x0-dma.c
@@ -863,7 +863,7 @@ static int sa11x0_dma_init_dmadev(struct dma_device *dmadev,
vchan_init(>vc, dmadev);
}
 
-   return dma_async_device_register(dmadev);
+   return dmaenginem_async_device_register(dmadev);
 }
 
 static int sa11x0_dma_request_irq(struct platform_device *pdev, int nr,
@@ -987,8 +987,6 @@ static int sa11x0_dma_remove(struct platform_device *pdev)
struct sa11x0_dma_dev *d = platform_get_drvdata(pdev);
unsigned pch;
 
-   dma_async_device_unregister(>slave);
-
sa11x0_dma_free_channels(>slave);
for (pch = 0; pch < NR_PHY_CHAN; pch++)
sa11x0_dma_free_irq(pdev, pch, >phy[pch]);
-- 
2.17.1



[PATCH 23/46] dmaengine: sa11x0-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/sa11x0-dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/sa11x0-dma.c b/drivers/dma/sa11x0-dma.c
index b31d07c7d93c..9181d6048f43 100644
--- a/drivers/dma/sa11x0-dma.c
+++ b/drivers/dma/sa11x0-dma.c
@@ -863,7 +863,7 @@ static int sa11x0_dma_init_dmadev(struct dma_device *dmadev,
vchan_init(>vc, dmadev);
}
 
-   return dma_async_device_register(dmadev);
+   return dmaenginem_async_device_register(dmadev);
 }
 
 static int sa11x0_dma_request_irq(struct platform_device *pdev, int nr,
@@ -987,8 +987,6 @@ static int sa11x0_dma_remove(struct platform_device *pdev)
struct sa11x0_dma_dev *d = platform_get_drvdata(pdev);
unsigned pch;
 
-   dma_async_device_unregister(>slave);
-
sa11x0_dma_free_channels(>slave);
for (pch = 0; pch < NR_PHY_CHAN; pch++)
sa11x0_dma_free_irq(pdev, pch, >phy[pch]);
-- 
2.17.1



[PATCH 27/46] dmaengine: usb-dmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/sh/usb-dmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index 1bb1a8e09025..c09d7c65c2c5 100644
--- a/drivers/dma/sh/usb-dmac.c
+++ b/drivers/dma/sh/usb-dmac.c
@@ -849,7 +849,7 @@ static int usb_dmac_probe(struct platform_device *pdev)
engine->device_tx_status = usb_dmac_tx_status;
engine->device_issue_pending = usb_dmac_issue_pending;
 
-   ret = dma_async_device_register(engine);
+   ret = dmaenginem_async_device_register(engine);
if (ret < 0)
goto error;
 
@@ -879,7 +879,6 @@ static int usb_dmac_remove(struct platform_device *pdev)
for (i = 0; i < dmac->n_channels; ++i)
usb_dmac_chan_remove(dmac, >channels[i]);
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>engine);
 
pm_runtime_disable(>dev);
 
-- 
2.17.1



[PATCH 13/46] dmaengine: sun4i-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister
   remove label err_dma_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/sun4i-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c
index f4ed3f17607c..c80a59c1fc38 100644
--- a/drivers/dma/sun4i-dma.c
+++ b/drivers/dma/sun4i-dma.c
@@ -1228,7 +1228,7 @@ static int sun4i_dma_probe(struct platform_device *pdev)
goto err_clk_disable;
}
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret) {
dev_warn(>dev, "Failed to register DMA engine device\n");
goto err_clk_disable;
@@ -1238,15 +1238,13 @@ static int sun4i_dma_probe(struct platform_device *pdev)
 priv);
if (ret) {
dev_err(>dev, "of_dma_controller_register failed\n");
-   goto err_dma_unregister;
+   goto err_clk_disable;
}
 
dev_dbg(>dev, "Successfully probed SUN4I_DMA\n");
 
return 0;
 
-err_dma_unregister:
-   dma_async_device_unregister(>slave);
 err_clk_disable:
clk_disable_unprepare(priv->clk);
return ret;
@@ -1260,7 +1258,6 @@ static int sun4i_dma_remove(struct platform_device *pdev)
disable_irq(priv->irq);
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>slave);
 
clk_disable_unprepare(priv->clk);
 
-- 
2.17.1



[PATCH 22/46] dmaengine: sudmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_slave_reg

Signed-off-by: Huang Shijie 
---
 drivers/dma/sh/sudmac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
index 69b9564dc9d9..f861067edef4 100644
--- a/drivers/dma/sh/sudmac.c
+++ b/drivers/dma/sh/sudmac.c
@@ -376,7 +376,7 @@ static int sudmac_probe(struct platform_device *pdev)
goto chan_probe_err;
}
 
-   err = dma_async_device_register(_dev->shdma_dev.dma_dev);
+   err = dmaenginem_async_device_register(_dev->shdma_dev.dma_dev);
if (err < 0)
goto chan_probe_err;
 
@@ -393,9 +393,7 @@ static int sudmac_probe(struct platform_device *pdev)
 static int sudmac_remove(struct platform_device *pdev)
 {
struct sudmac_device *su_dev = platform_get_drvdata(pdev);
-   struct dma_device *dma_dev = _dev->shdma_dev.dma_dev;
 
-   dma_async_device_unregister(dma_dev);
sudmac_chan_remove(su_dev);
shdma_cleanup(_dev->shdma_dev);
 
-- 
2.17.1



[PATCH 15/46] dmaengine: s3c24xx-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_slave_reg

Signed-off-by: Huang Shijie 
---
 drivers/dma/s3c24xx-dma.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
index 64744eb88720..1d820c0cd14b 100644
--- a/drivers/dma/s3c24xx-dma.c
+++ b/drivers/dma/s3c24xx-dma.c
@@ -1330,7 +1330,7 @@ static int s3c24xx_dma_probe(struct platform_device *pdev)
goto err_slave;
}
 
-   ret = dma_async_device_register(>memcpy);
+   ret = dmaenginem_async_device_register(>memcpy);
if (ret) {
dev_warn(>dev,
"%s failed to register memcpy as an async device - 
%d\n",
@@ -1338,12 +1338,12 @@ static int s3c24xx_dma_probe(struct platform_device 
*pdev)
goto err_memcpy_reg;
}
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret) {
dev_warn(>dev,
"%s failed to register slave as an async device - %d\n",
__func__, ret);
-   goto err_slave_reg;
+   goto err_memcpy_reg;
}
 
platform_set_drvdata(pdev, s3cdma);
@@ -1352,8 +1352,6 @@ static int s3c24xx_dma_probe(struct platform_device *pdev)
 
return 0;
 
-err_slave_reg:
-   dma_async_device_unregister(>memcpy);
 err_memcpy_reg:
s3c24xx_dma_free_virtual_channels(>slave);
 err_slave:
@@ -1388,9 +1386,6 @@ static int s3c24xx_dma_remove(struct platform_device 
*pdev)
struct soc_data *sdata = s3c24xx_dma_get_soc_data(pdev);
int i;
 
-   dma_async_device_unregister(>slave);
-   dma_async_device_unregister(>memcpy);
-
s3c24xx_dma_free_irq(pdev, s3cdma);
 
s3c24xx_dma_free_virtual_channels(>slave);
-- 
2.17.1



[PATCH 19/46] dmaengine: sprd-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_of_register

Signed-off-by: Huang Shijie 
---
 drivers/dma/sprd-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 55df0d41355b..d06459d1f96f 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -943,7 +943,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
if (ret < 0)
goto err_rpm;
 
-   ret = dma_async_device_register(>dma_dev);
+   ret = dmaenginem_async_device_register(>dma_dev);
if (ret < 0) {
dev_err(>dev, "register dma device failed:%d\n", ret);
goto err_register;
@@ -953,13 +953,11 @@ static int sprd_dma_probe(struct platform_device *pdev)
ret = of_dma_controller_register(np, of_dma_simple_xlate,
 _dma_info);
if (ret)
-   goto err_of_register;
+   goto err_register;
 
pm_runtime_put(>dev);
return 0;
 
-err_of_register:
-   dma_async_device_unregister(>dma_dev);
 err_register:
pm_runtime_put_noidle(>dev);
pm_runtime_disable(>dev);
@@ -989,7 +987,6 @@ static int sprd_dma_remove(struct platform_device *pdev)
}
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma_dev);
sprd_dma_disable(sdev);
 
pm_runtime_put_noidle(>dev);
-- 
2.17.1



[PATCH 16/46] dmaengine: ste_dma40: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label unregister_slave, unregister_memcpy

Signed-off-by: Huang Shijie 
---
 drivers/dma/ste_dma40.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index f4edfc56f34e..5e328bd10c27 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2839,7 +2839,7 @@ static int __init d40_dmaengine_init(struct d40_base 
*base,
 
d40_ops_init(base, >dma_slave);
 
-   err = dma_async_device_register(>dma_slave);
+   err = dmaenginem_async_device_register(>dma_slave);
 
if (err) {
d40_err(base->dev, "Failed to register slave channels\n");
@@ -2854,12 +2854,12 @@ static int __init d40_dmaengine_init(struct d40_base 
*base,
 
d40_ops_init(base, >dma_memcpy);
 
-   err = dma_async_device_register(>dma_memcpy);
+   err = dmaenginem_async_device_register(>dma_memcpy);
 
if (err) {
d40_err(base->dev,
"Failed to register memcpy only channels\n");
-   goto unregister_slave;
+   goto exit;
}
 
d40_chan_init(base, >dma_both, base->phy_chans,
@@ -2871,18 +2871,14 @@ static int __init d40_dmaengine_init(struct d40_base 
*base,
dma_cap_set(DMA_CYCLIC, base->dma_slave.cap_mask);
 
d40_ops_init(base, >dma_both);
-   err = dma_async_device_register(>dma_both);
+   err = dmaenginem_async_device_register(>dma_both);
 
if (err) {
d40_err(base->dev,
"Failed to register logical and physical capable 
channels\n");
-   goto unregister_memcpy;
+   goto exit;
}
return 0;
- unregister_memcpy:
-   dma_async_device_unregister(>dma_memcpy);
- unregister_slave:
-   dma_async_device_unregister(>dma_slave);
  exit:
return err;
 }
-- 
2.17.1



[PATCH 16/46] dmaengine: ste_dma40: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label unregister_slave, unregister_memcpy

Signed-off-by: Huang Shijie 
---
 drivers/dma/ste_dma40.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index f4edfc56f34e..5e328bd10c27 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2839,7 +2839,7 @@ static int __init d40_dmaengine_init(struct d40_base 
*base,
 
d40_ops_init(base, >dma_slave);
 
-   err = dma_async_device_register(>dma_slave);
+   err = dmaenginem_async_device_register(>dma_slave);
 
if (err) {
d40_err(base->dev, "Failed to register slave channels\n");
@@ -2854,12 +2854,12 @@ static int __init d40_dmaengine_init(struct d40_base 
*base,
 
d40_ops_init(base, >dma_memcpy);
 
-   err = dma_async_device_register(>dma_memcpy);
+   err = dmaenginem_async_device_register(>dma_memcpy);
 
if (err) {
d40_err(base->dev,
"Failed to register memcpy only channels\n");
-   goto unregister_slave;
+   goto exit;
}
 
d40_chan_init(base, >dma_both, base->phy_chans,
@@ -2871,18 +2871,14 @@ static int __init d40_dmaengine_init(struct d40_base 
*base,
dma_cap_set(DMA_CYCLIC, base->dma_slave.cap_mask);
 
d40_ops_init(base, >dma_both);
-   err = dma_async_device_register(>dma_both);
+   err = dmaenginem_async_device_register(>dma_both);
 
if (err) {
d40_err(base->dev,
"Failed to register logical and physical capable 
channels\n");
-   goto unregister_memcpy;
+   goto exit;
}
return 0;
- unregister_memcpy:
-   dma_async_device_unregister(>dma_memcpy);
- unregister_slave:
-   dma_async_device_unregister(>dma_slave);
  exit:
return err;
 }
-- 
2.17.1



[PATCH 22/46] dmaengine: sudmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_slave_reg

Signed-off-by: Huang Shijie 
---
 drivers/dma/sh/sudmac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
index 69b9564dc9d9..f861067edef4 100644
--- a/drivers/dma/sh/sudmac.c
+++ b/drivers/dma/sh/sudmac.c
@@ -376,7 +376,7 @@ static int sudmac_probe(struct platform_device *pdev)
goto chan_probe_err;
}
 
-   err = dma_async_device_register(_dev->shdma_dev.dma_dev);
+   err = dmaenginem_async_device_register(_dev->shdma_dev.dma_dev);
if (err < 0)
goto chan_probe_err;
 
@@ -393,9 +393,7 @@ static int sudmac_probe(struct platform_device *pdev)
 static int sudmac_remove(struct platform_device *pdev)
 {
struct sudmac_device *su_dev = platform_get_drvdata(pdev);
-   struct dma_device *dma_dev = _dev->shdma_dev.dma_dev;
 
-   dma_async_device_unregister(dma_dev);
sudmac_chan_remove(su_dev);
shdma_cleanup(_dev->shdma_dev);
 
-- 
2.17.1



[PATCH 15/46] dmaengine: s3c24xx-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_slave_reg

Signed-off-by: Huang Shijie 
---
 drivers/dma/s3c24xx-dma.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
index 64744eb88720..1d820c0cd14b 100644
--- a/drivers/dma/s3c24xx-dma.c
+++ b/drivers/dma/s3c24xx-dma.c
@@ -1330,7 +1330,7 @@ static int s3c24xx_dma_probe(struct platform_device *pdev)
goto err_slave;
}
 
-   ret = dma_async_device_register(>memcpy);
+   ret = dmaenginem_async_device_register(>memcpy);
if (ret) {
dev_warn(>dev,
"%s failed to register memcpy as an async device - 
%d\n",
@@ -1338,12 +1338,12 @@ static int s3c24xx_dma_probe(struct platform_device 
*pdev)
goto err_memcpy_reg;
}
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret) {
dev_warn(>dev,
"%s failed to register slave as an async device - %d\n",
__func__, ret);
-   goto err_slave_reg;
+   goto err_memcpy_reg;
}
 
platform_set_drvdata(pdev, s3cdma);
@@ -1352,8 +1352,6 @@ static int s3c24xx_dma_probe(struct platform_device *pdev)
 
return 0;
 
-err_slave_reg:
-   dma_async_device_unregister(>memcpy);
 err_memcpy_reg:
s3c24xx_dma_free_virtual_channels(>slave);
 err_slave:
@@ -1388,9 +1386,6 @@ static int s3c24xx_dma_remove(struct platform_device 
*pdev)
struct soc_data *sdata = s3c24xx_dma_get_soc_data(pdev);
int i;
 
-   dma_async_device_unregister(>slave);
-   dma_async_device_unregister(>memcpy);
-
s3c24xx_dma_free_irq(pdev, s3cdma);
 
s3c24xx_dma_free_virtual_channels(>slave);
-- 
2.17.1



[PATCH 19/46] dmaengine: sprd-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_of_register

Signed-off-by: Huang Shijie 
---
 drivers/dma/sprd-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 55df0d41355b..d06459d1f96f 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -943,7 +943,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
if (ret < 0)
goto err_rpm;
 
-   ret = dma_async_device_register(>dma_dev);
+   ret = dmaenginem_async_device_register(>dma_dev);
if (ret < 0) {
dev_err(>dev, "register dma device failed:%d\n", ret);
goto err_register;
@@ -953,13 +953,11 @@ static int sprd_dma_probe(struct platform_device *pdev)
ret = of_dma_controller_register(np, of_dma_simple_xlate,
 _dma_info);
if (ret)
-   goto err_of_register;
+   goto err_register;
 
pm_runtime_put(>dev);
return 0;
 
-err_of_register:
-   dma_async_device_unregister(>dma_dev);
 err_register:
pm_runtime_put_noidle(>dev);
pm_runtime_disable(>dev);
@@ -989,7 +987,6 @@ static int sprd_dma_remove(struct platform_device *pdev)
}
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma_dev);
sprd_dma_disable(sdev);
 
pm_runtime_put_noidle(>dev);
-- 
2.17.1



[PATCH 31/46] dmaengine: moxart-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/moxart-dma.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/dma/moxart-dma.c b/drivers/dma/moxart-dma.c
index e04499c1f27f..80bff27c5f9b 100644
--- a/drivers/dma/moxart-dma.c
+++ b/drivers/dma/moxart-dma.c
@@ -618,7 +618,7 @@ static int moxart_probe(struct platform_device *pdev)
}
mdc->irq = irq;
 
-   ret = dma_async_device_register(>dma_slave);
+   ret = dmaenginem_async_device_register(>dma_slave);
if (ret) {
dev_err(dev, "dma_async_device_register failed\n");
return ret;
@@ -627,7 +627,6 @@ static int moxart_probe(struct platform_device *pdev)
ret = of_dma_controller_register(node, moxart_of_xlate, mdc);
if (ret) {
dev_err(dev, "of_dma_controller_register failed\n");
-   dma_async_device_unregister(>dma_slave);
return ret;
}
 
@@ -642,8 +641,6 @@ static int moxart_remove(struct platform_device *pdev)
 
devm_free_irq(>dev, m->irq, m);
 
-   dma_async_device_unregister(>dma_slave);
-
if (pdev->dev.of_node)
of_dma_controller_free(pdev->dev.of_node);
 
-- 
2.17.1



[PATCH 18/46] dmaengine: stm32-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/stm32-dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 379e8d534e61..6bbb3fab4f13 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -1295,7 +1295,7 @@ static int stm32_dma_probe(struct platform_device *pdev)
vchan_init(>vchan, dd);
}
 
-   ret = dma_async_device_register(dd);
+   ret = dmaenginem_async_device_register(dd);
if (ret)
return ret;
 
@@ -1334,7 +1334,6 @@ static int stm32_dma_probe(struct platform_device *pdev)
return 0;
 
 err_unregister:
-   dma_async_device_unregister(dd);
 
return ret;
 }
-- 
2.17.1



[PATCH 34/46] dmaengine: mxs-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/mxs-dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index ae5182ff0128..35193b31a9e0 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -847,7 +847,7 @@ static int __init mxs_dma_probe(struct platform_device 
*pdev)
mxs_dma->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
mxs_dma->dma_device.device_issue_pending = mxs_dma_enable_chan;
 
-   ret = dma_async_device_register(_dma->dma_device);
+   ret = dmaenginem_async_device_register(_dma->dma_device);
if (ret) {
dev_err(mxs_dma->dma_device.dev, "unable to register\n");
return ret;
@@ -857,7 +857,6 @@ static int __init mxs_dma_probe(struct platform_device 
*pdev)
if (ret) {
dev_err(mxs_dma->dma_device.dev,
"failed to register controller\n");
-   dma_async_device_unregister(_dma->dma_device);
}
 
dev_info(mxs_dma->dma_device.dev, "initialized\n");
-- 
2.17.1



[PATCH 31/46] dmaengine: moxart-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/moxart-dma.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/dma/moxart-dma.c b/drivers/dma/moxart-dma.c
index e04499c1f27f..80bff27c5f9b 100644
--- a/drivers/dma/moxart-dma.c
+++ b/drivers/dma/moxart-dma.c
@@ -618,7 +618,7 @@ static int moxart_probe(struct platform_device *pdev)
}
mdc->irq = irq;
 
-   ret = dma_async_device_register(>dma_slave);
+   ret = dmaenginem_async_device_register(>dma_slave);
if (ret) {
dev_err(dev, "dma_async_device_register failed\n");
return ret;
@@ -627,7 +627,6 @@ static int moxart_probe(struct platform_device *pdev)
ret = of_dma_controller_register(node, moxart_of_xlate, mdc);
if (ret) {
dev_err(dev, "of_dma_controller_register failed\n");
-   dma_async_device_unregister(>dma_slave);
return ret;
}
 
@@ -642,8 +641,6 @@ static int moxart_remove(struct platform_device *pdev)
 
devm_free_irq(>dev, m->irq, m);
 
-   dma_async_device_unregister(>dma_slave);
-
if (pdev->dev.of_node)
of_dma_controller_free(pdev->dev.of_node);
 
-- 
2.17.1



[PATCH 18/46] dmaengine: stm32-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/stm32-dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 379e8d534e61..6bbb3fab4f13 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -1295,7 +1295,7 @@ static int stm32_dma_probe(struct platform_device *pdev)
vchan_init(>vchan, dd);
}
 
-   ret = dma_async_device_register(dd);
+   ret = dmaenginem_async_device_register(dd);
if (ret)
return ret;
 
@@ -1334,7 +1334,6 @@ static int stm32_dma_probe(struct platform_device *pdev)
return 0;
 
 err_unregister:
-   dma_async_device_unregister(dd);
 
return ret;
 }
-- 
2.17.1



[PATCH 34/46] dmaengine: mxs-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/mxs-dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index ae5182ff0128..35193b31a9e0 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -847,7 +847,7 @@ static int __init mxs_dma_probe(struct platform_device 
*pdev)
mxs_dma->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
mxs_dma->dma_device.device_issue_pending = mxs_dma_enable_chan;
 
-   ret = dma_async_device_register(_dma->dma_device);
+   ret = dmaenginem_async_device_register(_dma->dma_device);
if (ret) {
dev_err(mxs_dma->dma_device.dev, "unable to register\n");
return ret;
@@ -857,7 +857,6 @@ static int __init mxs_dma_probe(struct platform_device 
*pdev)
if (ret) {
dev_err(mxs_dma->dma_device.dev,
"failed to register controller\n");
-   dma_async_device_unregister(_dma->dma_device);
}
 
dev_info(mxs_dma->dma_device.dev, "initialized\n");
-- 
2.17.1



[PATCH 39/46] dmaengine: img-mdc-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister
remove label unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/img-mdc-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c
index 25cec9c243e1..1e555ac62b1e 100644
--- a/drivers/dma/img-mdc-dma.c
+++ b/drivers/dma/img-mdc-dma.c
@@ -1001,21 +1001,19 @@ static int mdc_dma_probe(struct platform_device *pdev)
return ret;
}
 
-   ret = dma_async_device_register(>dma_dev);
+   ret = dmaenginem_async_device_register(>dma_dev);
if (ret)
goto suspend;
 
ret = of_dma_controller_register(pdev->dev.of_node, mdc_of_xlate, mdma);
if (ret)
-   goto unregister;
+   goto suspend;
 
dev_info(>dev, "MDC with %u channels and %u threads\n",
 mdma->nr_channels, mdma->nr_threads);
 
return 0;
 
-unregister:
-   dma_async_device_unregister(>dma_dev);
 suspend:
if (!pm_runtime_enabled(>dev))
img_mdc_runtime_suspend(>dev);
@@ -1029,7 +1027,6 @@ static int mdc_dma_remove(struct platform_device *pdev)
struct mdc_chan *mchan, *next;
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma_dev);
 
list_for_each_entry_safe(mchan, next, >dma_dev.channels,
 vc.chan.device_node) {
-- 
2.17.1



[PATCH 39/46] dmaengine: img-mdc-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister
remove label unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/img-mdc-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c
index 25cec9c243e1..1e555ac62b1e 100644
--- a/drivers/dma/img-mdc-dma.c
+++ b/drivers/dma/img-mdc-dma.c
@@ -1001,21 +1001,19 @@ static int mdc_dma_probe(struct platform_device *pdev)
return ret;
}
 
-   ret = dma_async_device_register(>dma_dev);
+   ret = dmaenginem_async_device_register(>dma_dev);
if (ret)
goto suspend;
 
ret = of_dma_controller_register(pdev->dev.of_node, mdc_of_xlate, mdma);
if (ret)
-   goto unregister;
+   goto suspend;
 
dev_info(>dev, "MDC with %u channels and %u threads\n",
 mdma->nr_channels, mdma->nr_threads);
 
return 0;
 
-unregister:
-   dma_async_device_unregister(>dma_dev);
 suspend:
if (!pm_runtime_enabled(>dev))
img_mdc_runtime_suspend(>dev);
@@ -1029,7 +1027,6 @@ static int mdc_dma_remove(struct platform_device *pdev)
struct mdc_chan *mchan, *next;
 
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma_dev);
 
list_for_each_entry_safe(mchan, next, >dma_dev.channels,
 vc.chan.device_node) {
-- 
2.17.1



[PATCH 37/46] dmaengine: imx-sdma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_register

Signed-off-by: Huang Shijie 
---
 drivers/dma/imx-sdma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index b4ec2d20e661..3ee28d044e3c 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2062,7 +2062,7 @@ static int sdma_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, sdma);
 
-   ret = dma_async_device_register(>dma_device);
+   ret = dmaenginem_async_device_register(>dma_device);
if (ret) {
dev_err(>dev, "unable to register\n");
goto err_init;
@@ -2072,7 +2072,7 @@ static int sdma_probe(struct platform_device *pdev)
ret = of_dma_controller_register(np, sdma_xlate, sdma);
if (ret) {
dev_err(>dev, "failed to register controller\n");
-   goto err_register;
+   goto err_init;
}
 
spba_bus = of_find_compatible_node(NULL, NULL, "fsl,spba-bus");
@@ -2086,8 +2086,6 @@ static int sdma_probe(struct platform_device *pdev)
 
return 0;
 
-err_register:
-   dma_async_device_unregister(>dma_device);
 err_init:
kfree(sdma->script_addrs);
 err_irq:
@@ -2103,7 +2101,6 @@ static int sdma_remove(struct platform_device *pdev)
int i;
 
devm_free_irq(>dev, sdma->irq, sdma);
-   dma_async_device_unregister(>dma_device);
kfree(sdma->script_addrs);
clk_unprepare(sdma->clk_ahb);
clk_unprepare(sdma->clk_ipg);
-- 
2.17.1



[PATCH 38/46] dmaengine: imx-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_of_dma_controller

Signed-off-by: Huang Shijie 
---
 drivers/dma/imx-dma.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index 75b6ff0415ee..d651fbea77ee 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -1186,7 +1186,7 @@ static int __init imxdma_probe(struct platform_device 
*pdev)
imxdma->dma_device.dev->dma_parms = >dma_parms;
dma_set_max_seg_size(imxdma->dma_device.dev, 0xff);
 
-   ret = dma_async_device_register(>dma_device);
+   ret = dmaenginem_async_device_register(>dma_device);
if (ret) {
dev_err(>dev, "unable to register\n");
goto disable_dma_ahb_clk;
@@ -1197,14 +1197,12 @@ static int __init imxdma_probe(struct platform_device 
*pdev)
imxdma_xlate, imxdma);
if (ret) {
dev_err(>dev, "unable to register 
of_dma_controller\n");
-   goto err_of_dma_controller;
+   goto disable_dma_ahb_clk;
}
}
 
return 0;
 
-err_of_dma_controller:
-   dma_async_device_unregister(>dma_device);
 disable_dma_ahb_clk:
clk_disable_unprepare(imxdma->dma_ahb);
 disable_dma_ipg_clk:
@@ -1237,8 +1235,6 @@ static int imxdma_remove(struct platform_device *pdev)
 
imxdma_free_irq(pdev, imxdma);
 
-dma_async_device_unregister(>dma_device);
-
if (pdev->dev.of_node)
of_dma_controller_free(pdev->dev.of_node);
 
-- 
2.17.1



[PATCH 37/46] dmaengine: imx-sdma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_register

Signed-off-by: Huang Shijie 
---
 drivers/dma/imx-sdma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index b4ec2d20e661..3ee28d044e3c 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2062,7 +2062,7 @@ static int sdma_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, sdma);
 
-   ret = dma_async_device_register(>dma_device);
+   ret = dmaenginem_async_device_register(>dma_device);
if (ret) {
dev_err(>dev, "unable to register\n");
goto err_init;
@@ -2072,7 +2072,7 @@ static int sdma_probe(struct platform_device *pdev)
ret = of_dma_controller_register(np, sdma_xlate, sdma);
if (ret) {
dev_err(>dev, "failed to register controller\n");
-   goto err_register;
+   goto err_init;
}
 
spba_bus = of_find_compatible_node(NULL, NULL, "fsl,spba-bus");
@@ -2086,8 +2086,6 @@ static int sdma_probe(struct platform_device *pdev)
 
return 0;
 
-err_register:
-   dma_async_device_unregister(>dma_device);
 err_init:
kfree(sdma->script_addrs);
 err_irq:
@@ -2103,7 +2101,6 @@ static int sdma_remove(struct platform_device *pdev)
int i;
 
devm_free_irq(>dev, sdma->irq, sdma);
-   dma_async_device_unregister(>dma_device);
kfree(sdma->script_addrs);
clk_unprepare(sdma->clk_ahb);
clk_unprepare(sdma->clk_ipg);
-- 
2.17.1



[PATCH 38/46] dmaengine: imx-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_of_dma_controller

Signed-off-by: Huang Shijie 
---
 drivers/dma/imx-dma.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index 75b6ff0415ee..d651fbea77ee 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -1186,7 +1186,7 @@ static int __init imxdma_probe(struct platform_device 
*pdev)
imxdma->dma_device.dev->dma_parms = >dma_parms;
dma_set_max_seg_size(imxdma->dma_device.dev, 0xff);
 
-   ret = dma_async_device_register(>dma_device);
+   ret = dmaenginem_async_device_register(>dma_device);
if (ret) {
dev_err(>dev, "unable to register\n");
goto disable_dma_ahb_clk;
@@ -1197,14 +1197,12 @@ static int __init imxdma_probe(struct platform_device 
*pdev)
imxdma_xlate, imxdma);
if (ret) {
dev_err(>dev, "unable to register 
of_dma_controller\n");
-   goto err_of_dma_controller;
+   goto disable_dma_ahb_clk;
}
}
 
return 0;
 
-err_of_dma_controller:
-   dma_async_device_unregister(>dma_device);
 disable_dma_ahb_clk:
clk_disable_unprepare(imxdma->dma_ahb);
 disable_dma_ipg_clk:
@@ -1237,8 +1235,6 @@ static int imxdma_remove(struct platform_device *pdev)
 
imxdma_free_irq(pdev, imxdma);
 
-dma_async_device_unregister(>dma_device);
-
if (pdev->dev.of_node)
of_dma_controller_free(pdev->dev.of_node);
 
-- 
2.17.1



[PATCH 33/46] dmaengine: pch_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/pch_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index afd8f27bda96..505463d077c0 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -922,7 +922,7 @@ static int pch_dma_probe(struct pci_dev *pdev,
pd->dma.device_prep_slave_sg = pd_prep_slave_sg;
pd->dma.device_terminate_all = pd_device_terminate_all;
 
-   err = dma_async_device_register(>dma);
+   err = dmaenginem_async_device_register(>dma);
if (err) {
dev_err(>dev, "Failed to register DMA device\n");
goto err_free_pool;
@@ -952,8 +952,6 @@ static void pch_dma_remove(struct pci_dev *pdev)
struct dma_chan *chan, *_c;
 
if (pd) {
-   dma_async_device_unregister(>dma);
-
free_irq(pdev->irq, pd);
 
list_for_each_entry_safe(chan, _c, >dma.channels,
-- 
2.17.1



[PATCH 33/46] dmaengine: pch_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/pch_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index afd8f27bda96..505463d077c0 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -922,7 +922,7 @@ static int pch_dma_probe(struct pci_dev *pdev,
pd->dma.device_prep_slave_sg = pd_prep_slave_sg;
pd->dma.device_terminate_all = pd_device_terminate_all;
 
-   err = dma_async_device_register(>dma);
+   err = dmaenginem_async_device_register(>dma);
if (err) {
dev_err(>dev, "Failed to register DMA device\n");
goto err_free_pool;
@@ -952,8 +952,6 @@ static void pch_dma_remove(struct pci_dev *pdev)
struct dma_chan *chan, *_c;
 
if (pd) {
-   dma_async_device_unregister(>dma);
-
free_irq(pdev->irq, pd);
 
list_for_each_entry_safe(chan, _c, >dma.channels,
-- 
2.17.1



[PATCH 42/46] dmaengine: at_xdmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_dma_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/at_xdmac.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 4bf72561667c..c220f667be80 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -2041,7 +2041,7 @@ static int at_xdmac_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, atxdmac);
 
-   ret = dma_async_device_register(>dma);
+   ret = dmaenginem_async_device_register(>dma);
if (ret) {
dev_err(>dev, "fail to register DMA engine device\n");
goto err_clk_disable;
@@ -2051,7 +2051,7 @@ static int at_xdmac_probe(struct platform_device *pdev)
 at_xdmac_xlate, atxdmac);
if (ret) {
dev_err(>dev, "could not register of dma controller\n");
-   goto err_dma_unregister;
+   goto err_clk_disable;
}
 
dev_info(>dev, "%d channels, mapped at 0x%p\n",
@@ -2059,8 +2059,6 @@ static int at_xdmac_probe(struct platform_device *pdev)
 
return 0;
 
-err_dma_unregister:
-   dma_async_device_unregister(>dma);
 err_clk_disable:
clk_disable_unprepare(atxdmac->clk);
 err_free_irq:
@@ -2075,7 +2073,6 @@ static int at_xdmac_remove(struct platform_device *pdev)
 
at_xdmac_off(atxdmac);
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma);
clk_disable_unprepare(atxdmac->clk);
 
free_irq(atxdmac->irq, atxdmac);
-- 
2.17.1



[PATCH 42/46] dmaengine: at_xdmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_dma_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/at_xdmac.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 4bf72561667c..c220f667be80 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -2041,7 +2041,7 @@ static int at_xdmac_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, atxdmac);
 
-   ret = dma_async_device_register(>dma);
+   ret = dmaenginem_async_device_register(>dma);
if (ret) {
dev_err(>dev, "fail to register DMA engine device\n");
goto err_clk_disable;
@@ -2051,7 +2051,7 @@ static int at_xdmac_probe(struct platform_device *pdev)
 at_xdmac_xlate, atxdmac);
if (ret) {
dev_err(>dev, "could not register of dma controller\n");
-   goto err_dma_unregister;
+   goto err_clk_disable;
}
 
dev_info(>dev, "%d channels, mapped at 0x%p\n",
@@ -2059,8 +2059,6 @@ static int at_xdmac_probe(struct platform_device *pdev)
 
return 0;
 
-err_dma_unregister:
-   dma_async_device_unregister(>dma);
 err_clk_disable:
clk_disable_unprepare(atxdmac->clk);
 err_free_irq:
@@ -2075,7 +2073,6 @@ static int at_xdmac_remove(struct platform_device *pdev)
 
at_xdmac_off(atxdmac);
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>dma);
clk_disable_unprepare(atxdmac->clk);
 
free_irq(atxdmac->irq, atxdmac);
-- 
2.17.1



[PATCH 32/46] dmaengine: pl330: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/pl330.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 88750a34e859..e4bc330132c7 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -3037,7 +3037,7 @@ pl330_probe(struct amba_device *adev, const struct 
amba_id *id)
pd->max_burst = ((pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) ?
 1 : PL330_MAX_BURST);
 
-   ret = dma_async_device_register(pd);
+   ret = dmaenginem_async_device_register(pd);
if (ret) {
dev_err(>dev, "unable to register DMAC\n");
goto probe_err3;
@@ -3114,8 +3114,6 @@ static int pl330_remove(struct amba_device *adev)
devm_free_irq(>dev, irq, pl330);
}
 
-   dma_async_device_unregister(>ddma);
-
/* Idle the DMAC */
list_for_each_entry_safe(pch, _p, >ddma.channels,
chan.device_node) {
-- 
2.17.1



[PATCH 36/46] dmaengine: k3dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label of_dma_register_fail

Signed-off-by: Huang Shijie 
---
 drivers/dma/k3dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 6bfa217ed6d0..5d9ab35b982d 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -902,14 +902,14 @@ static int k3_dma_probe(struct platform_device *op)
 
k3_dma_enable_dma(d, true);
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret)
goto dma_async_register_fail;
 
ret = of_dma_controller_register((>dev)->of_node,
k3_of_dma_simple_xlate, d);
if (ret)
-   goto of_dma_register_fail;
+   goto dma_async_register_fail;
 
spin_lock_init(>lock);
INIT_LIST_HEAD(>chan_pending);
@@ -919,8 +919,6 @@ static int k3_dma_probe(struct platform_device *op)
 
return 0;
 
-of_dma_register_fail:
-   dma_async_device_unregister(>slave);
 dma_async_register_fail:
clk_disable_unprepare(d->clk);
return ret;
@@ -931,7 +929,6 @@ static int k3_dma_remove(struct platform_device *op)
struct k3_dma_chan *c, *cn;
struct k3_dma_dev *d = platform_get_drvdata(op);
 
-   dma_async_device_unregister(>slave);
of_dma_controller_free((>dev)->of_node);
 
devm_free_irq(>dev, d->irq, d);
-- 
2.17.1



[PATCH 30/46] dmaengine: pxa_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/pxa_dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b31c28b67ad3..21001ea078fb 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -1285,7 +1285,6 @@ static int pxad_remove(struct platform_device *op)
 
pxad_cleanup_debugfs(pdev);
pxad_free_channels(>slave);
-   dma_async_device_unregister(>slave);
return 0;
 }
 
@@ -1396,7 +1395,7 @@ static int pxad_init_dmadev(struct platform_device *op,
init_waitqueue_head(>wq_state);
}
 
-   return dma_async_device_register(>slave);
+   return dmaenginem_async_device_register(>slave);
 }
 
 static int pxad_probe(struct platform_device *op)
-- 
2.17.1



[PATCH 40/46] dmaengine: fsl-edma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/fsl-edma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
index c7568869284e..f475efce1d60 100644
--- a/drivers/dma/fsl-edma.c
+++ b/drivers/dma/fsl-edma.c
@@ -972,7 +972,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, fsl_edma);
 
-   ret = dma_async_device_register(_edma->dma_dev);
+   ret = dmaenginem_async_device_register(_edma->dma_dev);
if (ret) {
dev_err(>dev,
"Can't register Freescale eDMA engine. (%d)\n", ret);
@@ -984,7 +984,6 @@ static int fsl_edma_probe(struct platform_device *pdev)
if (ret) {
dev_err(>dev,
"Can't register Freescale eDMA of_dma. (%d)\n", ret);
-   dma_async_device_unregister(_edma->dma_dev);
fsl_disable_clocks(fsl_edma, DMAMUX_NR);
return ret;
}
@@ -1014,7 +1013,6 @@ static int fsl_edma_remove(struct platform_device *pdev)
fsl_edma_irq_exit(pdev, fsl_edma);
fsl_edma_cleanup_vchan(_edma->dma_dev);
of_dma_controller_free(np);
-   dma_async_device_unregister(_edma->dma_dev);
fsl_disable_clocks(fsl_edma, DMAMUX_NR);
 
return 0;
-- 
2.17.1



[PATCH 36/46] dmaengine: k3dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label of_dma_register_fail

Signed-off-by: Huang Shijie 
---
 drivers/dma/k3dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 6bfa217ed6d0..5d9ab35b982d 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -902,14 +902,14 @@ static int k3_dma_probe(struct platform_device *op)
 
k3_dma_enable_dma(d, true);
 
-   ret = dma_async_device_register(>slave);
+   ret = dmaenginem_async_device_register(>slave);
if (ret)
goto dma_async_register_fail;
 
ret = of_dma_controller_register((>dev)->of_node,
k3_of_dma_simple_xlate, d);
if (ret)
-   goto of_dma_register_fail;
+   goto dma_async_register_fail;
 
spin_lock_init(>lock);
INIT_LIST_HEAD(>chan_pending);
@@ -919,8 +919,6 @@ static int k3_dma_probe(struct platform_device *op)
 
return 0;
 
-of_dma_register_fail:
-   dma_async_device_unregister(>slave);
 dma_async_register_fail:
clk_disable_unprepare(d->clk);
return ret;
@@ -931,7 +929,6 @@ static int k3_dma_remove(struct platform_device *op)
struct k3_dma_chan *c, *cn;
struct k3_dma_dev *d = platform_get_drvdata(op);
 
-   dma_async_device_unregister(>slave);
of_dma_controller_free((>dev)->of_node);
 
devm_free_irq(>dev, d->irq, d);
-- 
2.17.1



[PATCH 30/46] dmaengine: pxa_dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/pxa_dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b31c28b67ad3..21001ea078fb 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -1285,7 +1285,6 @@ static int pxad_remove(struct platform_device *op)
 
pxad_cleanup_debugfs(pdev);
pxad_free_channels(>slave);
-   dma_async_device_unregister(>slave);
return 0;
 }
 
@@ -1396,7 +1395,7 @@ static int pxad_init_dmadev(struct platform_device *op,
init_waitqueue_head(>wq_state);
}
 
-   return dma_async_device_register(>slave);
+   return dmaenginem_async_device_register(>slave);
 }
 
 static int pxad_probe(struct platform_device *op)
-- 
2.17.1



[PATCH 40/46] dmaengine: fsl-edma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/fsl-edma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
index c7568869284e..f475efce1d60 100644
--- a/drivers/dma/fsl-edma.c
+++ b/drivers/dma/fsl-edma.c
@@ -972,7 +972,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, fsl_edma);
 
-   ret = dma_async_device_register(_edma->dma_dev);
+   ret = dmaenginem_async_device_register(_edma->dma_dev);
if (ret) {
dev_err(>dev,
"Can't register Freescale eDMA engine. (%d)\n", ret);
@@ -984,7 +984,6 @@ static int fsl_edma_probe(struct platform_device *pdev)
if (ret) {
dev_err(>dev,
"Can't register Freescale eDMA of_dma. (%d)\n", ret);
-   dma_async_device_unregister(_edma->dma_dev);
fsl_disable_clocks(fsl_edma, DMAMUX_NR);
return ret;
}
@@ -1014,7 +1013,6 @@ static int fsl_edma_remove(struct platform_device *pdev)
fsl_edma_irq_exit(pdev, fsl_edma);
fsl_edma_cleanup_vchan(_edma->dma_dev);
of_dma_controller_free(np);
-   dma_async_device_unregister(_edma->dma_dev);
fsl_disable_clocks(fsl_edma, DMAMUX_NR);
 
return 0;
-- 
2.17.1



[PATCH 32/46] dmaengine: pl330: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/pl330.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 88750a34e859..e4bc330132c7 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -3037,7 +3037,7 @@ pl330_probe(struct amba_device *adev, const struct 
amba_id *id)
pd->max_burst = ((pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP) ?
 1 : PL330_MAX_BURST);
 
-   ret = dma_async_device_register(pd);
+   ret = dmaenginem_async_device_register(pd);
if (ret) {
dev_err(>dev, "unable to register DMAC\n");
goto probe_err3;
@@ -3114,8 +3114,6 @@ static int pl330_remove(struct amba_device *adev)
devm_free_irq(>dev, irq, pl330);
}
 
-   dma_async_device_unregister(>ddma);
-
/* Idle the DMAC */
list_for_each_entry_safe(pch, _p, >ddma.channels,
chan.device_node) {
-- 
2.17.1



[PATCH 45/46] dmaengine: dma-axi-dmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_unregister_device

Signed-off-by: Huang Shijie 
---
 drivers/dma/dma-axi-dmac.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
index 15b2453d2647..d510184762e6 100644
--- a/drivers/dma/dma-axi-dmac.c
+++ b/drivers/dma/dma-axi-dmac.c
@@ -678,14 +678,14 @@ static int axi_dmac_probe(struct platform_device *pdev)
 
axi_dmac_write(dmac, AXI_DMAC_REG_IRQ_MASK, 0x00);
 
-   ret = dma_async_device_register(dma_dev);
+   ret = dmaenginem_async_device_register(dma_dev);
if (ret)
goto err_clk_disable;
 
ret = of_dma_controller_register(pdev->dev.of_node,
of_dma_xlate_by_chan_id, dma_dev);
if (ret)
-   goto err_unregister_device;
+   goto err_clk_disable;
 
ret = request_irq(dmac->irq, axi_dmac_interrupt_handler, IRQF_SHARED,
dev_name(>dev), dmac);
@@ -698,8 +698,6 @@ static int axi_dmac_probe(struct platform_device *pdev)
 
 err_unregister_of:
of_dma_controller_free(pdev->dev.of_node);
-err_unregister_device:
-   dma_async_device_unregister(>dma_dev);
 err_clk_disable:
clk_disable_unprepare(dmac->clk);
 
@@ -713,7 +711,6 @@ static int axi_dmac_remove(struct platform_device *pdev)
of_dma_controller_free(pdev->dev.of_node);
free_irq(dmac->irq, dmac);
tasklet_kill(>chan.vchan.task);
-   dma_async_device_unregister(>dma_dev);
clk_disable_unprepare(dmac->clk);
 
return 0;
-- 
2.17.1



[PATCH 20/46] dmaengine: sirf-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label unreg_dma_dev

Signed-off-by: Huang Shijie 
---
 drivers/dma/sirf-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index a0733ac3edb1..de19880d4254 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -944,7 +944,7 @@ static int sirfsoc_dma_probe(struct platform_device *op)
/* Register DMA engine */
dev_set_drvdata(dev, sdma);
 
-   ret = dma_async_device_register(dma);
+   ret = dmaenginem_async_device_register(dma);
if (ret)
goto free_irq;
 
@@ -952,7 +952,7 @@ static int sirfsoc_dma_probe(struct platform_device *op)
ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma);
if (ret) {
dev_err(dev, "failed to register DMA controller\n");
-   goto unreg_dma_dev;
+   goto free_irq;
}
 
pm_runtime_enable(>dev);
@@ -960,8 +960,6 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 
return 0;
 
-unreg_dma_dev:
-   dma_async_device_unregister(dma);
 free_irq:
free_irq(sdma->irq, sdma);
 irq_dispose:
@@ -975,7 +973,6 @@ static int sirfsoc_dma_remove(struct platform_device *op)
struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
 
of_dma_controller_free(op->dev.of_node);
-   dma_async_device_unregister(>dma);
free_irq(sdma->irq, sdma);
tasklet_kill(>tasklet);
irq_dispose_mapping(sdma->irq);
-- 
2.17.1



[PATCH 45/46] dmaengine: dma-axi-dmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label err_unregister_device

Signed-off-by: Huang Shijie 
---
 drivers/dma/dma-axi-dmac.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
index 15b2453d2647..d510184762e6 100644
--- a/drivers/dma/dma-axi-dmac.c
+++ b/drivers/dma/dma-axi-dmac.c
@@ -678,14 +678,14 @@ static int axi_dmac_probe(struct platform_device *pdev)
 
axi_dmac_write(dmac, AXI_DMAC_REG_IRQ_MASK, 0x00);
 
-   ret = dma_async_device_register(dma_dev);
+   ret = dmaenginem_async_device_register(dma_dev);
if (ret)
goto err_clk_disable;
 
ret = of_dma_controller_register(pdev->dev.of_node,
of_dma_xlate_by_chan_id, dma_dev);
if (ret)
-   goto err_unregister_device;
+   goto err_clk_disable;
 
ret = request_irq(dmac->irq, axi_dmac_interrupt_handler, IRQF_SHARED,
dev_name(>dev), dmac);
@@ -698,8 +698,6 @@ static int axi_dmac_probe(struct platform_device *pdev)
 
 err_unregister_of:
of_dma_controller_free(pdev->dev.of_node);
-err_unregister_device:
-   dma_async_device_unregister(>dma_dev);
 err_clk_disable:
clk_disable_unprepare(dmac->clk);
 
@@ -713,7 +711,6 @@ static int axi_dmac_remove(struct platform_device *pdev)
of_dma_controller_free(pdev->dev.of_node);
free_irq(dmac->irq, dmac);
tasklet_kill(>chan.vchan.task);
-   dma_async_device_unregister(>dma_dev);
clk_disable_unprepare(dmac->clk);
 
return 0;
-- 
2.17.1



[PATCH 20/46] dmaengine: sirf-dma: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.
remove label unreg_dma_dev

Signed-off-by: Huang Shijie 
---
 drivers/dma/sirf-dma.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index a0733ac3edb1..de19880d4254 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -944,7 +944,7 @@ static int sirfsoc_dma_probe(struct platform_device *op)
/* Register DMA engine */
dev_set_drvdata(dev, sdma);
 
-   ret = dma_async_device_register(dma);
+   ret = dmaenginem_async_device_register(dma);
if (ret)
goto free_irq;
 
@@ -952,7 +952,7 @@ static int sirfsoc_dma_probe(struct platform_device *op)
ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma);
if (ret) {
dev_err(dev, "failed to register DMA controller\n");
-   goto unreg_dma_dev;
+   goto free_irq;
}
 
pm_runtime_enable(>dev);
@@ -960,8 +960,6 @@ static int sirfsoc_dma_probe(struct platform_device *op)
 
return 0;
 
-unreg_dma_dev:
-   dma_async_device_unregister(dma);
 free_irq:
free_irq(sdma->irq, sdma);
 irq_dispose:
@@ -975,7 +973,6 @@ static int sirfsoc_dma_remove(struct platform_device *op)
struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
 
of_dma_controller_free(op->dev.of_node);
-   dma_async_device_unregister(>dma);
free_irq(sdma->irq, sdma);
tasklet_kill(>tasklet);
irq_dispose_mapping(sdma->irq);
-- 
2.17.1



[PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
   remove dma_async_device_unregister

Signed-off-by: Huang Shijie 
---
 drivers/dma/ti/cppi41.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
index 1497da367710..d2998a19ed2e 100644
--- a/drivers/dma/ti/cppi41.c
+++ b/drivers/dma/ti/cppi41.c
@@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device 
*pdev)
goto err_chans;
cdd->irq = irq;
 
-   ret = dma_async_device_register(>ddev);
+   ret = dmaenginem_async_device_register(>ddev);
if (ret)
goto err_chans;
 
ret = of_dma_controller_register(dev->of_node,
cppi41_dma_xlate, _dma_info);
if (ret)
-   goto err_of;
+   goto err_chans;
 
pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
 
return 0;
-err_of:
-   dma_async_device_unregister(>ddev);
 err_chans:
deinit_cppi41(dev, cdd);
 err_init_cppi:
@@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
dev_err(>dev, "%s could not pm_runtime_get: %i\n",
__func__, error);
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>ddev);
 
devm_free_irq(>dev, cdd->irq, cdd);
deinit_cppi41(>dev, cdd);
-- 
2.17.1



[PATCH 28/46] dmaengine: rcar-dmac: use dmaenginem_async_device_register to simplify the code

2018-08-03 Thread Huang Shijie
Use dmaenginem_async_device_register to simplify the code:
remove dma_async_device_unregister.

Signed-off-by: Huang Shijie 
---
 drivers/dma/sh/rcar-dmac.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 48ee35e2bce6..87130b3eef5c 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1884,7 +1884,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 *
 * Default transfer size of 32 bytes requires 32-byte alignment.
 */
-   ret = dma_async_device_register(engine);
+   ret = dmaenginem_async_device_register(engine);
if (ret < 0)
goto error;
 
@@ -1898,10 +1898,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 
 static int rcar_dmac_remove(struct platform_device *pdev)
 {
-   struct rcar_dmac *dmac = platform_get_drvdata(pdev);
-
of_dma_controller_free(pdev->dev.of_node);
-   dma_async_device_unregister(>engine);
 
pm_runtime_disable(>dev);
 
-- 
2.17.1



  1   2   3   4   5   6   7   8   9   >