[PATCH] staging: octeon-usb: use __delay() instead of cvmx_wait()

2017-11-17 Thread Aaro Koskinen
Commit edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait()
everywhere.") deleted cvmx_wait() but forgot to update OCTEON USB
staging driver. Fix that to allow driver build.

Fixes: edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait() everywhere.")
Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/octeon-hcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/octeon-usb/octeon-hcd.c 
b/drivers/staging/octeon-usb/octeon-hcd.c
index 068aece..cded30f 100644
--- a/drivers/staging/octeon-usb/octeon-hcd.c
+++ b/drivers/staging/octeon-usb/octeon-hcd.c
@@ -394,7 +394,7 @@ struct octeon_hcd {
result = -1;\
break;  \
} else  \
-   cvmx_wait(100); \
+   __delay(100);   \
}   \
} while (0);\
result; })
@@ -774,7 +774,7 @@ static int cvmx_usb_initialize(struct device *dev,
usbn_clk_ctl.s.hclk_rst = 1;
cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
/* 2e.  Wait 64 core-clock cycles for HCLK to stabilize */
-   cvmx_wait(64);
+   __delay(64);
/*
 * 3. Program the power-on reset field in the USBN clock-control
 *register:
@@ -795,7 +795,7 @@ static int cvmx_usb_initialize(struct device *dev,
cvmx_write64_uint64(CVMX_USBNX_USBP_CTL_STATUS(usb->index),
usbn_usbp_ctl_status.u64);
/* 6. Wait 10 cycles */
-   cvmx_wait(10);
+   __delay(10);
/*
 * 7. Clear ATE_RESET field in the USBN clock-control register:
 *USBN_USBP_CTL_STATUS[ATE_RESET] = 0
-- 
2.9.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-17 Thread Thomas Gleixner
On Fri, 17 Nov 2017, Arnd Bergmann wrote:
> On Thu, Nov 16, 2017 at 10:04 AM, Thomas Gleixner  wrote:
> > On Wed, 15 Nov 2017, Deepa Dinamani wrote:
> >> Would this work for everyone?
> >
> > Having extra config switches which are selectable by architectures and
> > removed when everything is converted is definitely the right way to go.
> >
> > That allows you to gradually convert stuff w/o inflicting wreckage all over
> > the place.
> 
> The CONFIG_64BIT_TIME would do that nicely for the new stuff like
> the conditional definition of __kernel_timespec, this one would get
> removed after we convert all architectures.
> 
> A second issue is how to control the compilation of the compat syscalls.
> CONFIG_COMPAT_32BIT_TIME handles that and could be defined
> in Kconfig as 'def_bool (!64BIT && CONFIG_64BIT_TIME) || COMPAT',
> this is then just a more readable way of expressing exactly when the
> functions should be built.
> 
> For completeness, there may be a third category, depending on how
> we handle things like sys_nanosleep(): Here, we want the native
> sys_nanosleep on 64-bit architectures, and compat_sys_nanosleep()
> to handle the 32-bit time_t variant on both 32-bit and 64-bit targets,
> but our plan is to not have a native 32-bit sys_nanosleep on 32-bit
> architectures any more, as new glibc should call clock_nanosleep()
> with a new syscall number instead. Should we then enclose

Isn't that going to break existing userspace?

Thanks

tglx
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-17 Thread Arnd Bergmann
On Fri, Nov 17, 2017 at 9:58 AM, Thomas Gleixner  wrote:
> On Fri, 17 Nov 2017, Arnd Bergmann wrote:
>> On Thu, Nov 16, 2017 at 10:04 AM, Thomas Gleixner  wrote:
>> > On Wed, 15 Nov 2017, Deepa Dinamani wrote:
>> >> Would this work for everyone?
>> >
>> > Having extra config switches which are selectable by architectures and
>> > removed when everything is converted is definitely the right way to go.
>> >
>> > That allows you to gradually convert stuff w/o inflicting wreckage all over
>> > the place.
>>
>> The CONFIG_64BIT_TIME would do that nicely for the new stuff like
>> the conditional definition of __kernel_timespec, this one would get
>> removed after we convert all architectures.
>>
>> A second issue is how to control the compilation of the compat syscalls.
>> CONFIG_COMPAT_32BIT_TIME handles that and could be defined
>> in Kconfig as 'def_bool (!64BIT && CONFIG_64BIT_TIME) || COMPAT',
>> this is then just a more readable way of expressing exactly when the
>> functions should be built.
>>
>> For completeness, there may be a third category, depending on how
>> we handle things like sys_nanosleep(): Here, we want the native
>> sys_nanosleep on 64-bit architectures, and compat_sys_nanosleep()
>> to handle the 32-bit time_t variant on both 32-bit and 64-bit targets,
>> but our plan is to not have a native 32-bit sys_nanosleep on 32-bit
>> architectures any more, as new glibc should call clock_nanosleep()
>> with a new syscall number instead. Should we then enclose
>
> Isn't that going to break existing userspace?

No, syscall that existing 32-bit user space enters would be handled by
compat_sys_nanosleep() on both 32-bit and 64-bit kernels at that
point. The idea here is to make the code path more uniform between
32-bit and 64-bit kernels.

  Arnd
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] binder: fix proc->files use-after-free

2017-11-17 Thread Greg KH
On Thu, Nov 16, 2017 at 12:37:02PM -0800, Todd Kjos wrote:
> Sorry about that, do you want a v3 with correct annotations?

Nah, this time is fine :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-17 Thread Thomas Gleixner
On Fri, 17 Nov 2017, Arnd Bergmann wrote:
> On Fri, Nov 17, 2017 at 9:58 AM, Thomas Gleixner  wrote:
> > On Fri, 17 Nov 2017, Arnd Bergmann wrote:
> >> On Thu, Nov 16, 2017 at 10:04 AM, Thomas Gleixner  
> >> wrote:
> >> > On Wed, 15 Nov 2017, Deepa Dinamani wrote:
> >> >> Would this work for everyone?
> >> >
> >> > Having extra config switches which are selectable by architectures and
> >> > removed when everything is converted is definitely the right way to go.
> >> >
> >> > That allows you to gradually convert stuff w/o inflicting wreckage all 
> >> > over
> >> > the place.
> >>
> >> The CONFIG_64BIT_TIME would do that nicely for the new stuff like
> >> the conditional definition of __kernel_timespec, this one would get
> >> removed after we convert all architectures.
> >>
> >> A second issue is how to control the compilation of the compat syscalls.
> >> CONFIG_COMPAT_32BIT_TIME handles that and could be defined
> >> in Kconfig as 'def_bool (!64BIT && CONFIG_64BIT_TIME) || COMPAT',
> >> this is then just a more readable way of expressing exactly when the
> >> functions should be built.
> >>
> >> For completeness, there may be a third category, depending on how
> >> we handle things like sys_nanosleep(): Here, we want the native
> >> sys_nanosleep on 64-bit architectures, and compat_sys_nanosleep()
> >> to handle the 32-bit time_t variant on both 32-bit and 64-bit targets,
> >> but our plan is to not have a native 32-bit sys_nanosleep on 32-bit
> >> architectures any more, as new glibc should call clock_nanosleep()
> >> with a new syscall number instead. Should we then enclose
> >
> > Isn't that going to break existing userspace?
> 
> No, syscall that existing 32-bit user space enters would be handled by
> compat_sys_nanosleep() on both 32-bit and 64-bit kernels at that
> point. The idea here is to make the code path more uniform between
> 32-bit and 64-bit kernels.

So on a 32bit system compat_sys_nanosleep() would be the legacy
sys_nanosleep() with the existing syscall number, but you don't want to
introduce a new sys_nanosleep64() for 32bit. That makes a lot of sense.

So back to your original question whether to use #if (MAGIC logic) or a
separate config symbol. Please use the latter, these magic logic constructs
are harder to read and prone to get wrong at some point. Having the
decision logic in one place is always the right thing to do.

Thanks,

tglx
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 1/6] ANDROID: binder: add support for RT prio inheritance.

2017-11-17 Thread Martijn Coenen
On Thu, Nov 16, 2017 at 4:10 PM, Peter Zijlstra  wrote:
> Well, I go by the one described in all the real-time computing texts;
> also found on Wikipedia FWIW:
>
>   https://en.wikipedia.org/wiki/Priority_inheritance

Guess I was taking inheritance too literally :-)

>
>> This behavior is also related to binder's threadpool - all those
>> threads run at a default prio of 120 (nice 0), and call into the
>> kernel to wait for work. If somebody then makes a call with a lower
>> prio (>120), we do change the binder thread that handles that call to
>> use the same low prio as well. Why run at nice 0 if the caller runs at
>> nice 10?
>
> Not immediately saying it doesn't make sense in the sync-rpc scenario;
> just saying that calling it PI is terribly confusing.
>
>> Yes, in case of asynchronous transactions it's not PI at all.
>
> It might be good to untangle some of that.

Yeah, I could possibly separate the part that deals with synchronous
transactions out, since that is "true PI".

> I'm still struggling with the fact that _binder_ has threads and not the
> apps themselves. Totally weird that.

Just to clarify - the threads do belong to the app; they are spawned
from the app process in userspace (sometimes on request of the
kernel), and call into the kernel driver for work. But, the app itself
is merely responsible for starting the threadpool; the libbinder
userspace library takes care of the rest. Beyond that, apps just
receive incoming calls on one of these threads, and that's it.

> Right; but real-time systems are about guarantees, not about mostly and
> on average.

Agreed. I wouldn't go so far to claim Android is RT, but we'll take
any gains we can get.

> But yes, you touch upon one way to have mixed priority thread pools. You
> need a max prio receiver thread that is basically always runnable, this
> is the one thread doing poll(). It is the thread you can immediately
> assign your rt_mutex ownership to etc..

This is an interesting design, I'll think about if I can make it work
with synchronous transactions. One concern is that running such a
thread at max prio means it would always preempt other work,
regardless of the importance of the incoming binder transaction.
Though I guess if you assign rt_mutex ownership to that thread before
even waking it up, it doesn't need to be max prio - it will be at the
prio it needs to be at.

Also I'm not sure how to make this work with async transactions that
need to be handled at a certain prio; either we already have a thread
lying around running at that prio, but if we don't we need to change
the prio before waking it up (which is more or less what this series
does).

> Sounds really weird to me though; I'd be curious to know why this
> 'feature' was created.

I think it may be because binder tries to abstract away from the fact
that a node can be remote - for userspace a binder object can be both
local and remote, and it shouldn't have to care. If you have a local
function call chain A() -> B() -> C(), then these functions obviously
all run on the same thread. But if A() and C() live in process P1 and
B lives in process P2, having A() and C() run in the same thread in
process P1 preserves those semantics. Arve (on CC) probably knows more
about this.

> I'm taking it changing this stuff is 'difficult' since much of it has
> been directly exposed to apps? And you'll need to build a parallel
> interface and slowly migrate apps away from it?

I think the whole threadpool design is actually abstracted pretty
nicely from apps, but we do have transaction ordering semantics that
we need to preserve; also the binder protocol between the kernel
driver and userspace is UAPI, and it can be hard to make large changes
to it while retaining support for an old Android userspace.

> Yeah I suppose so. Also I think the comments could be made clearer to
> avoid some of the confusion we've had here.

A lot of what we talked about is also about how binder works in
general. I'm writing more documentation about that internally, and I
hope I could some day add Documentation/ipc/binder.txt or something
like that :-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: octeon-usb: use __delay() instead of cvmx_wait()

2017-11-17 Thread James Hogan
On Fri, Nov 17, 2017 at 09:50:10AM +0200, Aaro Koskinen wrote:
> Commit edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait()
> everywhere.") deleted cvmx_wait() but forgot to update OCTEON USB
> staging driver. Fix that to allow driver build.
> 
> Fixes: edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait() everywhere.")
> Signed-off-by: Aaro Koskinen 

Reviewed-by: James Hogan 

Should this driver be enabled in the MIPS cavium_octeon_defconfig or
should that not happen until the driver comes out of staging?

Cheers
James

> ---
>  drivers/staging/octeon-usb/octeon-hcd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/octeon-usb/octeon-hcd.c 
> b/drivers/staging/octeon-usb/octeon-hcd.c
> index 068aece..cded30f 100644
> --- a/drivers/staging/octeon-usb/octeon-hcd.c
> +++ b/drivers/staging/octeon-usb/octeon-hcd.c
> @@ -394,7 +394,7 @@ struct octeon_hcd {
>   result = -1;\
>   break;  \
>   } else  \
> - cvmx_wait(100); \
> + __delay(100);   \
>   }   \
>   } while (0);\
>   result; })
> @@ -774,7 +774,7 @@ static int cvmx_usb_initialize(struct device *dev,
>   usbn_clk_ctl.s.hclk_rst = 1;
>   cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
>   /* 2e.  Wait 64 core-clock cycles for HCLK to stabilize */
> - cvmx_wait(64);
> + __delay(64);
>   /*
>* 3. Program the power-on reset field in the USBN clock-control
>*register:
> @@ -795,7 +795,7 @@ static int cvmx_usb_initialize(struct device *dev,
>   cvmx_write64_uint64(CVMX_USBNX_USBP_CTL_STATUS(usb->index),
>   usbn_usbp_ctl_status.u64);
>   /* 6. Wait 10 cycles */
> - cvmx_wait(10);
> + __delay(10);
>   /*
>* 7. Clear ATE_RESET field in the USBN clock-control register:
>*USBN_USBP_CTL_STATUS[ATE_RESET] = 0
> -- 
> 2.9.2
> 


signature.asc
Description: Digital signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-17 Thread Arnd Bergmann
On Fri, Nov 17, 2017 at 10:54 AM, Thomas Gleixner  wrote:
> On Fri, 17 Nov 2017, Arnd Bergmann wrote:
>> On Fri, Nov 17, 2017 at 9:58 AM, Thomas Gleixner  wrote:
>>
>> No, syscall that existing 32-bit user space enters would be handled by
>> compat_sys_nanosleep() on both 32-bit and 64-bit kernels at that
>> point. The idea here is to make the code path more uniform between
>> 32-bit and 64-bit kernels.
>
> So on a 32bit system compat_sys_nanosleep() would be the legacy
> sys_nanosleep() with the existing syscall number, but you don't want to
> introduce a new sys_nanosleep64() for 32bit. That makes a lot of sense.
>
> So back to your original question whether to use #if (MAGIC logic) or a
> separate config symbol. Please use the latter, these magic logic constructs
> are harder to read and prone to get wrong at some point. Having the
> decision logic in one place is always the right thing to do.

How about this:

config LEGACY_TIME_SYSCALLS
  def_bool 64BIT || !64BIT_TIME
  help
This controls the compilation of the following system calls:
time, stime,
gettimeofday, settimeofday, adjtimex, nanosleep, alarm, getitimer,
setitimer, select, utime, utimes, futimesat, and
{old,new}{l,f,}stat{,64}.
These all pass 32-bit time_t arguments on 32-bit architectures and
are replaced by other interfaces (e.g. posix timers and clocks, statx).
C libraries implementing 64-bit time_t in 32-bit architectures have to
implement the handles by wrapping around the newer interfaces.
New architectures should not explicitly disable this.

   Arnd
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-17 Thread Thomas Gleixner
On Fri, 17 Nov 2017, Arnd Bergmann wrote:
> On Fri, Nov 17, 2017 at 10:54 AM, Thomas Gleixner  wrote:
> > On Fri, 17 Nov 2017, Arnd Bergmann wrote:
> >> On Fri, Nov 17, 2017 at 9:58 AM, Thomas Gleixner  
> >> wrote:
> >>
> >> No, syscall that existing 32-bit user space enters would be handled by
> >> compat_sys_nanosleep() on both 32-bit and 64-bit kernels at that
> >> point. The idea here is to make the code path more uniform between
> >> 32-bit and 64-bit kernels.
> >
> > So on a 32bit system compat_sys_nanosleep() would be the legacy
> > sys_nanosleep() with the existing syscall number, but you don't want to
> > introduce a new sys_nanosleep64() for 32bit. That makes a lot of sense.
> >
> > So back to your original question whether to use #if (MAGIC logic) or a
> > separate config symbol. Please use the latter, these magic logic constructs
> > are harder to read and prone to get wrong at some point. Having the
> > decision logic in one place is always the right thing to do.
> 
> How about this:
> 
> config LEGACY_TIME_SYSCALLS
>   def_bool 64BIT || !64BIT_TIME
>   help
> This controls the compilation of the following system calls:
> time, stime,
> gettimeofday, settimeofday, adjtimex, nanosleep, alarm, getitimer,
> setitimer, select, utime, utimes, futimesat, and
> {old,new}{l,f,}stat{,64}.
> These all pass 32-bit time_t arguments on 32-bit architectures and
> are replaced by other interfaces (e.g. posix timers and clocks, 
> statx).
> C libraries implementing 64-bit time_t in 32-bit architectures have to
> implement the handles by wrapping around the newer interfaces.

s/handles/handling/ 

> New architectures should not explicitly disable this.

New architectures should never enable this, right?

Thanks,

tglx
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] posix_clocks: Prepare syscalls for 64 bit time_t conversion

2017-11-17 Thread Arnd Bergmann
On Fri, Nov 17, 2017 at 11:40 AM, Thomas Gleixner  wrote:
> On Fri, 17 Nov 2017, Arnd Bergmann wrote:
>> On Fri, Nov 17, 2017 at 10:54 AM, Thomas Gleixner  wrote:
>> > On Fri, 17 Nov 2017, Arnd Bergmann wrote:
>> >> On Fri, Nov 17, 2017 at 9:58 AM, Thomas Gleixner  
>> >> wrote:
>> >>
>> >> No, syscall that existing 32-bit user space enters would be handled by
>> >> compat_sys_nanosleep() on both 32-bit and 64-bit kernels at that
>> >> point. The idea here is to make the code path more uniform between
>> >> 32-bit and 64-bit kernels.
>> >
>> > So on a 32bit system compat_sys_nanosleep() would be the legacy
>> > sys_nanosleep() with the existing syscall number, but you don't want to
>> > introduce a new sys_nanosleep64() for 32bit. That makes a lot of sense.
>> >
>> > So back to your original question whether to use #if (MAGIC logic) or a
>> > separate config symbol. Please use the latter, these magic logic constructs
>> > are harder to read and prone to get wrong at some point. Having the
>> > decision logic in one place is always the right thing to do.
>>
>> How about this:
>>
>> config LEGACY_TIME_SYSCALLS
>>   def_bool 64BIT || !64BIT_TIME
>>   help
>> This controls the compilation of the following system calls:
>> time, stime,
>> gettimeofday, settimeofday, adjtimex, nanosleep, alarm, getitimer,
>> setitimer, select, utime, utimes, futimesat, and
>> {old,new}{l,f,}stat{,64}.
>> These all pass 32-bit time_t arguments on 32-bit architectures and
>> are replaced by other interfaces (e.g. posix timers and clocks, 
>> statx).
>> C libraries implementing 64-bit time_t in 32-bit architectures have 
>> to
>> implement the handles by wrapping around the newer interfaces.
>
> s/handles/handling/ 

I meant "handlers".

>> New architectures should not explicitly disable this.
>
> New architectures should never enable this, right?

Right, I got an extra "not". I guess if Deepa incorporates the new option,
she can also improve my English ;-)

 Arnd
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] Replace 'uint32_t' with 'u32' and 'uint64_t' with 'u64'

2017-11-17 Thread Roman Storozhenko
There are two reasons for that:
1) As Linus Torvalds said we should use kernel types:
http://lkml.iu.edu/hypermail//linux/kernel/1506.0/00160.html

2) There are only few places in the lustre codebase that use such types.
In the most cases it uses 'u32' and 'u64'.

Signed-off-by: Roman Storozhenko 

---
In the first version of this patch I replaced 'uint32_t' with '__u32' and
'uint64_t' with '__u64'. I was suggested to fix that by Greg K-H:

"The __ types are only needed for when you cross the user/kernel boundry.
Otherwise just use the "normal" types of u32 and u64.

Do the changes you made here all cross that boundry?  If not, please fix
this up."

I asked lustre community whether those code used only in the kernel
space and Andreas Dilger said:

"These headers are for kernel code only, so should use the "u32" and
similar
types, rather than the "__u32" that are used for user-kernel
structures."

So I have replaced my first patch version with this one.

 drivers/staging/lustre/lustre/include/lustre_sec.h |  4 ++--
 drivers/staging/lustre/lustre/llite/vvp_dev.c  |  2 +-
 drivers/staging/lustre/lustre/lov/lov_internal.h   | 12 ++--
 drivers/staging/lustre/lustre/osc/osc_internal.h   |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h 
b/drivers/staging/lustre/lustre/include/lustre_sec.h
index a40f706..64b6fd4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_sec.h
+++ b/drivers/staging/lustre/lustre/include/lustre_sec.h
@@ -341,8 +341,8 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd);
 #define SPTLRPC_MAX_PAYLOAD (1024)
 
 struct vfs_cred {
-   uint32_tvc_uid;
-   uint32_tvc_gid;
+   u32 vc_uid;
+   u32 vc_gid;
 };
 
 struct ptlrpc_ctx_ops {
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c 
b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index 8ccc8b7..987c03b 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -384,7 +384,7 @@ int cl_sb_fini(struct super_block *sb)
 struct vvp_pgcache_id {
unsigned int vpi_bucket;
unsigned int vpi_depth;
-   uint32_t vpi_index;
+   u32  vpi_index;
 
unsigned int vpi_curdep;
struct lu_object_header *vpi_obj;
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h 
b/drivers/staging/lustre/lustre/lov/lov_internal.h
index ae28ddf..a56d71c 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -115,19 +115,19 @@ static inline const struct lsm_operations 
*lsm_op_find(int magic)
  */
 #if BITS_PER_LONG == 64
 # define lov_do_div64(n, base) ({  \
-   uint64_t __base = (base);   \
-   uint64_t __rem; \
-   __rem = ((uint64_t)(n)) % __base;   \
-   (n) = ((uint64_t)(n)) / __base; \
+   u64 __base = (base);\
+   u64 __rem;  \
+   __rem = ((u64)(n)) % __base;\
+   (n) = ((u64)(n)) / __base;  \
__rem;  \
 })
 #elif BITS_PER_LONG == 32
 # define lov_do_div64(n, base) ({  \
