Re: [PATCH] sched: idle: Reenable sched tick for cpuidle request

2018-08-09 Thread leo . yan
On Thu, Aug 09, 2018 at 11:31:46PM +0200, Rafael J . Wysocki wrote:

[...]

> > >> And I really would prefer to avoid restarting the tick here, because
> > >> it is overhead and quite likely unnecessary.
> > >
> > > I understand the logic when read the code, actually I did some experiments
> > > on the function menu_select(), in menu_select() function it discards the
> > > consideration for typical pattern interval and it also tries to avoid to
> > > enable tick and select more shallow state at the bottom of function.  So I
> > > agree that in the middle of idles it's redundant to reenable tick and the
> > > code is careful thought.
> > >
> > > But this patch tries to rescue the case at the last time the CPU enter one
> > > shallow idle state but without wake up event.
> > 
> > It is better to avoid entering a shallow state IMO.  Let me think
> > about that a bit.
> 
> The simple change below should address this issue and I don't quite see
> what it can break.  It may cause deeper idle states to be selected with
> the tick already stopped, but that really shouldn't be problematic, as
> (since the tick has been stopped) there are no strict latency constraints,
> so even if there is an early wakeup, we should be able to tolerate the
> extra latency just fine.
> 
> ---
>  drivers/cpuidle/governors/menu.c |   10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> Index: linux-pm/drivers/cpuidle/governors/menu.c
> ===
> --- linux-pm.orig/drivers/cpuidle/governors/menu.c
> +++ linux-pm/drivers/cpuidle/governors/menu.c
> @@ -349,14 +349,12 @@ static int menu_select(struct cpuidle_dr
>* If the tick is already stopped, the cost of possible short
>* idle duration misprediction is much higher, because the CPU
>* may be stuck in a shallow idle state for a long time as a
> -  * result of it.  In that case say we might mispredict and try
> -  * to force the CPU into a state for which we would have stopped
> -  * the tick, unless a timer is going to expire really soon
> -  * anyway.
> +  * result of it.  In that case say we might mispredict and use
> +  * the known time to the closest timer event for the idle state
> +  * selection.
>*/
>   if (data->predicted_us < TICK_USEC)
> - data->predicted_us = min_t(unsigned int, TICK_USEC,
> -ktime_to_us(delta_next));
> + data->predicted_us = ktime_to_us(delta_next);

I did the testing on this, but above change cannot really resolve the
issue, it misses to handle the case if 'data->predicted_us > TICK_USEC';
if the prediction is longer than TICK_USEC, e.g. data->predicted_us is
2ms, TICK_USEC=1ms;  for this case the deepest state will not be
chosen and if the data->predicted_us is decided by typical pattern
value but not the closest timer, finally the CPU still might stay in
shallow state for long time.

Actually in the CPU idle loop with the tick is stopped, I think we
should achieve two targets:
- Ensure the CPU can enter the deepest idle state at the last time it
  runs into into idle;
- In the middle of idles, we will not reenable the tick at all; though
  the idle states can be chosen a shallow state for short prediction;

To achieve the first target, we need to define what's the possible
case the CPU might stay into shallow state but cannot be waken up in
short time; so for this purpose it's pointeless to compare the value
between 'data->predicted_us' and TICK_USEC, so I'd like to check if
the next timer event is reliable to wake up CPU in short time, this
can be finished by comparison between 'ktime_to_us(delta_next)' with
maximum target residency;

For the second target, we should not enable the tick again in the idle
loop after the tick is stopped, whatever the governor choose any idle
state.

So how about below changes?  I did some verify on this.

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 30ab759..e2de7c2 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -351,18 +351,21 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev,
data->predicted_us = min(data->predicted_us, expected_interval);
 
if (tick_nohz_tick_stopped()) {
+   unsigned int delta_next_us = ktime_to_us(delta_next);
+
/*
 * If the tick is already stopped, the cost of possible short
 * idle duration misprediction is much higher, because the CPU
 * may be stuck in a shallow idle state for a long time as a
-* result of it.  In that case say we might mispredict and try
-* to force the CPU into a state for which we would have stopped
-* the 

Re: [PATCH] sched: idle: Reenable sched tick for cpuidle request

2018-08-09 Thread leo . yan
On Thu, Aug 09, 2018 at 11:31:46PM +0200, Rafael J . Wysocki wrote:

[...]

> > >> And I really would prefer to avoid restarting the tick here, because
> > >> it is overhead and quite likely unnecessary.
> > >
> > > I understand the logic when read the code, actually I did some experiments
> > > on the function menu_select(), in menu_select() function it discards the
> > > consideration for typical pattern interval and it also tries to avoid to
> > > enable tick and select more shallow state at the bottom of function.  So I
> > > agree that in the middle of idles it's redundant to reenable tick and the
> > > code is careful thought.
> > >
> > > But this patch tries to rescue the case at the last time the CPU enter one
> > > shallow idle state but without wake up event.
> > 
> > It is better to avoid entering a shallow state IMO.  Let me think
> > about that a bit.
> 
> The simple change below should address this issue and I don't quite see
> what it can break.  It may cause deeper idle states to be selected with
> the tick already stopped, but that really shouldn't be problematic, as
> (since the tick has been stopped) there are no strict latency constraints,
> so even if there is an early wakeup, we should be able to tolerate the
> extra latency just fine.
> 
> ---
>  drivers/cpuidle/governors/menu.c |   10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> Index: linux-pm/drivers/cpuidle/governors/menu.c
> ===
> --- linux-pm.orig/drivers/cpuidle/governors/menu.c
> +++ linux-pm/drivers/cpuidle/governors/menu.c
> @@ -349,14 +349,12 @@ static int menu_select(struct cpuidle_dr
>* If the tick is already stopped, the cost of possible short
>* idle duration misprediction is much higher, because the CPU
>* may be stuck in a shallow idle state for a long time as a
> -  * result of it.  In that case say we might mispredict and try
> -  * to force the CPU into a state for which we would have stopped
> -  * the tick, unless a timer is going to expire really soon
> -  * anyway.
> +  * result of it.  In that case say we might mispredict and use
> +  * the known time to the closest timer event for the idle state
> +  * selection.
>*/
>   if (data->predicted_us < TICK_USEC)
> - data->predicted_us = min_t(unsigned int, TICK_USEC,
> -ktime_to_us(delta_next));
> + data->predicted_us = ktime_to_us(delta_next);

I did the testing on this, but above change cannot really resolve the
issue, it misses to handle the case if 'data->predicted_us > TICK_USEC';
if the prediction is longer than TICK_USEC, e.g. data->predicted_us is
2ms, TICK_USEC=1ms;  for this case the deepest state will not be
chosen and if the data->predicted_us is decided by typical pattern
value but not the closest timer, finally the CPU still might stay in
shallow state for long time.

Actually in the CPU idle loop with the tick is stopped, I think we
should achieve two targets:
- Ensure the CPU can enter the deepest idle state at the last time it
  runs into into idle;
- In the middle of idles, we will not reenable the tick at all; though
  the idle states can be chosen a shallow state for short prediction;

To achieve the first target, we need to define what's the possible
case the CPU might stay into shallow state but cannot be waken up in
short time; so for this purpose it's pointeless to compare the value
between 'data->predicted_us' and TICK_USEC, so I'd like to check if
the next timer event is reliable to wake up CPU in short time, this
can be finished by comparison between 'ktime_to_us(delta_next)' with
maximum target residency;

For the second target, we should not enable the tick again in the idle
loop after the tick is stopped, whatever the governor choose any idle
state.

So how about below changes?  I did some verify on this.

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 30ab759..e2de7c2 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -351,18 +351,21 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev,
data->predicted_us = min(data->predicted_us, expected_interval);
 
if (tick_nohz_tick_stopped()) {
+   unsigned int delta_next_us = ktime_to_us(delta_next);
+
/*
 * If the tick is already stopped, the cost of possible short
 * idle duration misprediction is much higher, because the CPU
 * may be stuck in a shallow idle state for a long time as a
-* result of it.  In that case say we might mispredict and try
-* to force the CPU into a state for which we would have stopped
-* the 

Re: [PATCH 2/3] perf report: Add raw report support for s390 auxiliary trace

2018-08-09 Thread Michael Ellerman
Arnaldo Carvalho de Melo  writes:
> Em Thu, Aug 09, 2018 at 06:35:58AM +0200, Thomas-Mich Richter escreveu:
>> On 08/08/2018 06:42 PM, Arnaldo Carvalho de Melo wrote:
>> > So for those I applied this, seems to pass the ones that were failing,
>> > restarting tests...
>
>> I just updated the perf/core branch, compiled it and all works fine.
>
> Thanks for checking!

Yep all building OK here too.

Thanks all.

cheers


Re: [PATCH 2/3] perf report: Add raw report support for s390 auxiliary trace

2018-08-09 Thread Michael Ellerman
Arnaldo Carvalho de Melo  writes:
> Em Thu, Aug 09, 2018 at 06:35:58AM +0200, Thomas-Mich Richter escreveu:
>> On 08/08/2018 06:42 PM, Arnaldo Carvalho de Melo wrote:
>> > So for those I applied this, seems to pass the ones that were failing,
>> > restarting tests...
>
>> I just updated the perf/core branch, compiled it and all works fine.
>
> Thanks for checking!

Yep all building OK here too.

Thanks all.

cheers


[PATCH] sched/fair : fix typos

2018-08-09 Thread Peng Hao
Signed-off-by: Peng Hao 
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2f0a0be..b7ab23d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3315,7 +3315,7 @@ static inline void cfs_se_util_change(struct sched_avg 
*avg)
  *
  * XXX collapse load_sum and runnable_load_sum
  *
- * cfq_rs:
+ * cfs_rq:
  *
  *   load_sum = \Sum se_weight(se) * se->avg.load_sum
  *   load_avg = \Sum se->avg.load_avg
-- 
1.8.3.1



[PATCH] sched/fair : fix typos

2018-08-09 Thread Peng Hao
Signed-off-by: Peng Hao 
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2f0a0be..b7ab23d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3315,7 +3315,7 @@ static inline void cfs_se_util_change(struct sched_avg 
*avg)
  *
  * XXX collapse load_sum and runnable_load_sum
  *
- * cfq_rs:
+ * cfs_rq:
  *
  *   load_sum = \Sum se_weight(se) * se->avg.load_sum
  *   load_avg = \Sum se->avg.load_avg
-- 
1.8.3.1



Re: [PATCH] perf tools: Check for null when copying nsinfo.

2018-08-09 Thread Namhyung Kim
Hello,

On Thu, Aug 09, 2018 at 11:53:48PM +0200, Benno Evers wrote:
> The argument to nsinfo__copy() was assumed to be valid, but some code paths
> exist that will lead to NULL being passed.
> 
> In particular, running 'perf script -D' on a perf.data file containing an
> PERF_RECORD_MMAP event associating the '[vdso]' dso with pid 0 earlier in
> the event stream will lead to a segfault.
> 
> Since all calling code is already checking for a non-null return value,
> just return NULL for this case as well.

Acked-by: Namhyung Kim 

It seems you missed the Signed-off-by though.

Thanks,
Namhyung


> ---
>  tools/perf/util/namespaces.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
> index 5be021701f34..cf8bd123cf73 100644
> --- a/tools/perf/util/namespaces.c
> +++ b/tools/perf/util/namespaces.c
> @@ -139,6 +139,9 @@ struct nsinfo *nsinfo__copy(struct nsinfo *nsi)
>  {
>   struct nsinfo *nnsi;
>  
> + if (nsi == NULL)
> + return NULL;
> +
>   nnsi = calloc(1, sizeof(*nnsi));
>   if (nnsi != NULL) {
>   nnsi->pid = nsi->pid;
> -- 
> 2.17.1
> 


Re: [PATCH] perf tools: Check for null when copying nsinfo.

2018-08-09 Thread Namhyung Kim
Hello,

On Thu, Aug 09, 2018 at 11:53:48PM +0200, Benno Evers wrote:
> The argument to nsinfo__copy() was assumed to be valid, but some code paths
> exist that will lead to NULL being passed.
> 
> In particular, running 'perf script -D' on a perf.data file containing an
> PERF_RECORD_MMAP event associating the '[vdso]' dso with pid 0 earlier in
> the event stream will lead to a segfault.
> 
> Since all calling code is already checking for a non-null return value,
> just return NULL for this case as well.

Acked-by: Namhyung Kim 

It seems you missed the Signed-off-by though.

Thanks,
Namhyung


> ---
>  tools/perf/util/namespaces.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
> index 5be021701f34..cf8bd123cf73 100644
> --- a/tools/perf/util/namespaces.c
> +++ b/tools/perf/util/namespaces.c
> @@ -139,6 +139,9 @@ struct nsinfo *nsinfo__copy(struct nsinfo *nsi)
>  {
>   struct nsinfo *nnsi;
>  
> + if (nsi == NULL)
> + return NULL;
> +
>   nnsi = calloc(1, sizeof(*nnsi));
>   if (nnsi != NULL) {
>   nnsi->pid = nsi->pid;
> -- 
> 2.17.1
> 


Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Guenter Roeck

On 08/09/2018 08:59 PM, Palmer Dabbelt wrote:
[ ... ]

Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV


Here are my qemu command lines:

qemu-system-riscv64 -M virt -m 512M -no-reboot -bios bbl \
-kernel vmlinux -netdev user,id=net0 -device 
virtio-net-device,netdev=net0 \
-initrd rootfs.cpio \
-append 'rdinit=/sbin/init earlycon console=ttyS0,115200' \
-nographic -monitor none

qemu-system-riscv64 -M virt -m 512M -no-reboot -bios bbl \
-kernel vmlinux -netdev user,id=net0 -device 
virtio-net-device,netdev=net0 \
-device virtio-blk-device,drive=d0 \
-drive file=rootfs.ext2,if=none,id=d0,format=raw \
-append 'root=/dev/vda rw earlycon console=ttyS0,115200' \
-nographic -monitor none

Root file systems and the bbl binary are published at
https://github.com/groeck/linux-build-test/tree/master/rootfs/riscv64

Hint: If you specify "noreboot" as additional command line option, you'll end 
up in a shell.

Qemu version:
https://github.com/riscv/riscv-qemu.git branch 'v3.0.0-local-riscv'

Guenter


Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Guenter Roeck

On 08/09/2018 08:59 PM, Palmer Dabbelt wrote:
[ ... ]

Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV


Here are my qemu command lines:

qemu-system-riscv64 -M virt -m 512M -no-reboot -bios bbl \
-kernel vmlinux -netdev user,id=net0 -device 
virtio-net-device,netdev=net0 \
-initrd rootfs.cpio \
-append 'rdinit=/sbin/init earlycon console=ttyS0,115200' \
-nographic -monitor none

qemu-system-riscv64 -M virt -m 512M -no-reboot -bios bbl \
-kernel vmlinux -netdev user,id=net0 -device 
virtio-net-device,netdev=net0 \
-device virtio-blk-device,drive=d0 \
-drive file=rootfs.ext2,if=none,id=d0,format=raw \
-append 'root=/dev/vda rw earlycon console=ttyS0,115200' \
-nographic -monitor none

Root file systems and the bbl binary are published at
https://github.com/groeck/linux-build-test/tree/master/rootfs/riscv64

Hint: If you specify "noreboot" as additional command line option, you'll end 
up in a shell.

Qemu version:
https://github.com/riscv/riscv-qemu.git branch 'v3.0.0-local-riscv'

Guenter


Re: [PATCH v1 01/10] arm/arm64: dts: msm8974/msm8916: thermal: Split address space into two

2018-08-09 Thread Amit Kucheria
On Fri, Aug 10, 2018 at 12:41 AM Matthias Kaehlcke  wrote:
>
> On Thu, Aug 09, 2018 at 06:02:33PM +0530, Amit Kucheria wrote:
> > We've earlier added support to split the register address space into TM
> > and SROT regions.
> >
> > Split up the regmap address space into two for the remaining platforms that
> > have a similar register layout and make corresponding changes to the
> > get_temp_common() function used by these platforms.
> >
> > Since tsens-common.c/init_common() currently only registers one address
> > space, the order is important (TM before SROT).  This is OK since the code
> > doesn't really use the SROT functionality yet.
> >
> > Signed-off-by: Amit Kucheria 
> > ---
> >  arch/arm/boot/dts/qcom-msm8974.dtsi   | 6 --
> >  arch/arm64/boot/dts/qcom/msm8916.dtsi | 6 --
> >  drivers/thermal/qcom/tsens-common.c   | 5 +++--
> >  3 files changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi 
> > b/arch/arm/boot/dts/qcom-msm8974.dtsi
> > index d9019a49b292..3c4b81c29798 100644
> > --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
> > +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
> > @@ -427,11 +427,13 @@
> >   };
> >   };
> >
> > - tsens: thermal-sensor@fc4a8000 {
> > + tsens: thermal-sensor@fc4a9000 {
> >   compatible = "qcom,msm8974-tsens";
> > - reg = <0xfc4a8000 0x2000>;
> > + reg = <0xfc4a9000 0x1000>, /* TM */
> > +   <0xfc4a8000 0x1000>; /* SROT */
> >   nvmem-cells = <_calib>, <_backup>;
> >   nvmem-cell-names = "calib", "calib_backup";
> > + #qcom,sensors = <11>;
>
> nit: adding the number of sensors isn't directly related and probably
> should be in a separate patch. Not important enough to re-spin just
> for this though ;-)

Hi Matthias,

Sometimes the urge to avoid frivolous patches takes over too strongly. :-)

I'll split it out in a respin. Thanks for the quick review of the series.

Regards,
Amit

> >   #thermal-sensor-cells = <1>;
> >   };
> >
> > diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi 
> > b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> > index cc1040eacdf5..abf84df5a7bc 100644
> > --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> > @@ -774,11 +774,13 @@
> >   };
> >   };
> >
> > - tsens: thermal-sensor@4a8000 {
> > + tsens: thermal-sensor@4a9000 {
> >   compatible = "qcom,msm8916-tsens";
> > - reg = <0x4a8000 0x2000>;
> > + reg = <0x4a9000 0x1000>, /* TM */
> > +   <0x4a8000 0x1000>; /* SROT */
> >   nvmem-cells = <_caldata>, <_calsel>;
> >   nvmem-cell-names = "calib", "calib_sel";
> > + #qcom,sensors = <5>;
>
> ditto
>
> >   #thermal-sensor-cells = <1>;
> >   };
> >
> > diff --git a/drivers/thermal/qcom/tsens-common.c 
> > b/drivers/thermal/qcom/tsens-common.c
> > index 6207d8d92351..478739543bbc 100644
> > --- a/drivers/thermal/qcom/tsens-common.c
> > +++ b/drivers/thermal/qcom/tsens-common.c
> > @@ -21,7 +21,7 @@
> >  #include 
> >  #include "tsens.h"
> >
> > -#define S0_ST_ADDR   0x1030
> > +#define STATUS_OFFSET0x30
> >  #define SN_ADDR_OFFSET   0x4
> >  #define SN_ST_TEMP_MASK  0x3ff
> >  #define CAL_DEGC_PT1 30
> > @@ -107,8 +107,9 @@ int get_temp_common(struct tsens_device *tmdev, int id, 
> > int *temp)
> >   unsigned int status_reg;
> >   int last_temp = 0, ret;
> >
> > - status_reg = S0_ST_ADDR + s->hw_id * SN_ADDR_OFFSET;
> > + status_reg = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * 
> > SN_ADDR_OFFSET;
> >   ret = regmap_read(tmdev->map, status_reg, );
> > +
> >   if (ret)
> >   return ret;
> >   last_temp = code & SN_ST_TEMP_MASK;
>
> Reviewed-by: Matthias Kaehlcke 


Re: [PATCH v1 01/10] arm/arm64: dts: msm8974/msm8916: thermal: Split address space into two

2018-08-09 Thread Amit Kucheria
On Fri, Aug 10, 2018 at 12:41 AM Matthias Kaehlcke  wrote:
>
> On Thu, Aug 09, 2018 at 06:02:33PM +0530, Amit Kucheria wrote:
> > We've earlier added support to split the register address space into TM
> > and SROT regions.
> >
> > Split up the regmap address space into two for the remaining platforms that
> > have a similar register layout and make corresponding changes to the
> > get_temp_common() function used by these platforms.
> >
> > Since tsens-common.c/init_common() currently only registers one address
> > space, the order is important (TM before SROT).  This is OK since the code
> > doesn't really use the SROT functionality yet.
> >
> > Signed-off-by: Amit Kucheria 
> > ---
> >  arch/arm/boot/dts/qcom-msm8974.dtsi   | 6 --
> >  arch/arm64/boot/dts/qcom/msm8916.dtsi | 6 --
> >  drivers/thermal/qcom/tsens-common.c   | 5 +++--
> >  3 files changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi 
> > b/arch/arm/boot/dts/qcom-msm8974.dtsi
> > index d9019a49b292..3c4b81c29798 100644
> > --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
> > +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
> > @@ -427,11 +427,13 @@
> >   };
> >   };
> >
> > - tsens: thermal-sensor@fc4a8000 {
> > + tsens: thermal-sensor@fc4a9000 {
> >   compatible = "qcom,msm8974-tsens";
> > - reg = <0xfc4a8000 0x2000>;
> > + reg = <0xfc4a9000 0x1000>, /* TM */
> > +   <0xfc4a8000 0x1000>; /* SROT */
> >   nvmem-cells = <_calib>, <_backup>;
> >   nvmem-cell-names = "calib", "calib_backup";
> > + #qcom,sensors = <11>;
>
> nit: adding the number of sensors isn't directly related and probably
> should be in a separate patch. Not important enough to re-spin just
> for this though ;-)

Hi Matthias,

Sometimes the urge to avoid frivolous patches takes over too strongly. :-)

I'll split it out in a respin. Thanks for the quick review of the series.

Regards,
Amit