-   uint64_t __rem; \
+   u64 __rem;  \
if ((sizeof(base) > 4) && (((base) & 0xULL) != 0)) {  \
int __remainder;  \
LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), "64 bit lov " \
-"division %llu / %llu\n", (n), (uint64_t)(base));\
+"division %llu / %llu\n", (n), (u64)(base));\
__remainder = (n) & (LOV_MIN_STRIPE_SIZE - 1);  \
(n) >>= LOV_MIN_STRIPE_BITS;\
__rem = do_div(n, (base) >> LOV_MIN_STRIPE_BITS);   \
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h 
b/drivers/staging/lustre/lustre/osc/osc_internal.h
index feda61b..32db150 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -168,9 +168,9 @@ struct osc_device {
 
/* Write stats is actually protected by client_obd's lock. */
struct osc_stats {
-   uint64_t os_lockless_writes;  /* by bytes */
-   uint64_t os_lockless_reads;/* by bytes */
-   uint64_t os_lockless_truncates;   /* by times */
+   

[PATCH 01/10] staging: fsl-mc: drop unused dpcon APIs

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

Couple of API functions are not used so lets drop them together with
the associated structures and defines.

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dpcon-cmd.h |  6 ---
 drivers/staging/fsl-mc/bus/dpcon.c | 69 --
 drivers/staging/fsl-mc/include/dpcon.h | 10 -
 3 files changed, 85 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpcon-cmd.h 
b/drivers/staging/fsl-mc/bus/dpcon-cmd.h
index 2bb6698..d2ba819 100644
--- a/drivers/staging/fsl-mc/bus/dpcon-cmd.h
+++ b/drivers/staging/fsl-mc/bus/dpcon-cmd.h
@@ -45,13 +45,11 @@
 /* Command IDs */
 #define DPCON_CMDID_CLOSE  DPCON_CMD(0x800)
 #define DPCON_CMDID_OPEN   DPCON_CMD(0x808)
-#define DPCON_CMDID_GET_API_VERSIONDPCON_CMD(0xa08)
 
 #define DPCON_CMDID_ENABLE DPCON_CMD(0x002)
 #define DPCON_CMDID_DISABLEDPCON_CMD(0x003)
 #define DPCON_CMDID_GET_ATTR   DPCON_CMD(0x004)
 #define DPCON_CMDID_RESET  DPCON_CMD(0x005)
-#define DPCON_CMDID_IS_ENABLED DPCON_CMD(0x006)
 
 #define DPCON_CMDID_SET_NOTIFICATION   DPCON_CMD(0x100)
 
@@ -61,10 +59,6 @@ struct dpcon_cmd_open {
 
 #define DPCON_ENABLE   1
 
-struct dpcon_rsp_is_enabled {
-   u8 enabled;
-};
-
 struct dpcon_rsp_get_attr {
/* response word 0 */
__le32 id;
diff --git a/drivers/staging/fsl-mc/bus/dpcon.c 
b/drivers/staging/fsl-mc/bus/dpcon.c
index ca1da85..ce7c0bf 100644
--- a/drivers/staging/fsl-mc/bus/dpcon.c
+++ b/drivers/staging/fsl-mc/bus/dpcon.c
@@ -156,42 +156,6 @@ int dpcon_disable(struct fsl_mc_io *mc_io,
 EXPORT_SYMBOL(dpcon_disable);
 
 /**
- * dpcon_is_enabled() -Check if the DPCON is enabled.
- * @mc_io: Pointer to MC portal's I/O object
- * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
- * @token: Token of DPCON object
- * @en:Returns '1' if object is enabled; '0' otherwise
- *
- * Return: '0' on Success; Error code otherwise.
- */
-int dpcon_is_enabled(struct fsl_mc_io *mc_io,
-u32 cmd_flags,
-u16 token,
-int *en)
-{
-   struct mc_command cmd = { 0 };
-   struct dpcon_rsp_is_enabled *dpcon_rsp;
-   int err;
-
-   /* prepare command */
-   cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED,
- cmd_flags,
- token);
-
-   /* send command to mc*/
-   err = mc_send_command(mc_io, &cmd);
-   if (err)
-   return err;
-
-   /* retrieve response parameters */
-   dpcon_rsp = (struct dpcon_rsp_is_enabled *)cmd.params;
-   *en = dpcon_rsp->enabled & DPCON_ENABLE;
-
-   return 0;
-}
-EXPORT_SYMBOL(dpcon_is_enabled);
-
-/**
  * dpcon_reset() - Reset the DPCON, returns the object to initial state.
  * @mc_io: Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
@@ -282,36 +246,3 @@ int dpcon_set_notification(struct fsl_mc_io *mc_io,
return mc_send_command(mc_io, &cmd);
 }
 EXPORT_SYMBOL(dpcon_set_notification);
-
-/**
- * dpcon_get_api_version - Get Data Path Concentrator API version
- * @mc_io: Pointer to MC portal's DPCON object
- * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
- * @major_ver: Major version of DPCON API
- * @minor_ver: Minor version of DPCON API
- *
- * Return: '0' on Success; Error code otherwise
- */
-int dpcon_get_api_version(struct fsl_mc_io *mc_io,
- u32 cmd_flags,
- u16 *major_ver,
- u16 *minor_ver)
-{
-   struct mc_command cmd = { 0 };
-   int err;
-
-   /* prepare command */
-   cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_API_VERSION,
- cmd_flags, 0);
-
-   /* send command to mc */
-   err = mc_send_command(mc_io, &cmd);
-   if (err)
-   return err;
-
-   /* retrieve response parameters */
-   mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
-
-   return 0;
-}
-EXPORT_SYMBOL(dpcon_get_api_version);
diff --git a/drivers/staging/fsl-mc/include/dpcon.h 
b/drivers/staging/fsl-mc/include/dpcon.h
index efa2390..425749e 100644
--- a/drivers/staging/fsl-mc/include/dpcon.h
+++ b/drivers/staging/fsl-mc/include/dpcon.h
@@ -62,11 +62,6 @@ int dpcon_disable(struct fsl_mc_io *mc_io,
  u32 cmd_flags,
  u16 token);
 
-int dpcon_is_enabled(struct fsl_mc_io *mc_io,
-u32 cmd_flags,
-u16 token,
-int *en);
-
 int dpcon_reset(struct fsl_mc_io *mc_io,
u32 cmd_flags,
u16 token);
@@ -107,9 +102,4 @@ int dpcon_set_notification(struct fsl_mc_io *mc_io,
   u16 token,
   struct 

[PATCH 02/10] staging: fsl-mc/dpio: remove incomplete refcount implementation

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

There's an unfinished implementation of reference counting for dpaa2_io
structure using atomics. Since it's unused lets remove it for now and,
if needed at a later time, make use of krefs instead of rolling our
own refcounting.

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index a609ec8..591d8b7 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -43,7 +43,6 @@
 #include "qbman-portal.h"
 
 struct dpaa2_io {
-   atomic_t refs;
struct dpaa2_io_desc dpio_desc;
struct qbman_swp_desc swp_desc;
struct qbman_swp *swp;
@@ -126,7 +125,6 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc 
*desc)
return NULL;
}
 
-   atomic_set(&obj->refs, 1);
obj->dpio_desc = *desc;
obj->swp_desc.cena_bar = obj->dpio_desc.regs_cena;
obj->swp_desc.cinh_bar = obj->dpio_desc.regs_cinh;
@@ -171,8 +169,6 @@ EXPORT_SYMBOL(dpaa2_io_create);
  */
 void dpaa2_io_down(struct dpaa2_io *d)
 {
-   if (!atomic_dec_and_test(&d->refs))
-   return;
kfree(d);
 }
 EXPORT_SYMBOL(dpaa2_io_down);
-- 
2.9.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/10] staging: fsl-mc/dpio: remove couple of unused functions

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

These couple of functions are not yet used so lets remove them
for now and add them back when/if needed.

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 58 --
 drivers/staging/fsl-mc/include/dpaa2-io.h  |  4 --
 2 files changed, 62 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index fca8c90dc..871078d 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -318,37 +318,6 @@ int dpaa2_io_service_rearm(struct dpaa2_io *d,
 EXPORT_SYMBOL(dpaa2_io_service_rearm);
 
 /**
- * dpaa2_io_service_pull_fq() - pull dequeue functions from a fq.
- * @d: the given DPIO service.
- * @fqid: the given frame queue id.
- * @s: the dpaa2_io_store object for the result.
- *
- * Return 0 for success, or error code for failure.
- */
-int dpaa2_io_service_pull_fq(struct dpaa2_io *d, u32 fqid,
-struct dpaa2_io_store *s)
-{
-   struct qbman_pull_desc pd;
-   int err;
-
-   qbman_pull_desc_clear(&pd);
-   qbman_pull_desc_set_storage(&pd, s->vaddr, s->paddr, 1);
-   qbman_pull_desc_set_numframes(&pd, (u8)s->max);
-   qbman_pull_desc_set_fq(&pd, fqid);
-
-   d = service_select(d);
-   if (!d)
-   return -ENODEV;
-   s->swp = d->swp;
-   err = qbman_swp_pull(d->swp, &pd);
-   if (err)
-   s->swp = NULL;
-
-   return err;
-}
-EXPORT_SYMBOL(dpaa2_io_service_pull_fq);
-
-/**
  * dpaa2_io_service_pull_channel() - pull dequeue functions from a channel.
  * @d: the given DPIO service.
  * @channelid: the given channel id.
@@ -381,33 +350,6 @@ int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 
channelid,
 EXPORT_SYMBOL(dpaa2_io_service_pull_channel);
 
 /**
- * dpaa2_io_service_enqueue_fq() - Enqueue a frame to a frame queue.
- * @d: the given DPIO service.
- * @fqid: the given frame queue id.
- * @fd: the frame descriptor which is enqueued.
- *
- * Return 0 for successful enqueue, -EBUSY if the enqueue ring is not ready,
- * or -ENODEV if there is no dpio service.
- */
-int dpaa2_io_service_enqueue_fq(struct dpaa2_io *d,
-   u32 fqid,
-   const struct dpaa2_fd *fd)
-{
-   struct qbman_eq_desc ed;
-
-   d = service_select(d);
-   if (!d)
-   return -ENODEV;
-
-   qbman_eq_desc_clear(&ed);
-   qbman_eq_desc_set_no_orp(&ed, 0);
-   qbman_eq_desc_set_fq(&ed, fqid);
-
-   return qbman_swp_enqueue(d->swp, &ed, fd);
-}
-EXPORT_SYMBOL(dpaa2_io_service_enqueue_fq);
-
-/**
  * dpaa2_io_service_enqueue_qd() - Enqueue a frame to a QD.
  * @d: the given DPIO service.
  * @qdid: the given queuing destination id.
diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h 
b/drivers/staging/fsl-mc/include/dpaa2-io.h
index afc2d06..07ad15a 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-io.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
@@ -120,13 +120,9 @@ void dpaa2_io_service_deregister(struct dpaa2_io *service,
 int dpaa2_io_service_rearm(struct dpaa2_io *service,
   struct dpaa2_io_notification_ctx *ctx);
 
-int dpaa2_io_service_pull_fq(struct dpaa2_io *d, u32 fqid,
-struct dpaa2_io_store *s);
 int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 channelid,
  struct dpaa2_io_store *s);
 
-int dpaa2_io_service_enqueue_fq(struct dpaa2_io *d, u32 fqid,
-   const struct dpaa2_fd *fd);
 int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
u16 qdbin, const struct dpaa2_fd *fd);
 int dpaa2_io_service_release(struct dpaa2_io *d, u32 bpid,
-- 
2.9.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/10] staging: fsl-mc/dpio: drop EXPORT_SYMBOL() for a few functions

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

These functions are only used within this driver so no need for
EXPORT_SYMBOL().

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index 591d8b7..fca8c90dc 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -156,7 +156,6 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc 
*desc)
 
return obj;
 }
-EXPORT_SYMBOL(dpaa2_io_create);
 
 /**
  * dpaa2_io_down() - release the dpaa2_io object.
@@ -171,7 +170,6 @@ void dpaa2_io_down(struct dpaa2_io *d)
 {
kfree(d);
 }
-EXPORT_SYMBOL(dpaa2_io_down);
 
 #define DPAA_POLL_MAX 32
 
@@ -218,7 +216,6 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj)
qbman_swp_interrupt_set_inhibit(swp, 0);
return IRQ_HANDLED;
 }
-EXPORT_SYMBOL(dpaa2_io_irq);
 
 /**
  * dpaa2_io_service_register() - Prepare for servicing of FQDAN or CDAN
-- 
2.9.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/10] staging: fsl-mc: remove debug WARN_ONs doubling error checks

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

A lot of error checks are doubled by debug WARN_ONs. Given that the
driver was thoroughly debugged and is in a stable state, it's time to
drop them.

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c   | 20 ++---
 drivers/staging/fsl-mc/bus/fsl-mc-allocator.c  | 86 +++---
 drivers/staging/fsl-mc/bus/fsl-mc-bus.c|  8 +-
 drivers/staging/fsl-mc/bus/fsl-mc-msi.c| 14 ++--
 .../staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c |  4 +-
 drivers/staging/fsl-mc/bus/mc-io.c | 13 ++--
 drivers/staging/fsl-mc/bus/mc-sys.c|  5 +-
 7 files changed, 73 insertions(+), 77 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index d6a84dd..28a6b87 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -382,11 +382,11 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, 
void *arg)
dev_dbg(dev, "DPRC IRQ %d triggered on CPU %u\n",
irq_num, smp_processor_id());
 
-   if (WARN_ON(!(mc_dev->flags & FSL_MC_IS_DPRC)))
+   if (!(mc_dev->flags & FSL_MC_IS_DPRC))
return IRQ_HANDLED;
 
mutex_lock(&mc_bus->scan_mutex);
-   if (WARN_ON(!msi_desc || msi_desc->irq != (u32)irq_num))
+   if (!msi_desc || msi_desc->irq != (u32)irq_num)
goto out;
 
status = 0;
@@ -593,20 +593,20 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
bool msi_domain_set = false;
u16 major_ver, minor_ver;
 
-   if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
+   if (strcmp(mc_dev->obj_desc.type, "dprc") != 0)
return -EINVAL;
 
-   if (WARN_ON(dev_get_msi_domain(&mc_dev->dev)))
+   if (dev_get_msi_domain(&mc_dev->dev))
return -EINVAL;
 
if (!mc_dev->mc_io) {
/*
 * This is a child DPRC:
 */
-   if (WARN_ON(!dev_is_fsl_mc(parent_dev)))
+   if (!dev_is_fsl_mc(parent_dev))
return -EINVAL;
 
-   if (WARN_ON(mc_dev->obj_desc.region_count == 0))
+   if (mc_dev->obj_desc.region_count == 0)
return -EINVAL;
 
region_size = resource_size(mc_dev->regions);
@@ -634,7 +634,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 */
struct irq_domain *mc_msi_domain;
 
-   if (WARN_ON(dev_is_fsl_mc(parent_dev)))
+   if (dev_is_fsl_mc(parent_dev))
return -EINVAL;
 
error = fsl_mc_find_msi_domain(parent_dev,
@@ -745,12 +745,12 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
int error;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
 
-   if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
+   if (strcmp(mc_dev->obj_desc.type, "dprc") != 0)
return -EINVAL;
-   if (WARN_ON(!mc_dev->mc_io))
+   if (!mc_dev->mc_io)
return -EINVAL;
 
-   if (WARN_ON(!mc_bus->irq_resources))
+   if (!mc_bus->irq_resources)
return -EINVAL;
 
if (dev_get_msi_domain(&mc_dev->dev))
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
index d472a85..f7fbebd 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
@@ -41,25 +41,25 @@ static int __must_check 
fsl_mc_resource_pool_add_device(struct fsl_mc_bus
struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
int error = -EINVAL;
 
-   if (WARN_ON(pool_type < 0 || pool_type >= FSL_MC_NUM_POOL_TYPES))
+   if (pool_type < 0 || pool_type >= FSL_MC_NUM_POOL_TYPES)
goto out;
-   if (WARN_ON(!fsl_mc_is_allocatable(mc_dev->obj_desc.type)))
+   if (!fsl_mc_is_allocatable(mc_dev->obj_desc.type))
goto out;
-   if (WARN_ON(mc_dev->resource))
+   if (mc_dev->resource)
goto out;
 
res_pool = &mc_bus->resource_pools[pool_type];
-   if (WARN_ON(res_pool->type != pool_type))
+   if (res_pool->type != pool_type)
goto out;
-   if (WARN_ON(res_pool->mc_bus != mc_bus))
+   if (res_pool->mc_bus != mc_bus)
goto out;
 
mutex_lock(&res_pool->mutex);
 
-   if (WARN_ON(res_pool->max_count < 0))
+   if (res_pool->max_count < 0)
goto out_unlock;
-   if (WARN_ON(res_pool->free_count < 0 ||
-   res_pool->free_count > res_pool->max_count))
+   if (res_pool->free_count < 0 ||
+   res_pool->free_count > res_pool->max_count)
goto out_unlock;
 
resource = devm_kzalloc(&mc_bus_dev->dev, sizeof(*resource),
@@ -105,25 +105,25 @@ static int __must_check 
fsl_mc_resource_pool_remove_device(s

[PATCH 07/10] staging: fsl-mc: remove some superfluous WARN_ONs

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

These WARN_ONs shouldn't trigger unless something went very wrong.
Since the driver is in a stable state let's remove these debug
WARN_ONs.

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c  |  8 
 drivers/staging/fsl-mc/bus/fsl-mc-allocator.c | 10 --
 drivers/staging/fsl-mc/bus/fsl-mc-bus.c   | 12 
 drivers/staging/fsl-mc/bus/fsl-mc-msi.c   |  1 -
 .../staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c|  3 ---
 drivers/staging/fsl-mc/bus/mc-io.c| 19 ---
 6 files changed, 53 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 06df528..d6a84dd 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -39,8 +39,6 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device 
*dev, void *data)
struct fsl_mc_child_objs *objs;
struct fsl_mc_device *mc_dev;
 
-   WARN_ON(!dev);
-   WARN_ON(!data);
mc_dev = to_fsl_mc_device(dev);
objs = data;
 
@@ -60,8 +58,6 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device 
*dev, void *data)
 
 static int __fsl_mc_device_remove(struct device *dev, void *data)
 {
-   WARN_ON(!dev);
-   WARN_ON(data);
fsl_mc_device_remove(to_fsl_mc_device(dev));
return 0;
 }
@@ -453,8 +449,6 @@ static int disable_dprc_irq(struct fsl_mc_device *mc_dev)
int error;
struct fsl_mc_io *mc_io = mc_dev->mc_io;
 
-   WARN_ON(mc_dev->obj_desc.irq_count != 1);
-
/*
 * Disable generation of interrupt, while we configure it:
 */
@@ -496,8 +490,6 @@ static int register_dprc_irq_handler(struct fsl_mc_device 
*mc_dev)
int error;
struct fsl_mc_device_irq *irq = mc_dev->irqs[0];
 
-   WARN_ON(mc_dev->obj_desc.irq_count != 1);
-
/*
 * NOTE: devm_request_threaded_irq() invokes the device-specific
 * function that programs the MSI physically in the device
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
index 8ea3920..d472a85 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
@@ -199,7 +199,6 @@ int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus 
*mc_bus,
struct fsl_mc_resource, node);
 
if (!resource) {
-   WARN_ON(res_pool->free_count != 0);
error = -ENXIO;
dev_err(&mc_bus_dev->dev,
"No more resources of type %s left\n",
@@ -474,7 +473,6 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device 
*mc_dev)
irqs[i] = to_fsl_mc_irq(resource);
res_allocated_count++;
 
-   WARN_ON(irqs[i]->mc_dev);
irqs[i]->mc_dev = mc_dev;
irqs[i]->dev_irq_index = i;
}
@@ -516,7 +514,6 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev)
return;
 
for (i = 0; i < irq_count; i++) {
-   WARN_ON(!irqs[i]->mc_dev);
irqs[i]->mc_dev = NULL;
fsl_mc_resource_free(&irqs[i]->resource);
}
@@ -553,17 +550,10 @@ static void fsl_mc_cleanup_resource_pool(struct 
fsl_mc_device *mc_bus_dev,
&mc_bus->resource_pools[pool_type];
int free_count = 0;
 
-   WARN_ON(res_pool->type != pool_type);
-   WARN_ON(res_pool->free_count != res_pool->max_count);
-
list_for_each_entry_safe(resource, next, &res_pool->free_list, node) {
free_count++;
-   WARN_ON(resource->type != res_pool->type);
-   WARN_ON(resource->parent_pool != res_pool);
devm_kfree(&mc_bus_dev->dev, resource);
}
-
-   WARN_ON(free_count != res_pool->free_count);
 }
 
 void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
index 409f2b9..1c2fd8d 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
@@ -162,12 +162,7 @@ static int fsl_mc_driver_probe(struct device *dev)
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
int error;
 
-   if (WARN_ON(!dev->driver))
-   return -EINVAL;
-
mc_drv = to_fsl_mc_driver(dev->driver);
-   if (WARN_ON(!mc_drv->probe))
-   return -EINVAL;
 
error = mc_drv->probe(mc_dev);
if (error < 0) {
@@ -184,9 +179,6 @@ static int fsl_mc_driver_remove(struct device *dev)
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
int error;
 
-   if (WARN_ON(!dev->driver))
-   return -EINVAL;
-
error = mc_drv->remove(mc_dev);
if (error < 0

[PATCH 09/10] staging: fsl-mc: add support for device type

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

The MC bus has different types of devices and this is supported by
device model. This patch adds initial support for device types
(defines them, adds helpers and sets the device type).

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 67 +
 drivers/staging/fsl-mc/include/mc.h | 55 +++
 2 files changed, 122 insertions(+)

diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
index 854bd80..aa935f3 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
@@ -156,6 +156,68 @@ struct bus_type fsl_mc_bus_type = {
 };
 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
 
+struct device_type fsl_mc_bus_dprc_type = {
+   .name = "fsl_mc_bus_dprc"
+};
+
+struct device_type fsl_mc_bus_dpni_type = {
+   .name = "fsl_mc_bus_dpni"
+};
+
+struct device_type fsl_mc_bus_dpio_type = {
+   .name = "fsl_mc_bus_dpio"
+};
+
+struct device_type fsl_mc_bus_dpsw_type = {
+   .name = "fsl_mc_bus_dpsw"
+};
+
+struct device_type fsl_mc_bus_dpbp_type = {
+   .name = "fsl_mc_bus_dpbp"
+};
+
+struct device_type fsl_mc_bus_dpcon_type = {
+   .name = "fsl_mc_bus_dpcon"
+};
+
+struct device_type fsl_mc_bus_dpmcp_type = {
+   .name = "fsl_mc_bus_dpmcp"
+};
+
+struct device_type fsl_mc_bus_dpmac_type = {
+   .name = "fsl_mc_bus_dpmac"
+};
+
+struct device_type fsl_mc_bus_dprtc_type = {
+   .name = "fsl_mc_bus_dprtc"
+};
+
+static struct device_type *fsl_mc_get_device_type(const char *type)
+{
+   static const struct {
+   struct device_type *dev_type;
+   const char *type;
+   } dev_types[] = {
+   { &fsl_mc_bus_dprc_type, "dprc" },
+   { &fsl_mc_bus_dpni_type, "dpni" },
+   { &fsl_mc_bus_dpio_type, "dpio" },
+   { &fsl_mc_bus_dpsw_type, "dpsw" },
+   { &fsl_mc_bus_dpbp_type, "dpbp" },
+   { &fsl_mc_bus_dpcon_type, "dpcon" },
+   { &fsl_mc_bus_dpmcp_type, "dpmcp" },
+   { &fsl_mc_bus_dpmac_type, "dpmac" },
+   { &fsl_mc_bus_dprtc_type, "dprtc" },
+   { NULL, NULL }
+   };
+   int i;
+
+   for (i = 0; dev_types[i].dev_type; i++)
+   if (!strcmp(dev_types[i].type, type))
+   return dev_types[i].dev_type;
+
+   return NULL;
+}
+
 static int fsl_mc_driver_probe(struct device *dev)
 {
struct fsl_mc_driver *mc_drv;
@@ -506,6 +568,11 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
mc_dev->dev.parent = parent_dev;
mc_dev->dev.bus = &fsl_mc_bus_type;
mc_dev->dev.release = fsl_mc_device_release;
+   mc_dev->dev.type = fsl_mc_get_device_type(obj_desc->type);
+   if (!mc_dev->dev.type) {
+   dev_err(parent_dev, "unknown device type %s\n", obj_desc->type);
+   goto error_cleanup_dev;
+   }
dev_set_name(&mc_dev->dev, "%s.%d", obj_desc->type, obj_desc->id);
 
if (strcmp(obj_desc->type, "dprc") == 0) {
diff --git a/drivers/staging/fsl-mc/include/mc.h 
b/drivers/staging/fsl-mc/include/mc.h
index aafe63a..15db93d 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -398,4 +398,59 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev);
 
 extern struct bus_type fsl_mc_bus_type;
 
+extern struct device_type fsl_mc_bus_dprc_type;
+extern struct device_type fsl_mc_bus_dpni_type;
+extern struct device_type fsl_mc_bus_dpio_type;
+extern struct device_type fsl_mc_bus_dpsw_type;
+extern struct device_type fsl_mc_bus_dpbp_type;
+extern struct device_type fsl_mc_bus_dpcon_type;
+extern struct device_type fsl_mc_bus_dpmcp_type;
+extern struct device_type fsl_mc_bus_dpmac_type;
+extern struct device_type fsl_mc_bus_dprtc_type;
+
+static inline bool is_fsl_mc_bus_dprc(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_dprc_type;
+}
+
+static inline bool is_fsl_mc_bus_dpni(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_dpni_type;
+}
+
+static inline bool is_fsl_mc_bus_dpio(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_dpio_type;
+}
+
+static inline bool is_fsl_mc_bus_dpsw(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_dpsw_type;
+}
+
+static inline bool is_fsl_mc_bus_dpbp(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_dpbp_type;
+}
+
+static inline bool is_fsl_mc_bus_dpcon(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_dpcon_type;
+}
+
+static inline bool is_fsl_mc_bus_dpmcp(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_dpmcp_type;
+}
+
+static inline bool is_fsl_mc_bus_dpmac(const struct fsl_mc_device *mc_dev)
+{
+   return mc_dev->dev.type == &fsl_mc_bus_d

[PATCH 05/10] staging: fsl-mc: consistently use EXPORT_SYMBOL_GPL()

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

The bus driver is mixing EXPORT_SYMBOL()/EXPORT_SYMBOL_GPL() usage.
Change it to consistently use EXPORT_SYMBOL_GPL().

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dpbp.c   | 16 
 drivers/staging/fsl-mc/bus/dpcon.c  | 14 +++---
 drivers/staging/fsl-mc/bus/dprc.c   | 16 
 drivers/staging/fsl-mc/bus/mc-sys.c |  2 +-
 4 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpbp.c 
b/drivers/staging/fsl-mc/bus/dpbp.c
index 363730a..fc76e90 100644
--- a/drivers/staging/fsl-mc/bus/dpbp.c
+++ b/drivers/staging/fsl-mc/bus/dpbp.c
@@ -77,7 +77,7 @@ int dpbp_open(struct fsl_mc_io *mc_io,
 
return err;
 }
-EXPORT_SYMBOL(dpbp_open);
+EXPORT_SYMBOL_GPL(dpbp_open);
 
 /**
  * dpbp_close() - Close the control session of the object
@@ -103,7 +103,7 @@ int dpbp_close(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpbp_close);
+EXPORT_SYMBOL_GPL(dpbp_close);
 
 /**
  * dpbp_enable() - Enable the DPBP.
@@ -126,7 +126,7 @@ int dpbp_enable(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpbp_enable);
+EXPORT_SYMBOL_GPL(dpbp_enable);
 
 /**
  * dpbp_disable() - Disable the DPBP.
@@ -149,7 +149,7 @@ int dpbp_disable(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpbp_disable);
+EXPORT_SYMBOL_GPL(dpbp_disable);
 
 /**
  * dpbp_is_enabled() - Check if the DPBP is enabled.
@@ -183,7 +183,7 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io,
 
return 0;
 }
-EXPORT_SYMBOL(dpbp_is_enabled);
+EXPORT_SYMBOL_GPL(dpbp_is_enabled);
 
 /**
  * dpbp_reset() - Reset the DPBP, returns the object to initial state.
@@ -206,7 +206,7 @@ int dpbp_reset(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpbp_reset);
+EXPORT_SYMBOL_GPL(dpbp_reset);
 
 /**
  * dpbp_get_attributes - Retrieve DPBP attributes.
@@ -243,7 +243,7 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io,
 
return 0;
 }
-EXPORT_SYMBOL(dpbp_get_attributes);
+EXPORT_SYMBOL_GPL(dpbp_get_attributes);
 
 /**
  * dpbp_get_api_version - Get Data Path Buffer Pool API version
@@ -276,4 +276,4 @@ int dpbp_get_api_version(struct fsl_mc_io *mc_io,
 
return 0;
 }
-EXPORT_SYMBOL(dpbp_get_api_version);
+EXPORT_SYMBOL_GPL(dpbp_get_api_version);
diff --git a/drivers/staging/fsl-mc/bus/dpcon.c 
b/drivers/staging/fsl-mc/bus/dpcon.c
index ce7c0bf..5ba1a0f 100644
--- a/drivers/staging/fsl-mc/bus/dpcon.c
+++ b/drivers/staging/fsl-mc/bus/dpcon.c
@@ -78,7 +78,7 @@ int dpcon_open(struct fsl_mc_io *mc_io,
 
return 0;
 }
-EXPORT_SYMBOL(dpcon_open);
+EXPORT_SYMBOL_GPL(dpcon_open);
 
 /**
  * dpcon_close() - Close the control session of the object
@@ -105,7 +105,7 @@ int dpcon_close(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpcon_close);
+EXPORT_SYMBOL_GPL(dpcon_close);
 
 /**
  * dpcon_enable() - Enable the DPCON
@@ -129,7 +129,7 @@ int dpcon_enable(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpcon_enable);
+EXPORT_SYMBOL_GPL(dpcon_enable);
 
 /**
  * dpcon_disable() - Disable the DPCON
@@ -153,7 +153,7 @@ int dpcon_disable(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpcon_disable);
+EXPORT_SYMBOL_GPL(dpcon_disable);
 
 /**
  * dpcon_reset() - Reset the DPCON, returns the object to initial state.
@@ -176,7 +176,7 @@ int dpcon_reset(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpcon_reset);
+EXPORT_SYMBOL_GPL(dpcon_reset);
 
 /**
  * dpcon_get_attributes() - Retrieve DPCON attributes.
@@ -214,7 +214,7 @@ int dpcon_get_attributes(struct fsl_mc_io *mc_io,
 
return 0;
 }
-EXPORT_SYMBOL(dpcon_get_attributes);
+EXPORT_SYMBOL_GPL(dpcon_get_attributes);
 
 /**
  * dpcon_set_notification() - Set DPCON notification destination
@@ -245,4 +245,4 @@ int dpcon_set_notification(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
 }
-EXPORT_SYMBOL(dpcon_set_notification);
+EXPORT_SYMBOL_GPL(dpcon_set_notification);
diff --git a/drivers/staging/fsl-mc/bus/dprc.c 
b/drivers/staging/fsl-mc/bus/dprc.c
index 6f6c65a..f29ea3e 100644
--- a/drivers/staging/fsl-mc/bus/dprc.c
+++ b/drivers/staging/fsl-mc/bus/dprc.c
@@ -71,7 +71,7 @@ int dprc_open(struct fsl_mc_io *mc_io,
 
return 0;
 }
-EXPORT_SYMBOL(dprc_open);
+EXPORT_SYMBOL_GPL(dprc_open);
 
 /**
  * dprc_close() - Close the control session of the object
@@ -97,7 +97,7 @@ int dprc_close(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd

[PATCH 06/10] staging: fsl-mc/dpio: change to use EXPORT_SYMBOL_GPL()

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

No need to use EXPORT_SYMBOL() so switch to the GPL variant.

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dpio/dpio-service.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c 
b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
index 871078d..a8a8e15 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
@@ -258,7 +258,7 @@ int dpaa2_io_service_register(struct dpaa2_io *d,
 ctx->qman64);
return 0;
 }
-EXPORT_SYMBOL(dpaa2_io_service_register);
+EXPORT_SYMBOL_GPL(dpaa2_io_service_register);
 
 /**
  * dpaa2_io_service_deregister - The opposite of 'register'.
@@ -281,7 +281,7 @@ void dpaa2_io_service_deregister(struct dpaa2_io *service,
list_del(&ctx->node);
spin_unlock_irqrestore(&d->lock_notifications, irqflags);
 }
-EXPORT_SYMBOL(dpaa2_io_service_deregister);
+EXPORT_SYMBOL_GPL(dpaa2_io_service_deregister);
 
 /**
  * dpaa2_io_service_rearm() - Rearm the notification for the given DPIO 
service.
@@ -315,7 +315,7 @@ int dpaa2_io_service_rearm(struct dpaa2_io *d,
 
return err;
 }
-EXPORT_SYMBOL(dpaa2_io_service_rearm);
+EXPORT_SYMBOL_GPL(dpaa2_io_service_rearm);
 
 /**
  * dpaa2_io_service_pull_channel() - pull dequeue functions from a channel.
@@ -347,7 +347,7 @@ int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 
channelid,
 
return err;
 }
-EXPORT_SYMBOL(dpaa2_io_service_pull_channel);
+EXPORT_SYMBOL_GPL(dpaa2_io_service_pull_channel);
 
 /**
  * dpaa2_io_service_enqueue_qd() - Enqueue a frame to a QD.
@@ -376,7 +376,7 @@ int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d,
 
return qbman_swp_enqueue(d->swp, &ed, fd);
 }
-EXPORT_SYMBOL(dpaa2_io_service_enqueue_qd);
+EXPORT_SYMBOL_GPL(dpaa2_io_service_enqueue_qd);
 
 /**
  * dpaa2_io_service_release() - Release buffers to a buffer pool.
@@ -403,7 +403,7 @@ int dpaa2_io_service_release(struct dpaa2_io *d,
 
return qbman_swp_release(d->swp, &rd, buffers, num_buffers);
 }
-EXPORT_SYMBOL(dpaa2_io_service_release);
+EXPORT_SYMBOL_GPL(dpaa2_io_service_release);
 
 /**
  * dpaa2_io_service_acquire() - Acquire buffers from a buffer pool.
@@ -434,7 +434,7 @@ int dpaa2_io_service_acquire(struct dpaa2_io *d,
 
return err;
 }
-EXPORT_SYMBOL(dpaa2_io_service_acquire);
+EXPORT_SYMBOL_GPL(dpaa2_io_service_acquire);
 
 /*
  * 'Stores' are reusable memory blocks for holding dequeue results, and to
@@ -488,7 +488,7 @@ struct dpaa2_io_store *dpaa2_io_store_create(unsigned int 
max_frames,
 
return ret;
 }
-EXPORT_SYMBOL(dpaa2_io_store_create);
+EXPORT_SYMBOL_GPL(dpaa2_io_store_create);
 
 /**
  * dpaa2_io_store_destroy() - Frees the dma memory storage for dequeue
@@ -502,7 +502,7 @@ void dpaa2_io_store_destroy(struct dpaa2_io_store *s)
kfree(s->alloced_addr);
kfree(s);
 }
-EXPORT_SYMBOL(dpaa2_io_store_destroy);
+EXPORT_SYMBOL_GPL(dpaa2_io_store_destroy);
 
 /**
  * dpaa2_io_store_next() - Determine when the next dequeue result is available.
@@ -550,4 +550,4 @@ struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store 
*s, int *is_last)
 
return ret;
 }
-EXPORT_SYMBOL(dpaa2_io_store_next);
+EXPORT_SYMBOL_GPL(dpaa2_io_store_next);
-- 
2.9.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/10] staging: fsl-mc: use device_type instead of strcmp()

2017-11-17 Thread laurentiu.tudor
From: Laurentiu Tudor 

Replace strcmp() based device type checks with the standard device
model type.

Signed-off-by: Laurentiu Tudor 
---
 drivers/staging/fsl-mc/bus/dprc-driver.c  |  4 ++--
 drivers/staging/fsl-mc/bus/fsl-mc-allocator.c | 20 ++--
 drivers/staging/fsl-mc/bus/fsl-mc-bus.c   |  8 
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c 
b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 28a6b87..131c715 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -593,7 +593,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
bool msi_domain_set = false;
u16 major_ver, minor_ver;
 
-   if (strcmp(mc_dev->obj_desc.type, "dprc") != 0)
+   if (!is_fsl_mc_bus_dprc(mc_dev))
return -EINVAL;
 
if (dev_get_msi_domain(&mc_dev->dev))
@@ -745,7 +745,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
int error;
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
 
-   if (strcmp(mc_dev->obj_desc.type, "dprc") != 0)
+   if (!is_fsl_mc_bus_dprc(mc_dev))
return -EINVAL;
if (!mc_dev->mc_io)
return -EINVAL;
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
index f7fbebd..1000fb3 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
@@ -14,11 +14,11 @@
 
 #include "fsl-mc-private.h"
 
-static bool __must_check fsl_mc_is_allocatable(const char *obj_type)
+static bool __must_check fsl_mc_is_allocatable(struct fsl_mc_device *mc_dev)
 {
-   return strcmp(obj_type, "dpbp") == 0 ||
-  strcmp(obj_type, "dpmcp") == 0 ||
-  strcmp(obj_type, "dpcon") == 0;
+   return is_fsl_mc_bus_dpbp(mc_dev) ||
+  is_fsl_mc_bus_dpmcp(mc_dev) ||
+  is_fsl_mc_bus_dpcon(mc_dev);
 }
 
 /**
@@ -43,7 +43,7 @@ static int __must_check 
fsl_mc_resource_pool_add_device(struct fsl_mc_bus
 
if (pool_type < 0 || pool_type >= FSL_MC_NUM_POOL_TYPES)
goto out;
-   if (!fsl_mc_is_allocatable(mc_dev->obj_desc.type))
+   if (!fsl_mc_is_allocatable(mc_dev))
goto out;
if (mc_dev->resource)
goto out;
@@ -105,7 +105,7 @@ static int __must_check 
fsl_mc_resource_pool_remove_device(struct fsl_mc_device
struct fsl_mc_resource *resource;
int error = -EINVAL;
 
-   if (!fsl_mc_is_allocatable(mc_dev->obj_desc.type))
+   if (!fsl_mc_is_allocatable(mc_dev))
goto out;
 
resource = mc_dev->resource;
@@ -442,7 +442,7 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device 
*mc_dev)
if (irq_count == 0)
return -EINVAL;
 
-   if (strcmp(mc_dev->obj_desc.type, "dprc") == 0)
+   if (is_fsl_mc_bus_dprc(mc_dev))
mc_bus = to_fsl_mc_bus(mc_dev);
else
mc_bus = to_fsl_mc_bus(to_fsl_mc_device(mc_dev->dev.parent));
@@ -505,7 +505,7 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev)
 
irq_count = mc_dev->obj_desc.irq_count;
 
-   if (strcmp(mc_dev->obj_desc.type, "dprc") == 0)
+   if (is_fsl_mc_bus_dprc(mc_dev))
mc_bus = to_fsl_mc_bus(mc_dev);
else
mc_bus = to_fsl_mc_bus(to_fsl_mc_device(mc_dev->dev.parent));
@@ -575,7 +575,7 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device 
*mc_dev)
struct fsl_mc_bus *mc_bus;
int error;
 
-   if (!fsl_mc_is_allocatable(mc_dev->obj_desc.type))
+   if (!fsl_mc_is_allocatable(mc_dev))
return -EINVAL;
 
mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
@@ -604,7 +604,7 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device 
*mc_dev)
 {
int error;
 
-   if (!fsl_mc_is_allocatable(mc_dev->obj_desc.type))
+   if (!fsl_mc_is_allocatable(mc_dev))
return -EINVAL;
 
if (mc_dev->resource) {
diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
index aa935f3..f84bc14 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c
@@ -442,10 +442,10 @@ static int fsl_mc_device_get_mmio_regions(struct 
fsl_mc_device *mc_dev,
struct device *parent_dev = mc_dev->dev.parent;
enum dprc_region_type mc_region_type;
 
-   if (strcmp(obj_desc->type, "dprc") == 0 ||
-   strcmp(obj_desc->type, "dpmcp") == 0) {
+   if (is_fsl_mc_bus_dprc(mc_dev) ||
+   is_fsl_mc_bus_dpmcp(mc_dev)) {
mc_region_type = DPRC_REGION_TYPE_MC_PORTAL;
-   } else if (strcmp(obj_desc->type, "dpio") == 0) {
+   } else if (is_fsl_mc_bus_dpio(mc_dev)) {
mc_region_type = DPRC_REGION_TYPE_QBMAN_PORTAL;
} else {
/*
@@ -520,7 +520,7 @@ static void fsl_mc_device_r

[PATCH] staging: rtl8822be: fix missing null check on dev_alloc_skb return

2017-11-17 Thread Colin King
From: Colin Ian King 

dev_alloc_skb can potentially return NULL, so add a null check to
avoid a null pointer dereference on skb

Detected by CoverityScan, CID#1454558 ("Dereference on null return")

Fixes: 7e5b796cde7e ("staging: r8822be: Add the driver code")
Signed-off-by: Colin Ian King 
---
 drivers/staging/rtlwifi/rtl8822be/fw.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c 
b/drivers/staging/rtlwifi/rtl8822be/fw.c
index f45487122517..483ea85943c3 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -464,6 +464,8 @@ bool rtl8822b_halmac_cb_write_data_rsvd_page(struct 
rtl_priv *rtlpriv, u8 *buf,
int count;
 
skb = dev_alloc_skb(size);
+   if (!skb)
+   return false;
memcpy((u8 *)skb_put(skb, size), buf, size);
 
if (!_rtl8822be_send_bcn_or_cmd_packet(rtlpriv->hw, skb, BEACON_QUEUE))
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8822be: fix missing null check on dev_alloc_skb return

2017-11-17 Thread Larry Finger

On 11/17/2017 08:50 AM, Colin King wrote:

From: Colin Ian King 

dev_alloc_skb can potentially return NULL, so add a null check to
avoid a null pointer dereference on skb


Acked-by: Larry Finger 

Larry



Detected by CoverityScan, CID#1454558 ("Dereference on null return")

Fixes: 7e5b796cde7e ("staging: r8822be: Add the driver code")
Signed-off-by: Colin Ian King 
---
  drivers/staging/rtlwifi/rtl8822be/fw.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c 
b/drivers/staging/rtlwifi/rtl8822be/fw.c
index f45487122517..483ea85943c3 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -464,6 +464,8 @@ bool rtl8822b_halmac_cb_write_data_rsvd_page(struct 
rtl_priv *rtlpriv, u8 *buf,
int count;
  
  	skb = dev_alloc_skb(size);

+   if (!skb)
+   return false;
memcpy((u8 *)skb_put(skb, size), buf, size);
  
  	if (!_rtl8822be_send_bcn_or_cmd_packet(rtlpriv->hw, skb, BEACON_QUEUE))




___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: unisys: visorbus: address theoretical int overflows

2017-11-17 Thread David Kershner
From: Tim Sell 

Add necessary casting to several places where we were doing 32-bit
arithmetic (unsigned) to produce a 64-bit (unsigned long) result, to
prevent the theoretical possibility of a 32-bit overflow during the
arithmetic.

FYI, these are unsigned long:

ctx->param_bytes
ctx->allocbytes

These are unsigned int:

bytes
phdr->name_offset
phdr->name_length

Here is the test program demonstrating why we really need the casts:

void main()
{
unsigned int i;
unsigned long il;

printf("sizeof(int) =%dn",sizeof(i));
printf("sizeof(long)=%dn",sizeof(il));

i = (unsigned int)unsigned long)(1)) << 32) - 1);
printf("i = %un", i);
il = i+1;
printf("adding 1 withOUT cast = %lun", il);
il = (unsigned long)i+1;
printf("adding 1 WITHcast = %lun", il);
}
[selltc@mac tmp]$ gcc x.c -o x.out
[selltc@mac tmp]$ ./x.out
sizeof(int) =4
sizeof(long)=8
i = 4294967295
adding 1 withOUT cast = 0
adding 1 WITHcast = 4294967296

Signed-off-by: Tim Sell 
Reported-by: Dan Carpenter 
Signed-off-by: David Kershner 
Reviewed-by: David Binder 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index fed554a4..ef2823a 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -590,7 +590,8 @@ static void *parser_name_get(struct parser_context *ctx)
struct visor_controlvm_parameters_header *phdr;
 
phdr = &ctx->data;
-   if (phdr->name_offset + phdr->name_length > ctx->param_bytes)
+   if ((unsigned long)phdr->name_offset +
+   (unsigned long)phdr->name_length > ctx->param_bytes)
return NULL;
ctx->curr = (char *)&phdr + phdr->name_offset;
ctx->bytes_remaining = phdr->name_length;
@@ -1317,13 +1318,13 @@ static void parser_done(struct parser_context *ctx)
 static struct parser_context *parser_init_stream(u64 addr, u32 bytes,
 bool *retry)
 {
-   int allocbytes;
+   unsigned long allocbytes;
struct parser_context *ctx;
void *mapping;
 
*retry = false;
/* alloc an extra byte to ensure payload is \0 terminated */
-   allocbytes = bytes + 1 + (sizeof(struct parser_context) -
+   allocbytes = (unsigned long)bytes + 1 + (sizeof(struct parser_context) -
 sizeof(struct visor_controlvm_parameters_header));
if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) >
 MAX_CONTROLVM_PAYLOAD_BYTES) {
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/2] drivers: Move visorbus from staging to drivers/visorbus

2017-11-17 Thread David Kershner
This patch series fixes an issue that was reported by Dan Carpenter, moves
the necessary include files to include/linux/visorbus and then moves the
visorbus driver from drivers/staging/unisys to drivers/visorbus.

Greg, thanks for the review of visorbus and for the assistance to get the
driver to this state.

David Kershner (1):
  drivers: visorbus: move driver out of staging

Tim Sell (1):
  staging: unisys: visorbus: address theoretical int overflows

 MAINTAINERS  | 2 ++
 drivers/Kconfig  | 2 ++
 drivers/Makefile | 1 +
 drivers/staging/unisys/Kconfig   | 1 -
 drivers/staging/unisys/Makefile  | 1 -
 drivers/staging/unisys/include/iochannel.h   | 3 +--
 drivers/staging/unisys/visorhba/visorhba_main.c  | 2 +-
 drivers/staging/unisys/visorinput/visorinput.c   | 2 +-
 drivers/staging/unisys/visornic/visornic_main.c  | 2 +-
 drivers/{staging/unisys => }/visorbus/Kconfig| 4 +++-
 drivers/{staging/unisys => }/visorbus/Makefile   | 2 --
 drivers/{staging/unisys => }/visorbus/controlvmchannel.h | 3 +--
 drivers/{staging/unisys => }/visorbus/vbuschannel.h  | 2 +-
 drivers/{staging/unisys => }/visorbus/visorbus_main.c| 2 +-
 drivers/{staging/unisys => }/visorbus/visorbus_private.h | 2 +-
 drivers/{staging/unisys => }/visorbus/visorchannel.c | 2 +-
 drivers/{staging/unisys => }/visorbus/visorchipset.c | 9 +
 .../staging/unisys/include => include/linux/visorbus}/visorbus.h | 0
 .../unisys/include => include/linux/visorbus}/visorchannel.h | 0
 19 files changed, 22 insertions(+), 20 deletions(-)
 rename drivers/{staging/unisys => }/visorbus/Kconfig (90%)
 rename drivers/{staging/unisys => }/visorbus/Makefile (81%)
 rename drivers/{staging/unisys => }/visorbus/controlvmchannel.h (99%)
 rename drivers/{staging/unisys => }/visorbus/vbuschannel.h (98%)
 rename drivers/{staging/unisys => }/visorbus/visorbus_main.c (99%)
 rename drivers/{staging/unisys => }/visorbus/visorbus_private.h (98%)
 rename drivers/{staging/unisys => }/visorbus/visorchannel.c (99%)
 rename drivers/{staging/unisys => }/visorbus/visorchipset.c (99%)
 rename {drivers/staging/unisys/include => include/linux/visorbus}/visorbus.h 
(100%)
 rename {drivers/staging/unisys/include => 
include/linux/visorbus}/visorchannel.h (100%)

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] drivers: visorbus: move driver out of staging

2017-11-17 Thread David Kershner
The s-Par header files that are referenced by all s-Par drivers, are being
moved into include/linux/visorbus.  Move the visorbus driver out of staging
and modify the configuration and makefiles so they now reference the new
file, this required moving some lines from drivers/staging/unisys/Kconfig
over to drives/visorbus/Kconfig to make sure dependencies were met.
Visorbus will now just live in the /drivers directory.

Signed-off-by: David Kershner 
Reviewed-by: David Binder 
Reviewed-by: Tim Sell 
---
 MAINTAINERS   | 2 ++
 drivers/Kconfig   | 2 ++
 drivers/Makefile  | 1 +
 drivers/staging/unisys/Kconfig| 1 -
 drivers/staging/unisys/Makefile   | 1 -
 drivers/staging/unisys/include/iochannel.h| 3 +--
 drivers/staging/unisys/visorhba/visorhba_main.c   | 2 +-
 drivers/staging/unisys/visorinput/visorinput.c| 2 +-
 drivers/staging/unisys/visornic/visornic_main.c   | 2 +-
 drivers/{staging/unisys => }/visorbus/Kconfig | 4 +++-
 drivers/{staging/unisys => }/visorbus/Makefile| 2 --
 drivers/{staging/unisys => }/visorbus/controlvmchannel.h  | 3 +--
 drivers/{staging/unisys => }/visorbus/vbuschannel.h   | 2 +-
 drivers/{staging/unisys => }/visorbus/visorbus_main.c | 2 +-
 drivers/{staging/unisys => }/visorbus/visorbus_private.h  | 2 +-
 drivers/{staging/unisys => }/visorbus/visorchannel.c  | 2 +-
 drivers/{staging/unisys => }/visorbus/visorchipset.c  | 2 +-
 {drivers/staging/unisys/include => include/linux/visorbus}/visorbus.h | 0
 .../staging/unisys/include => include/linux/visorbus}/visorchannel.h  | 0
 19 files changed, 18 insertions(+), 17 deletions(-)
 rename drivers/{staging/unisys => }/visorbus/Kconfig (90%)
 rename drivers/{staging/unisys => }/visorbus/Makefile (81%)
 rename drivers/{staging/unisys => }/visorbus/controlvmchannel.h (99%)
 rename drivers/{staging/unisys => }/visorbus/vbuschannel.h (98%)
 rename drivers/{staging/unisys => }/visorbus/visorbus_main.c (99%)
 rename drivers/{staging/unisys => }/visorbus/visorbus_private.h (98%)
 rename drivers/{staging/unisys => }/visorbus/visorchannel.c (99%)
 rename drivers/{staging/unisys => }/visorbus/visorchipset.c (99%)
 rename {drivers/staging/unisys/include => include/linux/visorbus}/visorbus.h 
(100%)
 rename {drivers/staging/unisys/include => 
include/linux/visorbus}/visorchannel.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 650aa0e..a1df0e9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13835,6 +13835,8 @@ UNISYS S-PAR DRIVERS
 M: David Kershner 
 L: sparmaintai...@unisys.com (Unisys internal)
 S: Supported
+F: include/linux/visorbus/
+F: drivers/visorbus/
 F: drivers/staging/unisys/
 
 UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 152744c..ef5fb83 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -211,4 +211,6 @@ source "drivers/mux/Kconfig"
 
 source "drivers/opp/Kconfig"
 
+source "drivers/visorbus/Kconfig"
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 1d034b6..d5061ed 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -183,3 +183,4 @@ obj-$(CONFIG_FPGA)  += fpga/
 obj-$(CONFIG_FSI)  += fsi/
 obj-$(CONFIG_TEE)  += tee/
 obj-$(CONFIG_MULTIPLEXER)  += mux/
+obj-$(CONFIG_UNISYS_VISORBUS)  += visorbus/
diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index 4f1f5e6..688b5e3 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -11,7 +11,6 @@ menuconfig UNISYSSPAR
 
 if UNISYSSPAR
 
-source "drivers/staging/unisys/visorbus/Kconfig"
 source "drivers/staging/unisys/visornic/Kconfig"
 source "drivers/staging/unisys/visorinput/Kconfig"
 source "drivers/staging/unisys/visorhba/Kconfig"
diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile
index 20eb098..e45f44b 100644
--- a/drivers/staging/unisys/Makefile
+++ b/drivers/staging/unisys/Makefile
@@ -1,7 +1,6 @@
 #
 # Makefile for Unisys SPAR drivers
 #
-obj-$(CONFIG_UNISYS_VISORBUS)  += visorbus/
 obj-$(CONFIG_UNISYS_VISORNIC)  += visornic/
 obj-$(CONFIG_UNISYS_VISORINPUT)+= visorinput/
 obj-$(CONFIG_UNISYS_VISORHBA)  += visorhba/
diff --git a/drivers/staging/unisys/include/iochannel.h 
b/drivers/staging/unisys/include/iochannel.h
index 5cd407c..6e401a7 100644
--- a/drivers/staging/unisys/include/iochannel.h
+++ b/drivers/staging/unisys/include/iochannel.h
@@ -43,8 +43,7 @@
 
 #include 
 #include 
-
-#include "visorchannel.h"
+#include 
 
 /*
  * Must increment these whenever you insert or 

Re: [PATCH] staging: octeon-usb: use __delay() instead of cvmx_wait()

2017-11-17 Thread Steven J. Hill
On 11/17/2017 04:06 AM, James Hogan wrote:
> On Fri, Nov 17, 2017 at 09:50:10AM +0200, Aaro Koskinen wrote:
>> Commit edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait()
>> everywhere.") deleted cvmx_wait() but forgot to update OCTEON USB
>> staging driver. Fix that to allow driver build.
>>
>> Fixes: edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait() everywhere.")
>> Signed-off-by: Aaro Koskinen 
> 
> Reviewed-by: James Hogan 
> 
> Should this driver be enabled in the MIPS cavium_octeon_defconfig or
> should that not happen until the driver comes out of staging?
> 
I think it should be enabled in the defconfig. I will update the
config file this evening and post a patch. There are some other
things that should be on by default and some Kconfig fixes too.

Steve
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: octeon-usb: use __delay() instead of cvmx_wait()

2017-11-17 Thread Aaro Koskinen
Hi,

On Fri, Nov 17, 2017 at 11:45:06AM -0600, Steven J. Hill wrote:
> On 11/17/2017 04:06 AM, James Hogan wrote:
> > On Fri, Nov 17, 2017 at 09:50:10AM +0200, Aaro Koskinen wrote:
> >> Commit edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait()
> >> everywhere.") deleted cvmx_wait() but forgot to update OCTEON USB
> >> staging driver. Fix that to allow driver build.
> >>
> >> Fixes: edf188bee1d9 ("MIPS: Octeon: Remove usage of cvmx_wait() 
> >> everywhere.")
> >> Signed-off-by: Aaro Koskinen 
> > 
> > Reviewed-by: James Hogan 
> > 
> > Should this driver be enabled in the MIPS cavium_octeon_defconfig or
> > should that not happen until the driver comes out of staging?
>
> I think it should be enabled in the defconfig. I will update the
> config file this evening and post a patch. There are some other
> things that should be on by default and some Kconfig fixes too.

It was already added in b4f37b2f2f7e ("MIPS: OCTEON:
cavium_octeon_defconfig: enable all OCTEON SoC drivers"), but got dropped
with f922bc0ad08b ("MIPS: Octeon: cavium_octeon_defconfig: Enable more
drivers"), probably by accident.

A.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ccree: fix incorrect indentation of break statement

2017-11-17 Thread Colin King
From: Colin Ian King 

The break statement is indented one level too many, fix this.

Signed-off-by: Colin Ian King 
---
 drivers/staging/ccree/ssi_aead.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index ba0954e4d2e5..446da9d47cd9 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -2108,7 +2108,7 @@ static int ssi_aead_process(struct aead_request *req, 
enum drv_crypto_direction
if (ctx->cipher_mode == DRV_CIPHER_GCTR)
ssi_aead_gcm(req, desc, &seq_len);
 #endif /*SSI_CC_HAS_AES_GCM*/