> >   #thermal-sensor-cells = <1>;
> >   };
> >
> > diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi 
> > b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> > index cc1040eacdf5..abf84df5a7bc 100644
> > --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> > @@ -774,11 +774,13 @@
> >   };
> >   };
> >
> > - tsens: thermal-sensor@4a8000 {
> > + tsens: thermal-sensor@4a9000 {
> >   compatible = "qcom,msm8916-tsens";
> > - reg = <0x4a8000 0x2000>;
> > + reg = <0x4a9000 0x1000>, /* TM */
> > +   <0x4a8000 0x1000>; /* SROT */
> >   nvmem-cells = <_caldata>, <_calsel>;
> >   nvmem-cell-names = "calib", "calib_sel";
> > + #qcom,sensors = <5>;
>
> ditto
>
> >   #thermal-sensor-cells = <1>;
> >   };
> >
> > diff --git a/drivers/thermal/qcom/tsens-common.c 
> > b/drivers/thermal/qcom/tsens-common.c
> > index 6207d8d92351..478739543bbc 100644
> > --- a/drivers/thermal/qcom/tsens-common.c
> > +++ b/drivers/thermal/qcom/tsens-common.c
> > @@ -21,7 +21,7 @@
> >  #include 
> >  #include "tsens.h"
> >
> > -#define S0_ST_ADDR   0x1030
> > +#define STATUS_OFFSET0x30
> >  #define SN_ADDR_OFFSET   0x4
> >  #define SN_ST_TEMP_MASK  0x3ff
> >  #define CAL_DEGC_PT1 30
> > @@ -107,8 +107,9 @@ int get_temp_common(struct tsens_device *tmdev, int id, 
> > int *temp)
> >   unsigned int status_reg;
> >   int last_temp = 0, ret;
> >
> > - status_reg = S0_ST_ADDR + s->hw_id * SN_ADDR_OFFSET;
> > + status_reg = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * 
> > SN_ADDR_OFFSET;
> >   ret = regmap_read(tmdev->map, status_reg, );
> > +
> >   if (ret)
> >   return ret;
> >   last_temp = code & SN_ST_TEMP_MASK;
>
> Reviewed-by: Matthias Kaehlcke 


[PATCH v2 1/2] PCI/ACPI: correct error message for ASPM disabling

2018-08-09 Thread Sinan Kaya
If _OSC execution fails today for platforms without an _OSC
entry, code is printing a misleading message saying disabling
ASPM as follows:

acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM

We need to ensure that platform supports ASPM to begin with.

Signed-off-by: Sinan Kaya 
Reported-by: Michael Kelley 
---
 drivers/acpi/pci_root.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7433035..e465e72 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -455,8 +455,9 @@ static void negotiate_os_control(struct acpi_pci_root 
*root, int *no_aspm)
decode_osc_support(root, "OS supports", support);
status = acpi_pci_osc_support(root, support);
if (ACPI_FAILURE(status)) {
-   dev_info(>dev, "_OSC failed (%s); disabling ASPM\n",
-acpi_format_exception(status));
+   dev_info(>dev, "_OSC failed (%s)%s\n",
+acpi_format_exception(status),
+pcie_aspm_support_enabled() ? "; disabling ASPM" : "");
*no_aspm = 1;
return;
}
-- 
2.7.4



[PATCH v2 2/2] PCI/ACPI: allow _OSC presence to be optional for PCI

2018-08-09 Thread Sinan Kaya
ACPI Spec 6.0 Section 6.2.11.3 OSC Implementation Example for PCI
Host Bridge Devices:

For a host bridge device that originates a PCI Express hierarchy,
the _OSC interface defined in this section is required.

For a host bridge device that originates a PCI/PCI-X bus hierarchy,
inclusion of an _OSC object is optional.

Allow PCI host bridges to bail out silently if _OSC is not found.

Signed-off-by: Sinan Kaya 
Reported-by: Michael Kelley 
---
 drivers/acpi/pci_root.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index e465e72..707aafc 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -421,7 +421,8 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, 
u32 *mask, u32 req)
 }
 EXPORT_SYMBOL(acpi_pci_osc_control_set);
 
-static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)
+static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
+bool is_pcie)
 {
u32 support, control, requested;
acpi_status status;
@@ -455,10 +456,15 @@ static void negotiate_os_control(struct acpi_pci_root 
*root, int *no_aspm)
decode_osc_support(root, "OS supports", support);
status = acpi_pci_osc_support(root, support);
if (ACPI_FAILURE(status)) {
+   *no_aspm = 1;
+
+   /* _OSC is optional for PCI host bridges */
+   if ((status == AE_NOT_FOUND) && !is_pcie)
+   return;
+
dev_info(>dev, "_OSC failed (%s)%s\n",
 acpi_format_exception(status),
 pcie_aspm_support_enabled() ? "; disabling ASPM" : "");
-   *no_aspm = 1;
return;
}
 
@@ -534,6 +540,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
acpi_handle handle = device->handle;
int no_aspm = 0;
bool hotadd = system_state == SYSTEM_RUNNING;
+   bool is_pcie;
 
root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root)
@@ -591,7 +598,8 @@ static int acpi_pci_root_add(struct acpi_device *device,
 
root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
 
-   negotiate_os_control(root, _aspm);
+   is_pcie = strcmp(acpi_device_hid(device), "PNP0A08") == 0;
+   negotiate_os_control(root, _aspm, is_pcie);
 
/*
 * TBD: Need PCI interface for enumeration/configuration of roots.
-- 
2.7.4



[PATCH v2 1/2] PCI/ACPI: correct error message for ASPM disabling

2018-08-09 Thread Sinan Kaya
If _OSC execution fails today for platforms without an _OSC
entry, code is printing a misleading message saying disabling
ASPM as follows:

acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM

We need to ensure that platform supports ASPM to begin with.

Signed-off-by: Sinan Kaya 
Reported-by: Michael Kelley 
---
 drivers/acpi/pci_root.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7433035..e465e72 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -455,8 +455,9 @@ static void negotiate_os_control(struct acpi_pci_root 
*root, int *no_aspm)
decode_osc_support(root, "OS supports", support);
status = acpi_pci_osc_support(root, support);
if (ACPI_FAILURE(status)) {
-   dev_info(>dev, "_OSC failed (%s); disabling ASPM\n",
-acpi_format_exception(status));
+   dev_info(>dev, "_OSC failed (%s)%s\n",
+acpi_format_exception(status),
+pcie_aspm_support_enabled() ? "; disabling ASPM" : "");
*no_aspm = 1;
return;
}
-- 
2.7.4



[PATCH v2 2/2] PCI/ACPI: allow _OSC presence to be optional for PCI

2018-08-09 Thread Sinan Kaya
ACPI Spec 6.0 Section 6.2.11.3 OSC Implementation Example for PCI
Host Bridge Devices:

For a host bridge device that originates a PCI Express hierarchy,
the _OSC interface defined in this section is required.

For a host bridge device that originates a PCI/PCI-X bus hierarchy,
inclusion of an _OSC object is optional.

Allow PCI host bridges to bail out silently if _OSC is not found.

Signed-off-by: Sinan Kaya 
Reported-by: Michael Kelley 
---
 drivers/acpi/pci_root.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index e465e72..707aafc 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -421,7 +421,8 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, 
u32 *mask, u32 req)
 }
 EXPORT_SYMBOL(acpi_pci_osc_control_set);
 
-static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)
+static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
+bool is_pcie)
 {
u32 support, control, requested;
acpi_status status;
@@ -455,10 +456,15 @@ static void negotiate_os_control(struct acpi_pci_root 
*root, int *no_aspm)
decode_osc_support(root, "OS supports", support);
status = acpi_pci_osc_support(root, support);
if (ACPI_FAILURE(status)) {
+   *no_aspm = 1;
+
+   /* _OSC is optional for PCI host bridges */
+   if ((status == AE_NOT_FOUND) && !is_pcie)
+   return;
+
dev_info(>dev, "_OSC failed (%s)%s\n",
 acpi_format_exception(status),
 pcie_aspm_support_enabled() ? "; disabling ASPM" : "");
-   *no_aspm = 1;
return;
}
 
@@ -534,6 +540,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
acpi_handle handle = device->handle;
int no_aspm = 0;
bool hotadd = system_state == SYSTEM_RUNNING;
+   bool is_pcie;
 