-   break;
+   break;
 #endif
default:
dev_err(dev, "Unsupported authenc (%d)\n", ctx->auth_mode);
-- 
2.14.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] drivers: visorbus: move driver out of staging

2017-11-17 Thread Christoph Hellwig
Please don' tcreate new subdirectories under include/linux
if you don't have to.

Also who outside of unisys has reviewed this whole code?

Instead of a move please send an actual patchset to add the new files
so people can review it just like any other code.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] binder: fix proc->files use-after-free

2017-11-17 Thread Al Viro
On Thu, Nov 16, 2017 at 09:56:50AM -0800, Todd Kjos wrote:

> +static struct files_struct *binder_get_files_struct(struct binder_proc *proc)
> +{
> + return get_files_struct(proc->tsk);
> +}

Hell, _no_.  You should never, ever use the result of get_files_struct() for
write access.  It's strictly for "let me look at other process' descriptor
table".  The whole reason for proc->files is that we want to keep a reference
that *could* be used for modifying the damn thing.  And such can be obtained
only by the process itself.

The rules are:
* you can use current->files both for read and write
* you can use get_files_struct(current) to get a reference that
can be used for modifying the damn thing.  Then it can be passed to
any other process and used by it.
* you can use get_files_struct(some_other_task) to get a reference
that can be used for examining the descriptor table of that other task.

Violation of those rules means an exploitable race.  Here's the logics
fdget() and friends are based on: "I'm going to do something to file
refered by descriptor N.  If my descriptor table is not shared, all
struct file references in it will stay around - I'm not changing it,
nobody else has it as their ->current, so any additional references
to that descriptor table will *not* be used for modifying it.
In other words, I don't need to bump the refcount of struct file I'm
about to work with - the reference from my descriptor table will keep
it alive".

Your patch breaks those assumptions.  NAK.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 2/2] drivers: visorbus: move driver out of staging

2017-11-17 Thread Kershner, David A
> -Original Message-
> From: Christoph Hellwig [mailto:h...@infradead.org]
> Sent: Friday, November 17, 2017 2:18 PM
> To: Kershner, David A 
> Cc: gre...@linuxfoundation.org; jes.soren...@gmail.com; linux-
> ker...@vger.kernel.org; driverdev-devel@linuxdriverproject.org; *S-Par-
> Maintainer ; erik.arfvid...@gmail.com;
> wadgaonkar...@gmail.com
> Subject: Re: [PATCH 2/2] drivers: visorbus: move driver out of staging
> 
> Please don' tcreate new subdirectories under include/linux
> if you don't have to.
> 

Thanks for the feedback, the s-Par drivers have 3 include files in the
 include directory in drivers/staging/unisys/include. The patch currently
 moves 2 of them, and the third will be moved when the other drivers
 get out of staging. When I did the move, I thought one directory with
 three files would be cleaner than just adding three files to include. I
 will change that.