root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root)
@@ -591,7 +598,8 @@ static int acpi_pci_root_add(struct acpi_device *device,
 
root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
 
-   negotiate_os_control(root, _aspm);
+   is_pcie = strcmp(acpi_device_hid(device), "PNP0A08") == 0;
+   negotiate_os_control(root, _aspm, is_pcie);
 
/*
 * TBD: Need PCI interface for enumeration/configuration of roots.
-- 
2.7.4



[PATCH] riscv: Drop setup_initrd

2018-08-09 Thread Guenter Roeck
setup_initrd() does not appear to serve a practical purpose other than
preventing qemu boots with "-initrd" parameter, so let's drop it.

Signed-off-by: Guenter Roeck 
---
 arch/riscv/kernel/setup.c | 39 ---
 1 file changed, 39 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 2e56af3281f8..579f58a42974 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -82,41 +82,6 @@ EXPORT_SYMBOL(empty_zero_page);
 /* The lucky hart to first increment this variable will boot the other cores */
 atomic_t hart_lottery;
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   extern char __initramfs_start[];
-   extern unsigned long __initramfs_size;
-   unsigned long size;
-
-   if (__initramfs_size > 0) {
-   initrd_start = (unsigned long)(&__initramfs_start);
-   initrd_end = initrd_start + __initramfs_size;
-   }
-
-   if (initrd_start >= initrd_end) {
-   printk(KERN_INFO "initrd not found or empty");
-   goto disable;
-   }
-   if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) {
-   printk(KERN_ERR "initrd extends beyond end of memory");
-   goto disable;
-   }
-
-   size =  initrd_end - initrd_start;
-   memblock_reserve(__pa(initrd_start), size);
-   initrd_below_start_ok = 1;
-
-   printk(KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
 pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
 
@@ -195,10 +160,6 @@ static void __init setup_bootmem(void)
set_max_mapnr(PFN_DOWN(mem_size));
max_low_pfn = pfn_base + PFN_DOWN(mem_size);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-   setup_initrd();
-#endif /* CONFIG_BLK_DEV_INITRD */
-
early_init_fdt_reserve_self();
early_init_fdt_scan_reserved_mem();
memblock_allow_resize();
-- 
2.7.4



[PATCH] riscv: Drop setup_initrd

2018-08-09 Thread Guenter Roeck
setup_initrd() does not appear to serve a practical purpose other than
preventing qemu boots with "-initrd" parameter, so let's drop it.

Signed-off-by: Guenter Roeck 
---
 arch/riscv/kernel/setup.c | 39 ---
 1 file changed, 39 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 2e56af3281f8..579f58a42974 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -82,41 +82,6 @@ EXPORT_SYMBOL(empty_zero_page);
 /* The lucky hart to first increment this variable will boot the other cores */
 atomic_t hart_lottery;
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   extern char __initramfs_start[];
-   extern unsigned long __initramfs_size;
-   unsigned long size;
-
-   if (__initramfs_size > 0) {
-   initrd_start = (unsigned long)(&__initramfs_start);
-   initrd_end = initrd_start + __initramfs_size;
-   }
-
-   if (initrd_start >= initrd_end) {
-   printk(KERN_INFO "initrd not found or empty");
-   goto disable;
-   }
-   if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) {
-   printk(KERN_ERR "initrd extends beyond end of memory");
-   goto disable;
-   }
-
-   size =  initrd_end - initrd_start;
-   memblock_reserve(__pa(initrd_start), size);
-   initrd_below_start_ok = 1;
-
-   printk(KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
 pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
 
@@ -195,10 +160,6 @@ static void __init setup_bootmem(void)
set_max_mapnr(PFN_DOWN(mem_size));
max_low_pfn = pfn_base + PFN_DOWN(mem_size);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-   setup_initrd();
-#endif /* CONFIG_BLK_DEV_INITRD */
-
early_init_fdt_reserve_self();
early_init_fdt_scan_reserved_mem();
memblock_allow_resize();
-- 
2.7.4



Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Guenter Roeck

On 08/09/2018 08:59 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 19:40:55 PDT (-0700), li...@roeck-us.net wrote:

On 08/09/2018 06:03 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 14:24:22 PDT (-0700), li...@roeck-us.net wrote:

On Thu, Aug 09, 2018 at 01:25:24PM -0700, Palmer Dabbelt wrote:

This file is expected to be included multiple times in the same file in
order to allow the __SYSCALL macro to generate system call tables.  With
a global include guard we end up missing __NR_riscv_flush_icache in the
syscall table, which results in icache flushes that escape the vDSO call
to not actually do anything.

The fix is to move to per-#define include guards, which allows the
system call tables to actually be populated.  Thanks to Macrus Comstedt
for finding and fixing the bug!

I also went ahead and fixed the SPDX header to use a //-style comment,
which I've been told is the canonical way to do it.

Cc: Marcus Comstedt 
Signed-off-by: Palmer Dabbelt 


[Compile-]Tested-by: Guenter Roeck 

on top of linux-next after reverting the version of the patch there.

I also tried to run the resulting image (defconfig) with qemu (built
from https://github.com/riscv/riscv-qemu.git), but that still doesn't
work. I assume there are still some patches missing ?


Do you have the PLIC patches?  They'll be necessary to make this all work, and 
there's a v4 out now that when combined with for-next should get you to 
userspace.

    https://lore.kernel.org/lkml/20180809075602.989-1-...@lst.de/T/#u


Yes, after merging that branch on top of linux-next I can boot into Linux.
If I add my "riscv: Drop setup_initrd" patch as well, I can boot using
initrd, otherwise I have to use virtio-blk-device.


Awesome!  If you patch isn't on for-next then I must have missed it, do you 
mind sending me a pointer?  I can't find any references in my email.


Hmm ... weird. I don't find it either. Maybe I sent it only in my dreams.
I'll send it out for review.

Guenter


Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV

and could could natively compile and run hello world with an earlier version of 
Christoph's patch set, which is really only cosmetically different than the v4. 
I use qemu's master branch as well, which when I tried was exactly 3.0.0-rc3.



That doesn't work for me, possibly because I don't specify a bbl
image with -kernel but vmlinux (using -bios for the bbl image).
I use branch qemu-for-upstream of https://github.com/riscv/riscv-qemu.git.

Guenter






Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Guenter Roeck

On 08/09/2018 08:59 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 19:40:55 PDT (-0700), li...@roeck-us.net wrote:

On 08/09/2018 06:03 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 14:24:22 PDT (-0700), li...@roeck-us.net wrote:

On Thu, Aug 09, 2018 at 01:25:24PM -0700, Palmer Dabbelt wrote:

This file is expected to be included multiple times in the same file in
order to allow the __SYSCALL macro to generate system call tables.  With
a global include guard we end up missing __NR_riscv_flush_icache in the
syscall table, which results in icache flushes that escape the vDSO call
to not actually do anything.

The fix is to move to per-#define include guards, which allows the
system call tables to actually be populated.  Thanks to Macrus Comstedt
for finding and fixing the bug!

I also went ahead and fixed the SPDX header to use a //-style comment,
which I've been told is the canonical way to do it.

Cc: Marcus Comstedt 
Signed-off-by: Palmer Dabbelt 


[Compile-]Tested-by: Guenter Roeck 

on top of linux-next after reverting the version of the patch there.

I also tried to run the resulting image (defconfig) with qemu (built
from https://github.com/riscv/riscv-qemu.git), but that still doesn't
work. I assume there are still some patches missing ?


Do you have the PLIC patches?  They'll be necessary to make this all work, and 
there's a v4 out now that when combined with for-next should get you to 
userspace.

    https://lore.kernel.org/lkml/20180809075602.989-1-...@lst.de/T/#u


Yes, after merging that branch on top of linux-next I can boot into Linux.
If I add my "riscv: Drop setup_initrd" patch as well, I can boot using
initrd, otherwise I have to use virtio-blk-device.


Awesome!  If you patch isn't on for-next then I must have missed it, do you 
mind sending me a pointer?  I can't find any references in my email.


Hmm ... weird. I don't find it either. Maybe I sent it only in my dreams.
I'll send it out for review.

Guenter


Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV

and could could natively compile and run hello world with an earlier version of 
Christoph's patch set, which is really only cosmetically different than the v4. 
I use qemu's master branch as well, which when I tried was exactly 3.0.0-rc3.



That doesn't work for me, possibly because I don't specify a bbl
image with -kernel but vmlinux (using -bios for the bbl image).
I use branch qemu-for-upstream of https://github.com/riscv/riscv-qemu.git.

Guenter






Re: [PATCH v1 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-09 Thread Borislav Petkov
On Wed, Aug 01, 2018 at 01:33:34PM -0700, Venkata Narendra Kumar Gutta wrote:
> From: Channagoud Kadabi 
> 
> Add error reporting driver for SBEs and DBEs. As of now, this driver

Please write out those abbreviations.

> supports erp for Last Level Cache Controller (LLCC). This driver takes
> care of dumping registers and adding config options to enable and
> disable panic when the errors happen in cache.
> 
> Co-developed-by: Venkata Narendra Kumar Gutta 
> Signed-off-by: Venkata Narendra Kumar Gutta 
> Signed-off-by: Channagoud Kadabi 

The proper order is:

SOB: Author
SOB: Sender/handler/...

So:

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 

> ---
>  MAINTAINERS  |   7 +
>  drivers/edac/Kconfig |  28 +++
>  drivers/edac/Makefile|   1 +
>  drivers/edac/qcom_edac.c | 507 
> +++
>  4 files changed, 543 insertions(+)
>  create mode 100644 drivers/edac/qcom_edac.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f6a9b08..68b3484 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5227,6 +5227,13 @@ L: linux-e...@vger.kernel.org
>  S:   Maintained
>  F:   drivers/edac/ti_edac.c
>  
> +EDAC-QUALCOMM
> +M:   Channagoud Kadabi
> +M:   Venkata Narendra Kumar Gutta

Space between name and email address.

> +L:   linux-arm-...@vger.kernel.org

Also

L:  linux-e...@vger.kernel.org

so that the EDAC ML gets CCed too.

> +S:   Maintained
> +F:   drivers/edac/qcom_edac.c
> +
>  EDIROL UA-101/UA-1000 DRIVER
>  M:   Clemens Ladisch 
>  L:   alsa-de...@alsa-project.org (moderated for non-subscribers)
> diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
> index 57304b2..c654b0e 100644
> --- a/drivers/edac/Kconfig
> +++ b/drivers/edac/Kconfig
> @@ -460,4 +460,32 @@ config EDAC_TI
> Support for error detection and correction on the
>TI SoCs.
>  
> +config EDAC_QCOM
> + depends on EDAC=y

Why on EDAC=y? Did you blindly copy it or is there a reason why
edac_core should be only built-in or can it be a module too?

> + tristate "QCOM EDAC Controller"
> + help
> + Support for error detection and correction on the
> + QCOM SoCs.
> +
> +config EDAC_QCOM_LLCC
> + depends on EDAC_QCOM=y && QCOM_LLCC
> + tristate "QCOM EDAC Controller for LLCC Cache"
> + help
> + Support for error detection and correction on the
> + QCOM LLCC cache. Report errors caught by LLCC ECC
> + mechanism.
> +
> + For debugging issues having to do with stability and overall 
> system
> + health, you should probably say 'Y' here.
> +
> +config EDAC_QCOM_LLCC_PANIC_ON_UE
> + depends on EDAC_QCOM_LLCC
> + bool "Panic on uncorrectable errors - qcom llcc"
> + help
> + Forcibly cause a kernel panic if an uncorrectable error (UE) is
> + detected. This can reduce debugging times on hardware which may 
> be
> + operating at voltages or frequencies outside normal 
> specification.
> +
> + For production builds, you should probably say 'N' here.
> +
>  endif # EDAC
> diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
> index 02b43a7..716096d 100644
> --- a/drivers/edac/Makefile
> +++ b/drivers/edac/Makefile
> @@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA)   += altera_edac.o
>  obj-$(CONFIG_EDAC_SYNOPSYS)  += synopsys_edac.o
>  obj-$(CONFIG_EDAC_XGENE) += xgene_edac.o
>  obj-$(CONFIG_EDAC_TI)+= ti_edac.o
> +obj-$(CONFIG_EDAC_QCOM)  += qcom_edac.o
> diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
> new file mode 100644
> index 000..cf3e2b0
> --- /dev/null
> +++ b/drivers/edac/qcom_edac.c
> @@ -0,0 +1,507 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "edac_mc.h"
> +#include "edac_device.h"
> +
> +#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
> +#define LLCC_ERP_PANIC_ON_UE1
> +#else
> +#define LLCC_ERP_PANIC_ON_UE0
> +#endif
> +
> +#define EDAC_LLCC   "qcom_llcc"
> +
> +#define TRP_SYN_REG_CNT 6
> +
> +#define DRP_SYN_REG_CNT 8
> +
> +#define LLCC_COMMON_STATUS0 0x0003000C
> +#define LLCC_LB_CNT_MASKGENMASK(31, 28)
> +#define LLCC_LB_CNT_SHIFT   28
> +
> +/* single & Double Bit syndrome register offsets */
> +#define TRP_ECC_SB_ERR_SYN0 0x0002304C
> +#define TRP_ECC_DB_ERR_SYN0 0x00020370
> +#define DRP_ECC_SB_ERR_SYN0 0x0004204C
> +#define DRP_ECC_DB_ERR_SYN0 0x00042070
> +
> +/* Error register offsets */
> +#define TRP_ECC_ERROR_STATUS1   0x00020348
> +#define TRP_ECC_ERROR_STATUS0   0x00020344
> +#define 

Re: [PATCH v1 3/4] drivers: edac: Add EDAC driver support for QCOM SoCs

2018-08-09 Thread Borislav Petkov
On Wed, Aug 01, 2018 at 01:33:34PM -0700, Venkata Narendra Kumar Gutta wrote:
> From: Channagoud Kadabi 
> 
> Add error reporting driver for SBEs and DBEs. As of now, this driver

Please write out those abbreviations.

> supports erp for Last Level Cache Controller (LLCC). This driver takes
> care of dumping registers and adding config options to enable and
> disable panic when the errors happen in cache.
> 
> Co-developed-by: Venkata Narendra Kumar Gutta 
> Signed-off-by: Venkata Narendra Kumar Gutta 
> Signed-off-by: Channagoud Kadabi 

The proper order is:

SOB: Author
SOB: Sender/handler/...

So:

Signed-off-by: Channagoud Kadabi 
Signed-off-by: Venkata Narendra Kumar Gutta 

> ---
>  MAINTAINERS  |   7 +
>  drivers/edac/Kconfig |  28 +++
>  drivers/edac/Makefile|   1 +
>  drivers/edac/qcom_edac.c | 507 
> +++
>  4 files changed, 543 insertions(+)
>  create mode 100644 drivers/edac/qcom_edac.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f6a9b08..68b3484 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5227,6 +5227,13 @@ L: linux-e...@vger.kernel.org
>  S:   Maintained
>  F:   drivers/edac/ti_edac.c
>  
> +EDAC-QUALCOMM
> +M:   Channagoud Kadabi
> +M:   Venkata Narendra Kumar Gutta

Space between name and email address.

> +L:   linux-arm-...@vger.kernel.org

Also

L:  linux-e...@vger.kernel.org

so that the EDAC ML gets CCed too.

> +S:   Maintained
> +F:   drivers/edac/qcom_edac.c
> +
>  EDIROL UA-101/UA-1000 DRIVER
>  M:   Clemens Ladisch 
>  L:   alsa-de...@alsa-project.org (moderated for non-subscribers)
> diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
> index 57304b2..c654b0e 100644
> --- a/drivers/edac/Kconfig
> +++ b/drivers/edac/Kconfig
> @@ -460,4 +460,32 @@ config EDAC_TI
> Support for error detection and correction on the
>TI SoCs.
>  
> +config EDAC_QCOM
> + depends on EDAC=y

Why on EDAC=y? Did you blindly copy it or is there a reason why
edac_core should be only built-in or can it be a module too?

> + tristate "QCOM EDAC Controller"
> + help
> + Support for error detection and correction on the
> + QCOM SoCs.
> +
> +config EDAC_QCOM_LLCC
> + depends on EDAC_QCOM=y && QCOM_LLCC
> + tristate "QCOM EDAC Controller for LLCC Cache"
> + help
> + Support for error detection and correction on the
> + QCOM LLCC cache. Report errors caught by LLCC ECC
> + mechanism.
> +
> + For debugging issues having to do with stability and overall 
> system
> + health, you should probably say 'Y' here.
> +
> +config EDAC_QCOM_LLCC_PANIC_ON_UE
> + depends on EDAC_QCOM_LLCC
> + bool "Panic on uncorrectable errors - qcom llcc"
> + help
> + Forcibly cause a kernel panic if an uncorrectable error (UE) is
> + detected. This can reduce debugging times on hardware which may 
> be
> + operating at voltages or frequencies outside normal 
> specification.
> +
> + For production builds, you should probably say 'N' here.
> +
>  endif # EDAC
> diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
> index 02b43a7..716096d 100644
> --- a/drivers/edac/Makefile
> +++ b/drivers/edac/Makefile
> @@ -77,3 +77,4 @@ obj-$(CONFIG_EDAC_ALTERA)   += altera_edac.o
>  obj-$(CONFIG_EDAC_SYNOPSYS)  += synopsys_edac.o
>  obj-$(CONFIG_EDAC_XGENE) += xgene_edac.o
>  obj-$(CONFIG_EDAC_TI)+= ti_edac.o
> +obj-$(CONFIG_EDAC_QCOM)  += qcom_edac.o
> diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
> new file mode 100644
> index 000..cf3e2b0
> --- /dev/null
> +++ b/drivers/edac/qcom_edac.c
> @@ -0,0 +1,507 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "edac_mc.h"
> +#include "edac_device.h"
> +
> +#ifdef CONFIG_EDAC_QCOM_LLCC_PANIC_ON_UE
> +#define LLCC_ERP_PANIC_ON_UE1
> +#else
> +#define LLCC_ERP_PANIC_ON_UE0
> +#endif
> +
> +#define EDAC_LLCC   "qcom_llcc"
> +
> +#define TRP_SYN_REG_CNT 6
> +
> +#define DRP_SYN_REG_CNT 8
> +
> +#define LLCC_COMMON_STATUS0 0x0003000C
> +#define LLCC_LB_CNT_MASKGENMASK(31, 28)
> +#define LLCC_LB_CNT_SHIFT   28
> +
> +/* single & Double Bit syndrome register offsets */
> +#define TRP_ECC_SB_ERR_SYN0 0x0002304C
> +#define TRP_ECC_DB_ERR_SYN0 0x00020370
> +#define DRP_ECC_SB_ERR_SYN0 0x0004204C
> +#define DRP_ECC_DB_ERR_SYN0 0x00042070
> +
> +/* Error register offsets */
> +#define TRP_ECC_ERROR_STATUS1   0x00020348
> +#define TRP_ECC_ERROR_STATUS0   0x00020344
> +#define 

Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Palmer Dabbelt

On Thu, 09 Aug 2018 19:40:55 PDT (-0700), li...@roeck-us.net wrote:

On 08/09/2018 06:03 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 14:24:22 PDT (-0700), li...@roeck-us.net wrote:

On Thu, Aug 09, 2018 at 01:25:24PM -0700, Palmer Dabbelt wrote:

This file is expected to be included multiple times in the same file in
order to allow the __SYSCALL macro to generate system call tables.  With
a global include guard we end up missing __NR_riscv_flush_icache in the
syscall table, which results in icache flushes that escape the vDSO call
to not actually do anything.

The fix is to move to per-#define include guards, which allows the
system call tables to actually be populated.  Thanks to Macrus Comstedt
for finding and fixing the bug!

I also went ahead and fixed the SPDX header to use a //-style comment,
which I've been told is the canonical way to do it.

Cc: Marcus Comstedt 
Signed-off-by: Palmer Dabbelt 


[Compile-]Tested-by: Guenter Roeck 

on top of linux-next after reverting the version of the patch there.

I also tried to run the resulting image (defconfig) with qemu (built
from https://github.com/riscv/riscv-qemu.git), but that still doesn't
work. I assume there are still some patches missing ?


Do you have the PLIC patches?  They'll be necessary to make this all work, and 
there's a v4 out now that when combined with for-next should get you to 
userspace.

    https://lore.kernel.org/lkml/20180809075602.989-1-...@lst.de/T/#u


Yes, after merging that branch on top of linux-next I can boot into Linux.
If I add my "riscv: Drop setup_initrd" patch as well, I can boot using
initrd, otherwise I have to use virtio-blk-device.


Awesome!  If you patch isn't on for-next then I must have missed it, do you 
mind sending me a pointer?  I can't find any references in my email.



Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV

and could could natively compile and run hello world with an earlier version of 
Christoph's patch set, which is really only cosmetically different than the v4. 
I use qemu's master branch as well, which when I tried was exactly 3.0.0-rc3.



That doesn't work for me, possibly because I don't specify a bbl
image with -kernel but vmlinux (using -bios for the bbl image).
I use branch qemu-for-upstream of https://github.com/riscv/riscv-qemu.git.

Guenter


Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Palmer Dabbelt

On Thu, 09 Aug 2018 19:40:55 PDT (-0700), li...@roeck-us.net wrote:

On 08/09/2018 06:03 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 14:24:22 PDT (-0700), li...@roeck-us.net wrote:

On Thu, Aug 09, 2018 at 01:25:24PM -0700, Palmer Dabbelt wrote:

This file is expected to be included multiple times in the same file in
order to allow the __SYSCALL macro to generate system call tables.  With
a global include guard we end up missing __NR_riscv_flush_icache in the
syscall table, which results in icache flushes that escape the vDSO call
to not actually do anything.

The fix is to move to per-#define include guards, which allows the
system call tables to actually be populated.  Thanks to Macrus Comstedt
for finding and fixing the bug!

I also went ahead and fixed the SPDX header to use a //-style comment,
which I've been told is the canonical way to do it.

Cc: Marcus Comstedt 
Signed-off-by: Palmer Dabbelt 


[Compile-]Tested-by: Guenter Roeck 

on top of linux-next after reverting the version of the patch there.

I also tried to run the resulting image (defconfig) with qemu (built
from https://github.com/riscv/riscv-qemu.git), but that still doesn't
work. I assume there are still some patches missing ?


Do you have the PLIC patches?  They'll be necessary to make this all work, and 
there's a v4 out now that when combined with for-next should get you to 
userspace.

    https://lore.kernel.org/lkml/20180809075602.989-1-...@lst.de/T/#u


Yes, after merging that branch on top of linux-next I can boot into Linux.
If I add my "riscv: Drop setup_initrd" patch as well, I can boot using
initrd, otherwise I have to use virtio-blk-device.


Awesome!  If you patch isn't on for-next then I must have missed it, do you 
mind sending me a pointer?  I can't find any references in my email.



Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV

and could could natively compile and run hello world with an earlier version of 
Christoph's patch set, which is really only cosmetically different than the v4. 
I use qemu's master branch as well, which when I tried was exactly 3.0.0-rc3.



That doesn't work for me, possibly because I don't specify a bbl
image with -kernel but vmlinux (using -bios for the bbl image).
I use branch qemu-for-upstream of https://github.com/riscv/riscv-qemu.git.

Guenter


Re: [PATCH RESEND 1/4] HID: multitouch: add MT_QUIRK_NOT_SEEN_MEANS_UP to MT_CLS_WIN_8 quirks

2018-08-09 Thread Joey Pabalinas
On Thu, Aug 09, 2018 at 01:39:16PM -1000, Joey Pabalinas wrote:
> The firmware found in the touch screen of the Surface Pro 3 is slightly
> buggy and occasionally doesn't send lift off reports for contacts; add
> MT_QUIRK_NOT_SEEN_MEANS_UP to .quirks to compensate for the missed
> reports.
> 
> Signed-off-by: Joey Pabalinas 

Sorry, my mail filters are in need of some adjusting; I completely missed
the review of the first send of this patchset :(

Please disregard this resend, as I am going to revise it and submit a
v2, thanks.

-- 
Cheers,
Joey Pabalinas


signature.asc
Description: PGP signature


Re: [PATCH RESEND 1/4] HID: multitouch: add MT_QUIRK_NOT_SEEN_MEANS_UP to MT_CLS_WIN_8 quirks

2018-08-09 Thread Joey Pabalinas
On Thu, Aug 09, 2018 at 01:39:16PM -1000, Joey Pabalinas wrote:
> The firmware found in the touch screen of the Surface Pro 3 is slightly
> buggy and occasionally doesn't send lift off reports for contacts; add
> MT_QUIRK_NOT_SEEN_MEANS_UP to .quirks to compensate for the missed
> reports.
> 
> Signed-off-by: Joey Pabalinas 

Sorry, my mail filters are in need of some adjusting; I completely missed
the review of the first send of this patchset :(

Please disregard this resend, as I am going to revise it and submit a
v2, thanks.

-- 
Cheers,
Joey Pabalinas


signature.asc
Description: PGP signature


Re: [PATCH 2/4] HID: multitouch: don't check HID_GROUP_MULTITOUCH_WIN_8 for serial protocol

2018-08-09 Thread Joey Pabalinas
On Tue, Jul 03, 2018 at 10:16:01AM +0200, Benjamin Tissoires wrote:
> There is a tiny difference between the HID group (this device looks
> like it is used as a Win 8 device) and the device class (this is
> effectively a Win8 device)
> 
> It makes sense to remove this check for Win8 devices, but I don't
> think it should be done for all devices.
> 
> All in all, it won't change much.

Hm, that sounds sane. I'll do a bit more research on this and see if
restricting it to just Win8 devices is simple enough to be worthwhile.

-- 
Cheers,
Joey Pabalinas


signature.asc
Description: PGP signature


Re: [PATCH 2/4] HID: multitouch: don't check HID_GROUP_MULTITOUCH_WIN_8 for serial protocol

2018-08-09 Thread Joey Pabalinas
On Tue, Jul 03, 2018 at 10:16:01AM +0200, Benjamin Tissoires wrote:
> There is a tiny difference between the HID group (this device looks
> like it is used as a Win 8 device) and the device class (this is
> effectively a Win8 device)
> 
> It makes sense to remove this check for Win8 devices, but I don't
> think it should be done for all devices.
> 
> All in all, it won't change much.

Hm, that sounds sane. I'll do a bit more research on this and see if
restricting it to just Win8 devices is simple enough to be worthwhile.

-- 
Cheers,
Joey Pabalinas


signature.asc
Description: PGP signature


Re: [PATCH 01/16] MAINTAINERS: Switch a maintainer for drivers/staging/gasket

2018-08-09 Thread John Joseph
Acked-by: John Joseph 

On Thu, Aug 9, 2018 at 8:20 PM, Todd Poynor  wrote:
> From: Todd Poynor 
>
> Todd Poynor takes over for John Joseph.
>
> Signed-off-by: John Joseph 
> Signed-off-by: Todd Poynor 
> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index af64fe0f0b41f..f3466b5c50482 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5939,7 +5939,7 @@ F:Documentation/gcc-plugins.txt
>
>  GASKET DRIVER FRAMEWORK
>  M: Rob Springer 
> -M: John Joseph 
> +M: Todd Poynor 
>  M: Ben Chan 
>  S: Maintained
>  F: drivers/staging/gasket/
> --
> 2.18.0.597.ga71716f1ad-goog
>


Re: [PATCH 01/16] MAINTAINERS: Switch a maintainer for drivers/staging/gasket

2018-08-09 Thread John Joseph
Acked-by: John Joseph 

On Thu, Aug 9, 2018 at 8:20 PM, Todd Poynor  wrote:
> From: Todd Poynor 
>
> Todd Poynor takes over for John Joseph.
>
> Signed-off-by: John Joseph 
> Signed-off-by: Todd Poynor 
> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index af64fe0f0b41f..f3466b5c50482 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5939,7 +5939,7 @@ F:Documentation/gcc-plugins.txt
>
>  GASKET DRIVER FRAMEWORK
>  M: Rob Springer 
> -M: John Joseph 
> +M: Todd Poynor 
>  M: Ben Chan 
>  S: Maintained
>  F: drivers/staging/gasket/
> --
> 2.18.0.597.ga71716f1ad-goog
>


Re: [PATCH 3/4] HID: multitouch: drop reports containing invalid values

2018-08-09 Thread Joey Pabalinas
On Tue, Jul 03, 2018 at 10:13:54AM +0200, Benjamin Tissoires wrote:
> Hi Joey,
> You can't really use plain values like that. There is a tiny chance
> these values are valid on an other device.
> IIRC, MS spec says that we should ignore out of band values if they
> are tagged as such. Such input are tagged with NULL values
> (http://www.usb.org/developers/hidpage/HID1_11.pdf page 31) and MS
> spec mentioned this.
> 
> All in all, if you have this bit set, you need to compare the value
> with the logical_max/min for each field.
> 
> I never encountered a device that required this, so you are probably
> the lucky one :)

Ah, you are completely right. After giving that pdf a read over
I will definitely be dropping this patch from the v2.

-- 
Cheers,
Joey Pabalinas


signature.asc
Description: PGP signature


Re: [PATCH 3/4] HID: multitouch: drop reports containing invalid values

2018-08-09 Thread Joey Pabalinas
On Tue, Jul 03, 2018 at 10:13:54AM +0200, Benjamin Tissoires wrote:
> Hi Joey,
> You can't really use plain values like that. There is a tiny chance
> these values are valid on an other device.
> IIRC, MS spec says that we should ignore out of band values if they
> are tagged as such. Such input are tagged with NULL values
> (http://www.usb.org/developers/hidpage/HID1_11.pdf page 31) and MS
> spec mentioned this.
> 
> All in all, if you have this bit set, you need to compare the value
> with the logical_max/min for each field.
> 
> I never encountered a device that required this, so you are probably
> the lucky one :)

Ah, you are completely right. After giving that pdf a read over
I will definitely be dropping this patch from the v2.

-- 
Cheers,
Joey Pabalinas


signature.asc
Description: PGP signature


[PATCH 05/16] staging: gasket: core: remove ftrace-style debug logs

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Remove debug logs that only indicate the name of the entered function,
in favor of using ftrace for function tracing style logs.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 5f54b3615f67c..0fe5b86b294c8 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1789,7 +1789,6 @@ static int __init gasket_init(void)
 {
int i;
 
-   pr_debug("%s\n", __func__);
mutex_lock(_mutex);
for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
g_descs[i].driver_desc = NULL;
@@ -1804,7 +1803,6 @@ static int __init gasket_init(void)
 
 static void __exit gasket_exit(void)
 {
-   pr_debug("%s\n", __func__);
 }
 MODULE_DESCRIPTION("Google Gasket driver framework");
 MODULE_VERSION(GASKET_FRAMEWORK_VERSION);
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 02/16] staging: gasket: core: remove debug log that could crash

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

A debug log in gasket_alloc_dev() is issued regardless of whether the
device pointer used returned success or error.  The log isn't that
useful anyway, remove it.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index d12ab560411f7..37d14e30ffa21 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -234,8 +234,6 @@ static int gasket_alloc_dev(struct gasket_internal_desc 
*internal_desc,
dev_info->device = device_create(internal_desc->class, parent,
dev_info->devt, gasket_dev, dev_info->name);
 
-   dev_dbg(dev_info->device, "Gasket device allocated.\n");
-
/* cdev has not yet been added; cdev_added is 0 */
dev_info->gasket_dev_ptr = gasket_dev;
/* ownership is all 0, indicating no owner or opens. */
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 00/16] staging: gasket: return of the son of cleanups

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Remove extraneous memory barriers, refactor PCI-specific code in prep
for platform devices in the near future, general cleanups, and make de
facto maintainership official.

Todd Poynor (16):
  MAINTAINERS: Switch a maintainer for drivers/staging/gasket
  staging: gasket: core: remove debug log that could crash
  staging: gasket: core: fix line continuation indent in
gasket_alloc_dev
  staging: gasket: core: remove kobj_name param from gasket_alloc_dev
  staging: gasket: core: remove ftrace-style debug logs
  staging: gasket: remove gasket_exit()
  staging: gasket: page table: remove unnecessary NULL check
  staging: gasket: page table: use dma_mapping_error for error detection
  staging: gasket: core: switch to relaxed memory-mapped I/O
  staging: gasket: page table: remove extraneous memory barriers
  staging: gasket: core: factor out generic device add code from PCI
code
  staging: gasket: core: factor out generic device remove code from PCI
  staging: gasket: core: rename lookup_internal_desc to be PCI-specific
  staging: gasket: interrupt: refactor PCI MSIX-specific handler code
  staging: gasket: interrupt: simplify interrupt init parameters
  staging: gasket: interrupt: remove unimplemented interrupt types

 MAINTAINERS|   2 +-
 drivers/staging/gasket/gasket_core.c   | 138 +++--
 drivers/staging/gasket/gasket_core.h   |  19 +--
 drivers/staging/gasket/gasket_interrupt.c  | 105 ++--
 drivers/staging/gasket/gasket_interrupt.h  |  24 +---
 drivers/staging/gasket/gasket_page_table.c |  24 ++--
 6 files changed, 124 insertions(+), 188 deletions(-)

-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 07/16] staging: gasket: page table: remove unnecessary NULL check

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

gasket_alloc_coherent_memory remove unnecessary NULL check for
coherent_pages.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index d4c5f8aa7dd34..bd921dc6094de 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -1328,10 +1328,8 @@ int gasket_alloc_coherent_memory(struct gasket_dev 
*gasket_dev, u64 size,
  num_pages * PAGE_SIZE, mem, handle);
}
 
-   if (gasket_dev->page_table[index]->coherent_pages) {
-   kfree(gasket_dev->page_table[index]->coherent_pages);
-   gasket_dev->page_table[index]->coherent_pages = NULL;
-   }
+   kfree(gasket_dev->page_table[index]->coherent_pages);
+   gasket_dev->page_table[index]->coherent_pages = NULL;
gasket_dev->page_table[index]->num_coherent_pages = 0;
return -ENOMEM;
 }
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 03/16] staging: gasket: core: fix line continuation indent in gasket_alloc_dev

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Previous cleanups missed a case of multi-line function call with line
continuation parameters not aligned per kernel style.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 37d14e30ffa21..3fb805204d700 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -231,8 +231,9 @@ static int gasket_alloc_dev(struct gasket_internal_desc 
*internal_desc,
dev_info->devt =
MKDEV(driver_desc->major, driver_desc->minor +
  gasket_dev->dev_idx);
-   dev_info->device = device_create(internal_desc->class, parent,
-   dev_info->devt, gasket_dev, dev_info->name);
+   dev_info->device =
+   device_create(internal_desc->class, parent, dev_info->devt,
+ gasket_dev, dev_info->name);
 
/* cdev has not yet been added; cdev_added is 0 */
dev_info->gasket_dev_ptr = gasket_dev;
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 00/16] staging: gasket: return of the son of cleanups

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Remove extraneous memory barriers, refactor PCI-specific code in prep
for platform devices in the near future, general cleanups, and make de
facto maintainership official.

Todd Poynor (16):
  MAINTAINERS: Switch a maintainer for drivers/staging/gasket
  staging: gasket: core: remove debug log that could crash
  staging: gasket: core: fix line continuation indent in
gasket_alloc_dev
  staging: gasket: core: remove kobj_name param from gasket_alloc_dev
  staging: gasket: core: remove ftrace-style debug logs
  staging: gasket: remove gasket_exit()
  staging: gasket: page table: remove unnecessary NULL check
  staging: gasket: page table: use dma_mapping_error for error detection
  staging: gasket: core: switch to relaxed memory-mapped I/O
  staging: gasket: page table: remove extraneous memory barriers
  staging: gasket: core: factor out generic device add code from PCI
code
  staging: gasket: core: factor out generic device remove code from PCI
  staging: gasket: core: rename lookup_internal_desc to be PCI-specific
  staging: gasket: interrupt: refactor PCI MSIX-specific handler code
  staging: gasket: interrupt: simplify interrupt init parameters
  staging: gasket: interrupt: remove unimplemented interrupt types

 MAINTAINERS|   2 +-
 drivers/staging/gasket/gasket_core.c   | 138 +++--
 drivers/staging/gasket/gasket_core.h   |  19 +--
 drivers/staging/gasket/gasket_interrupt.c  | 105 ++--
 drivers/staging/gasket/gasket_interrupt.h  |  24 +---
 drivers/staging/gasket/gasket_page_table.c |  24 ++--
 6 files changed, 124 insertions(+), 188 deletions(-)

-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 07/16] staging: gasket: page table: remove unnecessary NULL check

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

gasket_alloc_coherent_memory remove unnecessary NULL check for
coherent_pages.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index d4c5f8aa7dd34..bd921dc6094de 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -1328,10 +1328,8 @@ int gasket_alloc_coherent_memory(struct gasket_dev 
*gasket_dev, u64 size,
  num_pages * PAGE_SIZE, mem, handle);
}
 
-   if (gasket_dev->page_table[index]->coherent_pages) {
-   kfree(gasket_dev->page_table[index]->coherent_pages);
-   gasket_dev->page_table[index]->coherent_pages = NULL;
-   }
+   kfree(gasket_dev->page_table[index]->coherent_pages);
+   gasket_dev->page_table[index]->coherent_pages = NULL;
gasket_dev->page_table[index]->num_coherent_pages = 0;
return -ENOMEM;
 }
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 03/16] staging: gasket: core: fix line continuation indent in gasket_alloc_dev

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Previous cleanups missed a case of multi-line function call with line
continuation parameters not aligned per kernel style.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 37d14e30ffa21..3fb805204d700 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -231,8 +231,9 @@ static int gasket_alloc_dev(struct gasket_internal_desc 
*internal_desc,
dev_info->devt =
MKDEV(driver_desc->major, driver_desc->minor +
  gasket_dev->dev_idx);
-   dev_info->device = device_create(internal_desc->class, parent,
-   dev_info->devt, gasket_dev, dev_info->name);
+   dev_info->device =
+   device_create(internal_desc->class, parent, dev_info->devt,
+ gasket_dev, dev_info->name);
 
/* cdev has not yet been added; cdev_added is 0 */
dev_info->gasket_dev_ptr = gasket_dev;
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 05/16] staging: gasket: core: remove ftrace-style debug logs

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Remove debug logs that only indicate the name of the entered function,
in favor of using ftrace for function tracing style logs.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 5f54b3615f67c..0fe5b86b294c8 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1789,7 +1789,6 @@ static int __init gasket_init(void)
 {
int i;
 
-   pr_debug("%s\n", __func__);
mutex_lock(_mutex);
for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
g_descs[i].driver_desc = NULL;
@@ -1804,7 +1803,6 @@ static int __init gasket_init(void)
 
 static void __exit gasket_exit(void)
 {
-   pr_debug("%s\n", __func__);
 }
 MODULE_DESCRIPTION("Google Gasket driver framework");
 MODULE_VERSION(GASKET_FRAMEWORK_VERSION);
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 02/16] staging: gasket: core: remove debug log that could crash

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

A debug log in gasket_alloc_dev() is issued regardless of whether the
device pointer used returned success or error.  The log isn't that
useful anyway, remove it.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index d12ab560411f7..37d14e30ffa21 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -234,8 +234,6 @@ static int gasket_alloc_dev(struct gasket_internal_desc 
*internal_desc,
dev_info->device = device_create(internal_desc->class, parent,
dev_info->devt, gasket_dev, dev_info->name);
 
-   dev_dbg(dev_info->device, "Gasket device allocated.\n");
-
/* cdev has not yet been added; cdev_added is 0 */
dev_info->gasket_dev_ptr = gasket_dev;
/* ownership is all 0, indicating no owner or opens. */
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 13/16] staging: gasket: core: rename lookup_internal_desc to be PCI-specific

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Rename lookup_internal_desc() to lookup_pci_internal_desc() to reflect
use for PCI devices only, in prep for non-PCI devices in the future.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 5e048f6e16e12..99f3f11d75ce2 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -651,13 +651,13 @@ void gasket_disable_device(struct gasket_dev *gasket_dev)
 EXPORT_SYMBOL(gasket_disable_device);
 
 /*
- * Registered descriptor lookup.
+ * Registered driver descriptor lookup for PCI devices.
  *
  * Precondition: Called with g_mutex held (to avoid a race on return).
  * Returns NULL if no matching device was found.
  */
 static struct gasket_internal_desc *
-lookup_internal_desc(struct pci_dev *pci_dev)
+lookup_pci_internal_desc(struct pci_dev *pci_dev)
 {
int i;
 
@@ -1488,7 +1488,7 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
dev_dbg(_dev->dev, "add PCI gasket device\n");
 
mutex_lock(_mutex);
-   internal_desc = lookup_internal_desc(pci_dev);
+   internal_desc = lookup_pci_internal_desc(pci_dev);
mutex_unlock(_mutex);
if (!internal_desc) {
dev_err(_dev->dev,
@@ -1536,7 +1536,7 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
struct gasket_dev *gasket_dev = NULL;
/* Find the device desc. */
mutex_lock(_mutex);
-   internal_desc = lookup_internal_desc(pci_dev);
+   internal_desc = lookup_pci_internal_desc(pci_dev);
if (!internal_desc) {
mutex_unlock(_mutex);
return;
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 11/16] staging: gasket: core: factor out generic device add code from PCI code

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Split out generic gasket device add code from the code for adding a PCI
gasket device, in prep for other gasket device types in the future.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 76 ++--
 1 file changed, 48 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index aee819f379e9a..ce8ae226f82d9 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1419,6 +1419,48 @@ int gasket_enable_device(struct gasket_dev *gasket_dev)
 }
 EXPORT_SYMBOL(gasket_enable_device);
 
+static int __gasket_add_device(struct device *parent_dev,
+  struct gasket_internal_desc *internal_desc,
+  struct gasket_dev **gasket_devp)
+{
+   int ret;
+   struct gasket_dev *gasket_dev;
+   const struct gasket_driver_desc *driver_desc =
+   internal_desc->driver_desc;
+
+   ret = gasket_alloc_dev(internal_desc, parent_dev, _dev);
+   if (ret)
+   return ret;
+   if (IS_ERR(gasket_dev->dev_info.device)) {
+   dev_err(parent_dev, "Cannot create %s device %s [ret = %ld]\n",
+   driver_desc->name, gasket_dev->dev_info.name,
+   PTR_ERR(gasket_dev->dev_info.device));
+   ret = -ENODEV;
+   goto free_gasket_dev;
+   }
+
+   ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device,
+ gasket_dev);
+   if (ret)
+   goto remove_device;
+
+   ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
+ gasket_sysfs_generic_attrs);
+   if (ret)
+   goto remove_sysfs_mapping;
+
+   *gasket_devp = gasket_dev;
+   return 0;
+
+remove_sysfs_mapping:
+   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
+remove_device:
+   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
+free_gasket_dev:
+   gasket_free_dev(gasket_dev);
+   return ret;
+}
+
 /*
  * Add PCI gasket device.
  *
@@ -1433,7 +1475,6 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
int ret;
struct gasket_internal_desc *internal_desc;
struct gasket_dev *gasket_dev;
-   const struct gasket_driver_desc *driver_desc;
struct device *parent;
 
dev_dbg(_dev->dev, "add PCI gasket device\n");
@@ -1447,29 +1488,15 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
return -ENODEV;
}
 
-   driver_desc = internal_desc->driver_desc;
-
parent = _dev->dev;
-   ret = gasket_alloc_dev(internal_desc, parent, _dev);
+   ret = __gasket_add_device(parent, internal_desc, _dev);
if (ret)
return ret;
-   gasket_dev->pci_dev = pci_dev;
-   if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) {
-   pr_err("Cannot create %s device %s [ret = %ld]\n",
-  driver_desc->name, gasket_dev->dev_info.name,
-  PTR_ERR(gasket_dev->dev_info.device));
-   ret = -ENODEV;
-   goto fail1;
-   }
 
+   gasket_dev->pci_dev = pci_dev;
ret = gasket_setup_pci(pci_dev, gasket_dev);
if (ret)
-   goto fail2;
-
-   ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device,
- gasket_dev);
-   if (ret)
-   goto fail3;
+   goto cleanup_pci;
 
/*
 * Once we've created the mapping structures successfully, attempt to
@@ -1480,23 +1507,16 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
if (ret) {
dev_err(gasket_dev->dev,
"Cannot create sysfs pci link: %d\n", ret);
-   goto fail3;
+   goto cleanup_pci;
}
-   ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
- gasket_sysfs_generic_attrs);
-   if (ret)
-   goto fail4;
 
*gasket_devp = gasket_dev;
return 0;
 
-fail4:
-fail3:
-   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-fail2:
+cleanup_pci:
gasket_cleanup_pci(gasket_dev);
+   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-fail1:
gasket_free_dev(gasket_dev);
return ret;
 }
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 12/16] staging: gasket: core: factor out generic device remove code from PCI

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Separate code for generic parts of gasket device removal sequence from
the PCI device removal code, in prep for non-PCI devices later.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index ce8ae226f82d9..5e048f6e16e12 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1461,6 +1461,14 @@ static int __gasket_add_device(struct device *parent_dev,
return ret;
 }
 
+static void __gasket_remove_device(struct gasket_internal_desc *internal_desc,
+  struct gasket_dev *gasket_dev)
+{
+   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
+   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
+   gasket_free_dev(gasket_dev);
+}
+
 /*
  * Add PCI gasket device.
  *
@@ -1515,9 +1523,7 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
 
 cleanup_pci:
gasket_cleanup_pci(gasket_dev);
-   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-   gasket_free_dev(gasket_dev);
+   __gasket_remove_device(internal_desc, gasket_dev);
return ret;
 }
 EXPORT_SYMBOL(gasket_pci_add_device);
@@ -1528,7 +1534,6 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
int i;
struct gasket_internal_desc *internal_desc;
struct gasket_dev *gasket_dev = NULL;
-   const struct gasket_driver_desc *driver_desc;
/* Find the device desc. */
mutex_lock(_mutex);
internal_desc = lookup_internal_desc(pci_dev);
@@ -1538,8 +1543,6 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
}
mutex_unlock(_mutex);
 
-   driver_desc = internal_desc->driver_desc;
-
/* Now find the specific device */
mutex_lock(_desc->mutex);
for (i = 0; i < GASKET_DEV_MAX; i++) {
@@ -1558,10 +1561,7 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
internal_desc->driver_desc->name);
 
gasket_cleanup_pci(gasket_dev);
-
-   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-   gasket_free_dev(gasket_dev);
+   __gasket_remove_device(internal_desc, gasket_dev);
 }
 EXPORT_SYMBOL(gasket_pci_remove_device);
 
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 06/16] staging: gasket: remove gasket_exit()

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Remove now-empty gasket_exit() function.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 0fe5b86b294c8..aee819f379e9a 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1801,12 +1801,8 @@ static int __init gasket_init(void)
return 0;
 }
 
-static void __exit gasket_exit(void)
-{
-}
 MODULE_DESCRIPTION("Google Gasket driver framework");
 MODULE_VERSION(GASKET_FRAMEWORK_VERSION);
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Rob Springer ");
 module_init(gasket_init);
-module_exit(gasket_exit);
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 13/16] staging: gasket: core: rename lookup_internal_desc to be PCI-specific

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Rename lookup_internal_desc() to lookup_pci_internal_desc() to reflect
use for PCI devices only, in prep for non-PCI devices in the future.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 5e048f6e16e12..99f3f11d75ce2 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -651,13 +651,13 @@ void gasket_disable_device(struct gasket_dev *gasket_dev)
 EXPORT_SYMBOL(gasket_disable_device);
 
 /*
- * Registered descriptor lookup.
+ * Registered driver descriptor lookup for PCI devices.
  *
  * Precondition: Called with g_mutex held (to avoid a race on return).
  * Returns NULL if no matching device was found.
  */
 static struct gasket_internal_desc *
-lookup_internal_desc(struct pci_dev *pci_dev)
+lookup_pci_internal_desc(struct pci_dev *pci_dev)
 {
int i;
 
@@ -1488,7 +1488,7 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
dev_dbg(_dev->dev, "add PCI gasket device\n");
 
mutex_lock(_mutex);
-   internal_desc = lookup_internal_desc(pci_dev);
+   internal_desc = lookup_pci_internal_desc(pci_dev);
mutex_unlock(_mutex);
if (!internal_desc) {
dev_err(_dev->dev,
@@ -1536,7 +1536,7 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
struct gasket_dev *gasket_dev = NULL;
/* Find the device desc. */
mutex_lock(_mutex);
-   internal_desc = lookup_internal_desc(pci_dev);
+   internal_desc = lookup_pci_internal_desc(pci_dev);
if (!internal_desc) {
mutex_unlock(_mutex);
return;
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 11/16] staging: gasket: core: factor out generic device add code from PCI code

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Split out generic gasket device add code from the code for adding a PCI
gasket device, in prep for other gasket device types in the future.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 76 ++--
 1 file changed, 48 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index aee819f379e9a..ce8ae226f82d9 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1419,6 +1419,48 @@ int gasket_enable_device(struct gasket_dev *gasket_dev)
 }
 EXPORT_SYMBOL(gasket_enable_device);
 
+static int __gasket_add_device(struct device *parent_dev,
+  struct gasket_internal_desc *internal_desc,
+  struct gasket_dev **gasket_devp)
+{
+   int ret;
+   struct gasket_dev *gasket_dev;
+   const struct gasket_driver_desc *driver_desc =
+   internal_desc->driver_desc;
+
+   ret = gasket_alloc_dev(internal_desc, parent_dev, _dev);
+   if (ret)
+   return ret;
+   if (IS_ERR(gasket_dev->dev_info.device)) {
+   dev_err(parent_dev, "Cannot create %s device %s [ret = %ld]\n",
+   driver_desc->name, gasket_dev->dev_info.name,
+   PTR_ERR(gasket_dev->dev_info.device));
+   ret = -ENODEV;
+   goto free_gasket_dev;
+   }
+
+   ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device,
+ gasket_dev);
+   if (ret)
+   goto remove_device;
+
+   ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
+ gasket_sysfs_generic_attrs);
+   if (ret)
+   goto remove_sysfs_mapping;
+
+   *gasket_devp = gasket_dev;
+   return 0;
+
+remove_sysfs_mapping:
+   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
+remove_device:
+   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
+free_gasket_dev:
+   gasket_free_dev(gasket_dev);
+   return ret;
+}
+
 /*
  * Add PCI gasket device.
  *
@@ -1433,7 +1475,6 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
int ret;
struct gasket_internal_desc *internal_desc;
struct gasket_dev *gasket_dev;
-   const struct gasket_driver_desc *driver_desc;
struct device *parent;
 
dev_dbg(_dev->dev, "add PCI gasket device\n");
@@ -1447,29 +1488,15 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
return -ENODEV;
}
 
-   driver_desc = internal_desc->driver_desc;
-
parent = _dev->dev;
-   ret = gasket_alloc_dev(internal_desc, parent, _dev);
+   ret = __gasket_add_device(parent, internal_desc, _dev);
if (ret)
return ret;
-   gasket_dev->pci_dev = pci_dev;
-   if (IS_ERR_OR_NULL(gasket_dev->dev_info.device)) {
-   pr_err("Cannot create %s device %s [ret = %ld]\n",
-  driver_desc->name, gasket_dev->dev_info.name,
-  PTR_ERR(gasket_dev->dev_info.device));
-   ret = -ENODEV;
-   goto fail1;
-   }
 
+   gasket_dev->pci_dev = pci_dev;
ret = gasket_setup_pci(pci_dev, gasket_dev);
if (ret)
-   goto fail2;
-
-   ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device,
- gasket_dev);
-   if (ret)
-   goto fail3;
+   goto cleanup_pci;
 
/*
 * Once we've created the mapping structures successfully, attempt to
@@ -1480,23 +1507,16 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
if (ret) {
dev_err(gasket_dev->dev,
"Cannot create sysfs pci link: %d\n", ret);
-   goto fail3;
+   goto cleanup_pci;
}
-   ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
- gasket_sysfs_generic_attrs);
-   if (ret)
-   goto fail4;
 
*gasket_devp = gasket_dev;
return 0;
 
-fail4:
-fail3:
-   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-fail2:
+cleanup_pci:
gasket_cleanup_pci(gasket_dev);
+   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-fail1:
gasket_free_dev(gasket_dev);
return ret;
 }
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 12/16] staging: gasket: core: factor out generic device remove code from PCI

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Separate code for generic parts of gasket device removal sequence from
the PCI device removal code, in prep for non-PCI devices later.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index ce8ae226f82d9..5e048f6e16e12 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1461,6 +1461,14 @@ static int __gasket_add_device(struct device *parent_dev,
return ret;
 }
 
+static void __gasket_remove_device(struct gasket_internal_desc *internal_desc,
+  struct gasket_dev *gasket_dev)
+{
+   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
+   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
+   gasket_free_dev(gasket_dev);
+}
+
 /*
  * Add PCI gasket device.
  *
@@ -1515,9 +1523,7 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
 
 cleanup_pci:
gasket_cleanup_pci(gasket_dev);
-   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-   gasket_free_dev(gasket_dev);
+   __gasket_remove_device(internal_desc, gasket_dev);
return ret;
 }
 EXPORT_SYMBOL(gasket_pci_add_device);
@@ -1528,7 +1534,6 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
int i;
struct gasket_internal_desc *internal_desc;
struct gasket_dev *gasket_dev = NULL;
-   const struct gasket_driver_desc *driver_desc;
/* Find the device desc. */
mutex_lock(_mutex);
internal_desc = lookup_internal_desc(pci_dev);
@@ -1538,8 +1543,6 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
}
mutex_unlock(_mutex);
 
-   driver_desc = internal_desc->driver_desc;
-
/* Now find the specific device */
mutex_lock(_desc->mutex);
for (i = 0; i < GASKET_DEV_MAX; i++) {
@@ -1558,10 +1561,7 @@ void gasket_pci_remove_device(struct pci_dev *pci_dev)
internal_desc->driver_desc->name);
 
gasket_cleanup_pci(gasket_dev);
-
-   gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-   device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-   gasket_free_dev(gasket_dev);
+   __gasket_remove_device(internal_desc, gasket_dev);
 }
 EXPORT_SYMBOL(gasket_pci_remove_device);
 
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 06/16] staging: gasket: remove gasket_exit()

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Remove now-empty gasket_exit() function.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 0fe5b86b294c8..aee819f379e9a 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1801,12 +1801,8 @@ static int __init gasket_init(void)
return 0;
 }
 
-static void __exit gasket_exit(void)
-{
-}
 MODULE_DESCRIPTION("Google Gasket driver framework");
 MODULE_VERSION(GASKET_FRAMEWORK_VERSION);
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Rob Springer ");
 module_init(gasket_init);
-module_exit(gasket_exit);
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 08/16] staging: gasket: page table: use dma_mapping_error for error detection

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

gasket_perform_mapping() call dma_mapping_error() to determine if
mapping failed.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index bd921dc6094de..4d2499269499b 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -493,7 +493,8 @@ static int gasket_perform_mapping(struct gasket_page_table 
*pg_tbl,
(void *)page_to_pfn(page),
(unsigned long long)ptes[i].dma_addr);
 
-   if (ptes[i].dma_addr == -1) {
+   if (dma_mapping_error(pg_tbl->device,
+ ptes[i].dma_addr)) {
dev_dbg(pg_tbl->device,
"%s i %d -> fail to map page %llx "
"[pfn %p ohys %p]\n",
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 14/16] staging: gasket: interrupt: refactor PCI MSIX-specific handler code

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Split interrupt handler into PCI MSIX-specific and generic functions,
for adding non-MSIX handlers in the future.  Move MSIX init code
together,, out of generic init path.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_interrupt.c | 48 ---
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index 1cfbc120f2284..f94e4ea9a7ded 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -157,9 +157,22 @@ static void gasket_interrupt_setup(struct gasket_dev 
*gasket_dev)
}
 }
 
-static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id)
+static void
+gasket_handle_interrupt(struct gasket_interrupt_data *interrupt_data,
+   int interrupt_index)
 {
struct eventfd_ctx *ctx;
+
+   trace_gasket_interrupt_event(interrupt_data->name, interrupt_index);
+   ctx = interrupt_data->eventfd_ctxs[interrupt_index];
+   if (ctx)
+   eventfd_signal(ctx, 1);
+
+   ++(interrupt_data->interrupt_counts[interrupt_index]);
+}
+
+static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id)
+{
struct gasket_interrupt_data *interrupt_data = dev_id;
int interrupt = -1;
int i;
@@ -175,14 +188,7 @@ static irqreturn_t gasket_msix_interrupt_handler(int irq, 
void *dev_id)
pr_err("Received unknown irq %d\n", irq);
return IRQ_HANDLED;
}
-   trace_gasket_interrupt_event(interrupt_data->name, interrupt);
-
-   ctx = interrupt_data->eventfd_ctxs[interrupt];
-   if (ctx)
-   eventfd_signal(ctx, 1);
-
-   ++(interrupt_data->interrupt_counts[interrupt]);
-
+   gasket_handle_interrupt(interrupt_data, interrupt);
return IRQ_HANDLED;
 }
 
@@ -192,6 +198,12 @@ gasket_interrupt_msix_init(struct gasket_interrupt_data 
*interrupt_data)
int ret = 1;
int i;
 
+   interrupt_data->msix_entries =
+   kcalloc(interrupt_data->num_interrupts,
+   sizeof(struct msix_entry), GFP_KERNEL);
+   if (!interrupt_data->msix_entries)
+   return -ENOMEM;
+
for (i = 0; i < interrupt_data->num_interrupts; i++) {
interrupt_data->msix_entries[i].entry = i;
interrupt_data->msix_entries[i].vector = 0;
@@ -343,20 +355,10 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, 
const char *name,
interrupt_data->num_configured = 0;
interrupt_data->wire_interrupt_offsets = wire_int_offsets;
 
-   /* Allocate all dynamic structures. */
-   interrupt_data->msix_entries = kcalloc(num_interrupts,
-  sizeof(struct msix_entry),
-  GFP_KERNEL);
-   if (!interrupt_data->msix_entries) {
-   kfree(interrupt_data);
-   return -ENOMEM;
-   }
-
interrupt_data->eventfd_ctxs = kcalloc(num_interrupts,
   sizeof(struct eventfd_ctx *),
   GFP_KERNEL);
if (!interrupt_data->eventfd_ctxs) {
-   kfree(interrupt_data->msix_entries);
kfree(interrupt_data);
return -ENOMEM;
}
@@ -366,7 +368,6 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, 
const char *name,
   GFP_KERNEL);
if (!interrupt_data->interrupt_counts) {
kfree(interrupt_data->eventfd_ctxs);
-   kfree(interrupt_data->msix_entries);
kfree(interrupt_data);
return -ENOMEM;
}
@@ -417,6 +418,7 @@ gasket_interrupt_msix_cleanup(struct gasket_interrupt_data 
*interrupt_data)
if (interrupt_data->msix_configured)
pci_disable_msix(interrupt_data->pci_dev);
interrupt_data->msix_configured = 0;
+   kfree(interrupt_data->msix_entries);
 }
 
 int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
@@ -448,10 +450,11 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
}
 
if (ret) {
-   /* Failing to setup MSIx will cause the device
+   /* Failing to setup interrupts will cause the device
 * to report GASKET_STATUS_LAMED, but is not fatal.
 */
-   dev_warn(gasket_dev->dev, "Couldn't init msix: %d\n", ret);
+   dev_warn(gasket_dev->dev, "Couldn't reinit interrupts: %d\n",
+ret);
return 0;
}
 
@@ -497,7 +500,6 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev)
 
kfree(interrupt_data->interrupt_counts);
kfree(interrupt_data->eventfd_ctxs);
-   kfree(interrupt_data->msix_entries);
kfree(interrupt_data);

[PATCH 08/16] staging: gasket: page table: use dma_mapping_error for error detection

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

gasket_perform_mapping() call dma_mapping_error() to determine if
mapping failed.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index bd921dc6094de..4d2499269499b 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -493,7 +493,8 @@ static int gasket_perform_mapping(struct gasket_page_table 
*pg_tbl,
(void *)page_to_pfn(page),
(unsigned long long)ptes[i].dma_addr);
 
-   if (ptes[i].dma_addr == -1) {
+   if (dma_mapping_error(pg_tbl->device,
+ ptes[i].dma_addr)) {
dev_dbg(pg_tbl->device,
"%s i %d -> fail to map page %llx "
"[pfn %p ohys %p]\n",
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 14/16] staging: gasket: interrupt: refactor PCI MSIX-specific handler code

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Split interrupt handler into PCI MSIX-specific and generic functions,
for adding non-MSIX handlers in the future.  Move MSIX init code
together,, out of generic init path.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_interrupt.c | 48 ---
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index 1cfbc120f2284..f94e4ea9a7ded 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -157,9 +157,22 @@ static void gasket_interrupt_setup(struct gasket_dev 
*gasket_dev)
}
 }
 
-static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id)
+static void
+gasket_handle_interrupt(struct gasket_interrupt_data *interrupt_data,
+   int interrupt_index)
 {
struct eventfd_ctx *ctx;
+
+   trace_gasket_interrupt_event(interrupt_data->name, interrupt_index);
+   ctx = interrupt_data->eventfd_ctxs[interrupt_index];
+   if (ctx)
+   eventfd_signal(ctx, 1);
+
+   ++(interrupt_data->interrupt_counts[interrupt_index]);
+}
+
+static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id)
+{
struct gasket_interrupt_data *interrupt_data = dev_id;
int interrupt = -1;
int i;
@@ -175,14 +188,7 @@ static irqreturn_t gasket_msix_interrupt_handler(int irq, 
void *dev_id)
pr_err("Received unknown irq %d\n", irq);
return IRQ_HANDLED;
}
-   trace_gasket_interrupt_event(interrupt_data->name, interrupt);
-
-   ctx = interrupt_data->eventfd_ctxs[interrupt];
-   if (ctx)
-   eventfd_signal(ctx, 1);
-
-   ++(interrupt_data->interrupt_counts[interrupt]);
-
+   gasket_handle_interrupt(interrupt_data, interrupt);
return IRQ_HANDLED;
 }
 
@@ -192,6 +198,12 @@ gasket_interrupt_msix_init(struct gasket_interrupt_data 
*interrupt_data)
int ret = 1;
int i;
 
+   interrupt_data->msix_entries =
+   kcalloc(interrupt_data->num_interrupts,
+   sizeof(struct msix_entry), GFP_KERNEL);
+   if (!interrupt_data->msix_entries)
+   return -ENOMEM;
+
for (i = 0; i < interrupt_data->num_interrupts; i++) {
interrupt_data->msix_entries[i].entry = i;
interrupt_data->msix_entries[i].vector = 0;
@@ -343,20 +355,10 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, 
const char *name,
interrupt_data->num_configured = 0;
interrupt_data->wire_interrupt_offsets = wire_int_offsets;
 
-   /* Allocate all dynamic structures. */
-   interrupt_data->msix_entries = kcalloc(num_interrupts,
-  sizeof(struct msix_entry),
-  GFP_KERNEL);
-   if (!interrupt_data->msix_entries) {
-   kfree(interrupt_data);
-   return -ENOMEM;
-   }
-
interrupt_data->eventfd_ctxs = kcalloc(num_interrupts,
   sizeof(struct eventfd_ctx *),
   GFP_KERNEL);
if (!interrupt_data->eventfd_ctxs) {
-   kfree(interrupt_data->msix_entries);
kfree(interrupt_data);
return -ENOMEM;
}
@@ -366,7 +368,6 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, 
const char *name,
   GFP_KERNEL);
if (!interrupt_data->interrupt_counts) {
kfree(interrupt_data->eventfd_ctxs);
-   kfree(interrupt_data->msix_entries);
kfree(interrupt_data);
return -ENOMEM;
}
@@ -417,6 +418,7 @@ gasket_interrupt_msix_cleanup(struct gasket_interrupt_data 
*interrupt_data)
if (interrupt_data->msix_configured)
pci_disable_msix(interrupt_data->pci_dev);
interrupt_data->msix_configured = 0;
+   kfree(interrupt_data->msix_entries);
 }
 
 int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
@@ -448,10 +450,11 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
}
 