> Also who outside of unisys has reviewed this whole code?
> 

The driver has been in staging for 4 years with significant rework during
that period of time. Throughout that time, we have had input from several
different engineers, including Dan Carpenter, Jes Sorenson, and Greg KH.
In October, I requested a formal review from the community and after the
review had completed, Greg gave us the okay to move them out of staging.

> Instead of a move please send an actual patchset to add the new files
> so people can review it just like any other code.

Okay, I'll redo the patchset to show the explicit add of the files to
 the drivers directory.

Thanks,
David Kershner



smime.p7s
Description: S/MIME cryptographic signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] Replace 'uint32_t' with 'u32' and 'uint64_t' with 'u64'

2017-11-17 Thread Dilger, Andreas
On Nov 17, 2017, at 04:46, Roman Storozhenko  wrote:
> 
> There are two reasons for that:
> 1) As Linus Torvalds said we should use kernel types:
> http://lkml.iu.edu/hypermail//linux/kernel/1506.0/00160.html
> 
> 2) There are only few places in the lustre codebase that use such types.
> In the most cases it uses 'u32' and 'u64'.
> 
> Signed-off-by: Roman Storozhenko 

Reviewed-by: Andreas Dilger 

> ---
> In the first version of this patch I replaced 'uint32_t' with '__u32' and
> 'uint64_t' with '__u64'. I was suggested to fix that by Greg K-H:
> 
> "The __ types are only needed for when you cross the user/kernel boundry.
> Otherwise just use the "normal" types of u32 and u64.
> 
> Do the changes you made here all cross that boundry?  If not, please fix
> this up."
> 
> I asked lustre community whether those code used only in the kernel
> space and Andreas Dilger said:
> 
> "These headers are for kernel code only, so should use the "u32" and
> similar
> types, rather than the "__u32" that are used for user-kernel
> structures."
> 
> So I have replaced my first patch version with this one.
> 
> drivers/staging/lustre/lustre/include/lustre_sec.h |  4 ++--
> drivers/staging/lustre/lustre/llite/vvp_dev.c  |  2 +-
> drivers/staging/lustre/lustre/lov/lov_internal.h   | 12 ++--
> drivers/staging/lustre/lustre/osc/osc_internal.h   |  6 +++---
> 4 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h 
> b/drivers/staging/lustre/lustre/include/lustre_sec.h
> index a40f706..64b6fd4 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_sec.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h
> @@ -341,8 +341,8 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd);
> #define SPTLRPC_MAX_PAYLOAD (1024)
> 
> struct vfs_cred {
> - uint32_tvc_uid;
> - uint32_tvc_gid;
> + u32 vc_uid;
> + u32 vc_gid;
> };
> 
> struct ptlrpc_ctx_ops {
> diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c 
> b/drivers/staging/lustre/lustre/llite/vvp_dev.c
> index 8ccc8b7..987c03b 100644
> --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
> +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
> @@ -384,7 +384,7 @@ int cl_sb_fini(struct super_block *sb)
> struct vvp_pgcache_id {
>   unsigned int vpi_bucket;
>   unsigned int vpi_depth;
> - uint32_t vpi_index;
> + u32  vpi_index;
> 
>   unsigned int vpi_curdep;
>   struct lu_object_header *vpi_obj;
> diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h 
> b/drivers/staging/lustre/lustre/lov/lov_internal.h
> index ae28ddf..a56d71c 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_internal.h
> +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
> @@ -115,19 +115,19 @@ static inline const struct lsm_operations 
> *lsm_op_find(int magic)
>  */
> #if BITS_PER_LONG == 64
> # define lov_do_div64(n, base) ({ \
> - uint64_t __base = (base);   \
> - uint64_t __rem; \
> - __rem = ((uint64_t)(n)) % __base;   \
> - (n) = ((uint64_t)(n)) / __base; \
> + u64 __base = (base);\
> + u64 __rem;  \
> + __rem = ((u64)(n)) % __base;\
> + (n) = ((u64)(n)) / __base;  \
>   __rem;  \
> })
> #elif BITS_PER_LONG == 32
> # define lov_do_div64(n, base) ({ \
> - uint64_t __rem; \
> + u64 __rem;  \
>   if ((sizeof(base) > 4) && (((base) & 0xULL) != 0)) {  \
>   int __remainder;  \
>   LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), "64 bit lov " \
> -  "division %llu / %llu\n", (n), (uint64_t)(base));\
> +  "division %llu / %llu\n", (n), (u64)(base));\
>   __remainder = (n) & (LOV_MIN_STRIPE_SIZE - 1);  \
>   (n) >>= LOV_MIN_STRIPE_BITS;\
>   __rem = do_div(n, (base) >> LOV_MIN_STRIPE_BITS);   \
> diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h 
> b/drivers/staging/lustre/lustre/osc/osc_internal.h
> index feda61b..32db150 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_internal.h
> +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
> @@ -168,9 +168,9 @@ struct osc_device {
> 
>   /* Write stats is actually protected by client_obd's lock. */
>   struct osc_stats {
> -