if (ret) {
-   /* Failing to setup MSIx will cause the device
+   /* Failing to setup interrupts will cause the device
 * to report GASKET_STATUS_LAMED, but is not fatal.
 */
-   dev_warn(gasket_dev->dev, "Couldn't init msix: %d\n", ret);
+   dev_warn(gasket_dev->dev, "Couldn't reinit interrupts: %d\n",
+ret);
return 0;
}
 
@@ -497,7 +500,6 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev)
 
kfree(interrupt_data->interrupt_counts);
kfree(interrupt_data->eventfd_ctxs);
-   kfree(interrupt_data->msix_entries);
kfree(interrupt_data);

[PATCH 16/16] staging: gasket: interrupt: remove unimplemented interrupt types

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Interrupt types PCI_MSI and PLATFORM_WIRE are unused and unimplemented.
Remove these.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.h  | 11 
 drivers/staging/gasket/gasket_interrupt.c | 34 +--
 2 files changed, 1 insertion(+), 44 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.h 
b/drivers/staging/gasket/gasket_core.h
index fd7e75b765a6d..0203460f48957 100644
--- a/drivers/staging/gasket/gasket_core.h
+++ b/drivers/staging/gasket/gasket_core.h
@@ -50,8 +50,6 @@ enum gasket_interrupt_packing {
 /* Type of the interrupt supported by the device. */
 enum gasket_interrupt_type {
PCI_MSIX = 0,
-   PCI_MSI = 1,
-   PLATFORM_WIRE = 2,
 };
 
 /*
@@ -69,12 +67,6 @@ struct gasket_interrupt_desc {
int packing;
 };
 
-/* Offsets to the wire interrupt handling registers */
-struct gasket_wire_interrupt_offsets {
-   u64 pending_bit_array;
-   u64 mask_array;
-};
-
 /*
  * This enum is used to identify memory regions being part of the physical
  * memory that belongs to a device.
@@ -384,9 +376,6 @@ struct gasket_driver_desc {
 */
struct gasket_coherent_buffer_desc coherent_buffer_description;
 
-   /* Offset of wire interrupt registers. */
-   const struct gasket_wire_interrupt_offsets *wire_interrupt_offsets;
-
/* Interrupt type. (One of gasket_interrupt_type). */
int interrupt_type;
 
diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index eb5dfbe08e214..2cd262be65ca0 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -45,9 +45,6 @@ struct gasket_interrupt_data {
/* The width of a single interrupt in a packed interrupt register. */
int pack_width;
 
-   /* offset of wire interrupt registers */
-   const struct gasket_wire_interrupt_offsets *wire_interrupt_offsets;
-
/*
 * Design-wise, these elements should be bundled together, but
 * pci_enable_msix's interface requires that they be managed
@@ -92,19 +89,6 @@ static void gasket_interrupt_setup(struct gasket_dev 
*gasket_dev)
 
dev_dbg(gasket_dev->dev, "Running interrupt setup\n");
 
-   if (interrupt_data->type == PLATFORM_WIRE ||
-   interrupt_data->type == PCI_MSI) {
-   /* Nothing needs to be done for platform or PCI devices. */
-   return;
-   }
-
-   if (interrupt_data->type != PCI_MSIX) {
-   dev_dbg(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   interrupt_data->type);
-   return;
-   }
-
/* Setup the MSIX table. */
 
for (i = 0; i < interrupt_data->num_interrupts; i++) {
@@ -351,8 +335,6 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
interrupt_data->interrupt_bar_index = driver_desc->interrupt_bar_index;
interrupt_data->pack_width = driver_desc->interrupt_pack_width;
interrupt_data->num_configured = 0;
-   interrupt_data->wire_interrupt_offsets =
-   driver_desc->wire_interrupt_offsets;
 
interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts,
   sizeof(struct eventfd_ctx *),
@@ -379,12 +361,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
force_msix_interrupt_unmasking(gasket_dev);
break;
 
-   case PCI_MSI:
-   case PLATFORM_WIRE:
default:
-   dev_err(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   interrupt_data->type);
ret = -EINVAL;
}
 
@@ -439,12 +416,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
force_msix_interrupt_unmasking(gasket_dev);
break;
 
-   case PCI_MSI:
-   case PLATFORM_WIRE:
default:
-   dev_dbg(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   gasket_dev->interrupt_data->type);
ret = -EINVAL;
}
 
@@ -489,12 +461,8 @@ void gasket_interrupt_cleanup(struct gasket_dev 
*gasket_dev)
gasket_interrupt_msix_cleanup(interrupt_data);
break;
 
-   case PCI_MSI:
-   case PLATFORM_WIRE:
default:
-   dev_dbg(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   interrupt_data->type);
+   break;
}
 
kfree(interrupt_data->interrupt_counts);
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 16/16] staging: gasket: interrupt: remove unimplemented interrupt types

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Interrupt types PCI_MSI and PLATFORM_WIRE are unused and unimplemented.
Remove these.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.h  | 11 
 drivers/staging/gasket/gasket_interrupt.c | 34 +--
 2 files changed, 1 insertion(+), 44 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.h 
b/drivers/staging/gasket/gasket_core.h
index fd7e75b765a6d..0203460f48957 100644
--- a/drivers/staging/gasket/gasket_core.h
+++ b/drivers/staging/gasket/gasket_core.h
@@ -50,8 +50,6 @@ enum gasket_interrupt_packing {
 /* Type of the interrupt supported by the device. */
 enum gasket_interrupt_type {
PCI_MSIX = 0,
-   PCI_MSI = 1,
-   PLATFORM_WIRE = 2,
 };
 
 /*
@@ -69,12 +67,6 @@ struct gasket_interrupt_desc {
int packing;
 };
 
-/* Offsets to the wire interrupt handling registers */
-struct gasket_wire_interrupt_offsets {
-   u64 pending_bit_array;
-   u64 mask_array;
-};
-
 /*
  * This enum is used to identify memory regions being part of the physical
  * memory that belongs to a device.
@@ -384,9 +376,6 @@ struct gasket_driver_desc {
 */
struct gasket_coherent_buffer_desc coherent_buffer_description;
 
-   /* Offset of wire interrupt registers. */
-   const struct gasket_wire_interrupt_offsets *wire_interrupt_offsets;
-
/* Interrupt type. (One of gasket_interrupt_type). */
int interrupt_type;
 
diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index eb5dfbe08e214..2cd262be65ca0 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -45,9 +45,6 @@ struct gasket_interrupt_data {
/* The width of a single interrupt in a packed interrupt register. */
int pack_width;
 
-   /* offset of wire interrupt registers */
-   const struct gasket_wire_interrupt_offsets *wire_interrupt_offsets;
-
/*
 * Design-wise, these elements should be bundled together, but
 * pci_enable_msix's interface requires that they be managed
@@ -92,19 +89,6 @@ static void gasket_interrupt_setup(struct gasket_dev 
*gasket_dev)
 
dev_dbg(gasket_dev->dev, "Running interrupt setup\n");
 
-   if (interrupt_data->type == PLATFORM_WIRE ||
-   interrupt_data->type == PCI_MSI) {
-   /* Nothing needs to be done for platform or PCI devices. */
-   return;
-   }
-
-   if (interrupt_data->type != PCI_MSIX) {
-   dev_dbg(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   interrupt_data->type);
-   return;
-   }
-
/* Setup the MSIX table. */
 
for (i = 0; i < interrupt_data->num_interrupts; i++) {
@@ -351,8 +335,6 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
interrupt_data->interrupt_bar_index = driver_desc->interrupt_bar_index;
interrupt_data->pack_width = driver_desc->interrupt_pack_width;
interrupt_data->num_configured = 0;
-   interrupt_data->wire_interrupt_offsets =
-   driver_desc->wire_interrupt_offsets;
 
interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts,
   sizeof(struct eventfd_ctx *),
@@ -379,12 +361,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
force_msix_interrupt_unmasking(gasket_dev);
break;
 
-   case PCI_MSI:
-   case PLATFORM_WIRE:
default:
-   dev_err(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   interrupt_data->type);
ret = -EINVAL;
}
 
@@ -439,12 +416,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
force_msix_interrupt_unmasking(gasket_dev);
break;
 
-   case PCI_MSI:
-   case PLATFORM_WIRE:
default:
-   dev_dbg(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   gasket_dev->interrupt_data->type);
ret = -EINVAL;
}
 
@@ -489,12 +461,8 @@ void gasket_interrupt_cleanup(struct gasket_dev 
*gasket_dev)
gasket_interrupt_msix_cleanup(interrupt_data);
break;
 
-   case PCI_MSI:
-   case PLATFORM_WIRE:
default:
-   dev_dbg(gasket_dev->dev,
-   "Cannot handle unsupported interrupt type %d\n",
-   interrupt_data->type);
+   break;
}
 
kfree(interrupt_data->interrupt_counts);
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 04/16] staging: gasket: core: remove kobj_name param from gasket_alloc_dev

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

gasket_alloc_dev can retrieve the device name from the parent parameter,
a separate parameter isn't needed for this.  Rename the variable to
better reflect its meaning, as the name of the parent device for which a
gasket device is being allocated.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 3fb805204d700..5f54b3615f67c 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -189,26 +189,26 @@ static int gasket_find_dev_slot(struct 
gasket_internal_desc *internal_desc,
  * Returns 0 if successful, a negative error code otherwise.
  */
 static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc,
-   struct device *parent, struct gasket_dev **pdev,
-   const char *kobj_name)
+   struct device *parent, struct gasket_dev **pdev)
 {
int dev_idx;
const struct gasket_driver_desc *driver_desc =
internal_desc->driver_desc;
struct gasket_dev *gasket_dev;
struct gasket_cdev_info *dev_info;
+   const char *parent_name = dev_name(parent);
 
-   pr_debug("Allocating a Gasket device %s.\n", kobj_name);
+   pr_debug("Allocating a Gasket device, parent %s.\n", parent_name);
 
*pdev = NULL;
 
-   dev_idx = gasket_find_dev_slot(internal_desc, kobj_name);
+   dev_idx = gasket_find_dev_slot(internal_desc, parent_name);
if (dev_idx < 0)
return dev_idx;
 
gasket_dev = *pdev = kzalloc(sizeof(*gasket_dev), GFP_KERNEL);
if (!gasket_dev) {
-   pr_err("no memory for device %s\n", kobj_name);
+   pr_err("no memory for device, parent %s\n", parent_name);
return -ENOMEM;
}
internal_desc->devs[dev_idx] = gasket_dev;
@@ -217,7 +217,7 @@ static int gasket_alloc_dev(struct gasket_internal_desc 
*internal_desc,
 
gasket_dev->internal_desc = internal_desc;
gasket_dev->dev_idx = dev_idx;
-   snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", kobj_name);
+   snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", parent_name);
gasket_dev->dev = get_device(parent);
/* gasket_bar_data is uninitialized. */
gasket_dev->num_page_tables = driver_desc->num_page_tables;
@@ -1431,13 +1431,12 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
  struct gasket_dev **gasket_devp)
 {
int ret;
-   const char *kobj_name = dev_name(_dev->dev);
struct gasket_internal_desc *internal_desc;
struct gasket_dev *gasket_dev;
const struct gasket_driver_desc *driver_desc;
struct device *parent;
 
-   pr_debug("add PCI device %s\n", kobj_name);
+   dev_dbg(_dev->dev, "add PCI gasket device\n");
 
mutex_lock(_mutex);
internal_desc = lookup_internal_desc(pci_dev);
@@ -1451,7 +1450,7 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
driver_desc = internal_desc->driver_desc;
 
parent = _dev->dev;
-   ret = gasket_alloc_dev(internal_desc, parent, _dev, kobj_name);
+   ret = gasket_alloc_dev(internal_desc, parent, _dev);
if (ret)
return ret;
gasket_dev->pci_dev = pci_dev;
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 01/16] MAINTAINERS: Switch a maintainer for drivers/staging/gasket

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Todd Poynor takes over for John Joseph.

Signed-off-by: John Joseph 
Signed-off-by: Todd Poynor 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index af64fe0f0b41f..f3466b5c50482 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5939,7 +5939,7 @@ F:Documentation/gcc-plugins.txt
 
 GASKET DRIVER FRAMEWORK
 M: Rob Springer 
-M: John Joseph 
+M: Todd Poynor 
 M: Ben Chan 
 S: Maintained
 F: drivers/staging/gasket/
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 15/16] staging: gasket: interrupt: simplify interrupt init parameters

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Pass the gasket driver descriptor to the interrupt init function, rather
than exploding out separate parameters from various fields of that
structure.  This allows us to make more localized changes to the types
of interrupts supported (MSIX vs. wire, etc.) without affecting the
calling sequence, and seems nicer for simplification purposes.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c  |  8 +--
 drivers/staging/gasket/gasket_interrupt.c | 27 +++
 drivers/staging/gasket/gasket_interrupt.h | 24 +---
 3 files changed, 15 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 99f3f11d75ce2..f230bec76ae4e 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1357,13 +1357,7 @@ int gasket_enable_device(struct gasket_dev *gasket_dev)
const struct gasket_driver_desc *driver_desc =
gasket_dev->internal_desc->driver_desc;
 
-   ret = gasket_interrupt_init(gasket_dev, driver_desc->name,
-   driver_desc->interrupt_type,
-   driver_desc->interrupts,
-   driver_desc->num_interrupts,
-   driver_desc->interrupt_pack_width,
-   driver_desc->interrupt_bar_index,
-   driver_desc->wire_interrupt_offsets);
+   ret = gasket_interrupt_init(gasket_dev);
if (ret) {
dev_err(gasket_dev->dev,
"Critical failure to allocate interrupts: %d\n", ret);
diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index f94e4ea9a7ded..eb5dfbe08e214 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -331,31 +331,30 @@ static struct gasket_sysfs_attribute 
interrupt_sysfs_attrs[] = {
GASKET_END_OF_ATTR_ARRAY,
 };
 
-int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name,
- int type,
- const struct gasket_interrupt_desc *interrupts,
- int num_interrupts, int pack_width, int bar_index,
- const struct gasket_wire_interrupt_offsets 
*wire_int_offsets)
+int gasket_interrupt_init(struct gasket_dev *gasket_dev)
 {
int ret;
struct gasket_interrupt_data *interrupt_data;
+   const struct gasket_driver_desc *driver_desc =
+   gasket_get_driver_desc(gasket_dev);
 
interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data),
 GFP_KERNEL);
if (!interrupt_data)
return -ENOMEM;
gasket_dev->interrupt_data = interrupt_data;
-   interrupt_data->name = name;
-   interrupt_data->type = type;
+   interrupt_data->name = driver_desc->name;
+   interrupt_data->type = driver_desc->interrupt_type;
interrupt_data->pci_dev = gasket_dev->pci_dev;
-   interrupt_data->num_interrupts = num_interrupts;
-   interrupt_data->interrupts = interrupts;
-   interrupt_data->interrupt_bar_index = bar_index;
-   interrupt_data->pack_width = pack_width;
+   interrupt_data->num_interrupts = driver_desc->num_interrupts;
+   interrupt_data->interrupts = driver_desc->interrupts;
+   interrupt_data->interrupt_bar_index = driver_desc->interrupt_bar_index;
+   interrupt_data->pack_width = driver_desc->interrupt_pack_width;
interrupt_data->num_configured = 0;
-   interrupt_data->wire_interrupt_offsets = wire_int_offsets;
+   interrupt_data->wire_interrupt_offsets =
+   driver_desc->wire_interrupt_offsets;
 
-   interrupt_data->eventfd_ctxs = kcalloc(num_interrupts,
+   interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts,
   sizeof(struct eventfd_ctx *),
   GFP_KERNEL);
if (!interrupt_data->eventfd_ctxs) {
@@ -363,7 +362,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, 
const char *name,
return -ENOMEM;
}
 
-   interrupt_data->interrupt_counts = kcalloc(num_interrupts,
+   interrupt_data->interrupt_counts = kcalloc(driver_desc->num_interrupts,
   sizeof(ulong),
   GFP_KERNEL);
if (!interrupt_data->interrupt_counts) {
diff --git a/drivers/staging/gasket/gasket_interrupt.h 
b/drivers/staging/gasket/gasket_interrupt.h
index 835af439e96a9..85526a1374a1a 100644
--- a/drivers/staging/gasket/gasket_interrupt.h
+++ b/drivers/staging/gasket/gasket_interrupt.h
@@ -24,30 +24,8 @@ struct gasket_interrupt_data;
 /*
  * Initialize the interrupt module.
  * @gasket_dev: The Gasket 

[PATCH 09/16] staging: gasket: core: switch to relaxed memory-mapped I/O

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Use of readl() is deprecated; readl_relaxed() with appropriate memory
barriers is preferred.  Switch to relaxed reads and writes for better
performance as well.  Memory barriers required for I/O vs. normal
memory access on Apex devices have already been explicitly coded in the
page table routines.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.h 
b/drivers/staging/gasket/gasket_core.h
index 275fd0b345b6e..fd7e75b765a6d 100644
--- a/drivers/staging/gasket/gasket_core.h
+++ b/drivers/staging/gasket/gasket_core.h
@@ -590,25 +590,25 @@ const char *gasket_num_name_lookup(uint num,
 static inline ulong gasket_dev_read_64(struct gasket_dev *gasket_dev, int bar,
   ulong location)
 {
-   return readq(_dev->bar_data[bar].virt_base[location]);
+   return readq_relaxed(_dev->bar_data[bar].virt_base[location]);
 }
 
 static inline void gasket_dev_write_64(struct gasket_dev *dev, u64 value,
   int bar, ulong location)
 {
-   writeq(value, >bar_data[bar].virt_base[location]);
+   writeq_relaxed(value, >bar_data[bar].virt_base[location]);
 }
 
 static inline void gasket_dev_write_32(struct gasket_dev *dev, u32 value,
   int bar, ulong location)
 {
-   writel(value, >bar_data[bar].virt_base[location]);
+   writel_relaxed(value, >bar_data[bar].virt_base[location]);
 }
 
 static inline u32 gasket_dev_read_32(struct gasket_dev *dev, int bar,
 ulong location)
 {
-   return readl(>bar_data[bar].virt_base[location]);
+   return readl_relaxed(>bar_data[bar].virt_base[location]);
 }
 
 static inline void gasket_read_modify_write_64(struct gasket_dev *dev, int bar,
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 10/16] staging: gasket: page table: remove extraneous memory barriers

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Some explicit memory barriers in the page table code are not necessary,
either because:

(a) The barrier follows a non-relaxed MMIO access that already performs
a read or write memory barrier.

(b) The barrier follows DMA API calls for which the device-visible
effects of IOMMU programming are guaranteed to be flushed to the IOMMU
prior to the call returning, and doesn't need to sync with normal memory
access.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index 4d2499269499b..53492f4fad6aa 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -317,8 +317,6 @@ static void gasket_free_extended_subtable(struct 
gasket_page_table *pg_tbl,
 
/* Release the page table from the device */
writeq(0, slot);
-   /* Force sync around the address release. */
-   mb();
 
if (pte->dma_addr)
dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE,
@@ -504,8 +502,6 @@ static int gasket_perform_mapping(struct gasket_page_table 
*pg_tbl,
(void *)page_to_phys(page));
return -1;
}
-   /* Wait until the page is mapped. */
-   mb();
}
 
/* Make the DMA-space address available to the device. */
@@ -604,12 +600,13 @@ static void gasket_perform_unmapping(struct 
gasket_page_table *pg_tbl,
 */
for (i = 0; i < num_pages; i++) {
/* release the address from the device, */
-   if (is_simple_mapping || ptes[i].status == PTE_INUSE)
+   if (is_simple_mapping || ptes[i].status == PTE_INUSE) {
writeq(0, [i]);
-   else
+   } else {
((u64 __force *)slots)[i] = 0;
-   /* Force sync around the address release. */
-   mb();
+   /* sync above PTE update before updating mappings */
+   wmb();
+   }
 
/* release the address from the driver, */
if (ptes[i].status == PTE_INUSE) {
@@ -898,8 +895,6 @@ static int gasket_alloc_extended_subtable(struct 
gasket_page_table *pg_tbl,
/* Map the page into DMA space. */
pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE,
 DMA_BIDIRECTIONAL);
-   /* Wait until the page is mapped. */
-   mb();
 
/* make the addresses available to the device */
dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG;
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 04/16] staging: gasket: core: remove kobj_name param from gasket_alloc_dev

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

gasket_alloc_dev can retrieve the device name from the parent parameter,
a separate parameter isn't needed for this.  Rename the variable to
better reflect its meaning, as the name of the parent device for which a
gasket device is being allocated.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 3fb805204d700..5f54b3615f67c 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -189,26 +189,26 @@ static int gasket_find_dev_slot(struct 
gasket_internal_desc *internal_desc,
  * Returns 0 if successful, a negative error code otherwise.
  */
 static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc,
-   struct device *parent, struct gasket_dev **pdev,
-   const char *kobj_name)
+   struct device *parent, struct gasket_dev **pdev)
 {
int dev_idx;
const struct gasket_driver_desc *driver_desc =
internal_desc->driver_desc;
struct gasket_dev *gasket_dev;
struct gasket_cdev_info *dev_info;
+   const char *parent_name = dev_name(parent);
 
-   pr_debug("Allocating a Gasket device %s.\n", kobj_name);
+   pr_debug("Allocating a Gasket device, parent %s.\n", parent_name);
 
*pdev = NULL;
 
-   dev_idx = gasket_find_dev_slot(internal_desc, kobj_name);
+   dev_idx = gasket_find_dev_slot(internal_desc, parent_name);
if (dev_idx < 0)
return dev_idx;
 
gasket_dev = *pdev = kzalloc(sizeof(*gasket_dev), GFP_KERNEL);
if (!gasket_dev) {
-   pr_err("no memory for device %s\n", kobj_name);
+   pr_err("no memory for device, parent %s\n", parent_name);
return -ENOMEM;
}
internal_desc->devs[dev_idx] = gasket_dev;
@@ -217,7 +217,7 @@ static int gasket_alloc_dev(struct gasket_internal_desc 
*internal_desc,
 
gasket_dev->internal_desc = internal_desc;
gasket_dev->dev_idx = dev_idx;
-   snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", kobj_name);
+   snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", parent_name);
gasket_dev->dev = get_device(parent);
/* gasket_bar_data is uninitialized. */
gasket_dev->num_page_tables = driver_desc->num_page_tables;
@@ -1431,13 +1431,12 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
  struct gasket_dev **gasket_devp)
 {
int ret;
-   const char *kobj_name = dev_name(_dev->dev);
struct gasket_internal_desc *internal_desc;
struct gasket_dev *gasket_dev;
const struct gasket_driver_desc *driver_desc;
struct device *parent;
 
-   pr_debug("add PCI device %s\n", kobj_name);
+   dev_dbg(_dev->dev, "add PCI gasket device\n");
 
mutex_lock(_mutex);
internal_desc = lookup_internal_desc(pci_dev);
@@ -1451,7 +1450,7 @@ int gasket_pci_add_device(struct pci_dev *pci_dev,
driver_desc = internal_desc->driver_desc;
 
parent = _dev->dev;
-   ret = gasket_alloc_dev(internal_desc, parent, _dev, kobj_name);
+   ret = gasket_alloc_dev(internal_desc, parent, _dev);
if (ret)
return ret;
gasket_dev->pci_dev = pci_dev;
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 01/16] MAINTAINERS: Switch a maintainer for drivers/staging/gasket

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Todd Poynor takes over for John Joseph.

Signed-off-by: John Joseph 
Signed-off-by: Todd Poynor 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index af64fe0f0b41f..f3466b5c50482 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5939,7 +5939,7 @@ F:Documentation/gcc-plugins.txt
 
 GASKET DRIVER FRAMEWORK
 M: Rob Springer 
-M: John Joseph 
+M: Todd Poynor 
 M: Ben Chan 
 S: Maintained
 F: drivers/staging/gasket/
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 15/16] staging: gasket: interrupt: simplify interrupt init parameters

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Pass the gasket driver descriptor to the interrupt init function, rather
than exploding out separate parameters from various fields of that
structure.  This allows us to make more localized changes to the types
of interrupts supported (MSIX vs. wire, etc.) without affecting the
calling sequence, and seems nicer for simplification purposes.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c  |  8 +--
 drivers/staging/gasket/gasket_interrupt.c | 27 +++
 drivers/staging/gasket/gasket_interrupt.h | 24 +---
 3 files changed, 15 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 99f3f11d75ce2..f230bec76ae4e 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1357,13 +1357,7 @@ int gasket_enable_device(struct gasket_dev *gasket_dev)
const struct gasket_driver_desc *driver_desc =
gasket_dev->internal_desc->driver_desc;
 
-   ret = gasket_interrupt_init(gasket_dev, driver_desc->name,
-   driver_desc->interrupt_type,
-   driver_desc->interrupts,
-   driver_desc->num_interrupts,
-   driver_desc->interrupt_pack_width,
-   driver_desc->interrupt_bar_index,
-   driver_desc->wire_interrupt_offsets);
+   ret = gasket_interrupt_init(gasket_dev);
if (ret) {
dev_err(gasket_dev->dev,
"Critical failure to allocate interrupts: %d\n", ret);
diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index f94e4ea9a7ded..eb5dfbe08e214 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -331,31 +331,30 @@ static struct gasket_sysfs_attribute 
interrupt_sysfs_attrs[] = {
GASKET_END_OF_ATTR_ARRAY,
 };
 
-int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name,
- int type,
- const struct gasket_interrupt_desc *interrupts,
- int num_interrupts, int pack_width, int bar_index,
- const struct gasket_wire_interrupt_offsets 
*wire_int_offsets)
+int gasket_interrupt_init(struct gasket_dev *gasket_dev)
 {
int ret;
struct gasket_interrupt_data *interrupt_data;
+   const struct gasket_driver_desc *driver_desc =
+   gasket_get_driver_desc(gasket_dev);
 
interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data),
 GFP_KERNEL);
if (!interrupt_data)
return -ENOMEM;
gasket_dev->interrupt_data = interrupt_data;
-   interrupt_data->name = name;
-   interrupt_data->type = type;
+   interrupt_data->name = driver_desc->name;
+   interrupt_data->type = driver_desc->interrupt_type;
interrupt_data->pci_dev = gasket_dev->pci_dev;
-   interrupt_data->num_interrupts = num_interrupts;
-   interrupt_data->interrupts = interrupts;
-   interrupt_data->interrupt_bar_index = bar_index;
-   interrupt_data->pack_width = pack_width;
+   interrupt_data->num_interrupts = driver_desc->num_interrupts;
+   interrupt_data->interrupts = driver_desc->interrupts;
+   interrupt_data->interrupt_bar_index = driver_desc->interrupt_bar_index;
+   interrupt_data->pack_width = driver_desc->interrupt_pack_width;
interrupt_data->num_configured = 0;
-   interrupt_data->wire_interrupt_offsets = wire_int_offsets;
+   interrupt_data->wire_interrupt_offsets =
+   driver_desc->wire_interrupt_offsets;
 
-   interrupt_data->eventfd_ctxs = kcalloc(num_interrupts,
+   interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts,
   sizeof(struct eventfd_ctx *),
   GFP_KERNEL);
if (!interrupt_data->eventfd_ctxs) {
@@ -363,7 +362,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, 
const char *name,
return -ENOMEM;
}
 
-   interrupt_data->interrupt_counts = kcalloc(num_interrupts,
+   interrupt_data->interrupt_counts = kcalloc(driver_desc->num_interrupts,
   sizeof(ulong),
   GFP_KERNEL);
if (!interrupt_data->interrupt_counts) {
diff --git a/drivers/staging/gasket/gasket_interrupt.h 
b/drivers/staging/gasket/gasket_interrupt.h
index 835af439e96a9..85526a1374a1a 100644
--- a/drivers/staging/gasket/gasket_interrupt.h
+++ b/drivers/staging/gasket/gasket_interrupt.h
@@ -24,30 +24,8 @@ struct gasket_interrupt_data;
 /*
  * Initialize the interrupt module.
  * @gasket_dev: The Gasket 

[PATCH 09/16] staging: gasket: core: switch to relaxed memory-mapped I/O

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Use of readl() is deprecated; readl_relaxed() with appropriate memory
barriers is preferred.  Switch to relaxed reads and writes for better
performance as well.  Memory barriers required for I/O vs. normal
memory access on Apex devices have already been explicitly coded in the
page table routines.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.h 
b/drivers/staging/gasket/gasket_core.h
index 275fd0b345b6e..fd7e75b765a6d 100644
--- a/drivers/staging/gasket/gasket_core.h
+++ b/drivers/staging/gasket/gasket_core.h
@@ -590,25 +590,25 @@ const char *gasket_num_name_lookup(uint num,
 static inline ulong gasket_dev_read_64(struct gasket_dev *gasket_dev, int bar,
   ulong location)
 {
-   return readq(_dev->bar_data[bar].virt_base[location]);
+   return readq_relaxed(_dev->bar_data[bar].virt_base[location]);
 }
 
 static inline void gasket_dev_write_64(struct gasket_dev *dev, u64 value,
   int bar, ulong location)
 {
-   writeq(value, >bar_data[bar].virt_base[location]);
+   writeq_relaxed(value, >bar_data[bar].virt_base[location]);
 }
 
 static inline void gasket_dev_write_32(struct gasket_dev *dev, u32 value,
   int bar, ulong location)
 {
-   writel(value, >bar_data[bar].virt_base[location]);
+   writel_relaxed(value, >bar_data[bar].virt_base[location]);
 }
 
 static inline u32 gasket_dev_read_32(struct gasket_dev *dev, int bar,
 ulong location)
 {
-   return readl(>bar_data[bar].virt_base[location]);
+   return readl_relaxed(>bar_data[bar].virt_base[location]);
 }
 
 static inline void gasket_read_modify_write_64(struct gasket_dev *dev, int bar,
-- 
2.18.0.597.ga71716f1ad-goog



[PATCH 10/16] staging: gasket: page table: remove extraneous memory barriers

2018-08-09 Thread Todd Poynor
From: Todd Poynor 

Some explicit memory barriers in the page table code are not necessary,
either because:

(a) The barrier follows a non-relaxed MMIO access that already performs
a read or write memory barrier.

(b) The barrier follows DMA API calls for which the device-visible
effects of IOMMU programming are guaranteed to be flushed to the IOMMU
prior to the call returning, and doesn't need to sync with normal memory
access.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index 4d2499269499b..53492f4fad6aa 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -317,8 +317,6 @@ static void gasket_free_extended_subtable(struct 
gasket_page_table *pg_tbl,
 
/* Release the page table from the device */
writeq(0, slot);
-   /* Force sync around the address release. */
-   mb();
 
if (pte->dma_addr)
dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE,
@@ -504,8 +502,6 @@ static int gasket_perform_mapping(struct gasket_page_table 
*pg_tbl,
(void *)page_to_phys(page));
return -1;
}
-   /* Wait until the page is mapped. */
-   mb();
}
 
/* Make the DMA-space address available to the device. */
@@ -604,12 +600,13 @@ static void gasket_perform_unmapping(struct 
gasket_page_table *pg_tbl,
 */
for (i = 0; i < num_pages; i++) {
/* release the address from the device, */
-   if (is_simple_mapping || ptes[i].status == PTE_INUSE)
+   if (is_simple_mapping || ptes[i].status == PTE_INUSE) {
writeq(0, [i]);
-   else
+   } else {
((u64 __force *)slots)[i] = 0;
-   /* Force sync around the address release. */
-   mb();
+   /* sync above PTE update before updating mappings */
+   wmb();
+   }
 
/* release the address from the driver, */
if (ptes[i].status == PTE_INUSE) {
@@ -898,8 +895,6 @@ static int gasket_alloc_extended_subtable(struct 
gasket_page_table *pg_tbl,
/* Map the page into DMA space. */
pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE,
 DMA_BIDIRECTIONAL);
-   /* Wait until the page is mapped. */
-   mb();
 
/* make the addresses available to the device */
dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG;
-- 
2.18.0.597.ga71716f1ad-goog



Re: [PATCH] reiserfs: fix broken xattr handling (heap corruption, bad retval)

2018-08-09 Thread Jann Horn
On Thu, Aug 2, 2018 at 5:16 PM Jann Horn  wrote:
>
> This fixes the following issues:
>
>  - When a buffer size is supplied to reiserfs_listxattr() such that each
>individual name fits, but the concatenation of all names doesn't
>fit, reiserfs_listxattr() overflows the supplied buffer. This leads to
>a kernel heap overflow (verified using KASAN) followed by an
>out-of-bounds usercopy and is therefore a security bug.
>  - When a buffer size is supplied to reiserfs_listxattr() such that a name
>doesn't fit, -ERANGE should be returned. But reiserfs instead just
>truncates the list of names; I have verified that if the only xattr on
>a file has a longer name than the supplied buffer length, listxattr()
>incorrectly returns zero.
>
> With my patch applied, -ERANGE is returned in both cases and the memory
> corruption doesn't happen anymore.
>
> Credit for making me clean this code up a bit goes to Al Viro, who pointed
> out that the ->actor calling convention is suboptimal and should be
> changed.
>
> Fixes: 48b32a3553a5 ("reiserfs: use generic xattr handlers")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Jann Horn 

+security@
Ping. I have not received any replies to this patch, which fixes a
kernel security bug, for a week.
Whose tree should this go through? reiserfs is marked as "supported",
but does not have a maintainer or a git repo listed, just a
mailinglist, so I guess it probably has to go through either Al Viro's
or akpm's tree? Looks like akpm signed off on the last commits in
reiserfs...

> ---
> Triggering the bug:
>
> root@debian:/home/user# mount -o user_xattr reiserimg reisermount/
> root@debian:/home/user# cd reisermount/
> root@debian:/home/user/reisermount# touch test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo1 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo2 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo3 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo4 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo5 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo6 -v A test_file
> root@debian:/home/user/reisermount# cat xattr_test.c
> #include 
> #include 
> #include 
> #include 
> #include 
> int main(int argc, char **argv) {
>   if (argc != 2) errx(1, "bad invocation");
>   char list[10];
>   int res = listxattr(argv[1], list, sizeof(list));
>   if (res == -1)
> err(1, "listxattr failed");
>   printf("listxattr returned %d\n", res);
>   for (char *p = list; p < list+res-1; p = p + strlen(p) + 1) {
> printf("list entry: %s\n", p);
>   }
> }
> root@debian:/home/user/reisermount# gcc -o xattr_test xattr_test.c
> root@debian:/home/user/reisermount# ./xattr_test test_file
> Segmentation fault
> root@debian:/home/user/reisermount#
>
> Result:
>
> [  122.071318] 
> ==
> [  122.072334] BUG: KASAN: slab-out-of-bounds in listxattr_filler+0x170/0x1b0
> [  122.073173] Write of size 9 at addr 8801c43b474a by task xattr_test/923
> [  122.074030]
> [  122.074223] CPU: 1 PID: 923 Comm: xattr_test Not tainted 4.18.0-rc7+ #67
> [  122.075050] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> 1.10.2-1 04/01/2014
> [  122.076107] Call Trace:
> [  122.076453]  dump_stack+0x71/0xab
> [  122.076900]  print_address_description+0x6a/0x250
> [  122.077514]  kasan_report+0x258/0x380
> [  122.077961]  ? listxattr_filler+0x170/0x1b0
> [  122.078469]  memcpy+0x34/0x50
> [  122.078894]  listxattr_filler+0x170/0x1b0
> [...]
>
>  fs/reiserfs/xattr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
> index ff94fad477e4..48cdfc81fe10 100644
> --- a/fs/reiserfs/xattr.c
> +++ b/fs/reiserfs/xattr.c
> @@ -792,8 +792,10 @@ static int listxattr_filler(struct dir_context *ctx, 
> const char *name,
> return 0;
> size = namelen + 1;
> if (b->buf) {
> -   if (size > b->size)
> +   if (b->pos + size > b->size) {
> +   b->pos = -ERANGE;
> return -ERANGE;
> +   }
> memcpy(b->buf + b->pos, name, namelen);
> b->buf[b->pos + namelen] = 0;
> }
> --
> 2.18.0.597.ga71716f1ad-goog
>


Re: [PATCH] reiserfs: fix broken xattr handling (heap corruption, bad retval)

2018-08-09 Thread Jann Horn
On Thu, Aug 2, 2018 at 5:16 PM Jann Horn  wrote:
>
> This fixes the following issues:
>
>  - When a buffer size is supplied to reiserfs_listxattr() such that each
>individual name fits, but the concatenation of all names doesn't
>fit, reiserfs_listxattr() overflows the supplied buffer. This leads to
>a kernel heap overflow (verified using KASAN) followed by an
>out-of-bounds usercopy and is therefore a security bug.
>  - When a buffer size is supplied to reiserfs_listxattr() such that a name
>doesn't fit, -ERANGE should be returned. But reiserfs instead just
>truncates the list of names; I have verified that if the only xattr on
>a file has a longer name than the supplied buffer length, listxattr()
>incorrectly returns zero.
>
> With my patch applied, -ERANGE is returned in both cases and the memory
> corruption doesn't happen anymore.
>
> Credit for making me clean this code up a bit goes to Al Viro, who pointed
> out that the ->actor calling convention is suboptimal and should be
> changed.
>
> Fixes: 48b32a3553a5 ("reiserfs: use generic xattr handlers")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Jann Horn 

+security@
Ping. I have not received any replies to this patch, which fixes a
kernel security bug, for a week.
Whose tree should this go through? reiserfs is marked as "supported",
but does not have a maintainer or a git repo listed, just a
mailinglist, so I guess it probably has to go through either Al Viro's
or akpm's tree? Looks like akpm signed off on the last commits in
reiserfs...

> ---
> Triggering the bug:
>
> root@debian:/home/user# mount -o user_xattr reiserimg reisermount/
> root@debian:/home/user# cd reisermount/
> root@debian:/home/user/reisermount# touch test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo1 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo2 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo3 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo4 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo5 -v A test_file
> root@debian:/home/user/reisermount# setfattr -n user.foo6 -v A test_file
> root@debian:/home/user/reisermount# cat xattr_test.c
> #include 
> #include 
> #include 
> #include 
> #include 
> int main(int argc, char **argv) {
>   if (argc != 2) errx(1, "bad invocation");
>   char list[10];
>   int res = listxattr(argv[1], list, sizeof(list));
>   if (res == -1)
> err(1, "listxattr failed");
>   printf("listxattr returned %d\n", res);
>   for (char *p = list; p < list+res-1; p = p + strlen(p) + 1) {
> printf("list entry: %s\n", p);
>   }
> }
> root@debian:/home/user/reisermount# gcc -o xattr_test xattr_test.c
> root@debian:/home/user/reisermount# ./xattr_test test_file
> Segmentation fault
> root@debian:/home/user/reisermount#
>
> Result:
>
> [  122.071318] 
> ==
> [  122.072334] BUG: KASAN: slab-out-of-bounds in listxattr_filler+0x170/0x1b0
> [  122.073173] Write of size 9 at addr 8801c43b474a by task xattr_test/923
> [  122.074030]
> [  122.074223] CPU: 1 PID: 923 Comm: xattr_test Not tainted 4.18.0-rc7+ #67
> [  122.075050] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> 1.10.2-1 04/01/2014
> [  122.076107] Call Trace:
> [  122.076453]  dump_stack+0x71/0xab
> [  122.076900]  print_address_description+0x6a/0x250
> [  122.077514]  kasan_report+0x258/0x380
> [  122.077961]  ? listxattr_filler+0x170/0x1b0
> [  122.078469]  memcpy+0x34/0x50
> [  122.078894]  listxattr_filler+0x170/0x1b0
> [...]
>
>  fs/reiserfs/xattr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
> index ff94fad477e4..48cdfc81fe10 100644
> --- a/fs/reiserfs/xattr.c
> +++ b/fs/reiserfs/xattr.c
> @@ -792,8 +792,10 @@ static int listxattr_filler(struct dir_context *ctx, 
> const char *name,
> return 0;
> size = namelen + 1;
> if (b->buf) {
> -   if (size > b->size)
> +   if (b->pos + size > b->size) {
> +   b->pos = -ERANGE;
> return -ERANGE;
> +   }
> memcpy(b->buf + b->pos, name, namelen);
> b->buf[b->pos + namelen] = 0;
> }
> --
> 2.18.0.597.ga71716f1ad-goog
>


Re: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups

2018-08-09 Thread NeilBrown
On Thu, Aug 09 2018, J. Bruce Fields wrote:

> On Fri, Aug 10, 2018 at 11:50:58AM +1000, NeilBrown wrote:
>> You're good at this game!
>
> Everybody's got to have a hobby, mine is pathological posix locking
> cases
>
>> So, because a locker with the same "owner" gets a free pass, you can
>> *never* say that any lock which conflicts with A also conflicts with B,
>> as a lock with the same owner as B will never conflict with B, even
>> though it conflicts with A.
>> 
>> I think there is still value in having the tree, but when a waiter is
>> attached under a new blocker, we need to walk the whole tree beneath the
>> waiter and detach/wake anything that is not blocked by the new blocker.
>
> If you're walking the whole tree every time then it might as well be a
> flat list, I think?

The advantage of a tree is that it keeps over-lapping locks closer
together.
For it to make a difference you would need a load where lots of threads
were locking several different small ranges, and other threads were
locking large ranges that cover all the small ranges.
I doubt this is common, but it doesn't seem as strange as other things
I've seen in the wild.
The other advantage, of course, is that I've already written the code,
and I like it.

Maybe I'll do a simple-list version, then a patch to convert that to the
clever-tree version, and we can then have something concrete to assess.

Thanks,
NeilBrown


signature.asc
Description: PGP signature


Re: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups

2018-08-09 Thread NeilBrown
On Thu, Aug 09 2018, J. Bruce Fields wrote:

> On Fri, Aug 10, 2018 at 11:50:58AM +1000, NeilBrown wrote:
>> You're good at this game!
>
> Everybody's got to have a hobby, mine is pathological posix locking
> cases
>
>> So, because a locker with the same "owner" gets a free pass, you can
>> *never* say that any lock which conflicts with A also conflicts with B,
>> as a lock with the same owner as B will never conflict with B, even
>> though it conflicts with A.
>> 
>> I think there is still value in having the tree, but when a waiter is
>> attached under a new blocker, we need to walk the whole tree beneath the
>> waiter and detach/wake anything that is not blocked by the new blocker.
>
> If you're walking the whole tree every time then it might as well be a
> flat list, I think?

The advantage of a tree is that it keeps over-lapping locks closer
together.
For it to make a difference you would need a load where lots of threads
were locking several different small ranges, and other threads were
locking large ranges that cover all the small ranges.
I doubt this is common, but it doesn't seem as strange as other things
I've seen in the wild.
The other advantage, of course, is that I've already written the code,
and I like it.

Maybe I'll do a simple-list version, then a patch to convert that to the
clever-tree version, and we can then have something concrete to assess.

Thanks,
NeilBrown


signature.asc
Description: PGP signature


mmotm 2018-08-09-20-10 uploaded

2018-08-09 Thread akpm
The mm-of-the-moment snapshot 2018-08-09-20-10 has been uploaded to

   http://www.ozlabs.org/~akpm/mmotm/

mmotm-readme.txt says

README for mm-of-the-moment:

http://www.ozlabs.org/~akpm/mmotm/

This is a snapshot of my -mm patch queue.  Uploaded at random hopefully
more than once a week.

You will need quilt to apply these patches to the latest Linus release (4.x
or 4.x-rcY).  The series file is in broken-out.tar.gz and is duplicated in
http://ozlabs.org/~akpm/mmotm/series

The file broken-out.tar.gz contains two datestamp files: .DATE and
.DATE--mm-dd-hh-mm-ss.  Both contain the string -mm-dd-hh-mm-ss,
followed by the base kernel version against which this patch series is to
be applied.

This tree is partially included in linux-next.  To see which patches are
included in linux-next, consult the `series' file.  Only the patches
within the #NEXT_PATCHES_START/#NEXT_PATCHES_END markers are included in
linux-next.

A git tree which contains the memory management portion of this tree is
maintained at git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
by Michal Hocko.  It contains the patches which are between the
"#NEXT_PATCHES_START mm" and "#NEXT_PATCHES_END" markers, from the series
file, http://www.ozlabs.org/~akpm/mmotm/series.


A full copy of the full kernel tree with the linux-next and mmotm patches
already applied is available through git within an hour of the mmotm
release.  Individual mmotm releases are tagged.  The master branch always
points to the latest release, so it's constantly rebasing.

http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/

To develop on top of mmotm git:

  $ git remote add mmotm 
git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
  $ git remote update mmotm
  $ git checkout -b topic mmotm/master
  
  $ git send-email mmotm/master.. [...]

To rebase a branch with older patches to a new mmotm release:

  $ git remote update mmotm
  $ git rebase --onto mmotm/master  topic




The directory http://www.ozlabs.org/~akpm/mmots/ (mm-of-the-second)
contains daily snapshots of the -mm tree.  It is updated more frequently
than mmotm, and is untested.

A git copy of this tree is available at

http://git.cmpxchg.org/cgit.cgi/linux-mmots.git/

and use of this tree is similar to
http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/, described above.


This mmotm tree contains the following patches against 4.18-rc8:
(patches marked "*" will be included in linux-next)

  origin.patch
  i-need-old-gcc.patch
* maintainers-gdb-update-e-mail-address.patch
* lib-ubsan-remove-null-pointer-checks.patch
* mm-bugfix-check-return-value-of-ioremap_prot.patch
* zram-remove-bd_cap_synchronous_io-with-writeback-feature.patch
* zram-remove-bd_cap_synchronous_io-with-writeback-feature-v2.patch
* 
zram-remove-bd_cap_synchronous_io-with-writeback-feature-v2-checkpatch-fixes.patch
* arm-arch-arm-include-asm-pageh-needs-personalityh.patch
* dax-remove-vm_mixedmap-for-fsdax-and-device-dax.patch
* prctl-add-pr_et_pdeathsig_proc.patch
* firewire-use-64-bit-time_t-based-interfaces.patch
* ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps.patch
* ntfs-use-timespec64-directly-for-timestamp-conversion.patch
* hpfs-extend-gmt_to_local-conversion-to-64-bit-times.patch
* spdxcheck-work-with-current-head-licenses-directory.patch
* scripts-add-python-3-compatibility-to-spdxcheckpy.patch
* ntfs-dont-disable-interrupts-during-kmap_atomic.patch
* ntfs-aops-remove-vla-usage.patch
* ntfs-decompress-remove-vla-usage.patch
* ntfs-mft-remove-vla-usage.patch
* sh-make-use-of-for_each_node_by_type.patch
* sh-prefer-_this_ip_-to-current_text_addr.patch
* ocfs2-return-erofs-when-filesystem-becomes-read-only.patch
* ocfs2-return-erofs-when-filesystem-becomes-read-only-checkpatch-fixes.patch
* ocfs2-clean-up-some-unnecessary-code.patch
* ocfs2-make-several-functions-and-variables-static-and-some-const.patch
* ocfs2-get-rid-of-ocfs2_is_o2cb_active-function.patch
* ocfs2-without-quota-support-try-to-avoid-calling-quota-recovery.patch
* ocfs2-dont-use-iocb-when-eiocbqueued-returns.patch
* ocfs2-fix-a-misuse-a-of-brelse-after-failing-ocfs2_check_dir_entry.patch
* ocfs2-dont-put-and-assigning-null-to-bh-allocated-outside.patch
* ocfs2-dlmglue-clean-up-timestamp-handling.patch
* 
block-restore-proc-partitions-to-not-display-non-partitionable-removable-devices.patch
* dentry-fix-kmemcheck-splat-at-take_dentry_name_snapshot.patch
* vfs-discard-attr_attr_flag.patch
* vfs-simplify-seq_file-iteration-code-and-interface.patch
* vfs-simplify-seq_file-iteration-code-and-interface-fix.patch
* namei-allow-restricted-o_creat-of-fifos-and-regular-files.patch
  mm.patch
* mm-slub-restore-the-original-intention-of-prefetch_freepointer.patch
* mm-convert-return-type-of-handle_mm_fault-caller-to-vm_fault_t.patch
* mm-skip-invalid-pages-block-at-a-time-in-zero_resv_unresv.patch
* thp-use-mm_file_counter-to-determine-update-which-rss-counter.patch
* tools-modifying-page-types-to-include-shared-map-counts.patch
* 

mmotm 2018-08-09-20-10 uploaded

2018-08-09 Thread akpm
The mm-of-the-moment snapshot 2018-08-09-20-10 has been uploaded to

   http://www.ozlabs.org/~akpm/mmotm/

mmotm-readme.txt says

README for mm-of-the-moment:

http://www.ozlabs.org/~akpm/mmotm/

This is a snapshot of my -mm patch queue.  Uploaded at random hopefully
more than once a week.

You will need quilt to apply these patches to the latest Linus release (4.x
or 4.x-rcY).  The series file is in broken-out.tar.gz and is duplicated in
http://ozlabs.org/~akpm/mmotm/series

The file broken-out.tar.gz contains two datestamp files: .DATE and
.DATE--mm-dd-hh-mm-ss.  Both contain the string -mm-dd-hh-mm-ss,
followed by the base kernel version against which this patch series is to
be applied.

This tree is partially included in linux-next.  To see which patches are
included in linux-next, consult the `series' file.  Only the patches
within the #NEXT_PATCHES_START/#NEXT_PATCHES_END markers are included in
linux-next.

A git tree which contains the memory management portion of this tree is
maintained at git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
by Michal Hocko.  It contains the patches which are between the
"#NEXT_PATCHES_START mm" and "#NEXT_PATCHES_END" markers, from the series
file, http://www.ozlabs.org/~akpm/mmotm/series.


A full copy of the full kernel tree with the linux-next and mmotm patches
already applied is available through git within an hour of the mmotm
release.  Individual mmotm releases are tagged.  The master branch always
points to the latest release, so it's constantly rebasing.

http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/

To develop on top of mmotm git:

  $ git remote add mmotm 
git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
  $ git remote update mmotm
  $ git checkout -b topic mmotm/master
  
  $ git send-email mmotm/master.. [...]

To rebase a branch with older patches to a new mmotm release:

  $ git remote update mmotm
  $ git rebase --onto mmotm/master  topic




The directory http://www.ozlabs.org/~akpm/mmots/ (mm-of-the-second)
contains daily snapshots of the -mm tree.  It is updated more frequently
than mmotm, and is untested.

A git copy of this tree is available at

http://git.cmpxchg.org/cgit.cgi/linux-mmots.git/

and use of this tree is similar to
http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/, described above.


This mmotm tree contains the following patches against 4.18-rc8:
(patches marked "*" will be included in linux-next)

  origin.patch
  i-need-old-gcc.patch
* maintainers-gdb-update-e-mail-address.patch
* lib-ubsan-remove-null-pointer-checks.patch
* mm-bugfix-check-return-value-of-ioremap_prot.patch
* zram-remove-bd_cap_synchronous_io-with-writeback-feature.patch
* zram-remove-bd_cap_synchronous_io-with-writeback-feature-v2.patch
* 
zram-remove-bd_cap_synchronous_io-with-writeback-feature-v2-checkpatch-fixes.patch
* arm-arch-arm-include-asm-pageh-needs-personalityh.patch
* dax-remove-vm_mixedmap-for-fsdax-and-device-dax.patch
* prctl-add-pr_et_pdeathsig_proc.patch
* firewire-use-64-bit-time_t-based-interfaces.patch
* ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps.patch
* ntfs-use-timespec64-directly-for-timestamp-conversion.patch
* hpfs-extend-gmt_to_local-conversion-to-64-bit-times.patch
* spdxcheck-work-with-current-head-licenses-directory.patch
* scripts-add-python-3-compatibility-to-spdxcheckpy.patch
* ntfs-dont-disable-interrupts-during-kmap_atomic.patch
* ntfs-aops-remove-vla-usage.patch
* ntfs-decompress-remove-vla-usage.patch
* ntfs-mft-remove-vla-usage.patch
* sh-make-use-of-for_each_node_by_type.patch
* sh-prefer-_this_ip_-to-current_text_addr.patch
* ocfs2-return-erofs-when-filesystem-becomes-read-only.patch
* ocfs2-return-erofs-when-filesystem-becomes-read-only-checkpatch-fixes.patch
* ocfs2-clean-up-some-unnecessary-code.patch
* ocfs2-make-several-functions-and-variables-static-and-some-const.patch
* ocfs2-get-rid-of-ocfs2_is_o2cb_active-function.patch
* ocfs2-without-quota-support-try-to-avoid-calling-quota-recovery.patch
* ocfs2-dont-use-iocb-when-eiocbqueued-returns.patch
* ocfs2-fix-a-misuse-a-of-brelse-after-failing-ocfs2_check_dir_entry.patch
* ocfs2-dont-put-and-assigning-null-to-bh-allocated-outside.patch
* ocfs2-dlmglue-clean-up-timestamp-handling.patch
* 
block-restore-proc-partitions-to-not-display-non-partitionable-removable-devices.patch
* dentry-fix-kmemcheck-splat-at-take_dentry_name_snapshot.patch
* vfs-discard-attr_attr_flag.patch
* vfs-simplify-seq_file-iteration-code-and-interface.patch
* vfs-simplify-seq_file-iteration-code-and-interface-fix.patch
* namei-allow-restricted-o_creat-of-fifos-and-regular-files.patch
  mm.patch
* mm-slub-restore-the-original-intention-of-prefetch_freepointer.patch
* mm-convert-return-type-of-handle_mm_fault-caller-to-vm_fault_t.patch
* mm-skip-invalid-pages-block-at-a-time-in-zero_resv_unresv.patch
* thp-use-mm_file_counter-to-determine-update-which-rss-counter.patch
* tools-modifying-page-types-to-include-shared-map-counts.patch
* 

Re: [PATCH v3 7/7] firmware: coreboot: Request table region for exclusive access

2018-08-09 Thread Stephen Boyd
What's with the top posting? ;-)

Quoting Julius Werner (2018-08-09 16:44:43)
> Actually, looking at what IO_STRICT_DEVMEM really does, would it
> really prevent userspace accesses to these areas? Because it seems
> that it only prevents accesses to areas marked as IORESOURCE_BUSY, and
> while I can't fully follow how the kernel assigns that, comments
> suggest that this is only set when "Driver has marked this resource
> busy".

Requesting the memory region as is done in this patch marks it as busy.

> 
> So after you make the change to the other patch where we immediately
> unmap the coreboot table again at the end of the probe() function,
> shouldn't it become available to userspace again even with
> IO_STRICT_DEVMEM set?

Yes, if we unmap the region immediately after devices are populated then
this whole point is moot with the assumption that this code isn't
running at the same time as the cbmem utility. I've done this already
and it is working on arm. I still need to build/boot/test on an x86
platform which I should be able to do tomorrow.



Re: [PATCH v3 7/7] firmware: coreboot: Request table region for exclusive access

2018-08-09 Thread Stephen Boyd
What's with the top posting? ;-)

Quoting Julius Werner (2018-08-09 16:44:43)
> Actually, looking at what IO_STRICT_DEVMEM really does, would it
> really prevent userspace accesses to these areas? Because it seems
> that it only prevents accesses to areas marked as IORESOURCE_BUSY, and
> while I can't fully follow how the kernel assigns that, comments
> suggest that this is only set when "Driver has marked this resource
> busy".

Requesting the memory region as is done in this patch marks it as busy.

> 
> So after you make the change to the other patch where we immediately
> unmap the coreboot table again at the end of the probe() function,
> shouldn't it become available to userspace again even with
> IO_STRICT_DEVMEM set?

Yes, if we unmap the region immediately after devices are populated then
this whole point is moot with the assumption that this code isn't
running at the same time as the cbmem utility. I've done this already
and it is working on arm. I still need to build/boot/test on an x86
platform which I should be able to do tomorrow.



Re: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups

2018-08-09 Thread J. Bruce Fields
On Fri, Aug 10, 2018 at 11:50:58AM +1000, NeilBrown wrote:
> You're good at this game!

Everybody's got to have a hobby, mine is pathological posix locking
cases

> So, because a locker with the same "owner" gets a free pass, you can
> *never* say that any lock which conflicts with A also conflicts with B,
> as a lock with the same owner as B will never conflict with B, even
> though it conflicts with A.
> 
> I think there is still value in having the tree, but when a waiter is
> attached under a new blocker, we need to walk the whole tree beneath the
> waiter and detach/wake anything that is not blocked by the new blocker.

If you're walking the whole tree every time then it might as well be a
flat list, I think?

--b.


Re: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups

2018-08-09 Thread J. Bruce Fields
On Fri, Aug 10, 2018 at 11:50:58AM +1000, NeilBrown wrote:
> You're good at this game!

Everybody's got to have a hobby, mine is pathological posix locking
cases

> So, because a locker with the same "owner" gets a free pass, you can
> *never* say that any lock which conflicts with A also conflicts with B,
> as a lock with the same owner as B will never conflict with B, even
> though it conflicts with A.
> 
> I think there is still value in having the tree, but when a waiter is
> attached under a new blocker, we need to walk the whole tree beneath the
> waiter and detach/wake anything that is not blocked by the new blocker.

If you're walking the whole tree every time then it might as well be a
flat list, I think?

--b.


[PATCH] arm:pm: Use kmemdup to replace duplicating its implementation

2018-08-09 Thread zhong jiang
kmemdup is better than kmalloc() + memcpy(), and we do not like
open code. So just use kmemdup instead.

Signed-off-by: zhong jiang 
---
 arch/arm/mach-lpc32xx/pm.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c
index 6247157..6eefff8 100644
--- a/arch/arm/mach-lpc32xx/pm.c
+++ b/arch/arm/mach-lpc32xx/pm.c
@@ -86,7 +86,8 @@ static int lpc32xx_pm_enter(suspend_state_t state)
void *iram_swap_area;
 
/* Allocate some space for temporary IRAM storage */
-   iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL);
+   iram_swap_area = kmemdup((void *)TEMP_IRAM_AREA,
+   lpc32xx_sys_suspend_sz, GFP_KERNEL);
if (!iram_swap_area) {
printk(KERN_ERR
   "PM Suspend: cannot allocate memory to save portion "
@@ -94,10 +95,6 @@ static int lpc32xx_pm_enter(suspend_state_t state)
return -ENOMEM;
}
 
-   /* Backup a small area of IRAM used for the suspend code */
-   memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA,
-   lpc32xx_sys_suspend_sz);
-
/*
 * Copy code to suspend system into IRAM. The suspend code
 * needs to run from IRAM as DRAM may no longer be available
-- 
1.7.12.4



[PATCH] arm:pm: Use kmemdup to replace duplicating its implementation

2018-08-09 Thread zhong jiang
kmemdup is better than kmalloc() + memcpy(), and we do not like
open code. So just use kmemdup instead.

Signed-off-by: zhong jiang 
---
 arch/arm/mach-lpc32xx/pm.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c
index 6247157..6eefff8 100644
--- a/arch/arm/mach-lpc32xx/pm.c
+++ b/arch/arm/mach-lpc32xx/pm.c
@@ -86,7 +86,8 @@ static int lpc32xx_pm_enter(suspend_state_t state)
void *iram_swap_area;
 
/* Allocate some space for temporary IRAM storage */
-   iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL);
+   iram_swap_area = kmemdup((void *)TEMP_IRAM_AREA,
+   lpc32xx_sys_suspend_sz, GFP_KERNEL);
if (!iram_swap_area) {
printk(KERN_ERR
   "PM Suspend: cannot allocate memory to save portion "
@@ -94,10 +95,6 @@ static int lpc32xx_pm_enter(suspend_state_t state)
return -ENOMEM;
}
 
-   /* Backup a small area of IRAM used for the suspend code */
-   memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA,
-   lpc32xx_sys_suspend_sz);
-
/*
 * Copy code to suspend system into IRAM. The suspend code
 * needs to run from IRAM as DRAM may no longer be available
-- 
1.7.12.4



[PATCH] ia64:tioce_provider: Use kmemdup rather than implement the function

2018-08-09 Thread zhong jiang
The kmemdup has implemented the function that kmalloc() + memcpy will
do. So just replace them to make the code concise.

Signed-off-by: zhong jiang 
---
 arch/ia64/sn/pci/tioce_provider.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/sn/pci/tioce_provider.c 
b/arch/ia64/sn/pci/tioce_provider.c
index 3bd9abc..9ba61bc 100644
--- a/arch/ia64/sn/pci/tioce_provider.c
+++ b/arch/ia64/sn/pci/tioce_provider.c
@@ -1000,11 +1000,11 @@
 * Allocate kernel bus soft and copy from prom.
 */
 
-   tioce_common = kzalloc(sizeof(struct tioce_common), GFP_KERNEL);
+   tioce_common = kmemdup(prom_bussoft, sizeof(struct tioce_common),
+  GFP_KERNEL);
if (!tioce_common)
return NULL;
 
-   memcpy(tioce_common, prom_bussoft, sizeof(struct tioce_common));
tioce_common->ce_pcibus.bs_base = (unsigned long)
ioremap(REGION_OFFSET(tioce_common->ce_pcibus.bs_base),
sizeof(struct tioce_common));
-- 
1.7.12.4



[PATCH] ia64:tioce_provider: Use kmemdup rather than implement the function

2018-08-09 Thread zhong jiang
The kmemdup has implemented the function that kmalloc() + memcpy will
do. So just replace them to make the code concise.

Signed-off-by: zhong jiang 
---
 arch/ia64/sn/pci/tioce_provider.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/sn/pci/tioce_provider.c 
b/arch/ia64/sn/pci/tioce_provider.c
index 3bd9abc..9ba61bc 100644
--- a/arch/ia64/sn/pci/tioce_provider.c
+++ b/arch/ia64/sn/pci/tioce_provider.c
@@ -1000,11 +1000,11 @@
 * Allocate kernel bus soft and copy from prom.
 */
 
-   tioce_common = kzalloc(sizeof(struct tioce_common), GFP_KERNEL);
+   tioce_common = kmemdup(prom_bussoft, sizeof(struct tioce_common),
+  GFP_KERNEL);
if (!tioce_common)
return NULL;
 
-   memcpy(tioce_common, prom_bussoft, sizeof(struct tioce_common));
tioce_common->ce_pcibus.bs_base = (unsigned long)
ioremap(REGION_OFFSET(tioce_common->ce_pcibus.bs_base),
sizeof(struct tioce_common));
-- 
1.7.12.4



[PATCH] 9p: Add Dominique Martinet to MAINTAINERS

2018-08-09 Thread Dominique Martinet
From: Dominique Martinet 

Signed-off-by: Dominique Martinet 
Cc: Eric Van Hensbergen 
Cc: Latchesar Ionkov 
Cc: Ron Minnich 
Cc: Andrew Morton 
---

I've had an off-list Ack from Lucho and Eric about adding myself, and
got reminded I should probably do it sooner than later by Andrew.

Could (a subset of) you three please confirm on the list?

(As usual, I was a bit hesitant on what email to use, but I really would
not be reactive on my work email so it probably is better that way)


FWIW, I did not get any answer from Ron when I tried reaching out to
him, but I finally found why: he left sandia 7 years ago so that mail
is likely a black hole.
I've sent him a mail on another address now asking him if he is ok to
be removed, and will probably submit another patch doing that within
the next few days.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7cebd5bba8a8..15116e6dff3a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -201,10 +201,12 @@ F:drivers/net/ethernet/8390/
 M: Eric Van Hensbergen 
 M: Ron Minnich 
 M: Latchesar Ionkov 
+M: Dominique Martinet 
 L: v9fs-develo...@lists.sourceforge.net
 W: http://swik.net/v9fs
 Q: http://patchwork.kernel.org/project/v9fs-devel/list/
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs.git
+T: git git://github.com/martinetd/linux.git
 S: Maintained
 F: Documentation/filesystems/9p.txt
 F: fs/9p/
-- 
2.17.1



[PATCH] 9p: Add Dominique Martinet to MAINTAINERS

2018-08-09 Thread Dominique Martinet
From: Dominique Martinet 

Signed-off-by: Dominique Martinet 
Cc: Eric Van Hensbergen 
Cc: Latchesar Ionkov 
Cc: Ron Minnich 
Cc: Andrew Morton 
---

I've had an off-list Ack from Lucho and Eric about adding myself, and
got reminded I should probably do it sooner than later by Andrew.

Could (a subset of) you three please confirm on the list?

(As usual, I was a bit hesitant on what email to use, but I really would
not be reactive on my work email so it probably is better that way)


FWIW, I did not get any answer from Ron when I tried reaching out to
him, but I finally found why: he left sandia 7 years ago so that mail
is likely a black hole.
I've sent him a mail on another address now asking him if he is ok to
be removed, and will probably submit another patch doing that within
the next few days.


 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7cebd5bba8a8..15116e6dff3a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -201,10 +201,12 @@ F:drivers/net/ethernet/8390/
 M: Eric Van Hensbergen 
 M: Ron Minnich 
 M: Latchesar Ionkov 
+M: Dominique Martinet 
 L: v9fs-develo...@lists.sourceforge.net
 W: http://swik.net/v9fs
 Q: http://patchwork.kernel.org/project/v9fs-devel/list/
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs.git
+T: git git://github.com/martinetd/linux.git
 S: Maintained
 F: Documentation/filesystems/9p.txt
 F: fs/9p/
-- 
2.17.1



Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Guenter Roeck

On 08/09/2018 06:03 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 14:24:22 PDT (-0700), li...@roeck-us.net wrote:

On Thu, Aug 09, 2018 at 01:25:24PM -0700, Palmer Dabbelt wrote:

This file is expected to be included multiple times in the same file in
order to allow the __SYSCALL macro to generate system call tables.  With
a global include guard we end up missing __NR_riscv_flush_icache in the
syscall table, which results in icache flushes that escape the vDSO call
to not actually do anything.

The fix is to move to per-#define include guards, which allows the
system call tables to actually be populated.  Thanks to Macrus Comstedt
for finding and fixing the bug!

I also went ahead and fixed the SPDX header to use a //-style comment,
which I've been told is the canonical way to do it.

Cc: Marcus Comstedt 
Signed-off-by: Palmer Dabbelt 


[Compile-]Tested-by: Guenter Roeck 

on top of linux-next after reverting the version of the patch there.

I also tried to run the resulting image (defconfig) with qemu (built
from https://github.com/riscv/riscv-qemu.git), but that still doesn't
work. I assume there are still some patches missing ?


Do you have the PLIC patches?  They'll be necessary to make this all work, and 
there's a v4 out now that when combined with for-next should get you to 
userspace.

    https://lore.kernel.org/lkml/20180809075602.989-1-...@lst.de/T/#u


Yes, after merging that branch on top of linux-next I can boot into Linux.
If I add my "riscv: Drop setup_initrd" patch as well, I can boot using
initrd, otherwise I have to use virtio-blk-device.


Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV

and could could natively compile and run hello world with an earlier version of 
Christoph's patch set, which is really only cosmetically different than the v4. 
I use qemu's master branch as well, which when I tried was exactly 3.0.0-rc3.



That doesn't work for me, possibly because I don't specify a bbl
image with -kernel but vmlinux (using -bios for the bbl image).
I use branch qemu-for-upstream of https://github.com/riscv/riscv-qemu.git.

Guenter


Re: [PATCH v2 2/2] RISC-V: Don't use a global include guard for uapi/asm/syscalls.h

2018-08-09 Thread Guenter Roeck

On 08/09/2018 06:03 PM, Palmer Dabbelt wrote:

On Thu, 09 Aug 2018 14:24:22 PDT (-0700), li...@roeck-us.net wrote:

On Thu, Aug 09, 2018 at 01:25:24PM -0700, Palmer Dabbelt wrote:

This file is expected to be included multiple times in the same file in
order to allow the __SYSCALL macro to generate system call tables.  With
a global include guard we end up missing __NR_riscv_flush_icache in the
syscall table, which results in icache flushes that escape the vDSO call
to not actually do anything.

The fix is to move to per-#define include guards, which allows the
system call tables to actually be populated.  Thanks to Macrus Comstedt
for finding and fixing the bug!

I also went ahead and fixed the SPDX header to use a //-style comment,
which I've been told is the canonical way to do it.

Cc: Marcus Comstedt 
Signed-off-by: Palmer Dabbelt 


[Compile-]Tested-by: Guenter Roeck 

on top of linux-next after reverting the version of the patch there.

I also tried to run the resulting image (defconfig) with qemu (built
from https://github.com/riscv/riscv-qemu.git), but that still doesn't
work. I assume there are still some patches missing ?


Do you have the PLIC patches?  They'll be necessary to make this all work, and 
there's a v4 out now that when combined with for-next should get you to 
userspace.

    https://lore.kernel.org/lkml/20180809075602.989-1-...@lst.de/T/#u


Yes, after merging that branch on top of linux-next I can boot into Linux.
If I add my "riscv: Drop setup_initrd" patch as well, I can boot using
initrd, otherwise I have to use virtio-blk-device.


Also, what is your methodology?  I follow

    https://wiki.qemu.org/Documentation/Platforms/RISCV

and could could natively compile and run hello world with an earlier version of 
Christoph's patch set, which is really only cosmetically different than the v4. 
I use qemu's master branch as well, which when I tried was exactly 3.0.0-rc3.



That doesn't work for me, possibly because I don't specify a bbl
image with -kernel but vmlinux (using -bios for the bbl image).
I use branch qemu-for-upstream of https://github.com/riscv/riscv-qemu.git.

Guenter


[PATCH] sched/core: Fix compiling warring in smp=n case

2018-08-09 Thread Dou Liyang
When compiling kernel with SMP disabled, the build warns with:

kernel/sched/core.c: In function ‘update_rq_clock_task’:
kernel/sched/core.c:139:17: warning: unused variable ‘irq_delta’ 
[-Wunused-variable]
  s64 steal = 0, irq_delta = 0;

Fix this by revert the HAVE_SCHED_AVG_IRQ to

  defined(CONFIG_IRQ_TIME_ACCOUNTING) || 
defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)

Fixes: 2e62c4743adc ("sched/fair: Remove #ifdefs from scale_rt_capacity()")
Signed-off-by: Dou Liyang 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c45de46fdf10..ef954d96c80c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -177,7 +177,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
 
rq->clock_task += delta;
 
-#ifdef HAVE_SCHED_AVG_IRQ
+#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || 
defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
update_irq_load_avg(rq, irq_delta + steal);
 #endif
-- 
2.14.3





[PATCH] sched/core: Fix compiling warring in smp=n case

2018-08-09 Thread Dou Liyang
When compiling kernel with SMP disabled, the build warns with:

kernel/sched/core.c: In function ‘update_rq_clock_task’:
kernel/sched/core.c:139:17: warning: unused variable ‘irq_delta’ 
[-Wunused-variable]
  s64 steal = 0, irq_delta = 0;

Fix this by revert the HAVE_SCHED_AVG_IRQ to

  defined(CONFIG_IRQ_TIME_ACCOUNTING) || 
defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)

Fixes: 2e62c4743adc ("sched/fair: Remove #ifdefs from scale_rt_capacity()")
Signed-off-by: Dou Liyang 
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c45de46fdf10..ef954d96c80c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -177,7 +177,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
 
rq->clock_task += delta;
 
-#ifdef HAVE_SCHED_AVG_IRQ
+#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || 
defined(CONFIG_PARAVIRT_TIME_ACCOUNTING)
if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
update_irq_load_avg(rq, irq_delta + steal);
 #endif
-- 
2.14.3





Re: [PATCH v2 2/4] phy: socionext: add USB3 PHY driver for UniPhier SoC

2018-08-09 Thread Kunihiko Hayashi
Hi Kishon,

On Thu, 9 Aug 2018 16:00:19 +0530
Kishon Vijay Abraham I  wrote:

> Hi,
> 
> On Friday 03 August 2018 03:24 PM, Kunihiko Hayashi wrote:
> > Add a driver for PHY interface built into USB3 controller
> > implemented in UniPhier SoCs.
> > This driver supports High-Speed PHY and Super-Speed PHY.
> > 
> > Signed-off-by: Kunihiko Hayashi 
> > Signed-off-by: Motoya Tanigawa 
> > Signed-off-by: Masami Hiramatsu 
> > ---
> >  drivers/phy/Kconfig |   1 +
> >  drivers/phy/Makefile|   1 +
> >  drivers/phy/socionext/Kconfig   |  12 +
> >  drivers/phy/socionext/Makefile  |   6 +
> >  drivers/phy/socionext/phy-uniphier-usb3hs.c | 423 
> > 
> >  drivers/phy/socionext/phy-uniphier-usb3ss.c | 350 +++
> >  6 files changed, 793 insertions(+)
> >  create mode 100644 drivers/phy/socionext/Kconfig
> >  create mode 100644 drivers/phy/socionext/Makefile
> >  create mode 100644 drivers/phy/socionext/phy-uniphier-usb3hs.c
> >  create mode 100644 drivers/phy/socionext/phy-uniphier-usb3ss.c

[snip]

> > --- /dev/null
> > +++ b/drivers/phy/socionext/phy-uniphier-usb3hs.c
> > @@ -0,0 +1,423 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// phy-uniphier-usb3hs.c - HS-PHY driver for Socionext UniPhier USB3 
> > controller
> > +// Copyright 2015-2018 Socionext Inc.
> > +// Author:
> > +//  Kunihiko Hayashi 
> > +// Contributors:
> > +//  Motoya Tanigawa 
> > +//  Masami Hiramatsu 
> > +
> 
> I'm not sure if there is a standard format for adding SPDX identifiers. But
> other PHY drivers seems to have used single line comment style only for the
> first line. (see drivers/phy/amlogic/phy-meson-gxl-usb3.c)

Okay, I understand that the format differs depending on each sub-system so far.
I'll rewrite it according to other PHY drivers.

Same as phy-uniphier-usb3ss.c.

> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 

[snip]

> > +   phy = devm_phy_create(dev, dev->of_node, _u3hsphy_ops);
> > +   if (IS_ERR(phy))
> > +   return PTR_ERR(phy);
> > +
> > +   phy_set_drvdata(phy, priv);
> > +   phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> > +   if (IS_ERR(phy_provider))
> > +   return PTR_ERR(phy_provider);
> 
> return PTR_ERR_OR_ZERO()?

Indeed. I'll replace it as follows.

phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
return PTR_ERR_OR_ZERO(phy_provider);

Same as phy-uniphier-usb3ss.c.

Thank you,

---
Best Regards,
Kunihiko Hayashi




Re: [PATCH v2 2/4] phy: socionext: add USB3 PHY driver for UniPhier SoC

2018-08-09 Thread Kunihiko Hayashi
Hi Kishon,

On Thu, 9 Aug 2018 16:00:19 +0530
Kishon Vijay Abraham I  wrote:

> Hi,
> 
> On Friday 03 August 2018 03:24 PM, Kunihiko Hayashi wrote:
> > Add a driver for PHY interface built into USB3 controller
> > implemented in UniPhier SoCs.
> > This driver supports High-Speed PHY and Super-Speed PHY.
> > 
> > Signed-off-by: Kunihiko Hayashi 
> > Signed-off-by: Motoya Tanigawa 
> > Signed-off-by: Masami Hiramatsu 
> > ---
> >  drivers/phy/Kconfig |   1 +
> >  drivers/phy/Makefile|   1 +
> >  drivers/phy/socionext/Kconfig   |  12 +
> >  drivers/phy/socionext/Makefile  |   6 +
> >  drivers/phy/socionext/phy-uniphier-usb3hs.c | 423 
> > 
> >  drivers/phy/socionext/phy-uniphier-usb3ss.c | 350 +++
> >  6 files changed, 793 insertions(+)
> >  create mode 100644 drivers/phy/socionext/Kconfig
> >  create mode 100644 drivers/phy/socionext/Makefile
> >  create mode 100644 drivers/phy/socionext/phy-uniphier-usb3hs.c
> >  create mode 100644 drivers/phy/socionext/phy-uniphier-usb3ss.c

[snip]

> > --- /dev/null
> > +++ b/drivers/phy/socionext/phy-uniphier-usb3hs.c
> > @@ -0,0 +1,423 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +//
> > +// phy-uniphier-usb3hs.c - HS-PHY driver for Socionext UniPhier USB3 
> > controller
> > +// Copyright 2015-2018 Socionext Inc.
> > +// Author:
> > +//  Kunihiko Hayashi 
> > +// Contributors:
> > +//  Motoya Tanigawa 
> > +//  Masami Hiramatsu 
> > +
> 
> I'm not sure if there is a standard format for adding SPDX identifiers. But
> other PHY drivers seems to have used single line comment style only for the
> first line. (see drivers/phy/amlogic/phy-meson-gxl-usb3.c)

Okay, I understand that the format differs depending on each sub-system so far.
I'll rewrite it according to other PHY drivers.

Same as phy-uniphier-usb3ss.c.

> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 

[snip]

> > +   phy = devm_phy_create(dev, dev->of_node, _u3hsphy_ops);
> > +   if (IS_ERR(phy))
> > +   return PTR_ERR(phy);
> > +
> > +   phy_set_drvdata(phy, priv);
> > +   phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> > +   if (IS_ERR(phy_provider))
> > +   return PTR_ERR(phy_provider);
> 
> return PTR_ERR_OR_ZERO()?

Indeed. I'll replace it as follows.

phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
return PTR_ERR_OR_ZERO(phy_provider);

Same as phy-uniphier-usb3ss.c.

Thank you,

---
Best Regards,
Kunihiko Hayashi




Re: [PATCH 1/2] PCI/ACPI: correct error message for ASPM disabling

2018-08-09 Thread Sinan Kaya

On 8/9/2018 8:27 PM, Joe Perches wrote:

I think this would read better not using a temporary and
using a ternary instead.


Makes sense.


Re: [PATCH 1/2] PCI/ACPI: correct error message for ASPM disabling

2018-08-09 Thread Sinan Kaya

On 8/9/2018 8:27 PM, Joe Perches wrote:

I think this would read better not using a temporary and
using a ternary instead.


Makes sense.


Re: [PATCH RESEND v2] arm64: clean the additional checks before calling ghes_notify_sea()

2018-08-09 Thread Tyler Baicar
On Thu, Aug 9, 2018 at 6:16 PM, gengdongjiu  wrote:
> 2018-08-10 5:05 GMT+08:00 Tyler Baicar :
>> On Thu, Aug 9, 2018 at 8:32 AM, gengdongjiu  wrote:
>>>
>>> 2018-08-08 0:26 GMT+08:00 Dongjiu Geng :
>>> > In order to remove the additional check before calling the
>>> > ghes_notify_sea(), make stub definition when !CONFIG_ACPI_APEI_SEA.
>>> >
>>> > After this cleanup, we can simply call the ghes_notify_sea() to let
>>> > APEI driver handle the SEA notification.
>>> >
>>> > CC: Tyler Baicar 
>>> > CC: James Morse 
>>> > Signed-off-by: Dongjiu Geng 
>>> > Acked-by: Will Deacon 
>>> > ---
>>> > This cleanup is ever mentioned by Mark Rutland in [1]
>>> >
>>> > [1]:
>>> > https://lkml.org/lkml/2018/5/31/289
>>> >
>>
>> FWIW - Looks good to me!
>
> Thanks very much for this comments and review,
> whether I can get your "Acked-by" or "Reviewed-by"? thanks
>
Sorry, yes!

Reviewed-by: Tyler Baicar 


Re: [PATCH RESEND v2] arm64: clean the additional checks before calling ghes_notify_sea()

2018-08-09 Thread Tyler Baicar
On Thu, Aug 9, 2018 at 6:16 PM, gengdongjiu  wrote:
> 2018-08-10 5:05 GMT+08:00 Tyler Baicar :
>> On Thu, Aug 9, 2018 at 8:32 AM, gengdongjiu  wrote:
>>>
>>> 2018-08-08 0:26 GMT+08:00 Dongjiu Geng :
>>> > In order to remove the additional check before calling the
>>> > ghes_notify_sea(), make stub definition when !CONFIG_ACPI_APEI_SEA.
>>> >
>>> > After this cleanup, we can simply call the ghes_notify_sea() to let
>>> > APEI driver handle the SEA notification.
>>> >
>>> > CC: Tyler Baicar 
>>> > CC: James Morse 
>>> > Signed-off-by: Dongjiu Geng 
>>> > Acked-by: Will Deacon 
>>> > ---
>>> > This cleanup is ever mentioned by Mark Rutland in [1]
>>> >
>>> > [1]:
>>> > https://lkml.org/lkml/2018/5/31/289
>>> >
>>
>> FWIW - Looks good to me!
>
> Thanks very much for this comments and review,
> whether I can get your "Acked-by" or "Reviewed-by"? thanks
>
Sorry, yes!

Reviewed-by: Tyler Baicar 


Re: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups

2018-08-09 Thread NeilBrown
On Thu, Aug 09 2018, J. Bruce Fields wrote:

> On Fri, Aug 10, 2018 at 08:12:43AM +1000, NeilBrown wrote:
>> On Thu, Aug 09 2018, J. Bruce Fields wrote:
>> 
>> > I think there's also a problem with multiple tasks sharing the same
>> > lock owner.
>> >
>> > So, all locks are exclusive locks for the same range.  We have four
>> > tasks.  Tasks 1 and 4 share the same owner, the others' owners are
>> > distinct.
>> >
>> >- Task 1 gets a lock.
>> >- Task 2 gets a conflicting lock.
>> >- Task 3 gets another conflicting lock.  So now we the tree is
>> >3->2->1.
>> >- Task 1's lock is released.
>> >- Before task 2 is scheduled, task 4 acquires a new lock.
>> >- Task 2 waits on task 4's lock, we now have
>> >3->2->4.
>> >
>> > Task 3 shouldn't be waiting--the lock it's requesting has the same owner
>> > as the lock task 4 holds--but we fail to wake up task 3.
>> 
>> So task 1 and task 4 are threads in the one process - OK.
>> Tasks 2 and 3 are threads in two other processes.
>> 
>> So 2 and 3 conflict with either 1 or 4 equally - why should task 3 be
>> woken?
>> 
>> I suspect you got the numbers bit mixed up,
>
> Whoops.
>
>> but in any case, the "conflict()" function that is passed around takes
>> ownership into account when assessing if one lock conflicts with
>> another.
>
> Right, I know, but, let me try again:
>
> All locks are exclusive locks for the same range.  Only tasks 3 and 4
> share the the same owner.
>
>   - Task 1 gets a lock.
>   - Task 2 requests a conflicting lock, so we have2->1.
>   - Task 3 requests a conflicting lock, so we have 3->2->1.
>   - Task 1 unlocks.  We wake up task 2, but it isn't scheduled yet.
>   - Task 4 gets a new lock.
>   - Task 2 runs, discovers the conflict, and waits.  Now we have:
>   3->2->4.
>
> There is no conflict between the lock 3 requested and the lock 4 holds,
> but 3 is not woken up.
>
> This is another version of the first problem: there's information we
> need (the owners of the waiting locks in the tree) that we can't
> determine just from looking at the root of the tree.
>
> I'm not sure what to do about that.

You're good at this game!

So, because a locker with the same "owner" gets a free pass, you can
*never* say that any lock which conflicts with A also conflicts with B,
as a lock with the same owner as B will never conflict with B, even
though it conflicts with A.

I think there is still value in having the tree, but when a waiter is
attached under a new blocker, we need to walk the whole tree beneath the
waiter and detach/wake anything that is not blocked by the new blocker.

Thanks,
NeilBrown


signature.asc
Description: PGP signature


Re: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups

2018-08-09 Thread NeilBrown
On Thu, Aug 09 2018, J. Bruce Fields wrote:

> On Fri, Aug 10, 2018 at 08:12:43AM +1000, NeilBrown wrote:
>> On Thu, Aug 09 2018, J. Bruce Fields wrote:
>> 
>> > I think there's also a problem with multiple tasks sharing the same
>> > lock owner.
>> >
>> > So, all locks are exclusive locks for the same range.  We have four
>> > tasks.  Tasks 1 and 4 share the same owner, the others' owners are
>> > distinct.
>> >
>> >- Task 1 gets a lock.
>> >- Task 2 gets a conflicting lock.
>> >- Task 3 gets another conflicting lock.  So now we the tree is
>> >3->2->1.
>> >- Task 1's lock is released.
>> >- Before task 2 is scheduled, task 4 acquires a new lock.
>> >- Task 2 waits on task 4's lock, we now have
>> >3->2->4.
>> >
>> > Task 3 shouldn't be waiting--the lock it's requesting has the same owner
>> > as the lock task 4 holds--but we fail to wake up task 3.
>> 
>> So task 1 and task 4 are threads in the one process - OK.
>> Tasks 2 and 3 are threads in two other processes.
>> 
>> So 2 and 3 conflict with either 1 or 4 equally - why should task 3 be
>> woken?
>> 
>> I suspect you got the numbers bit mixed up,
>
> Whoops.
>
>> but in any case, the "conflict()" function that is passed around takes
>> ownership into account when assessing if one lock conflicts with
>> another.
>
> Right, I know, but, let me try again:
>
> All locks are exclusive locks for the same range.  Only tasks 3 and 4
> share the the same owner.
>
>   - Task 1 gets a lock.
>   - Task 2 requests a conflicting lock, so we have2->1.
>   - Task 3 requests a conflicting lock, so we have 3->2->1.
>   - Task 1 unlocks.  We wake up task 2, but it isn't scheduled yet.
>   - Task 4 gets a new lock.
>   - Task 2 runs, discovers the conflict, and waits.  Now we have:
>   3->2->4.
>
> There is no conflict between the lock 3 requested and the lock 4 holds,
> but 3 is not woken up.
>
> This is another version of the first problem: there's information we
> need (the owners of the waiting locks in the tree) that we can't
> determine just from looking at the root of the tree.
>
> I'm not sure what to do about that.

You're good at this game!

So, because a locker with the same "owner" gets a free pass, you can
*never* say that any lock which conflicts with A also conflicts with B,
as a lock with the same owner as B will never conflict with B, even
though it conflicts with A.

I think there is still value in having the tree, but when a waiter is
attached under a new blocker, we need to walk the whole tree beneath the
waiter and detach/wake anything that is not blocked by the new blocker.

Thanks,
NeilBrown


signature.asc
Description: PGP signature


Re: FW: [PATCH v2] RISC-V: Add the directive for alignment of stvec's value

2018-08-09 Thread Palmer Dabbelt

On Thu, 09 Aug 2018 17:37:39 PDT (-0700), zong...@gmail.com wrote:

Subject: [PATCH v2] RISC-V: Add the directive for alignment of stvec's value

The stvec's value must be 4 byte alignment by specification definition.
These directives avoid to stvec be set the non-alignment value.

Signed-off-by: Zong Li 
---
 arch/riscv/kernel/head.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 
3b6293f..11066d5 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -94,6 +94,7 @@ relocate:
or a0, a0, a1
sfence.vma
csrw sptbr, a0
+.align 2
 1:
/* Set trap vector to spin forever to help debug */
la a0, .Lsecondary_park
@@ -143,6 +144,7 @@ relocate:
tail smp_callin
 #endif

+.align 2
 .Lsecondary_park:
/* We lack SMP support or have too many harts, so park this hart */
wfi


Thanks, this got lost in the shuffle somewhere.  It's in for-next now.


Re: FW: [PATCH v2] RISC-V: Add the directive for alignment of stvec's value

2018-08-09 Thread Palmer Dabbelt

On Thu, 09 Aug 2018 17:37:39 PDT (-0700), zong...@gmail.com wrote:

Subject: [PATCH v2] RISC-V: Add the directive for alignment of stvec's value

The stvec's value must be 4 byte alignment by specification definition.
These directives avoid to stvec be set the non-alignment value.

Signed-off-by: Zong Li 
---
 arch/riscv/kernel/head.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 
3b6293f..11066d5 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -94,6 +94,7 @@ relocate:
or a0, a0, a1
sfence.vma
csrw sptbr, a0
+.align 2
 1:
/* Set trap vector to spin forever to help debug */
la a0, .Lsecondary_park
@@ -143,6 +144,7 @@ relocate:
tail smp_callin
 #endif

+.align 2
 .Lsecondary_park:
/* We lack SMP support or have too many harts, so park this hart */
wfi


Thanks, this got lost in the shuffle somewhere.  It's in for-next now.


Re: [PATCH v3 2/2] net/9p: add a per-client fcall kmem_cache

2018-08-09 Thread piaojun
Thanks for clearing my doubt, and you can add:

Acked-by: Jun Piao 

On 2018/8/10 9:41, Dominique Martinet wrote:
> piaojun wrote on Fri, Aug 10, 2018:
>> Could you help paste the test result of before-after-applied this patch in
>> comment? And please see my comments below.
> 
> Thanks the the review, do you mean the commit message?
> 
> I'll add the summary I wrote in reply to your question a few mails
> before.
> 
Yes, I mean the commit message.

> 
>>> diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
>>> index e23896116d9a..645266b74652 100644
>>> --- a/include/net/9p/9p.h
>>> +++ b/include/net/9p/9p.h
>>> @@ -336,6 +336,9 @@ enum p9_qid_t {
>>>  #define P9_NOFID   (u32)(~0)
>>>  #define P9_MAXWELEM16
>>>  
>>> +/* Minimal header size: len + id + tag */
>>
>> Here should be 'size + id + tag'.
> 
> hm I didn't want to repeat size, but I guess people do refer to that
> field as size.
> I'll actually rewrite it as:
>  Minimal header size: size[4] type[1] tag[2]
> 
It looks better.

>>> +   kmem_cache_destroy(clnt->fcall_cache);
>>
>> I'm afraid that we should check NULL for clnt->fcall_cache.
> 
> kmem_cache_destroy() in mm/slab_common.c does the null check for us:
> --
> void kmem_cache_destroy(struct kmem_cache *s)
> {
> int err;
> 
> if (unlikely(!s))
> return;
> --
> 
OK, it makes sense.


Re: [PATCH v3 2/2] net/9p: add a per-client fcall kmem_cache

2018-08-09 Thread piaojun
Thanks for clearing my doubt, and you can add:

Acked-by: Jun Piao 

On 2018/8/10 9:41, Dominique Martinet wrote:
> piaojun wrote on Fri, Aug 10, 2018:
>> Could you help paste the test result of before-after-applied this patch in
>> comment? And please see my comments below.
> 
> Thanks the the review, do you mean the commit message?
> 
> I'll add the summary I wrote in reply to your question a few mails
> before.
> 
Yes, I mean the commit message.

> 
>>> diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
>>> index e23896116d9a..645266b74652 100644
>>> --- a/include/net/9p/9p.h
>>> +++ b/include/net/9p/9p.h
>>> @@ -336,6 +336,9 @@ enum p9_qid_t {
>>>  #define P9_NOFID   (u32)(~0)
>>>  #define P9_MAXWELEM16
>>>  
>>> +/* Minimal header size: len + id + tag */
>>
>> Here should be 'size + id + tag'.
> 
> hm I didn't want to repeat size, but I guess people do refer to that
> field as size.
> I'll actually rewrite it as:
>  Minimal header size: size[4] type[1] tag[2]
> 
It looks better.

>>> +   kmem_cache_destroy(clnt->fcall_cache);
>>
>> I'm afraid that we should check NULL for clnt->fcall_cache.
> 
> kmem_cache_destroy() in mm/slab_common.c does the null check for us:
> --
> void kmem_cache_destroy(struct kmem_cache *s)
> {
> int err;
> 
> if (unlikely(!s))
> return;
> --
> 
OK, it makes sense.


Re: [PATCH v3 2/2] net/9p: add a per-client fcall kmem_cache

2018-08-09 Thread Dominique Martinet
piaojun wrote on Fri, Aug 10, 2018:
> Could you help paste the test result of before-after-applied this patch in
> comment? And please see my comments below.

Thanks the the review, do you mean the commit message?

I'll add the summary I wrote in reply to your question a few mails
before.


> > diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
> > index e23896116d9a..645266b74652 100644
> > --- a/include/net/9p/9p.h
> > +++ b/include/net/9p/9p.h
> > @@ -336,6 +336,9 @@ enum p9_qid_t {
> >  #define P9_NOFID   (u32)(~0)
> >  #define P9_MAXWELEM16
> >  
> > +/* Minimal header size: len + id + tag */
> 
> Here should be 'size + id + tag'.

hm I didn't want to repeat size, but I guess people do refer to that
field as size.
I'll actually rewrite it as:
 Minimal header size: size[4] type[1] tag[2]

> > +   kmem_cache_destroy(clnt->fcall_cache);
> 
> I'm afraid that we should check NULL for clnt->fcall_cache.

kmem_cache_destroy() in mm/slab_common.c does the null check for us:
--
void kmem_cache_destroy(struct kmem_cache *s)
{
int err;

if (unlikely(!s))
return;
--

-- 
Dominique


Re: [PATCH v3 2/2] net/9p: add a per-client fcall kmem_cache

2018-08-09 Thread Dominique Martinet
piaojun wrote on Fri, Aug 10, 2018:
> Could you help paste the test result of before-after-applied this patch in
> comment? And please see my comments below.

Thanks the the review, do you mean the commit message?

I'll add the summary I wrote in reply to your question a few mails
before.


> > diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
> > index e23896116d9a..645266b74652 100644
> > --- a/include/net/9p/9p.h
> > +++ b/include/net/9p/9p.h
> > @@ -336,6 +336,9 @@ enum p9_qid_t {
> >  #define P9_NOFID   (u32)(~0)
> >  #define P9_MAXWELEM16
> >  
> > +/* Minimal header size: len + id + tag */
> 
> Here should be 'size + id + tag'.

hm I didn't want to repeat size, but I guess people do refer to that
field as size.
I'll actually rewrite it as:
 Minimal header size: size[4] type[1] tag[2]

> > +   kmem_cache_destroy(clnt->fcall_cache);
> 
> I'm afraid that we should check NULL for clnt->fcall_cache.

kmem_cache_destroy() in mm/slab_common.c does the null check for us:
--
void kmem_cache_destroy(struct kmem_cache *s)
{
int err;

if (unlikely(!s))
return;
--

-- 
Dominique


  1   2   3   4   5   6   7   8   9   10   >