[PATCH] microblaze: use sg_phys()

2017-03-23 Thread Geliang Tang
Use sg_phys() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 arch/microblaze/kernel/dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
index 12e093a..e45ada8 100644
--- a/arch/microblaze/kernel/dma.c
+++ b/arch/microblaze/kernel/dma.c
@@ -65,8 +65,7 @@ static int dma_direct_map_sg(struct device *dev, struct 
scatterlist *sgl,
if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
continue;
 
-   __dma_sync(page_to_phys(sg_page(sg)) + sg->offset,
-   sg->length, direction);
+   __dma_sync(sg_phys(sg), sg->length, direction);
}
 
return nents;
-- 
2.9.3



Re: [PATCH] drivers/staging/dgnc: Removing manual function tracing using dev_dbg

2017-03-23 Thread Greg Kroah-Hartman
On Thu, Mar 23, 2017 at 02:20:53PM +0530, Pushkar Jambhlekar wrote:
> Current implementation manually traces function using 'dev_dbg'. This way is 
> not needed because of ftrace, making these calls redundant.


Always wrap your changelog lines properly.

Also, someone else sent this same patch in right before you did, sorry.

greg k-h


RE: Query on DT overlay support.

2017-03-23 Thread Nava kishore Manne
Hi,

    This mail is regarding the DT overlay support in the Linux 
kernel
    I am able to make the device-tree overlay work out of box by 
using my own dtc complier (I mean I used the dtc compiler
    Available here 
http://www.embedded-things.com/bbb/patching-the-device-tree-compiler-for-ubuntu/
  )
    When can I expect the same changes in the scripts/dtc in 
mainline 
    In case of any support needed for testing I can help on testing 
the same I works in Xilinx and we had a lot of combinations to test overlay ☺ 

    

Regards,
Navakishore.


Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls

2017-03-23 Thread Linus Walleij
On Thu, Mar 23, 2017 at 11:10 AM, Uwe Kleine-König
 wrote:

> So you exchanged many obvious and easy to fix problems with a few hard
> ones. I don't agree that's a good idea, but you seem to be willing to
> try it. Good luck.

I think instead of going to sarcastic remarks you can say you NACK the
patch and suggest that it be reverted?

The problem I have here as maintainer is that both you and Dmitry are
very smart people and I have a great deal of trust invested in both of you.

When two valued contributors give me very different advice I get a bit
confused and maybe the best option is not to change anything at all
right now, and just revert Dmitry's patch.

git grep -e 'gpio.*optional(' | wc -l
gives 154 use sites outside drivers/gpio, so it is not impossible to fix
this if we want a good and strict order to it. I'm just a bit overworked to
do it myself right now.

What do you all say, is it better to revert Dmitry's patch and instead go
around and fix the consumers to do it correctly everywhere, after
hammering down the exact semantics?

Yours,
Linus Walleij


[PATCH 2/4] sched: cpudeadline: don't re-initialize struct cpudl

2017-03-23 Thread Viresh Kumar
The struct cpudl passed to cpudl_init() is already initialized to zero.
Don't do that again.

Signed-off-by: Viresh Kumar 
---
 kernel/sched/cpudeadline.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index fba235c7d026..a51e91bf3907 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -246,9 +246,7 @@ int cpudl_init(struct cpudl *cp)
 {
int i;
 
-   memset(cp, 0, sizeof(*cp));
raw_spin_lock_init(>lock);
-   cp->size = 0;
 
cp->elements = kcalloc(nr_cpu_ids,
   sizeof(struct cpudl_item),
-- 
2.12.0.432.g71c3a4f4ba37



[PATCH 1/4] sched: topology: drop memset() from init_rootdomain()

2017-03-23 Thread Viresh Kumar
There are only two callers of init_rootdomain(). One of them passes a
global to it and another one sends dynamically allocated root-domain.

There is no need to memset the root-domain in the first case as the
structure is already reset.

Update alloc_rootdomain() to allocate the memory with kzalloc() and
remove the memset() call from init_rootdomain().

Signed-off-by: Viresh Kumar 
---
 kernel/sched/topology.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 1b0b4fb12837..a2497702e628 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -242,8 +242,6 @@ void rq_attach_root(struct rq *rq, struct root_domain *rd)
 
 static int init_rootdomain(struct root_domain *rd)
 {
-   memset(rd, 0, sizeof(*rd));
-
if (!zalloc_cpumask_var(>span, GFP_KERNEL))
goto out;
if (!zalloc_cpumask_var(>online, GFP_KERNEL))
@@ -292,7 +290,7 @@ static struct root_domain *alloc_rootdomain(void)
 {
struct root_domain *rd;
 
-   rd = kmalloc(sizeof(*rd), GFP_KERNEL);
+   rd = kzalloc(sizeof(*rd), GFP_KERNEL);
if (!rd)
return NULL;
 
-- 
2.12.0.432.g71c3a4f4ba37



[PATCH] staging: ad7746: Moved contents of the header to the source file.

2017-03-23 Thread Arushi Singhal
Moved the contents of the header(ad7746.h) into the source file
ad7746.c with the exception of the platform data struct which is
supposed to be used from somewhere else other than the driver.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/iio/cdc/ad7746.c | 5 +
 drivers/staging/iio/cdc/ad7746.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 2d8397b11b19..033a41fd9bee 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -21,6 +21,11 @@
 
 #include "ad7746.h"
 
+#define AD7466_EXCLVL_0 0 /* +-VDD/8 */
+#define AD7466_EXCLVL_1 1 /* +-VDD/4 */
+#define AD7466_EXCLVL_2 2 /* +-VDD * 3/8 */
+#define AD7466_EXCLVL_3 3 /* +-VDD/2 */
+
 /*
  * AD7746 Register Definition
  */
diff --git a/drivers/staging/iio/cdc/ad7746.h b/drivers/staging/iio/cdc/ad7746.h
index ea8572d1df02..2fbcee88fda6 100644
--- a/drivers/staging/iio/cdc/ad7746.h
+++ b/drivers/staging/iio/cdc/ad7746.h
@@ -13,11 +13,6 @@
  * TODO: struct ad7746_platform_data needs to go into include/linux/iio
  */
 
-#define AD7466_EXCLVL_00 /* +-VDD/8 */
-#define AD7466_EXCLVL_11 /* +-VDD/4 */
-#define AD7466_EXCLVL_22 /* +-VDD * 3/8 */
-#define AD7466_EXCLVL_33 /* +-VDD/2 */
-
 struct ad7746_platform_data {
unsigned char exclvl;   /*Excitation Voltage Level */
bool exca_en;   /* enables EXCA pin as the excitation output */
-- 
2.11.0



Re: [PATCH v5 3/3] mfd: wm831x: Add device tree binding document

2017-03-23 Thread Lee Jones
On Fri, 17 Mar 2017, Charles Keepax wrote:

> Add a device tree binding document for the wm831x series of PMICs.
> Currently only support for the registering the device and the GPIOs are
> actually implemented in the driver.
> 
> Signed-off-by: Charles Keepax 
> ---
> 
> Changes since v4:
>  - Removed one extra level of ../ for relative links that was incorrect
> 
> Thanks,
> Charles
> 
>  Documentation/devicetree/bindings/mfd/wm831x.txt | 81 
> 
>  MAINTAINERS  |  1 +
>  2 files changed, 82 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/wm831x.txt

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/wm831x.txt 
> b/Documentation/devicetree/bindings/mfd/wm831x.txt
> new file mode 100644
> index 000..9f8b743
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/wm831x.txt
> @@ -0,0 +1,81 @@
> +Cirrus Logic/Wolfson Microelectronics wm831x PMICs
> +
> +System PMICs with a wide range of additional features.
> +
> +Required properties:
> +
> +  - compatible : One of the following chip-specific strings:
> +"wlf,wm8310"
> +"wlf,wm8311"
> +"wlf,wm8312"
> +"wlf,wm8320"
> +"wlf,wm8321"
> +"wlf,wm8325"
> +"wlf,wm8326"
> +
> +  - reg : I2C slave address when connected using I2C, chip select number
> +when using SPI.
> +
> +  - gpio-controller : Indicates this device is a GPIO controller.
> +  - #gpio-cells : Must be 2. The first cell is the pin number and the
> +second cell is used to specify optional parameters (currently unused).
> +
> +  - interrupts : The interrupt line the IRQ signal for the device is
> +connected to.
> +  - interrupt-parent : The parent interrupt controller.
> +
> +  - interrupt-controller : wm831x devices contain interrupt controllers and
> +may provide interrupt services to other devices.
> +  - #interrupt-cells: Must be 2. The first cell is the IRQ number, and the
> +second cell is the flags, encoded as the trigger masks from
> +../interrupt-controller/interrupts.txt
> +
> +Optional sub-nodes:
> +  - regulators : Contains sub-nodes for each of the regulators supplied by
> +the device. The regulators are bound using their names listed below:
> +
> +dcdc1 : DCDC1
> +dcdc2 : DCDC2
> +dcdc3 : DCDC3
> +dcdc4 : DCDC3
> +isink1 : ISINK1
> +isink2 : ISINK2
> +ldo1 : LDO1
> +ldo2 : LDO2
> +ldo3 : LDO3
> +ldo4 : LDO4
> +ldo5 : LDO5
> +ldo7 : LDO7
> +ldo11 : LDO11
> +
> +The bindings details of each regulator can be found in:
> +../regulator/regulator.txt
> +
> +Example:
> +
> +wm8310: pmic@36 {
> + compatible = "wlf,wm8310";
> + reg = <0x36>;
> +
> + gpio-controller;
> + #gpio-cells = <2>;
> +
> + interrupts = <347>;
> + interrupt-parent = <>;
> +
> + interrupt-controller;
> + #interrupt-cells = <2>;
> +
> + regulators {
> + dcdc1: dcdc1 {
> + regulator-name = "DCDC1";
> + regulator-min-microvolt = <60>;
> + regulator-max-microvolt = <60>;
> + };
> + ldo1: ldo1 {
> + regulator-name = "LDO1";
> + regulator-min-microvolt = <170>;
> + regulator-max-microvolt = <170>;
> + };
> + };
> +};
> diff --git a/MAINTAINERS b/MAINTAINERS
> index c265a5f..dfe761b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13600,6 +13600,7 @@ F:Documentation/hwmon/wm83??
>  F:   Documentation/devicetree/bindings/extcon/extcon-arizona.txt
>  F:   Documentation/devicetree/bindings/regulator/arizona-regulator.txt
>  F:   Documentation/devicetree/bindings/mfd/arizona.txt
> +F:   Documentation/devicetree/bindings/mfd/wm831x.txt
>  F:   arch/arm/mach-s3c64xx/mach-crag6410*
>  F:   drivers/clk/clk-wm83*.c
>  F:   drivers/extcon/extcon-arizona.c

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


[PATCH v2] kasan: report only the first error by default

2017-03-23 Thread Andrey Ryabinin
Disable kasan after the first report. There are several reasons for this:
 * Single bug quite often has multiple invalid memory accesses causing
storm in the dmesg.
 * Write OOB access might corrupt metadata so the next report will print
bogus alloc/free stacktraces.
 * Reports after the first easily could be not bugs by itself but just side
effects of the first one.

Given that multiple reports usually only do harm, it makes sense to disable
kasan after the first one. If user wants to see all the reports, the
boot-time parameter kasan_multi_shot must be used.

Signed-off-by: Andrey Ryabinin 
---
Changes since v1:
- provide kasan_multi_shot boot parameter.

 Documentation/admin-guide/kernel-parameters.txt |  6 ++
 lib/test_kasan.c| 12 
 mm/kasan/kasan.h|  5 -
 mm/kasan/report.c   | 18 ++
 4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 2906987..f88d60e 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1726,6 +1726,12 @@
kernel and module base offset ASLR (Address Space
Layout Randomization).
 
+   kasan_multi_shot
+   [KNL] Enforce KASAN (Kernel Address Sanitizer) to print
+   report on every invalid memory access. Without this
+   parameter KASAN will print report only for the first
+   invalid access.
+
keepinitrd  [HW,ARM]
 
kernelcore= [KNL,X86,IA-64,PPC]
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 0b1d314..f3acece 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -11,6 +11,7 @@
 
 #define pr_fmt(fmt) "kasan test: %s " fmt, __func__
 
+#include 
 #include 
 #include 
 #include 
@@ -21,6 +22,8 @@
 #include 
 #include 
 
+extern atomic_t kasan_report_count;
+
 /*
  * Note: test functions are marked noinline so that their names appear in
  * reports.
@@ -474,6 +477,9 @@ static noinline void __init use_after_scope_test(void)
 
 static int __init kmalloc_tests_init(void)
 {
+   /* Rise reports limit high enough to see all the following bugs */
+   atomic_add(100, _report_count);
+
kmalloc_oob_right();
kmalloc_oob_left();
kmalloc_node_oob_right();
@@ -499,6 +505,12 @@ static int __init kmalloc_tests_init(void)
ksize_unpoisons_memory();
copy_user_test();
use_after_scope_test();
+
+   /*
+* kasan is unreliable now, disable reports if
+* we are in single shot mode
+*/
+   atomic_sub(100, _report_count);
return -EAGAIN;
 }
 
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index 7572917..1229298 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -96,11 +96,6 @@ static inline const void *kasan_shadow_to_mem(const void 
*shadow_addr)
<< KASAN_SHADOW_SCALE_SHIFT);
 }
 
-static inline bool kasan_report_enabled(void)
-{
-   return !current->kasan_depth;
-}
-
 void kasan_report(unsigned long addr, size_t size,
bool is_write, unsigned long ip);
 void kasan_report_double_free(struct kmem_cache *cache, void *object,
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 718a10a..5650534 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -13,7 +13,9 @@
  *
  */
 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -354,6 +356,22 @@ static void kasan_report_error(struct kasan_access_info 
*info)
kasan_end_report();
 }
 
+atomic_t kasan_report_count = ATOMIC_INIT(1);
+EXPORT_SYMBOL_GPL(kasan_report_count);
+
+static int __init kasan_set_multi_shot(char *str)
+{
+   atomic_set(_report_count, 10);
+   return 1;
+}
+__setup("kasan_multi_shot", kasan_set_multi_shot);
+
+static inline bool kasan_report_enabled(void)
+{
+   return !current->kasan_depth &&
+   (atomic_dec_if_positive(_report_count) >= 0);
+}
+
 void kasan_report(unsigned long addr, size_t size,
bool is_write, unsigned long ip)
 {
-- 
2.10.2



Re: [PATCH] video: fbdev: pmag-aa-fb: remove incorrect __exit markups

2017-03-23 Thread Maciej W. Rozycki
On Mon, 20 Mar 2017, Bartlomiej Zolnierkiewicz wrote:

> > Even if bus is not hot-pluggable, devices can be unbound from the
> > driver via sysfs, so we should not be using __exit annotations on
> > remove() methods. The only exception is drivers registered with
> > platform_driver_probe() which specifically disables sysfs bind/unbind
> > attributes.
> > 
> > Signed-off-by: Dmitry Torokhov 
> 
> Patch queued for 4.12, thanks.

 Thanks!

  Maciej


[GIT PULL] Immutable branch between MFD and GPIO due for the v4.12 merge window

2017-03-23 Thread Lee Jones
Enjoy,

The following changes since commit c1ae3cfa0e89fa1a7ecc4c99031f5e9ae99d9201:

  Linux 4.11-rc1 (2017-03-05 12:59:56 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-gpio-v4.12

for you to fetch changes up to 9f7c7ceefe5e824e8333859bded12257a6d3548a:

  mfd: wm831x: Add device tree binding document (2017-03-23 11:46:00 +)


Immutable branch between MFD and GPIO due for the v4.12 merge window


Charles Keepax (3):
  mfd: wm831x: Add basic device tree binding
  gpio: wm831x: Add basic device tree support
  mfd: wm831x: Add device tree binding document

 Documentation/devicetree/bindings/mfd/wm831x.txt | 81 
 MAINTAINERS  |  1 +
 drivers/gpio/gpio-wm831x.c   |  5 +-
 drivers/mfd/wm831x-core.c| 29 ++---
 drivers/mfd/wm831x-i2c.c | 19 +-
 drivers/mfd/wm831x-irq.c |  6 +-
 drivers/mfd/wm831x-spi.c | 18 +-
 include/linux/mfd/wm831x/core.h  |  9 ++-
 8 files changed, 152 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/wm831x.txt

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH] ARM: nommu: access ID_PFR1 only if CPUID scheme

2017-03-23 Thread Greg Ungerer

Hi Afzal,

On 23/03/17 20:43, afzal mohammed wrote:

On Fri, Mar 17, 2017 at 10:10:34PM +0530, afzal mohammed wrote:

Greg upon trying to boot no-MMU Kernel on ARM926EJ reported boot
failure. He root caused it to ID_PFR1 access introduced by the
commit mentioned in the fixes tag below.

All CP15 processors need not have processor feature registers, only
for architectures defined by CPUID scheme would have it. Hence check
for it before accessing processor feature register, ID_PFR1.

Fixes: f8300a0b5de0 ("ARM: 8647/2: nommu: dynamic exception base address 
setting")
Reported-by: Greg Ungerer 
Signed-off-by: afzal mohammed 


Greg, can i add your Tested-by ?


Absolutely:

Tested-by: Greg Ungerer 

Thanks for taking care of this.

Regards
Greg



---

Hi Russell,

It would be good to have the fix go in during -rc, as,

1. Culprit commit went in during the last merge window
2. Though nothing supported in mainline is known to be broken, the
original change needs to be modified to be reliable




[PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer

2017-03-23 Thread Colin King
From: Colin Ian King 

info is being checked to see if it is a null pointer, however, vpgu is
dereferencing info before this check, leading to a potential null
pointer dereference.  If info is null, then the error message being
printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
use a null vpgu as the macro has a sanity check to see if vpgu is null,
so this is OK.

Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")

Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 1ea3eb270de8..f8619a772c44 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
 
 static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
 {
-   struct intel_vgpu *vgpu = info->vgpu;
-
if (!info) {
+   struct intel_vgpu *vgpu = NULL;
+
gvt_vgpu_err("kvmgt_guest_info invalid\n");
return false;
}
-- 
2.11.0



[PATCH] arm/arm64: KVM: send SIGBUS error to qemu

2017-03-23 Thread Dongjiu Geng
when the pfn is KVM_PFN_ERR_HWPOISON, it indicates to send
SIGBUS signal from KVM's fault-handling code to qemu, qemu
can handle this signal according to the fault address.

Signed-off-by: Dongjiu Geng 
---
 arch/arm/kvm/mmu.c   | 20 
 include/linux/kvm_host.h |  5 +
 2 files changed, 25 insertions(+)

diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 962616fd4ddd..1307ec400de3 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1237,6 +1237,20 @@ static void coherent_cache_guest_page(struct kvm_vcpu 
*vcpu, kvm_pfn_t pfn,
__coherent_cache_guest_page(vcpu, pfn, size);
 }
 
+static void kvm_send_hwpoison_signal(unsigned long address,
+   struct task_struct *tsk)
+{
+   siginfo_t info;
+
+   info.si_signo   = SIGBUS;
+   info.si_errno   = 0;
+   info.si_code= BUS_MCEERR_AR;
+   info.si_addr= (void __user *)address;
+   info.si_addr_lsb = PAGE_SHIFT;
+
+   send_sig_info(SIGBUS, , tsk);
+}
+
 static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
  struct kvm_memory_slot *memslot, unsigned long hva,
  unsigned long fault_status)
@@ -1309,6 +1323,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, 
phys_addr_t fault_ipa,
if (is_error_noslot_pfn(pfn))
return -EFAULT;
 
+   if (is_error_hwpoison_pfn(pfn)) {
+   kvm_send_hwpoison_signal(kvm_vcpu_gfn_to_hva(vcpu, gfn),
+   current);
+   return -EFAULT;
+   }
+
if (kvm_is_device_pfn(pfn)) {
mem_type = PAGE_S2_DEVICE;
flags |= KVM_S2PTE_FLAG_IS_IOMAP;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 2c14ad9809da..610ded9ebe9b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -91,6 +91,11 @@ static inline bool is_noslot_pfn(kvm_pfn_t pfn)
 {
return pfn == KVM_PFN_NOSLOT;
 }
+/* hwpoison pfn indicates that it needs to send SIGBUS */
+static inline bool is_error_hwpoison_pfn(kvm_pfn_t pfn)
+{
+   return pfn == KVM_PFN_ERR_HWPOISON;
+}
 
 /*
  * architectures with KVM_HVA_ERR_BAD other than PAGE_OFFSET (e.g. s390)
-- 
2.11.0



[PATCH 5/5] w83627ehf: Drop support for nct6775/nct6776

2017-03-23 Thread Peter Huewe
Since there exists a dedicated driver for nct6775/nct6776 it makes sense
to remove support for these chips from this driver, in order to have
only one code base for these types of chips.

This also improves maintainability and readability (and size) of this
driver.

Some not so-obvious changes are:
- removal of fan_debounce module parameter (now unused)
- removal of has_fan_div flag (nct6776 specific)
- w83627ehf_update_fan_div_common -> w83627ehf_update_fan_div
  (no distinction needed anymore)
- w83627ehf_update_pwm_common -> w83627ehf_update_pwm
  (no distinction needed anymore)
- NUM_REG_TEMP changed to ARRAY_SIZE(W83627EHF_REG_TEMP)
  (different number of max temp sensors)
- removal of intrusion1_alarm (nct6776 specific)

v2: Updated Kconfig, Documentation and removed unused temp_sensors (5-9)

Tested on NCT6776F (not probed anymore)

Signed-off-by: Peter Huewe 
---
 Documentation/hwmon/w83627ehf |  36 +--
 drivers/hwmon/Kconfig |   5 +-
 drivers/hwmon/w83627ehf.c | 546 --
 3 files changed, 57 insertions(+), 530 deletions(-)

diff --git a/Documentation/hwmon/w83627ehf b/Documentation/hwmon/w83627ehf
index 735c42a85ead..d6b05abc1dcb 100644
--- a/Documentation/hwmon/w83627ehf
+++ b/Documentation/hwmon/w83627ehf
@@ -26,14 +26,6 @@ Supported chips:
 Prefix: 'w83667hg'
 Addresses scanned: ISA address retrieved from Super I/O registers
 Datasheet: Available from Nuvoton upon request
-  * Nuvoton NCT6775F/W83667HG-I
-Prefix: 'nct6775'
-Addresses scanned: ISA address retrieved from Super I/O registers
-Datasheet: Available from Nuvoton upon request
-  * Nuvoton NCT6776F
-Prefix: 'nct6776'
-Addresses scanned: ISA address retrieved from Super I/O registers
-Datasheet: Available from Nuvoton upon request
 
 Authors:
 Jean Delvare 
@@ -46,24 +38,22 @@ Description
 ---
 
 This driver implements support for the Winbond W83627EHF, W83627EHG,
-W83627DHG, W83627DHG-P, W83627UHG, W83667HG, W83667HG-B, W83667HG-I
-(NCT6775F), and NCT6776F super I/O chips. We will refer to them collectively
-as Winbond chips.
+W83627DHG, W83627DHG-P, W83627UHG, W83667HG and W83667HG-B super I/O chips.
+We will refer to them collectively as Winbond chips.
 
-The chips implement 3 to 4 temperature sensors (9 for NCT6775F and NCT6776F),
-2 to 5 fan rotation speed sensors, 8 to 10 analog voltage sensors, one VID
-(except for 627UHG), alarms with beep warnings (control unimplemented),
-and some automatic fan regulation strategies (plus manual fan control mode).
+The chips implement 3 to 4 temperature sensors, 2 to 5 fan rotation speed
+sensors, 8 to 10 analog voltage sensors, one VID (except for 627UHG), alarms
+with beep warnings (control unimplemented), and some automatic fan regulation
+strategies (plus manual fan control mode).
 
-The temperature sensor sources on W82677HG-B, NCT6775F, and NCT6776F are
-configurable. temp4 and higher attributes are only reported if its temperature
-source differs from the temperature sources of the already reported temperature
-sensors. The configured source for each of the temperature sensors is provided
-in tempX_label.
+The temperature sensor sources on W82677HG-B are configurable. temp4 and higher
+attributes are only reported if its temperature source differs from the
+temperature sources of the already reported temperature sensors. The configured
+source for each of the temperature sensors is provided in tempX_label.
 
 Temperatures are measured in degrees Celsius and measurement resolution is 1
 degC for temp1 and and 0.5 degC for temp2 and temp3. For temp4 and higher,
-resolution is 1 degC for W83667HG-B and 0.0 degC for NCT6775F and NCT6776F.
+resolution is 1 degC for W83667HG-B.
 An alarm is triggered when the temperature gets higher than high limit;
 it stays on until the temperature falls below the hysteresis value.
 Alarms are only supported for temp1, temp2, and temp3.
@@ -110,10 +100,8 @@ pwm[1-4]_enable - this file controls mode of 
fan/temperature control:
* 4 "Smart Fan III" mode
* 5 "Smart Fan IV" mode
 
-   SmartFan III mode is not supported on NCT6776F.
-
SmartFan IV mode is configurable only if it was configured at system
-   startup, and is only supported for W83677HG-B, NCT6775F, and NCT6776F.
+   startup, and is only supported for W83677HG-B.
SmartFan IV operational parameters can not be configured at this time,
and the various pwm attributes are not used in SmartFan IV mode.
The attributes can be written to, which is useful if you plan to
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 0649d53f3d16..38edc81fb87e 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1807,7 +1807,7 @@ config SENSORS_W83627HF
  will be called w83627hf.
 
 config SENSORS_W83627EHF
-   tristate "Winbond W83627EHF/EHG/DHG/UHG, W83667HG, NCT6775F, NCT6776F"
+  

[PATCH 1/5] w83627ehf: Use hwmon_device_register_with_info and sensor groups

2017-03-23 Thread Peter Huewe
This patch replaces the old, deprecated call to hwmon_device_register
with the new hwmon_device_register_with_info and converts the whole
driver to the new hwmon interface using the hwmon_chip_info methods
and the attribute_group method.

All standard attributes were converted to the corresponding
hwmon_chip_info methods.
For some functions a hwmon channel to device channel conversion had to
be performed, e.g. hwmon_in_alarm has the info for alert_5 in channel 8.

All non-standard attributes are converted to the attribute_group method,
by
- adding them statically to the attribute_group if they are available
for all variants of devices supported by this driver
- adding them at probe time to the attribute_group if the availability
is depending on the actual chip type.
The appropriate count of entries was reserved.

As a pre-condition a reference to the sio_data structure was moved into
w83627ehf_data for easier retrieval of the information, since this is
much easier than trying to access the platform_data.

The driver is now much more "checkpatch clean" than it used to be, but
still not completely.
The conversion saves about 20k in the resulting .ko

Tested with a NCT6776F chip.

v2:
- converted to proper is_visible methods
- applied minor feedback of v1

Signed-off-by: Peter Huewe 
---
 drivers/hwmon/w83627ehf.c | 1536 +++--
 1 file changed, 778 insertions(+), 758 deletions(-)

diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index ad68b6d9ff17..f2f33dd35fd4 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1,6 +1,7 @@
 /*
  *  w83627ehf - Driver for the hardware monitoring functionality of
  * the Winbond W83627EHF Super-I/O chip
+ *  Copyright (C) 2017  Peter Huewe 
  *  Copyright (C) 2005-2012  Jean Delvare 
  *  Copyright (C) 2006  Yuan Mu (Winbond),
  * Rudolf Marek 
@@ -426,6 +427,11 @@ static inline u8 in_to_reg(u32 val, u8 nr, const u16 
*scale_in)
 /*
  * Data structures and manipulation thereof
  */
+struct w83627ehf_sio_data {
+   int sioreg;
+   enum kinds kind;
+};
+
 
 struct w83627ehf_data {
int addr;   /* IO base of hw monitor block */
@@ -514,11 +520,7 @@ struct w83627ehf_data {
u8 fandiv1;
u8 fandiv2;
 #endif
-};
-
-struct w83627ehf_sio_data {
-   int sioreg;
-   enum kinds kind;
+   struct w83627ehf_sio_data *sio_data;
 };
 
 /*
@@ -679,7 +681,7 @@ static void w83627ehf_write_fan_div(struct w83627ehf_data 
*data, int nr)
 static void w83627ehf_write_fan_div_common(struct device *dev,
   struct w83627ehf_data *data, int nr)
 {
-   struct w83627ehf_sio_data *sio_data = dev_get_platdata(dev);
+   struct w83627ehf_sio_data *sio_data = data->sio_data;
 
if (sio_data->kind == nct6776)
; /* no dividers, do nothing */
@@ -730,11 +732,9 @@ static void w83627ehf_update_fan_div(struct w83627ehf_data 
*data)
 static void w83627ehf_update_fan_div_common(struct device *dev,
struct w83627ehf_data *data)
 {
-   struct w83627ehf_sio_data *sio_data = dev_get_platdata(dev);
-
-   if (sio_data->kind == nct6776)
+   if (data->sio_data->kind == nct6776)
; /* no dividers, do nothing */
-   else if (sio_data->kind == nct6775)
+   else if (data->sio_data->kind == nct6775)
nct6775_update_fan_div(data);
else
w83627ehf_update_fan_div(data);
@@ -787,7 +787,7 @@ static void w83627ehf_update_pwm(struct w83627ehf_data 
*data)
 static void w83627ehf_update_pwm_common(struct device *dev,
struct w83627ehf_data *data)
 {
-   struct w83627ehf_sio_data *sio_data = dev_get_platdata(dev);
+   struct w83627ehf_sio_data *sio_data = data->sio_data;
 
if (sio_data->kind == nct6775 || sio_data->kind == nct6776)
nct6775_update_pwm(data);
@@ -798,8 +798,7 @@ static void w83627ehf_update_pwm_common(struct device *dev,
 static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
 {
struct w83627ehf_data *data = dev_get_drvdata(dev);
-   struct w83627ehf_sio_data *sio_data = dev_get_platdata(dev);
-
+   struct w83627ehf_sio_data *sio_data = data->sio_data;
int i;
 
mutex_lock(>update_lock);
@@ -936,157 +935,15 @@ static struct w83627ehf_data 
*w83627ehf_update_device(struct device *dev)
return data;
 }
 
-/*
- * Sysfs callback functions
- */
-#define show_in_reg(reg) \
-static ssize_t \
-show_##reg(struct device *dev, struct device_attribute *attr, \
-  char *buf) \
-{ \
-   struct w83627ehf_data *data = w83627ehf_update_device(dev); \
-   struct sensor_device_attribute *sensor_attr = \
-   to_sensor_dev_attr(attr); \
-   int nr = sensor_attr->index; \
-

Re: [PATCH] ARM: gemini: don't select SERIAL_OF_PLATFORM

2017-03-23 Thread Linus Walleij
On Thu, Mar 23, 2017 at 1:13 PM, Arnd Bergmann  wrote:
> On Thu, Mar 23, 2017 at 11:22 AM, Linus Walleij
>  wrote:
>> On Tue, Mar 21, 2017 at 9:52 PM, Arnd Bergmann  wrote:
>>
>>> We cannot select the option when SERIAL_8250 is not also set:
>>>
>>> warning: (ARCH_GEMINI) selects SERIAL_OF_PLATFORM which has unmet direct 
>>> dependencies (TTY && HAS_IOMEM && SERIAL_8250 && OF)
>>>
>>> This removes the 'select' statement, requiring that users enable the
>>> option manually. Alternatively, we could make it a conditional
>>> 'select SERIAL_OF_PLATFORM if SERIAL_8250' or also select a handful
>>> of other symbols that it depends on.
>>>
>>> Signed-off-by: Arnd Bergmann 
>>
>> Reviewed-by: Linus Walleij 
>>
>> Will you apply this directly to the interestingly misspelled
>> "gemeni/multiplatform" branch in the ARM SoC tree
>> directly?
>>
>> I will send pull requests on top of that branch later
>> for more features.
>
> If you are going to send more pull requests, just add the fixup there,
> it's not urgent.

OK thanks, I'll queue it.

Yours,
Linus Walleij


[PATCH 3/5] w83627ehf: Minor readability fixes

2017-03-23 Thread Peter Huewe
just some cosmetics for better readability, proposed by
Lindent/checkpatch

Signed-off-by: Peter Huewe 
---
 drivers/hwmon/w83627ehf.c | 39 +++
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 0acadeece509..a6f56b12727b 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -410,6 +410,7 @@ div_from_reg(u8 reg)
 static const u16 scale_in_common[10] = {
800, 800, 1600, 1600, 800, 800, 800, 1600, 1600, 800
 };
+
 static const u16 scale_in_w83627uhg[9] = {
800, 800, 3328, 3424, 800, 800, 0, 3328, 3400
 };
@@ -432,7 +433,6 @@ struct w83627ehf_sio_data {
enum kinds kind;
 };
 
-
 struct w83627ehf_data {
int addr;   /* IO base of hw monitor block */
const char *name;
@@ -532,6 +532,7 @@ struct w83627ehf_data {
 static inline void w83627ehf_set_bank(struct w83627ehf_data *data, u16 reg)
 {
u8 bank = reg >> 8;
+
if (data->bank != bank) {
outb_p(W83627EHF_REG_BANK, data->addr + ADDR_REG_OFFSET);
outb_p(bank, data->addr + DATA_REG_OFFSET);
@@ -549,8 +550,7 @@ static u16 w83627ehf_read_value(struct w83627ehf_data 
*data, u16 reg)
outb_p(reg & 0xff, data->addr + ADDR_REG_OFFSET);
res = inb_p(data->addr + DATA_REG_OFFSET);
if (word_sized) {
-   outb_p((reg & 0xff) + 1,
-  data->addr + ADDR_REG_OFFSET);
+   outb_p((reg & 0xff) + 1, data->addr + ADDR_REG_OFFSET);
res = (res << 8) + inb_p(data->addr + DATA_REG_OFFSET);
}
 
@@ -569,8 +569,7 @@ static int w83627ehf_write_value(struct w83627ehf_data 
*data, u16 reg,
outb_p(reg & 0xff, data->addr + ADDR_REG_OFFSET);
if (word_sized) {
outb_p(value >> 8, data->addr + DATA_REG_OFFSET);
-   outb_p((reg & 0xff) + 1,
-  data->addr + ADDR_REG_OFFSET);
+   outb_p((reg & 0xff) + 1, data->addr + ADDR_REG_OFFSET);
}
outb_p(value & 0xff, data->addr + DATA_REG_OFFSET);
 
@@ -590,8 +589,7 @@ static u16 w83627ehf_read_temp(struct w83627ehf_data *data, 
u16 reg)
return res;
 }
 
-static int w83627ehf_write_temp(struct w83627ehf_data *data, u16 reg,
-  u16 value)
+static int w83627ehf_write_temp(struct w83627ehf_data *data, u16 reg, u16 
value)
 {
if (!is_word_sized(reg))
value >>= 8;
@@ -700,7 +698,7 @@ static void nct6775_update_fan_div(struct w83627ehf_data 
*data)
data->fan_div[1] = (i & 0x70) >> 4;
i = w83627ehf_read_value(data, NCT6775_REG_FANDIV2);
data->fan_div[2] = i & 0x7;
-   if (data->has_fan & (1<<3))
+   if (data->has_fan & (1 << 3))
data->fan_div[3] = (i & 0x70) >> 4;
 }
 
@@ -935,9 +933,7 @@ static struct w83627ehf_data 
*w83627ehf_update_device(struct device *dev)
return data;
 }
 
-
-static void
-store_fan_min(struct device *dev, u32 channel, unsigned long val)
+static void store_fan_min(struct device *dev, u32 channel, unsigned long val)
 {
struct w83627ehf_data *data = dev_get_drvdata(dev);
int nr = channel;
@@ -1014,10 +1010,8 @@ store_fan_min(struct device *dev, u32 channel, unsigned 
long val)
data->last_updated = jiffies;
}
 done:
-   w83627ehf_write_value(data, data->REG_FAN_MIN[nr],
- data->fan_min[nr]);
+   w83627ehf_write_value(data, data->REG_FAN_MIN[nr], data->fan_min[nr]);
mutex_unlock(>update_lock);
-
 }
 
 #define show_tol_temp(reg) \
@@ -1036,7 +1030,7 @@ show_tol_temp(target_temp)
 
 static ssize_t
 store_target_temp(struct device *dev, struct device_attribute *attr,
-   const char *buf, size_t count)
+ const char *buf, size_t count)
 {
struct w83627ehf_data *data = dev_get_drvdata(dev);
struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
@@ -1059,7 +1053,7 @@ store_target_temp(struct device *dev, struct 
device_attribute *attr,
 
 static ssize_t
 store_tolerance(struct device *dev, struct device_attribute *attr,
-   const char *buf, size_t count)
+   const char *buf, size_t count)
 {
struct w83627ehf_data *data = dev_get_drvdata(dev);
struct w83627ehf_sio_data *sio_data = data->sio_data;
@@ -1243,6 +1237,7 @@ static ssize_t
 cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
struct w83627ehf_data *data = dev_get_drvdata(dev);
+
return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
 }
 static DEVICE_ATTR_RO(cpu0_vid);
@@ -1486,8 +1481,7 @@ static inline void w83627ehf_init_device(struct 
w83627ehf_data *data,
/* Start monitoring is needed */
tmp = w83627ehf_read_value(data, W83627EHF_REG_CONFIG);
if (!(tmp & 0x01))
-   

Re: [PATCH 3/7] iommu/iova: insert start_pfn boundary of dma32

2017-03-23 Thread Robin Murphy
On 22/03/17 06:27, Zhen Lei wrote:
> Reserve the first granule size memory(start at start_pfn) as boundary
> iova, to make sure that iovad->cached32_node can not be NULL in future.
> Meanwhile, changed the assignment of iovad->cached32_node from rb_next to
> rb_prev of >node in function __cached_rbnode_delete_update.

I'm not sure I follow this. It's a top-down allocator, so cached32_node
points to the last node allocated (or the node above the last one freed)
on the assumption that there is likely free space directly below there,
thus it's a pretty good place for the next allocation to start searching
from. On the other hand, start_pfn is a hard "do not go below this line"
limit, so it doesn't seem to make any sense to ever point the former at
the latter.

I could understand slightly more if we were reserving the PFN *above*
the cached range, but as-is I don't see what we gain from the change
here, nor what benefit the cached32_node != NULL assumption gives
(AFAICS it would be more useful to simply restrict the cases where it
may be NULL to when the address space is either completely full or
completely empty, or perhaps both).

Robin.

> Signed-off-by: Zhen Lei 
> ---
>  drivers/iommu/iova.c | 63 
> ++--
>  1 file changed, 37 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index 1c49969..b5a148e 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -32,6 +32,17 @@ static unsigned long iova_rcache_get(struct iova_domain 
> *iovad,
>  static void init_iova_rcaches(struct iova_domain *iovad);
>  static void free_iova_rcaches(struct iova_domain *iovad);
>  
> +static void
> +insert_iova_boundary(struct iova_domain *iovad)
> +{
> + struct iova *iova;
> + unsigned long start_pfn_32bit = iovad->start_pfn;
> +
> + iova = reserve_iova(iovad, start_pfn_32bit, start_pfn_32bit);
> + BUG_ON(!iova);
> + iovad->cached32_node = >node;
> +}
> +
>  void
>  init_iova_domain(struct iova_domain *iovad, unsigned long granule,
>   unsigned long start_pfn, unsigned long pfn_32bit)
> @@ -45,27 +56,38 @@ init_iova_domain(struct iova_domain *iovad, unsigned long 
> granule,
>  
>   spin_lock_init(>iova_rbtree_lock);
>   iovad->rbroot = RB_ROOT;
> - iovad->cached32_node = NULL;
>   iovad->granule = granule;
>   iovad->start_pfn = start_pfn;
>   iovad->dma_32bit_pfn = pfn_32bit;
>   init_iova_rcaches(iovad);
> +
> + /*
> +  * Insert boundary nodes for dma32. So cached32_node can not be NULL in
> +  * future.
> +  */
> + insert_iova_boundary(iovad);
>  }
>  EXPORT_SYMBOL_GPL(init_iova_domain);
>  
>  static struct rb_node *
>  __get_cached_rbnode(struct iova_domain *iovad, unsigned long *limit_pfn)
>  {
> - if ((*limit_pfn > iovad->dma_32bit_pfn) ||
> - (iovad->cached32_node == NULL))
> + struct rb_node *cached_node;
> + struct rb_node *next_node;
> +
> + if (*limit_pfn > iovad->dma_32bit_pfn)
>   return rb_last(>rbroot);
> - else {
> - struct rb_node *prev_node = rb_prev(iovad->cached32_node);
> - struct iova *curr_iova =
> - rb_entry(iovad->cached32_node, struct iova, node);
> - *limit_pfn = curr_iova->pfn_lo - 1;
> - return prev_node;
> + else
> + cached_node = iovad->cached32_node;
> +
> + next_node = rb_next(cached_node);
> + if (next_node) {
> + struct iova *next_iova = rb_entry(next_node, struct iova, node);
> +
> + *limit_pfn = min(*limit_pfn, next_iova->pfn_lo - 1);
>   }
> +
> + return cached_node;
>  }
>  
>  static void
> @@ -83,20 +105,13 @@ __cached_rbnode_delete_update(struct iova_domain *iovad, 
> struct iova *free)
>   struct iova *cached_iova;
>   struct rb_node *curr;
>  
> - if (!iovad->cached32_node)
> - return;
>   curr = iovad->cached32_node;
>   cached_iova = rb_entry(curr, struct iova, node);
>  
>   if (free->pfn_lo >= cached_iova->pfn_lo) {
> - struct rb_node *node = rb_next(>node);
> - struct iova *iova = rb_entry(node, struct iova, node);
> -
>   /* only cache if it's below 32bit pfn */
> - if (node && iova->pfn_lo < iovad->dma_32bit_pfn)
> - iovad->cached32_node = node;
> - else
> - iovad->cached32_node = NULL;
> + if (free->pfn_hi <= iovad->dma_32bit_pfn)
> + iovad->cached32_node = rb_prev(>node);
>   }
>  }
>  
> @@ -114,7 +129,7 @@ static int __alloc_and_insert_iova_range(struct 
> iova_domain *iovad,
>   unsigned long size, unsigned long limit_pfn,
>   struct iova *new, bool size_aligned)
>  {
> - struct rb_node *prev, *curr = NULL;
> + struct rb_node *prev, *curr;
>   unsigned long flags;
>   unsigned long 

[PATCH] qla2xxx: use sg_virt()

2017-03-23 Thread Geliang Tang
Use sg_virt() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/scsi/qla2xxx/qla_isr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 3203367..9610d85 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1991,7 +1991,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx 
*sts24)
return 1;
}
 
-   spt = page_address(sg_page(sg)) + sg->offset;
+   spt = sg_virt(sg);
spt += j;
 
spt->app_tag = 0x;
-- 
2.9.3



[PATCH] iommu: use sg_phys()

2017-03-23 Thread Geliang Tang
Use sg_phys() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/iommu/intel-iommu.c | 2 +-
 drivers/iommu/iommu.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index d412a31..9d09a9e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3892,7 +3892,7 @@ static int intel_nontranslate_map_sg(struct device *hddev,
 
for_each_sg(sglist, sg, nelems, i) {
BUG_ON(!sg_page(sg));
-   sg->dma_address = page_to_phys(sg_page(sg)) + sg->offset;
+   sg->dma_address = sg_phys(sg);
sg->dma_length = sg->length;
}
return nelems;
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3b67144..26f57b3 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1603,7 +1603,7 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, 
unsigned long iova,
min_pagesz = 1 << __ffs(domain->pgsize_bitmap);
 
for_each_sg(sg, s, nents, i) {
-   phys_addr_t phys = page_to_phys(sg_page(s)) + s->offset;
+   phys_addr_t phys = sg_phys(s);
 
/*
 * We are mapping on IOMMU page boundaries, so offset within
-- 
2.9.3



[PATCH] crypto: ixp4xx - Use sg_virt()

2017-03-23 Thread Geliang Tang
Use sg_virt() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/crypto/ixp4xx_crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 7868765..771dd26 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -806,7 +806,7 @@ static struct buffer_desc *chainup_buffers(struct device 
*dev,
void *ptr;
 
nbytes -= len;
-   ptr = page_address(sg_page(sg)) + sg->offset;
+   ptr = sg_virt(sg);
next_buf = dma_pool_alloc(buffer_pool, flags, _buf_phys);
if (!next_buf) {
buf = NULL;
-- 
2.9.3



Re: [PATCH v2 02/10] x86: assembly, FUNC_START for fn, DATA_START for data

2017-03-23 Thread Josh Poimboeuf
On Thu, Mar 23, 2017 at 08:38:20AM +0100, Ingo Molnar wrote:
> 
> * Josh Poimboeuf  wrote:
> 
> > On Wed, Mar 22, 2017 at 08:46:16AM +0100, Ingo Molnar wrote:
> > > 
> > > * Jiri Slaby  wrote:
> > > 
> > > > On 03/22/2017, 08:25 AM, Ingo Molnar wrote:
> > > > > 
> > > > > * Pavel Machek  wrote:
> > > > > 
> > > > >> Hi!
> > > > >>
> > > > >>> -ENTRY(saved_rbp)   .quad   0
> > > > >>> -ENTRY(saved_rsi)   .quad   0
> > > > >>> -ENTRY(saved_rdi)   .quad   0
> > > > >>> -ENTRY(saved_rbx)   .quad   0
> > > > >>> +SYM_DATA_START(saved_rbp)  .quad   0
> > > > >>> +SYM_DATA_START(saved_rsi)  .quad   0
> > > > >>> +SYM_DATA_START(saved_rdi)  .quad   0
> > > > >>> +SYM_DATA_START(saved_rbx)  .quad   0
> > > > >>
> > > > >> Does it make sense to call it SYM_DATA_*START* when there's no
> > > > >> corresponding end?
> > > > > 
> > > > > That looks like a bug - I think we should strive for them to always 
> > > > > be in pairs.
> > > > > 
> > > > > Jiri, Josh, could objtool help here perhaps, to detect 
> > > > > 'non-terminated' 
> > > > > SYM_*_START() uses? This could be done by emitting debug data into a 
> > > > > special 
> > > > > section and then analyzing that section for unpaired entries. The 
> > > > > section can be 
> > > > > discarded in the final link, it won't show up in the kernel image.
> > > > 
> > > > It should be easier than that. No introduction of other info needed --
> > > > every global symbol without a ".type" or ".size" (i.e. SYM_*_END) should
> > > > be a bug now.
> > > 
> > > I'm all for that!
> > 
> > It would be easy to add this checking to objtool since it already reads
> > the symbol table.  The hard part is figuring out the logistics. :-)
> > 
> > - Should the warnings be on by default?
> 
> Yes, if objtool is running. Keep it simple.
> 
> > - Part of the "objtool check" command or something else?
> 
> Yes - I think it's still within the 'object file check' functionality.
> 
> > - Separate config option or just include it with
> >   CONFIG_STACK_VALIDATION?
> 
> Yeah, but I'd rename CONFIG_STACK_VALIDATION to CONFIG_OBJ_VALIDATION or 
> such. As 
> I predicted early on, objtool will go beyond stack checking! ;-)
> 
> > - Should all asm files be checked, including those currently skipped by
> >   objtool with OBJECT_FILES_NON_STANDARD?
> 
> The symbol syntax check should definitely be for all files, yes.

That all sounds reasonable.  I'll work something up.

> Could we perhaps emit 'non-standard stack frames' information into the .o 
> itself 
> (via a flag or a special section?), so that objtool can decide on its own 
> whether 
> to complain about any weirdnesses there?

For the OBJECT_FILES_NON_STANDARD case, where the whole file is
"special", we can just provide a flag to "objtool check" to tell it to
skip stack checking for that file, but still do the symbol checks.

> > > Can we detect double ends as well - i.e. do a build check of the full 
> > > syntax of 
> > > these symbol definition primitives?
> > 
> > Detecting double ends would be a little trickier.  The second SYM_*_END
> > supersedes the first, so that information isn't in the ELF symbol table.
> 
> Indeed.
> 
> > We could use a special section to annotate all the macro uses and have
> > objtool do the checking, similar to what you suggested earlier.
> 
> That might be useful for other purposes as well - such as the non-standard 
> stack 
> frame annotations?

To start with we can try going without all the special sections (other
than the SYM_END double end check).  If we end up finding another case
which isn't covered then we can always add the special sections later.

-- 
Josh


Re: [PATCH] staging: media: atomisp: use kvmalloc and kvfree

2017-03-23 Thread Greg Kroah-Hartman
On Thu, Mar 23, 2017 at 09:12:39PM +0800, Geliang Tang wrote:
> Use kvmalloc() and kvfree() instead of open-coding.

These functions are not in Linus's tree, so I can't apply this patch
without breaking things :(

thanks,

greg k-h


[PATCH] staging: rtl8192e: Fix embedded function names with __func__

2017-03-23 Thread suniel . spartan
From: Suniel Mahesh 

Prefer and make it generic by using %s and __func__ to print
functions name instead of embedding functions name in print statements

Signed-off-by: Suniel Mahesh 
---
 drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
index aa4b015..9281116 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
@@ -35,7 +35,7 @@ static void _rtl92e_hw_sleep(struct net_device *dev)
if (priv->RFChangeInProgress) {
spin_unlock_irqrestore(>rf_ps_lock, flags);
RT_TRACE(COMP_DBG,
-"_rtl92e_hw_sleep(): RF Change in progress!\n");
+"%s(): RF Change in progress!\n", __func__);
return;
}
spin_unlock_irqrestore(>rf_ps_lock, flags);
@@ -62,7 +62,7 @@ void rtl92e_hw_wakeup(struct net_device *dev)
if (priv->RFChangeInProgress) {
spin_unlock_irqrestore(>rf_ps_lock, flags);
RT_TRACE(COMP_DBG,
-"rtl92e_hw_wakeup(): RF Change in progress!\n");
+"%s(): RF Change in progress!\n", __func__);
schedule_delayed_work(>rtllib->hw_wakeup_wq,
  msecs_to_jiffies(10));
return;
@@ -121,15 +121,15 @@ static void _rtl92e_ps_update_rf_state(struct net_device 
*dev)
struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
&(priv->rtllib->PowerSaveControl);
 
-   RT_TRACE(COMP_PS, "_rtl92e_ps_update_rf_state() ->\n");
+   RT_TRACE(COMP_PS, "%s() ->\n", __func__);
pPSC->bSwRfProcessing = true;
 
-   RT_TRACE(COMP_PS, "_rtl92e_ps_update_rf_state(): Set RF to %s.\n",
+   RT_TRACE(COMP_PS, "%s(): Set RF to %s.\n", __func__,
 pPSC->eInactivePowerState == eRfOff ? "OFF" : "ON");
rtl92e_set_rf_state(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS);
 
pPSC->bSwRfProcessing = false;
-   RT_TRACE(COMP_PS, "_rtl92e_ps_update_rf_state() <-\n");
+   RT_TRACE(COMP_PS, "%s() <-\n", __func__);
 }
 
 void rtl92e_ips_enter(struct net_device *dev)
@@ -144,7 +144,7 @@ void rtl92e_ips_enter(struct net_device *dev)
if (rtState == eRfOn && !pPSC->bSwRfProcessing &&
(priv->rtllib->state != RTLLIB_LINKED) &&
(priv->rtllib->iw_mode != IW_MODE_MASTER)) {
-   RT_TRACE(COMP_PS, "rtl92e_ips_enter(): Turn off RF.\n");
+   RT_TRACE(COMP_PS, "%s(): Turn off RF.\n", __func__);
pPSC->eInactivePowerState = eRfOff;
priv->isRFOff = true;
priv->bInPowerSaveMode = true;
@@ -164,7 +164,7 @@ void rtl92e_ips_leave(struct net_device *dev)
rtState = priv->rtllib->eRFPowerState;
if (rtState != eRfOn  && !pPSC->bSwRfProcessing &&
priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) {
-   RT_TRACE(COMP_PS, "rtl92e_ips_leave(): Turn on RF.\n");
+   RT_TRACE(COMP_PS, "%s(): Turn on RF.\n", __func__);
pPSC->eInactivePowerState = eRfOn;
priv->bInPowerSaveMode = false;
_rtl92e_ps_update_rf_state(dev);
@@ -247,7 +247,7 @@ void rtl92e_leisure_ps_enter(struct net_device *dev)
struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
&(priv->rtllib->PowerSaveControl);
 
-   RT_TRACE(COMP_PS, "rtl92e_leisure_ps_enter()...\n");
+   RT_TRACE(COMP_PS, "%s()...\n", __func__);
RT_TRACE(COMP_PS,
 "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is 
%d,RT_CHECK_FOR_HANG_PERIOD is %d\n",
 pPSC->bLeisurePs, priv->rtllib->ps, pPSC->LpsIdleCount,
@@ -265,7 +265,7 @@ void rtl92e_leisure_ps_enter(struct net_device *dev)
if (priv->rtllib->ps == RTLLIB_PS_DISABLED) {
 
RT_TRACE(COMP_LPS,
-"rtl92e_leisure_ps_enter(): Enter 
802.11 power save mode...\n");
+"%s(): Enter 802.11 power save 
mode...\n", __func__);
 
if (!pPSC->bFwCtrlLPS) {
if (priv->rtllib->SetFwCmdHandler)
@@ -287,14 +287,14 @@ void rtl92e_leisure_ps_leave(struct net_device *dev)
&(priv->rtllib->PowerSaveControl);
 
 
-   RT_TRACE(COMP_PS, "rtl92e_leisure_ps_leave()...\n");
+   RT_TRACE(COMP_PS, "%s()...\n", __func__);
RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, 

Re: [PATCH] scsi: fcoe: sanity check string size for store_ctrl_mode option

2017-03-23 Thread Dan Carpenter
On Wed, Mar 22, 2017 at 07:42:08PM +, Colin Ian King wrote:
> On 22/03/17 19:39, Dan Carpenter wrote:
> > On Wed, Mar 22, 2017 at 02:01:37PM +, Colin King wrote:
> >> From: Colin Ian King 
> >>
> >> Reading and writing to mode[count - 1] implies the count should not
> >> be less than 1 so add a sanity check for this.
> >>
> >> Detected with CoverityScan, CID#1357345 ("Overflowed array index write")
> >>
> >> Signed-off-by: Colin Ian King 
> > 
> > This is harmless, of course, but count can't be zero.  This is a sysfs
> > file so we test for zero size writes in sysfs_kf_write() and return
> > early.
> 
> Ah, thanks for pointing out that. I overlooked that detail.
> 

The only reason I know this stuff is because it's annotated in Smatch.
So I do this:

diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index 9cf3d56296ab..c491ad8fb0a8 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -281,6 +281,7 @@ static ssize_t show_ctlr_mode(struct device *dev,
"%s\n", name);
 }
 
+#include "/home/dcarpenter/progs/smatch/devel/check_debug.h"
 static ssize_t store_ctlr_mode(struct device *dev,
   struct device_attribute *attr,
   const char *buf, size_t count)
@@ -288,6 +289,7 @@ static ssize_t store_ctlr_mode(struct device *dev,
struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev);
char mode[FCOE_MAX_MODENAME_LEN + 1];
 
+   __smatch_implied(count);
if (count > FCOE_MAX_MODENAME_LEN)
return -EINVAL;
 

Then when I run kchecker drivers/scsi/fcoe/fcoe_sysfs.c, it tells me:

drivers/scsi/fcoe/fcoe_sysfs.c:292 store_ctlr_mode() implied: count = 
'1-10,2147479552'

Which is sort of surprising...  The 10 value is a hack I made so
that it would never complain that "off + count" will wrap.  But
apparently something has changed so it's also picking up the true limit
of count which is 2147479552.

Then I run the following commands to view the call tree:
smdb.py store_ctlr_mode
smdb.py dev_attr_store
smdb.py sysfs_kf_write
I have some vim macros so I can look these up really quickly.

regards,
dan carpenter


Re: [PATCH] staging: tsl2x7x: Moved contents of the header to the source file.

2017-03-23 Thread Lars-Peter Clausen
On 03/23/2017 12:53 PM, Arushi Singhal wrote:
> Moved the contents of the header(tsl2x7x.h) into the source file
> tsl2x7x_core.c with the exception of the platform data struct which is
> supposed to be used from somewhere else other than the driver.

The platform_data struct uses the other structs though.


Re: [PATCH] selinux: Remove unnecessary check of array base in selinux_set_mapping()

2017-03-23 Thread Paul Moore
On Wed, Mar 22, 2017 at 8:28 PM, Grant Grundler  wrote:
> Ping? Any feedback on this patch?

It's on my list of patches to review, patience please.

> On Thu, Mar 16, 2017 at 3:26 PM, Matthias Kaehlcke  wrote:
>>
>> 'perms' will never be NULL since it isn't a plain pointer but an array
>> of u32 values.
>>
>> This fixes the following warning when building with clang:
>>
>> security/selinux/ss/services.c:158:16: error: address of array
>> 'p_in->perms' will always evaluate to 'true'
>> [-Werror,-Wpointer-bool-conversion]
>> while (p_in->perms && p_in->perms[k]) {
>>
>> Signed-off-by: Matthias Kaehlcke 
>> ---
>>  security/selinux/ss/services.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/security/selinux/ss/services.c
>> b/security/selinux/ss/services.c
>> index 082b20c78363..2f20b5f974f4 100644
>> --- a/security/selinux/ss/services.c
>> +++ b/security/selinux/ss/services.c
>> @@ -155,7 +155,7 @@ static int selinux_set_mapping(struct policydb *pol,
>> }
>>
>> k = 0;
>> -   while (p_in->perms && p_in->perms[k]) {
>> +   while (p_in->perms[k]) {
>> /* An empty permission string skips ahead */
>> if (!*p_in->perms[k]) {
>> k++;
>> --
>> 2.12.0.367.g23dc2f6d3c-goog
>>
>



-- 
paul moore
www.paul-moore.com


Re: [PATCH] blk-mq: don't complete un-started request in timeout handler

2017-03-23 Thread Ming Lei
On Wed, Mar 22, 2017 at 11:58:17AM -0400, Keith Busch wrote:
> On Tue, Mar 21, 2017 at 11:03:59PM -0400, Jens Axboe wrote:
> > On 03/21/2017 10:14 PM, Ming Lei wrote:
> > > When iterating busy requests in timeout handler,
> > > if the STARTED flag of one request isn't set, that means
> > > the request is being processed in block layer or driver, and
> > > isn't submitted to hardware yet.
> > > 
> > > In current implementation of blk_mq_check_expired(),
> > > if the request queue becomes dying, un-started requests are
> > > handled as being completed/freed immediately. This way is
> > > wrong, and can cause rq corruption or double allocation[1][2],
> > > when doing I/O and removing NVMe device at the sametime.
> > 
> > I agree, completing it looks bogus. If the request is in a scheduler or
> > on a software queue, this won't end well at all. Looks like it was
> > introduced by this patch:
> > 
> > commit eb130dbfc40eabcd4e10797310bda6b9f6dd7e76
> > Author: Keith Busch 
> > Date:   Thu Jan 8 08:59:53 2015 -0700
> > 
> > blk-mq: End unstarted requests on a dying queue
> > 
> > Before that, we just ignored it. Keith?
> 
> The above was intended for a stopped hctx on a dying queue such that
> there's nothing in flight to the driver. Nvme had been relying on this
> to end unstarted requests so we may progress when a controller dies.

So the brokenness started just from the begining.

> 
> We've since obviated the need: we restart the hw queues to flush entered
> requests to failure, so we don't need that brokenness.

Looks the following commit need to be backported too if we port this patch.

commit 69d9a99c258eb1d6478fd9608a2070890797eed7
Author: Keith Busch 
Date:   Wed Feb 24 09:15:56 2016 -0700

NVMe: Move error handling to failed reset handler
 

Thanks,
Ming


Re: [PATCH v3 2/3] mfd: intel_soc_pmic_bxtwc: Move inclusion to c-file

2017-03-23 Thread Lee Jones
On Fri, 17 Mar 2017, Andy Shevchenko wrote:

> There is no need to include intel_soc_pmic.h into header which doesn't
> require it.
> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/mfd/intel_soc_pmic_bxtwc.c | 1 +
>  include/linux/mfd/intel_bxtwc.h| 2 --
>  2 files changed, 1 insertion(+), 2 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c 
> b/drivers/mfd/intel_soc_pmic_bxtwc.c
> index 699c8c7c9052..c71db687b7ca 100644
> --- a/drivers/mfd/intel_soc_pmic_bxtwc.c
> +++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
> @@ -21,6 +21,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  /* PMIC device registers */
> diff --git a/include/linux/mfd/intel_bxtwc.h b/include/linux/mfd/intel_bxtwc.h
> index 1a0ee9d6efe9..240d6752ec64 100644
> --- a/include/linux/mfd/intel_bxtwc.h
> +++ b/include/linux/mfd/intel_bxtwc.h
> @@ -13,8 +13,6 @@
>   * more details.
>   */
>  
> -#include 
> -
>  #ifndef __INTEL_BXTWC_H__
>  #define __INTEL_BXTWC_H__
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v4 1/7] mfd: rk808: fix up the chip id get failed

2017-03-23 Thread Lee Jones
On Fri, 17 Mar 2017, Elaine Zhang wrote:

> the rk8xx chip id is:
> ((MSB << 8) | LSB) & 0xfff0
> 
> Signed-off-by: Elaine Zhang 
> ---
>  drivers/mfd/rk808.c   | 21 +++--
>  include/linux/mfd/rk808.h |  1 +
>  2 files changed, 16 insertions(+), 6 deletions(-)

For my own reference:
  Acked-for-MFD-by: Lee Jones 
  
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index fd087cbb0bde..3334a2a7f3fb 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
>   void (*pm_pwroff_fn)(void);
>   int nr_pre_init_regs;
>   int nr_cells;
> - int pm_off = 0;
> + int pm_off = 0, msb, lsb;
>   int ret;
>   int i;
>  
> @@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
>   if (!rk808)
>   return -ENOMEM;
>  
> - rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
> - if (rk808->variant < 0) {
> - dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
> + /* read Chip variant */
> + msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
> + if (msb < 0) {
> + dev_err(>dev, "failed to read the chip id at 0x%x\n",
>   RK808_ID_MSB);
> - return rk808->variant;
> + return msb;
>   }
>  
> - dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
> + lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
> + if (lsb < 0) {
> + dev_err(>dev, "failed to read the chip id at 0x%x\n",
> + RK808_ID_LSB);
> + return lsb;
> + }
> +
> + rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
> + dev_info(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
>  
>   switch (rk808->variant) {
>   case RK808_ID:
> diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
> index 83701ef7d3c7..54feb140c210 100644
> --- a/include/linux/mfd/rk808.h
> +++ b/include/linux/mfd/rk808.h
> @@ -298,6 +298,7 @@ enum rk818_reg {
>  #define VOUT_LO_INT  BIT(0)
>  #define CLK32KOUT2_ENBIT(0)
>  
> +#define RK8XX_ID_MSK 0xfff0
>  enum {
>   BUCK_ILMIN_50MA,
>   BUCK_ILMIN_100MA,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH] ARM: gemini: don't select SERIAL_OF_PLATFORM

2017-03-23 Thread Arnd Bergmann
On Thu, Mar 23, 2017 at 11:22 AM, Linus Walleij
 wrote:
> On Tue, Mar 21, 2017 at 9:52 PM, Arnd Bergmann  wrote:
>
>> We cannot select the option when SERIAL_8250 is not also set:
>>
>> warning: (ARCH_GEMINI) selects SERIAL_OF_PLATFORM which has unmet direct 
>> dependencies (TTY && HAS_IOMEM && SERIAL_8250 && OF)
>>
>> This removes the 'select' statement, requiring that users enable the
>> option manually. Alternatively, we could make it a conditional
>> 'select SERIAL_OF_PLATFORM if SERIAL_8250' or also select a handful
>> of other symbols that it depends on.
>>
>> Signed-off-by: Arnd Bergmann 
>
> Reviewed-by: Linus Walleij 
>
> Will you apply this directly to the interestingly misspelled
> "gemeni/multiplatform" branch in the ARM SoC tree
> directly?
>
> I will send pull requests on top of that branch later
> for more features.

If you are going to send more pull requests, just add the fixup there,
it's not urgent.

  Arnd


Re: [PATCH v3 1/3] mfd: intel_soc_pmic: Fix a mess with compilation units

2017-03-23 Thread Lee Jones
On Fri, 17 Mar 2017, Andy Shevchenko wrote:

> Crystal Cove and Whiskey Cove are two different PMICs which are
> installed on Intel Atom SoC based platforms.
> 
> Moreover there are two independent drivers that by some reason were
> supposed (*) to get into one kernel module.
> 
> Fix the mess by clarifying Kconfig option for Crystal Cove and split
> Whiskey Cove out of it.
> 
> (*) It looks like the configuration was never tested with
> INTEL_SOC_PMIC=n. The line in Makefile is actually wrong.
> 
> Cc: "Rafael J. Wysocki"  (supporter:ACPI)
> Cc: Linus Walleij  (maintainer:GPIO SUBSYSTEM)
> Cc: Zhang Rui  (supporter:THERMAL)
> Cc: Eduardo Valentin  (supporter:THERMAL)
> Signed-off-by: Andy Shevchenko 
> ---
> - make option visible
> - fix dependencies
>  drivers/acpi/Kconfig |  2 +-

This needs an ACPI Ack before I can do anything with it.

>  drivers/gpio/Kconfig |  2 +-
>  drivers/mfd/Kconfig  | 14 --
>  drivers/mfd/Makefile |  2 +-
>  drivers/platform/x86/Kconfig |  2 +-
>  drivers/thermal/Kconfig  |  2 +-
>  6 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index 83e5f7e1a20d..03708e08fcb4 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -512,7 +512,7 @@ config XPOWER_PMIC_OPREGION
>  
>  config BXT_WC_PMIC_OPREGION
>   bool "ACPI operation region support for BXT WhiskeyCove PMIC"
> - depends on INTEL_SOC_PMIC
> + depends on INTEL_SOC_PMIC_BXTWC
>   help
> This config adds ACPI operation region support for BXT WhiskeyCove 
> PMIC.
>  
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index 05043071fc98..9b1bcb4d0df7 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -1054,7 +1054,7 @@ config GPIO_UCB1400
>  
>  config GPIO_WHISKEY_COVE
>   tristate "GPIO support for Whiskey Cove PMIC"
> - depends on (X86 || COMPILE_TEST) && INTEL_SOC_PMIC
> + depends on (X86 || COMPILE_TEST) && INTEL_SOC_PMIC_BXTWC
>   select GPIOLIB_IRQCHIP
>   help
> Support for GPIO pins on Whiskey Cove PMIC.
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 55ecdfb74d31..e43afb8956ea 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -425,18 +425,28 @@ config LPC_SCH
> System Management Bus and General Purpose I/O.
>  
>  config INTEL_SOC_PMIC
> - bool "Support for Intel Atom SoC PMIC"
> + bool "Support for Crystal Cove PMIC"
>   depends on GPIOLIB
>   depends on I2C=y
>   select MFD_CORE
>   select REGMAP_I2C
>   select REGMAP_IRQ
>   help
> -   Select this option to enable support for the PMIC device
> +   Select this option to enable support for Crystal Cove PMIC
> on some Intel SoC systems. The PMIC provides ADC, GPIO,
> thermal, charger and related power management functions
> on these systems.
>  
> +config INTEL_SOC_PMIC_BXTWC
> + tristate "Support for Intel Broxton Whiskey Cove PMIC"
> + select MFD_CORE
> + select REGMAP_IRQ
> + help
> +   Select this option to enable support for Whiskey Cove PMIC
> +   on Intel Broxton systems. The PMIC provides ADC, GPIO,
> +   thermal, charger and related power management functions
> +   on these systems.
> +
>  config MFD_INTEL_LPSS
>   tristate
>   select COMMON_CLK
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 31ce07611a6f..201aeaf5112a 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -207,8 +207,8 @@ obj-$(CONFIG_MFD_RT5033)  += rt5033.o
>  obj-$(CONFIG_MFD_SKY81452)   += sky81452.o
>  
>  intel-soc-pmic-objs  := intel_soc_pmic_core.o intel_soc_pmic_crc.o
> -intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC)   += intel_soc_pmic_bxtwc.o
>  obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o
> +obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC)   += intel_soc_pmic_bxtwc.o
>  obj-$(CONFIG_MFD_MT6397) += mt6397-core.o
>  
>  obj-$(CONFIG_MFD_ALTERA_A10SR)   += altera-a10sr.o
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index e1bffc9bb194..883fbe7a2466 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -1019,7 +1019,7 @@ config INTEL_PMC_IPC
>  config INTEL_BXTWC_PMIC_TMU
>   tristate "Intel BXT Whiskey Cove TMU Driver"
>   depends on REGMAP
> - depends on INTEL_SOC_PMIC && INTEL_PMC_IPC
> + depends on INTEL_SOC_PMIC_BXTWC && INTEL_PMC_IPC
>   ---help---
> Select this driver to use Intel BXT Whiskey Cove PMIC TMU feature.
> This driver enables the alarm wakeup functionality in the TMU unit
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index 776b34396144..751e50a3d946 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -365,7 +365,7 @@ 

Re: [PATCH v18 0/3] USB Type-C Connector class

2017-03-23 Thread Greg KH
On Tue, Mar 21, 2017 at 01:56:45PM +0200, Heikki Krogerus wrote:
> The USB Type-C class is meant to provide unified interface to the
> userspace to present the USB Type-C ports in a system.

Now applied, nice job, thanks for sticking with this, it's much
appreciated.

greg k-h


[PATCH] xen, fbfront: fix connecting to backend

2017-03-23 Thread Juergen Gross
Connecting to the backend isn't working reliably in xen-fbfront: in
case XenbusStateInitWait of the backend has been missed the backend
transition to XenbusStateConnected will trigger the connected state
only without doing the actions required when the backend has
connected.

Cc: sta...@vger.kernel.org
Signed-off-by: Juergen Gross 
---
 drivers/video/fbdev/xen-fbfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/xen-fbfront.c 
b/drivers/video/fbdev/xen-fbfront.c
index d0115a7..3ee309c 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -643,7 +643,6 @@ static void xenfb_backend_changed(struct xenbus_device *dev,
break;
 
case XenbusStateInitWait:
-InitWait:
xenbus_switch_state(dev, XenbusStateConnected);
break;
 
@@ -654,7 +653,8 @@ static void xenfb_backend_changed(struct xenbus_device *dev,
 * get Connected twice here.
 */
if (dev->state != XenbusStateConnected)
-   goto InitWait; /* no InitWait seen yet, fudge it */
+   /* no InitWait seen yet, fudge it */
+   xenbus_switch_state(dev, XenbusStateConnected);
 
if (xenbus_read_unsigned(info->xbdev->otherend,
 "request-update", 0))
-- 
2.10.2



[PATCH] xen, fbfront: add support for specifying size via xenstore

2017-03-23 Thread Juergen Gross
Today xen-fbfront supports specifying the display size via module
parameters only. Add support for specifying the size via Xenstore in
order to enable doing this easily via the domain's Xen configuration.

Add an error message in case the configured display size conflicts
with video memory size.

Signed-off-by: Juergen Gross 
---
 drivers/video/fbdev/xen-fbfront.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/video/fbdev/xen-fbfront.c 
b/drivers/video/fbdev/xen-fbfront.c
index 3ee309c..46f6396 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -18,6 +18,8 @@
  * frame buffer.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -380,10 +382,18 @@ static int xenfb_probe(struct xenbus_device *dev,
video[KPARAM_MEM] = val;
}
 
+   video[KPARAM_WIDTH] = xenbus_read_unsigned(dev->otherend, "width",
+  video[KPARAM_WIDTH]);
+   video[KPARAM_HEIGHT] = xenbus_read_unsigned(dev->otherend, "height",
+   video[KPARAM_HEIGHT]);
+
/* If requested res does not fit in available memory, use default */
fb_size = video[KPARAM_MEM] * 1024 * 1024;
if (video[KPARAM_WIDTH] * video[KPARAM_HEIGHT] * XENFB_DEPTH / 8
> fb_size) {
+   pr_warn("display parameters %d,%d,%d invalid, use defaults\n",
+   video[KPARAM_MEM], video[KPARAM_WIDTH],
+   video[KPARAM_HEIGHT]);
video[KPARAM_WIDTH] = XENFB_WIDTH;
video[KPARAM_HEIGHT] = XENFB_HEIGHT;
fb_size = XENFB_DEFAULT_FB_LEN;
-- 
2.10.2



[PATCH 4/5] w83627ehf: Drop FSFE template and replace with SPDX License information

2017-03-23 Thread Peter Huewe
As indicated by checkpatch it makes sense to not use the FSFE Template
about GPLv2+

Signed-off-by: Peter Huewe 
---
 drivers/hwmon/w83627ehf.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index a6f56b12727b..c4b755cd506c 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -18,19 +18,8 @@
  *  This driver also supports the W83627EHG, which is the lead-free
  *  version of the W83627EHF.
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  Released under the GPLv2 or later.
+ *  SPDX-License-Identifier: GPL-2.0+
  *
  *  Supports the following chips:
  *
-- 
2.10.2



[PATCH] x86/boot: Support uncompressed kernel

2017-03-23 Thread Chao Peng
Compressed kernel has its own drawback: uncompressing takes time. Even
though the time is short enough to ignore for most cases but for cases that
time is critical this is still a big number. In our on-going optimization
for kernel boot time, the measured overall kernel boot time is ~90ms while
the uncompressing takes ~50ms with gzip.

The patch adds a 'CONFIG_KERNEL_RAW' configure choice so the built binary
can have no uncompressing at all. The experiment shows:

kernel   kernel sizetime in decompress_kernel
compressed (gzip)3.3M   53ms
uncompressed 14M3ms

Signed-off-by: Chao Peng 
---
 arch/x86/boot/compressed/Makefile |  3 +++
 arch/x86/boot/compressed/misc.c   | 14 ++
 init/Kconfig  |  7 +++
 scripts/Makefile.lib  |  8 
 4 files changed, 32 insertions(+)

diff --git a/arch/x86/boot/compressed/Makefile 
b/arch/x86/boot/compressed/Makefile
index f9ce75d..fc0e1c0 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -73,6 +73,8 @@ $(obj)/vmlinux.relocs: vmlinux FORCE
 vmlinux.bin.all-y := $(obj)/vmlinux.bin
 vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs
 
+$(obj)/vmlinux.bin.raw: $(vmlinux.bin.all-y) FORCE
+   $(call if_changed,raw)
 $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
$(call if_changed,gzip)
 $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
@@ -86,6 +88,7 @@ $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
 $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
$(call if_changed,lz4)
 
+suffix-$(CONFIG_KERNEL_RAW):= raw
 suffix-$(CONFIG_KERNEL_GZIP)   := gz
 suffix-$(CONFIG_KERNEL_BZIP2)  := bz2
 suffix-$(CONFIG_KERNEL_LZMA)   := lzma
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 79dac17..fb3cd43 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -123,6 +123,20 @@ static char *vidmem;
 static int vidport;
 static int lines, cols;
 
+#ifdef CONFIG_KERNEL_RAW
+#include 
+static int __decompress(unsigned char *buf, long len,
+   long (*fill)(void*, unsigned long),
+   long (*flush)(void*, unsigned long),
+   unsigned char *outbuf, long olen,
+   long *pos,
+   void (*error)(char *x))
+{
+   memcpy(outbuf, buf, olen);
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_KERNEL_GZIP
 #include "../../../../lib/decompress_inflate.c"
 #endif
diff --git a/init/Kconfig b/init/Kconfig
index 2232080..1db2ea2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -137,6 +137,13 @@ choice
 
  If in doubt, select 'gzip'
 
+config KERNEL_RAW
+   bool "RAW"
+   help
+ No compression. It creates much bigger kernel and uses much more
+ space (disk/memory) than other choices. It can be useful when
+ decompression speed is the most concern while space is not a problem.
+
 config KERNEL_GZIP
bool "Gzip"
depends on HAVE_KERNEL_GZIP
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 2edbcad..384128d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -344,6 +344,14 @@ cmd_lz4 = (cat $(filter-out FORCE,$^) | \
lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out 
FORCE,$^))) > $@ || \
(rm -f $@ ; false)
 
+# RAW
+# ---
+quiet_cmd_raw = RAW $@
+cmd_raw = (cat $(filter-out FORCE,$^) && \
+   $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+   (rm -f $@ ; false)
+
+
 # U-Boot mkimage
 # ---
 
-- 
1.8.3.1



[PATCH 2/5] w83627ehf: Use octal values for access rights of sysfs files

2017-03-23 Thread Peter Huewe
As indicated by checkpatch, use the octal representation for the access
rights.

S_IWUSR | S_IRUGO => 0644
S_IRUGO => 0444

Signed-off-by: Peter Huewe 
---
 drivers/hwmon/w83627ehf.c | 52 ---
 1 file changed, 22 insertions(+), 30 deletions(-)

diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index f2f33dd35fd4..0acadeece509 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1098,25 +1098,17 @@ store_tolerance(struct device *dev, struct 
device_attribute *attr,
 }
 
 static struct sensor_device_attribute sda_target_temp[] = {
-   SENSOR_ATTR(pwm1_target, S_IWUSR | S_IRUGO, show_target_temp,
-   store_target_temp, 0),
-   SENSOR_ATTR(pwm2_target, S_IWUSR | S_IRUGO, show_target_temp,
-   store_target_temp, 1),
-   SENSOR_ATTR(pwm3_target, S_IWUSR | S_IRUGO, show_target_temp,
-   store_target_temp, 2),
-   SENSOR_ATTR(pwm4_target, S_IWUSR | S_IRUGO, show_target_temp,
-   store_target_temp, 3),
+   SENSOR_ATTR(pwm1_target, 0644, show_target_temp, store_target_temp, 0),
+   SENSOR_ATTR(pwm2_target, 0644, show_target_temp, store_target_temp, 1),
+   SENSOR_ATTR(pwm3_target, 0644, show_target_temp, store_target_temp, 2),
+   SENSOR_ATTR(pwm4_target, 0644, show_target_temp, store_target_temp, 3),
 };
 
 static struct sensor_device_attribute sda_tolerance[] = {
-   SENSOR_ATTR(pwm1_tolerance, S_IWUSR | S_IRUGO, show_tolerance,
-   store_tolerance, 0),
-   SENSOR_ATTR(pwm2_tolerance, S_IWUSR | S_IRUGO, show_tolerance,
-   store_tolerance, 1),
-   SENSOR_ATTR(pwm3_tolerance, S_IWUSR | S_IRUGO, show_tolerance,
-   store_tolerance, 2),
-   SENSOR_ATTR(pwm4_tolerance, S_IWUSR | S_IRUGO, show_tolerance,
-   store_tolerance, 3),
+   SENSOR_ATTR(pwm1_tolerance, 0644, show_tolerance, store_tolerance, 0),
+   SENSOR_ATTR(pwm2_tolerance, 0644, show_tolerance, store_tolerance, 1),
+   SENSOR_ATTR(pwm3_tolerance, 0644, show_tolerance, store_tolerance, 2),
+   SENSOR_ATTR(pwm4_tolerance, 0644, show_tolerance, store_tolerance, 3),
 };
 
 /* Smart Fan registers */
@@ -1194,24 +1186,24 @@ store_##reg(struct device *dev, struct device_attribute 
*attr, \
 fan_time_functions(fan_stop_time, FAN_STOP_TIME)
 
 static struct sensor_device_attribute sda_sf3_arrays_fan4[] = {
-   SENSOR_ATTR(pwm4_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
+   SENSOR_ATTR(pwm4_stop_time, 0644, show_fan_stop_time,
store_fan_stop_time, 3),
-   SENSOR_ATTR(pwm4_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
+   SENSOR_ATTR(pwm4_start_output, 0644, show_fan_start_output,
store_fan_start_output, 3),
-   SENSOR_ATTR(pwm4_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
+   SENSOR_ATTR(pwm4_stop_output, 0644, show_fan_stop_output,
store_fan_stop_output, 3),
-   SENSOR_ATTR(pwm4_max_output, S_IWUSR | S_IRUGO, show_fan_max_output,
+   SENSOR_ATTR(pwm4_max_output, 0644, show_fan_max_output,
store_fan_max_output, 3),
-   SENSOR_ATTR(pwm4_step_output, S_IWUSR | S_IRUGO, show_fan_step_output,
+   SENSOR_ATTR(pwm4_step_output, 0644, show_fan_step_output,
store_fan_step_output, 3),
 };
 
 static struct sensor_device_attribute sda_sf3_arrays_fan3[] = {
-   SENSOR_ATTR(pwm3_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
+   SENSOR_ATTR(pwm3_stop_time, 0644, show_fan_stop_time,
store_fan_stop_time, 2),
-   SENSOR_ATTR(pwm3_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
+   SENSOR_ATTR(pwm3_start_output, 0644, show_fan_start_output,
store_fan_start_output, 2),
-   SENSOR_ATTR(pwm3_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
+   SENSOR_ATTR(pwm3_stop_output, 0644, show_fan_stop_output,
store_fan_stop_output, 2),
 };
 
@@ -1233,17 +1225,17 @@ static SENSOR_DEVICE_ATTR(pwm2_stop_output, 0644, 
show_fan_stop_output,
  * Need to check support while generating/removing attribute files.
  */
 static struct sensor_device_attribute sda_sf3_max_step_arrays[] = {
-   SENSOR_ATTR(pwm1_max_output, S_IWUSR | S_IRUGO, show_fan_max_output,
+   SENSOR_ATTR(pwm1_max_output, 0644, show_fan_max_output,
store_fan_max_output, 0),
-   SENSOR_ATTR(pwm1_step_output, S_IWUSR | S_IRUGO, show_fan_step_output,
+   SENSOR_ATTR(pwm1_step_output, 0644, show_fan_step_output,
store_fan_step_output, 0),
-   SENSOR_ATTR(pwm2_max_output, S_IWUSR | S_IRUGO, show_fan_max_output,
+   SENSOR_ATTR(pwm2_max_output, 0644, show_fan_max_output,
store_fan_max_output, 1),
-   SENSOR_ATTR(pwm2_step_output, S_IWUSR | S_IRUGO, show_fan_step_output,
+   SENSOR_ATTR(pwm2_step_output, 

[PATCH] isdn: use setup_timer

2017-03-23 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/isdn/divert/isdn_divert.c   |  9 +++--
 drivers/isdn/hardware/eicon/divasi.c|  5 ++---
 drivers/isdn/hardware/mISDN/hfcmulti.c  | 10 --
 drivers/isdn/hardware/mISDN/hfcpci.c|  9 +++--
 drivers/isdn/hardware/mISDN/mISDNipac.c |  5 ++---
 drivers/isdn/hardware/mISDN/mISDNisar.c | 10 --
 drivers/isdn/hardware/mISDN/w6692.c |  5 ++---
 drivers/isdn/hisax/amd7930_fn.c |  4 +---
 drivers/isdn/hisax/arcofi.c |  4 +---
 drivers/isdn/hisax/diva.c   |  5 ++---
 drivers/isdn/hisax/elsa.c   |  4 +---
 drivers/isdn/hisax/fsm.c|  4 +---
 drivers/isdn/hisax/hfc4s8s_l1.c |  5 ++---
 drivers/isdn/hisax/hfc_2bds0.c  |  4 +---
 drivers/isdn/hisax/hfc_pci.c|  8 ++--
 drivers/isdn/hisax/hfc_sx.c |  8 ++--
 drivers/isdn/hisax/hfc_usb.c|  8 ++--
 drivers/isdn/hisax/hfcscard.c   |  4 +---
 drivers/isdn/hisax/icc.c|  4 +---
 drivers/isdn/hisax/ipacx.c  |  4 +---
 drivers/isdn/hisax/isac.c   |  4 +---
 drivers/isdn/hisax/isar.c   | 10 --
 drivers/isdn/hisax/isdnl3.c |  4 +---
 drivers/isdn/hisax/teleint.c|  4 +---
 drivers/isdn/hisax/w6692.c  |  5 ++---
 drivers/isdn/i4l/isdn_ppp.c |  5 ++---
 drivers/isdn/i4l/isdn_tty.c |  5 ++---
 drivers/isdn/mISDN/dsp_core.c   |  4 +---
 drivers/isdn/mISDN/fsm.c|  4 +---
 drivers/isdn/mISDN/l1oip_core.c |  4 +---
 30 files changed, 54 insertions(+), 114 deletions(-)

diff --git a/drivers/isdn/divert/isdn_divert.c 
b/drivers/isdn/divert/isdn_divert.c
index 50749a7..060d357 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -157,10 +157,8 @@ int cf_command(int drvid, int mode,
/* allocate mem for information struct */
if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
return (-ENOMEM); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire, (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own structure */
cs->ics.driver = drvid;
cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */
cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */
@@ -452,10 +450,9 @@ static int isdn_divert_icall(isdn_ctrl *ic)
return (0); /* no external deflection 
needed */
if (!(cs = kmalloc(sizeof(struct call_struc), 
GFP_ATOMIC)))
return (0); /* no memory */
-   init_timer(>timer);
+   setup_timer(>timer, deflect_timer_expire,
+   (ulong)cs);
cs->info[0] = '\0';
-   cs->timer.function = deflect_timer_expire;
-   cs->timer.data = (ulong) cs; /* pointer to own 
structure */
 
cs->ics = *ic; /* copy incoming data */
if (!cs->ics.parm.setup.phone[0]) 
strcpy(cs->ics.parm.setup.phone, "0");
diff --git a/drivers/isdn/hardware/eicon/divasi.c 
b/drivers/isdn/hardware/eicon/divasi.c
index cb88090..c610495 100644
--- a/drivers/isdn/hardware/eicon/divasi.c
+++ b/drivers/isdn/hardware/eicon/divasi.c
@@ -300,9 +300,8 @@ static int um_idi_open_adapter(struct file *file, int 
adapter_nr)
p_os = (diva_um_idi_os_context_t *) diva_um_id_get_os_context(e);
init_waitqueue_head(_os->read_wait);
init_waitqueue_head(_os->close_wait);
-   init_timer(_os->diva_timer_id);
-   p_os->diva_timer_id.function = (void *) diva_um_timer_function;
-   p_os->diva_timer_id.data = (unsigned long) p_os;
+   setup_timer(_os->diva_timer_id, (void *)diva_um_timer_function,
+   (unsigned long)p_os);
p_os->aborted = 0;
p_os->adapter_nr = adapter_nr;
return (1);
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c 
b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 480c2d7..961c07e 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -3878,9 +3878,8 @@ hfcmulti_initmode(struct dchannel *dch)
if (hc->dnum[pt]) {
mode_hfcmulti(hc, dch->slot, dch->dev.D.protocol,
  -1, 0, -1, 0);
-   dch->timer.function = (void *) hfcmulti_dbusy_timer;
-   dch->timer.data = (long) dch;
-   init_timer(>timer);
+   setup_timer(>timer, (void *)hfcmulti_dbusy_timer,
+   (long)dch);
}
  

Re: Updates, autofocus, 5Mpix mode on N900? Re: [RFC 08/13] smiapp-pll: Take existing divisor into account in minimum divisor check

2017-03-23 Thread Pavel Machek
Hi!

> > Plus I have played with v4l-utils, and managed to implement autofocus
> > and autoexposure -- it was easier than expected. I believe you
> > mentioned you had some patches to automatically initialize the
> > pipeline. Do you and can I have them?
> 
> It was an early prototype and it wasn't really functional yet.
> 
> Given a video node, it can find possible pipelines to the image sources with
> common formats. I.e. the ccdc -> rsz path is not available for raw
> cameras.

> C (especially without helper libraries) wasn't particularly suitable for the
> task, the data structures I had didn't end up too nice. What would also be
> necessary is to associate library or application specific data to entities,
> this could be as simple as key-value pairs with both key and value being
> pointers.

Could I get a copy, anyway? Need not be perfect, but starting point
would be welcome.

Thanks,
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v2] kasan: report only the first error by default

2017-03-23 Thread Mark Rutland
On Thu, Mar 23, 2017 at 04:06:59PM +0300, Andrey Ryabinin wrote:
> On 03/23/2017 03:41 PM, Mark Rutland wrote:

> > Rather than trying to pick an arbitrarily large number, how about we use
> > separate flags to determine whether we're in multi-shot mode, and
> > whether a (oneshot) report has been made.
> > 
> > How about the below?
>  
> Yes, it deferentially looks better.
> Can you send a patch with a changelog, or do you want me to care of it?

Would you be happy to take care of it, along with the fixup you
suggested below, as v3?

You can add my:

Signed-off-by: Mark Rutland 

Thanks,
Mark.


> >  
> > +#include 
> >  #include 
> 
> We also need  for __setup().
> 
> >  #include 
> >  #include 
> > @@ -293,6 +294,40 @@ static void kasan_report_error(struct 
> > kasan_access_info *info)


Re: [PATCH v4] KVM: VMX: Fix enable VPID even if INVVPID is not exposed in vmx capability

2017-03-23 Thread David Hildenbrand
On 23.03.2017 03:39, Wanpeng Li wrote:
> From: Wanpeng Li 
> 
> This can be reproduced by running L2 on L1, and disable VPID on L0 
> if w/o commit "KVM: nVMX: Fix nested VPID vmx exec control", the L2 
> crash as below:
> 
> KVM: entry failed, hardware error 0x7
> EAX= EBX= ECX= EDX=000306c3
> ESI= EDI= EBP= ESP=
> EIP=fff0 EFL=0002 [---] CPL=0 II=0 A20=1 SMM=0 HLT=0
> ES =   9300
> CS =f000   9b00
> SS =   9300
> DS =   9300
> FS =   9300
> GS =   9300
> LDT=   8200
> TR =   8b00
> GDT=  
> IDT=  
> CR0=6010 CR2= CR3= CR4=
> DR0= DR1= DR2= 
> DR3= 
> DR6=0ff0 DR7=0400
> EFER=
> 
> Reference SDM 30.3 INVVPID:
>  
> Protected Mode Exceptions
> #UD 
>   - If not in VMX operation.
>   - If the logical processor does not support VPIDs 
> (IA32_VMX_PROCBASED_CTLS2[37]=0).
>   - If the logical processor supports VPIDs (IA32_VMX_PROCBASED_CTLS2[37]=1) 
> but does 
> not support the INVVPID instruction (IA32_VMX_EPT_VPID_CAP[32]=0).
> 
> So we should check both VPID enable bit in vmx exec control and INVVPID 
> support bit 
> in vmx capability MSRs to enable VPID. This patch adds the guarantee to not 
> enable VPID
> if INVVPID is not exposed in vmx capability MSRs.

You should change the subject and this description to also take the
single/global capability into account.

> 
> Reviewed-by: David Hildenbrand 
> Cc: Jim Mattson 
> Cc: Paolo Bonzini 
> Cc: Radim Krčmář 
> Signed-off-by: Wanpeng Li 
> ---
>  arch/x86/kvm/vmx.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 8795a70..8925c76 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -1239,6 +1239,11 @@ static inline bool cpu_has_vmx_invvpid_global(void)
>   return vmx_capability.vpid & VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT;
>  }
>  
> +static inline bool cpu_has_vmx_invvpid(void)
> +{
> + return vmx_capability.vpid & VMX_VPID_INVVPID_BIT;
> +}
> +
>  static inline bool cpu_has_vmx_ept(void)
>  {
>   return vmcs_config.cpu_based_2nd_exec_ctrl &
> @@ -6518,8 +6523,10 @@ static __init int hardware_setup(void)
>   if (boot_cpu_has(X86_FEATURE_NX))
>   kvm_enable_efer_bits(EFER_NX);
>  
> - if (!cpu_has_vmx_vpid())
> + if (!cpu_has_vmx_vpid() || !cpu_has_vmx_invvpid() ||
> + !cpu_has_vmx_invvpid_single() || !cpu_has_vmx_invvpid_global())

According to Jim

"KVM's vpid_sync_context() assumes that at least one of
{VMX_VPID_EXTENT_SINGLE_CONTEXT, VMX_VPID_EXTENT_ALL_CONTEXT} ..."

So we should only require one of these two, not both.

if (!cpu_has_vmx_vpid() || !cpu_has_vmx_invvpid() ||
!(cpu_has_vmx_invvpid_single() || cpu_has_vmx_invvpid_global()))

>   enable_vpid = 0;
> +
>   if (!cpu_has_vmx_shadow_vmcs())
>   enable_shadow_vmcs = 0;
>   if (enable_shadow_vmcs)
> 


-- 

Thanks,

David


[PATCH] ASoC: WM8962: Let codec driver enable/disable its MCLK

2017-03-23 Thread Daniel Baluta
From: Nicolin Chen 

WM8962 needs its MCLK when powerup in wm8962_resume(). Thus it's better
to control the MCLK in codec driver. Thus remove the clock enable in
machine dirver accordingly.

While at it, get rid of imx_wm8962_remove function since it is now
empty.

Signed-off-by: Nicolin Chen 
Signed-off-by: Daniel Baluta 
---
 sound/soc/fsl/imx-wm8962.c | 40 
 1 file changed, 8 insertions(+), 32 deletions(-)

diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c
index 1b60958..3d894d9 100644
--- a/sound/soc/fsl/imx-wm8962.c
+++ b/sound/soc/fsl/imx-wm8962.c
@@ -33,7 +33,6 @@ struct imx_wm8962_data {
struct snd_soc_card card;
char codec_dai_name[DAI_NAME_SIZE];
char platform_name[DAI_NAME_SIZE];
-   struct clk *codec_clk;
unsigned int clk_frequency;
 };
 
@@ -163,6 +162,7 @@ static int imx_wm8962_probe(struct platform_device *pdev)
struct imx_priv *priv = _priv;
struct i2c_client *codec_dev;
struct imx_wm8962_data *data;
+   struct clk *codec_clk;
int int_port, ext_port;
int ret;
 
@@ -231,19 +231,14 @@ static int imx_wm8962_probe(struct platform_device *pdev)
goto fail;
}
 
-   data->codec_clk = devm_clk_get(_dev->dev, NULL);
-   if (IS_ERR(data->codec_clk)) {
-   ret = PTR_ERR(data->codec_clk);
+   codec_clk = devm_clk_get(_dev->dev, NULL);
+   if (IS_ERR(codec_clk)) {
+   ret = PTR_ERR(codec_clk);
dev_err(_dev->dev, "failed to get codec clk: %d\n", ret);
goto fail;
}
 
-   data->clk_frequency = clk_get_rate(data->codec_clk);
-   ret = clk_prepare_enable(data->codec_clk);
-   if (ret) {
-   dev_err(_dev->dev, "failed to enable codec clk: %d\n", 
ret);
-   goto fail;
-   }
+   data->clk_frequency = clk_get_rate(codec_clk);
 
data->dai.name = "HiFi";
data->dai.stream_name = "HiFi";
@@ -258,10 +253,10 @@ static int imx_wm8962_probe(struct platform_device *pdev)
data->card.dev = >dev;
ret = snd_soc_of_parse_card_name(>card, "model");
if (ret)
-   goto clk_fail;
+   goto fail;
ret = snd_soc_of_parse_audio_routing(>card, "audio-routing");
if (ret)
-   goto clk_fail;
+   goto fail;
data->card.num_links = 1;
data->card.owner = THIS_MODULE;
data->card.dai_link = >dai;
@@ -277,16 +272,9 @@ static int imx_wm8962_probe(struct platform_device *pdev)
ret = devm_snd_soc_register_card(>dev, >card);
if (ret) {
dev_err(>dev, "snd_soc_register_card failed (%d)\n", ret);
-   goto clk_fail;
+   goto fail;
}
 
-   of_node_put(ssi_np);
-   of_node_put(codec_np);
-
-   return 0;
-
-clk_fail:
-   clk_disable_unprepare(data->codec_clk);
 fail:
of_node_put(ssi_np);
of_node_put(codec_np);
@@ -294,17 +282,6 @@ static int imx_wm8962_probe(struct platform_device *pdev)
return ret;
 }
 
-static int imx_wm8962_remove(struct platform_device *pdev)
-{
-   struct snd_soc_card *card = platform_get_drvdata(pdev);
-   struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
-
-   if (!IS_ERR(data->codec_clk))
-   clk_disable_unprepare(data->codec_clk);
-
-   return 0;
-}
-
 static const struct of_device_id imx_wm8962_dt_ids[] = {
{ .compatible = "fsl,imx-audio-wm8962", },
{ /* sentinel */ }
@@ -318,7 +295,6 @@ static struct platform_driver imx_wm8962_driver = {
.of_match_table = imx_wm8962_dt_ids,
},
.probe = imx_wm8962_probe,
-   .remove = imx_wm8962_remove,
 };
 module_platform_driver(imx_wm8962_driver);
 
-- 
2.7.4



kvm: use-after-free function call in kvm_io_bus_destroy

2017-03-23 Thread Dmitry Vyukov
Hello,

I've got the following report while running syzkaller fuzzer on
093b995e3b55a0ae0670226ddfcb05bfbf0099ae. Note the preceding injected
kmalloc failure, most likely it's the root cause.


FAULT_INJECTION: forcing a failure.
name failslab, interval 1, probability 0, space 0, times 0
CPU: 0 PID: 14650 Comm: syz-executor2 Not tainted 4.11.0-rc3+ #364
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x1b8/0x28d lib/dump_stack.c:52
 fail_dump lib/fault-inject.c:45 [inline]
 should_fail+0x78a/0x870 lib/fault-inject.c:154
 should_failslab+0xec/0x120 mm/failslab.c:31
 slab_pre_alloc_hook mm/slab.h:434 [inline]
 slab_alloc mm/slab.c:3394 [inline]
 __do_kmalloc mm/slab.c:3734 [inline]
 __kmalloc+0x220/0x730 mm/slab.c:3745
 kmalloc include/linux/slab.h:495 [inline]
 kvm_io_bus_unregister_dev+0x1a2/0x300
arch/x86/kvm/../../../virt/kvm/kvm_main.c:3594
 kvm_free_pit+0x58/0x110 arch/x86/kvm/i8254.c:727
 kvm_arch_sync_events+0x35/0x40 arch/x86/kvm/x86.c:8078
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:727 [inline]
 kvm_put_kvm+0x27f/0xa70 arch/x86/kvm/../../../virt/kvm/kvm_main.c:761
 kvm_vm_release+0x42/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:772
 __fput+0x327/0x7f0 fs/file_table.c:209
 fput+0x15/0x20 fs/file_table.c:245
 task_work_run+0x1a4/0x270 kernel/task_work.c:116
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x24d/0x2d0 arch/x86/entry/common.c:161
 prepare_exit_to_usermode arch/x86/entry/common.c:191 [inline]
 syscall_return_slowpath+0x3bd/0x460 arch/x86/entry/common.c:260
 entry_SYSCALL_64_fastpath+0xc0/0xc2
RIP: 0033:0x445b79
RSP: 002b:7f6e094bc858 EFLAGS: 0292 ORIG_RAX: 0021
RAX: 001c RBX: 00708000 RCX: 00445b79
RDX:  RSI: 001c RDI: 001b
RBP: 0430 R08:  R09: 
R10:  R11: 0292 R12: 006de4f0
R13: 001c R14:  R15: 001b
==
BUG: KASAN: use-after-free in kvm_io_bus_destroy
include/kvm/iodev.h:72 [inline] at addr 88003bfb7d40
BUG: KASAN: use-after-free in kvm_destroy_vm
arch/x86/kvm/../../../virt/kvm/kvm_main.c:733 [inline] at addr
88003bfb7d40
BUG: KASAN: use-after-free in kvm_put_kvm+0x932/0xa70
arch/x86/kvm/../../../virt/kvm/kvm_main.c:761 at addr 88003bfb7d40
Read of size 8 by task syz-executor2/14650
CPU: 0 PID: 14650 Comm: syz-executor2 Not tainted 4.11.0-rc3+ #364
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x1b8/0x28d lib/dump_stack.c:52
 kasan_object_err+0x1c/0x70 mm/kasan/report.c:166
 print_address_description mm/kasan/report.c:210 [inline]
 kasan_report_error mm/kasan/report.c:294 [inline]
 kasan_report.part.2+0x1be/0x480 mm/kasan/report.c:316
 kasan_report mm/kasan/report.c:337 [inline]
 __asan_report_load8_noabort+0x29/0x30 mm/kasan/report.c:337
 kvm_io_bus_destroy include/kvm/iodev.h:72 [inline]
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:733 [inline]
 kvm_put_kvm+0x932/0xa70 arch/x86/kvm/../../../virt/kvm/kvm_main.c:761
 kvm_vm_release+0x42/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:772
 __fput+0x327/0x7f0 fs/file_table.c:209
 fput+0x15/0x20 fs/file_table.c:245
 task_work_run+0x1a4/0x270 kernel/task_work.c:116
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x24d/0x2d0 arch/x86/entry/common.c:161
 prepare_exit_to_usermode arch/x86/entry/common.c:191 [inline]
 syscall_return_slowpath+0x3bd/0x460 arch/x86/entry/common.c:260
 entry_SYSCALL_64_fastpath+0xc0/0xc2
RIP: 0033:0x445b79
RSP: 002b:7f6e094bc858 EFLAGS: 0292 ORIG_RAX: 0021
RAX: 001c RBX: 00708000 RCX: 00445b79
RDX:  RSI: 001c RDI: 001b
RBP: 0430 R08:  R09: 
R10:  R11: 0292 R12: 006de4f0
R13: 001c R14:  R15: 001b
Object at 88003bfb7d40, in cache kmalloc-512 size: 512
Allocated:
PID = 14650
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x43/0xd0 mm/kasan/kasan.c:517
 set_track mm/kasan/kasan.c:529 [inline]
 kasan_kmalloc+0xbc/0xf0 mm/kasan/kasan.c:620
 kmem_cache_alloc_trace+0x11a/0x720 mm/slab.c:3638
 kmalloc include/linux/slab.h:490 [inline]
 kzalloc include/linux/slab.h:663 [inline]
 kvm_create_pit+0xc2/0x8b0 arch/x86/kvm/i8254.c:656
 kvm_arch_vm_ioctl+0x1339/0x2190 arch/x86/kvm/x86.c:4058
 kvm_vm_ioctl+0x20f/0x1c60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3113
 vfs_ioctl fs/ioctl.c:45 [inline]
 do_vfs_ioctl+0x1af/0x16d0 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 

Re: [PATCH 4/4] tty/serial: sh-sci: remove uneeded IS_ERR_OR_NULL calls

2017-03-23 Thread Uwe Kleine-König
On Thu, Mar 23, 2017 at 01:03:56PM +0100, Geert Uytterhoeven wrote:
> Hi Uwe,
> 
> On Thu, Mar 23, 2017 at 12:11 PM, Uwe Kleine-König
>  wrote:
> >> Make sure to enable all drivers and subsystems you need when building
> >> your kernel. That's always true. And may indeed be hard to debug (e.g. what
> >> kernel options do I need to make systemd work?).
> >
> > It's worse here. If you forget to enable a driver the device isn't bound
> > and that's obvious to diagnose. When ignoring an optional GPIO there
> > might be a device that claims to work but fails to do so. (e.g. you
> > write to memory, write() returns 0, but the data never landed there.)
> >
> >> > write(2) and close(2) succeed most of the time, too. Still it's not a
> >> > good idea to not check the return value. Or let the kernel return
> >> > success unconditionally.
> >>
> >> Writing all bytes passed in the buffer is "optional" in another sense than
> >> an "optional" GPIO: you must retry the write, while you can continue if
> >> an optional GPIO is not present.
> >
> > And that is the point. You can continue *iff* the optional GPIO is not
> > present. The patch in question removes the ability to determine if that
> > GPIO is present and claims it is not present.
> 
> If you forget to enable a driver/subsystem, you sometimes cannot determine
> if the device is present or not neither.
> 
> Hence it boils down to "knowing" if there is a GPIO or not.
> So, when can there be a GPIO?
>   1. The GPIO is described in DT.
>  => Not an issue, as DT GPIO implies GPIOLIB,
>   2. The GPIO is described in legacy platform data.
>  => The platform code should make sure GPIOLIB is selected when needed.
> 
> Issue solved?

I like it better to not rely on platform code to do the right thing.

Maybe we can make gpiod_get_optional look like this:

if (!dev->of_node && isnt_a_acpi_device(dev) && !IS_ENABLED(GPIOLIB))
return NULL;
else
return -ENOSYS;

I don't know how isnt_a_acpi_device looks like, probably it involves
CONFIG_ACPI and/or dev->acpi_node.

This should be safe and still comfortable for legacy platforms, isn't it?

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer

2017-03-23 Thread Chris Wilson
On Thu, Mar 23, 2017 at 12:22:30PM +, Colin King wrote:
> From: Colin Ian King 
> 
> info is being checked to see if it is a null pointer, however, vpgu is
> dereferencing info before this check, leading to a potential null
> pointer dereference.  If info is null, then the error message being
> printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> use a null vpgu as the macro has a sanity check to see if vpgu is null,
> so this is OK.

It is never NULL, it gets checked by its only caller.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


Re: [PATCH] ARM: nommu: access ID_PFR1 only if CPUID scheme

2017-03-23 Thread afzal mohammed
Hi,

On Thu, Mar 23, 2017 at 09:37:48PM +1000, Greg Ungerer wrote:
> Tested-by: Greg Ungerer 

Thanks Greg

Since there was no negative feedback yet, change has been deposited in
rmk's patch system as 8665/1

Regards
afzal 


[RFC PATCH 0/2] Add hstate parameter to huge_pte_offset()

2017-03-23 Thread Punit Agrawal
On architectures that support hugepages composed of contiguous pte as
well as block entries at the same level in the page table,
huge_pte_offset() is not able to determine the right offset to return
when it encounters a swap entry (which is used to mark poisoned as
well as migrated pages in the page table).

huge_pte_offset() needs to know the size of the hugepage at the
requested address to determine the offset to return - the current
entry or the first entry of a set of contiguous hugepages. This came
up while enabling support for memory failure handling on arm64[0].

Patch 1 adds a hstate parameter to huge_pte_offset() to provide
additional information about the target address. It also updates the
signatures (and usage) of huge_pte_offset() for architectures that
override the generic implementation. This patch has been compile
tested on ia64 and x86.

Patch 2 uses the size determined by the parameter added in Patch 1, to
return the correct page table offset.

The patchset is based on top of v4.11-rc3 and the arm64 huge page
cleanup for break-before-make[1].

Thanks,
Punit


[0] http://marc.info/?l=linux-arm-kernel=148772028907925=2
[1] https://www.spinics.net/lists/arm-kernel/msg570422.html

Punit Agrawal (2):
  mm/hugetlb.c: add hstate parameter to huge_pte_offset()
  arm64: hugetlbpages: Correctly handle swap entries in
huge_pte_offset()

 arch/arm64/mm/hugetlbpage.c   | 33 +
 arch/ia64/mm/hugetlbpage.c|  4 ++--
 arch/metag/mm/hugetlbpage.c   |  2 +-
 arch/mips/mm/hugetlbpage.c|  2 +-
 arch/parisc/mm/hugetlbpage.c  |  2 +-
 arch/powerpc/mm/hugetlbpage.c |  2 +-
 arch/s390/mm/hugetlbpage.c|  2 +-
 arch/sh/mm/hugetlbpage.c  |  2 +-
 arch/sparc/mm/hugetlbpage.c   |  2 +-
 arch/tile/mm/hugetlbpage.c|  2 +-
 arch/x86/mm/hugetlbpage.c |  2 +-
 fs/userfaultfd.c  |  7 +--
 include/linux/hugetlb.h   |  2 +-
 mm/hugetlb.c  | 18 +-
 mm/page_vma_mapped.c  |  2 +-
 mm/pagewalk.c |  2 +-
 16 files changed, 45 insertions(+), 41 deletions(-)

-- 
2.11.0



Re: [PATCH 1/5] w83627ehf: Use hwmon_device_register_with_info and sensor groups

2017-03-23 Thread Guenter Roeck

On 03/23/2017 06:05 AM, Peter Hüwe wrote:

This is of course v2 of the series
Forgot to add it to git-send-email, sorry.
Shall I resend with v2 in subject?



No, it's ok. At least you have a change log :-).

Thanks,
Guenter



Re: [PATCH v1] mfd: core: Preserve PLATFORM_DEVID_NONE

2017-03-23 Thread Andy Shevchenko
On Thu, 2017-03-23 at 11:21 +, Lee Jones wrote:
> On Thu, 16 Mar 2017, Andy Shevchenko wrote:
> 
> > There is a potential flaw if cell has id > 0 and is going to be
> > registered with PLATFORM_DEVID_NONE.
> > 
> > Ignore if PLATFORM_DEVID_NONE is supplied.
> 
> This is a substantial change to a pretty tried and tested piece of
> sub-system code.  Can you put some more meat on the bones in the
> commit log, and include examples.

Example in pseudo code:

cells = {
 [0] = { .id = 0, .name = "moduleX", },
 [1] = { .id = 1, .name = "moduleY", },
 [2] = { .id = 2, .name = "moduleZ", },
 ...
};

mfd_add_devices(..., PLATFORM_DEVID_NONE, cells, ARRAY_SIZE(cells),
...);

Output (names of the devices in the drivers):
"moduleX"
"moduleY.0"
"moduleX.1"

Desired output:
"moduleX"
"moduleY"
"moduleZ"

Is it by design?

> 
> > Signed-off-by: Andy Shevchenko 
> > ---
> >  drivers/mfd/mfd-core.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> > index c57e407020f1..c9583f895058 100644
> > --- a/drivers/mfd/mfd-core.c
> > +++ b/drivers/mfd/mfd-core.c
> > @@ -149,7 +149,7 @@ static int mfd_add_device(struct device *parent,
> > int id,
> >     int platform_id;
> >     int r;
> >  
> > -   if (id == PLATFORM_DEVID_AUTO)
> > +   if (id < 0)
> >     platform_id = id;
> >     else
> >     platform_id = id + cell->id;
> 
> 

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH 11/11] staging: speakup: Fix alignment with parenthesis.

2017-03-23 Thread Greg KH
On Tue, Mar 21, 2017 at 05:12:35PM +0530, Arushi Singhal wrote:
> This patch fixes the warnings reported by checkpatch.pl
> for please use a blank line after function/struct/union/enum
> declarations.

That's not what this patch does at all!

Please be more careful.

greg k-h


[PATCH] nvmem: imx-ocotp: fix usage of "dev" pointers

2017-03-23 Thread Richard Leitner
Assign the correct dev pointer to struct ocotp_priv during probe. This
is needed to display dev_* messages correctly. Furthermore harmonize
the usage of dev (instead of >dev) in the probe function.

Signed-off-by: Richard Leitner 
---
 drivers/nvmem/imx-ocotp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
index b8ca1e6..549177d 100644
--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -90,12 +90,14 @@ static int imx_ocotp_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
 
+   priv->dev = dev;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->base = devm_ioremap_resource(dev, res);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
 
-   priv->clk = devm_clk_get(>dev, NULL);
+   priv->clk = devm_clk_get(dev, NULL);
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
 
-- 
2.1.4



ata: WARNING in ata_qc_issue

2017-03-23 Thread Dmitry Vyukov
Hello,

The following program triggers WARNING in ata_qc_issue:
https://gist.githubusercontent.com/dvyukov/3503afce181b7d48dabb421e10e70b00/raw/d049bd2128a8b1089497beb6104ba48c5550b4a8/gistfile1.txt

[ cut here ]
WARNING: CPU: 3 PID: 2956 at drivers/ata/libata-core.c:5317
ata_qc_issue+0xd14/0x1040 drivers/ata/libata-core.c:5316
CPU: 3 PID: 2956 Comm: a.out Not tainted 4.11.0-rc3+ #365
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x1b8/0x28d lib/dump_stack.c:52
 panic+0x20c/0x423 kernel/panic.c:180
 __warn+0x1c4/0x1e0 kernel/panic.c:541
 warn_slowpath_null+0x2c/0x40 kernel/panic.c:584
 ata_qc_issue+0xd14/0x1040 drivers/ata/libata-core.c:5316
 ata_scsi_translate+0x34a/0x5e0 drivers/ata/libata-scsi.c:2021
 __ata_scsi_queuecmd drivers/ata/libata-scsi.c:4249 [inline]
 ata_scsi_queuecmd+0x2ae/0x660 drivers/ata/libata-scsi.c:4298
 scsi_dispatch_cmd+0x43e/0xb70 drivers/scsi/scsi_lib.c:1665
 scsi_request_fn+0x13dc/0x1ec0 drivers/scsi/scsi_lib.c:1800
 __blk_run_queue_uncond block/blk-core.c:305 [inline]
 __blk_run_queue+0xe3/0x150 block/blk-core.c:323
 __elv_add_request+0x494/0xce0 block/elevator.c:677
 blk_execute_rq_nowait+0x214/0x370 block/blk-exec.c:78
 blk_execute_rq+0x1ca/0x280 block/blk-exec.c:103
 sg_scsi_ioctl+0x3d0/0x7f0 block/scsi_ioctl.c:510
 sg_ioctl+0x1fdd/0x2f00 drivers/scsi/sg.c:1075
 vfs_ioctl fs/ioctl.c:45 [inline]
 do_vfs_ioctl+0x1af/0x16d0 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 entry_SYSCALL_64_fastpath+0x1f/0xc2
RIP: 0033:0x434cd9
RSP: 002b:7ffc5cd86308 EFLAGS: 0286 ORIG_RAX: 0010
RAX: ffda RBX: 004002b0 RCX: 00434cd9
RDX: 20001000 RSI: 0001 RDI: 0003
RBP: 0086 R08:  R09: 
R10:  R11: 0286 R12: 
R13: 00401a30 R14: 00401ac0 R15: 

On commit 093b995e3b55a0ae0670226ddfcb05bfbf0099ae


[PATCH] auxdisplay: hd44780: Fix DT properties to include units of measurement

2017-03-23 Thread Geert Uytterhoeven
DT properties specifying physical properties should contain appropriate
suffices indicating the units of measurement.

Hence amend the HD44780 DT bindings to add "chars" suffixes to the
"display-height" and "display-width" properties, and update the driver
to parse them.

Fixes: dd9502a9e9156dd8 ("dt-bindings: auxdisplay: Add bindings for Hitachi 
HD44780")
Fixes: d47d88361feea2ce ("auxdisplay: Add HD44780 Character LCD support")
Signed-off-by: Geert Uytterhoeven 
---
Against char-misc-next

 Documentation/devicetree/bindings/auxdisplay/hit,hd44780.txt | 11 ++-
 drivers/auxdisplay/hd44780.c |  5 +++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.txt 
b/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.txt
index ee4054da458d412f..2aa24b8899236882 100644
--- a/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.txt
+++ b/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.txt
@@ -15,8 +15,8 @@ Required properties:
   - rs-gpios: Must contain a GPIO specifier, referring to the GPIO pin
 connected to the "RS" (Register Select) signal line of the LCD Controller's
 bus interface,
-  - display-height: Height of the display, in character cells,
-  - display-width: Width of the display, in character cells.
+  - display-height-chars: Height of the display, in character cells,
+  - display-width-chars: Width of the display, in character cells.
 
 Optional properties:
   - rw-gpios: Must contain a GPIO specifier, referring to the GPIO pin
@@ -25,7 +25,8 @@ Optional properties:
   - backlight-gpios: Must contain a GPIO specifier, referring to the GPIO pin
 used for enabling the LCD's backlight,
   - internal-buffer-width: Internal buffer width (default is 40 for displays
-with 1 or 2 lines, and display-width for displays with more than 2 lines).
+with 1 or 2 lines, and display-width-chars for displays with more than 2
+lines).
 
 Example:
 
@@ -39,6 +40,6 @@ Example:
enable-gpios = < 4 GPIO_ACTIVE_HIGH>;
rs-gpios = < 5 GPIO_ACTIVE_HIGH>;
 
-   display-height = <2>;
-   display-width = <16>;
+   display-height-chars = <2>;
+   display-width-chars = <16>;
};
diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c
index 1665ac6ef9ffcb31..036eec40428943b7 100644
--- a/drivers/auxdisplay/hd44780.c
+++ b/drivers/auxdisplay/hd44780.c
@@ -264,10 +264,11 @@ static int hd44780_probe(struct platform_device *pdev)
}
 
/* Required properties */
-   ret = device_property_read_u32(dev, "display-height", >height);
+   ret = device_property_read_u32(dev, "display-height-chars",
+  >height);
if (ret)
goto fail;
-   ret = device_property_read_u32(dev, "display-width", >width);
+   ret = device_property_read_u32(dev, "display-width-chars", >width);
if (ret)
goto fail;
 
-- 
2.7.4



[PATCH v2] staging:speakup: Fix alignment with parenthesis.

2017-03-23 Thread Arushi Singhal
Fix checkpatch issues: "CHECK: Alignment should match open parenthesis".

Signed-off-by: Arushi Singhal 
---
changes in v2
 - change the commit message.

 drivers/staging/speakup/speakup_apollo.c | 2 +-
 drivers/staging/speakup/speakup_decext.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/speakup/speakup_apollo.c 
b/drivers/staging/speakup/speakup_apollo.c
index 9cfdbbfb9742..6ad83dc642c4 100644
--- a/drivers/staging/speakup/speakup_apollo.c
+++ b/drivers/staging/speakup/speakup_apollo.c
@@ -173,7 +173,7 @@ static void do_catch_up(struct spk_synth *synth)
if (!synth->io_ops->synth_out(synth, ch)) {
outb(UART_MCR_DTR, speakup_info.port_tts + UART_MCR);
outb(UART_MCR_DTR | UART_MCR_RTS,
-   speakup_info.port_tts + UART_MCR);
+speakup_info.port_tts + UART_MCR);
schedule_timeout(msecs_to_jiffies(full_time_val));
continue;
}
diff --git a/drivers/staging/speakup/speakup_decext.c 
b/drivers/staging/speakup/speakup_decext.c
index 929a28d618dc..c564bf8e1531 100644
--- a/drivers/staging/speakup/speakup_decext.c
+++ b/drivers/staging/speakup/speakup_decext.c
@@ -206,11 +206,11 @@ static void do_catch_up(struct spk_synth *synth)
if (!in_escape)
synth->io_ops->synth_out(synth, 
PROCSPEECH);
spin_lock_irqsave(_info.spinlock,
-   flags);
+ flags);
jiffy_delta_val = jiffy_delta->u.n.value;
delay_time_val = delay_time->u.n.value;
spin_unlock_irqrestore(_info.spinlock,
-   flags);
+  flags);
schedule_timeout(msecs_to_jiffies
 (delay_time_val));
jiff_max = jiffies + jiffy_delta_val;
-- 
2.11.0



[PATCH 2/8] pinctrl: meson: gxbb: add spdif output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c 
b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
index 8d5dd4772042..9bae2e3968af 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
@@ -240,6 +240,8 @@ static const unsigned int i2s_out_ch23_y_pins[] = { 
PIN(GPIOY_8, EE_OFF) };
 static const unsigned int i2s_out_ch45_y_pins[]= { PIN(GPIOY_9, 
EE_OFF) };
 static const unsigned int i2s_out_ch67_y_pins[]= { PIN(GPIOY_10, 
EE_OFF) };
 
+static const unsigned int spdif_out_y_pins[]   = { PIN(GPIOY_12, EE_OFF) };
+
 static const struct pinctrl_pin_desc meson_gxbb_aobus_pins[] = {
MESON_PIN(GPIOAO_0, 0),
MESON_PIN(GPIOAO_1, 0),
@@ -285,6 +287,9 @@ static const unsigned int i2s_out_ch01_ao_pins[] = { 
PIN(GPIOAO_11, 0) };
 static const unsigned int i2s_out_ch23_ao_pins[] = { PIN(GPIOAO_12, 0) };
 static const unsigned int i2s_out_ch45_ao_pins[] = { PIN(GPIOAO_13, 0) };
 
+static const unsigned int spdif_out_ao_6_pins[]= { PIN(GPIOAO_6, 0) };
+static const unsigned int spdif_out_ao_13_pins[] = { PIN(GPIOAO_13, 0) };
+
 static struct meson_pmx_group meson_gxbb_periphs_groups[] = {
GPIO_GROUP(GPIOZ_0, EE_OFF),
GPIO_GROUP(GPIOZ_1, EE_OFF),
@@ -440,6 +445,7 @@ static struct meson_pmx_group meson_gxbb_periphs_groups[] = 
{
GROUP(i2s_out_ch23_y,   1,  5),
GROUP(i2s_out_ch45_y,   1,  6),
GROUP(i2s_out_ch67_y,   1,  7),
+   GROUP(spdif_out_y,  1,  9),
 
/* Bank Z */
GROUP(eth_mdio, 6,  1),
@@ -543,6 +549,8 @@ static struct meson_pmx_group meson_gxbb_aobus_groups[] = {
GROUP(i2s_out_ch01_ao,  0,  27),
GROUP(i2s_out_ch23_ao,  1,  0),
GROUP(i2s_out_ch45_ao,  1,  1),
+   GROUP(spdif_out_ao_6,   0,  16),
+   GROUP(spdif_out_ao_13,  0,  4),
 };
 
 static const char * const gpio_periphs_groups[] = {
@@ -676,6 +684,10 @@ static const char * const i2s_out_groups[] = {
"i2s_out_ch23_y", "i2s_out_ch45_y", "i2s_out_ch67_y",
 };
 
+static const char * const spdif_out_groups[] = {
+   "spdif_out_y",
+};
+
 static const char * const gpio_aobus_groups[] = {
"GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3", "GPIOAO_4",
"GPIOAO_5", "GPIOAO_6", "GPIOAO_7", "GPIOAO_8", "GPIOAO_9",
@@ -723,6 +735,10 @@ static const char * const i2s_out_ao_groups[] = {
"i2s_out_ch01_ao", "i2s_out_ch23_ao", "i2s_out_ch45_ao",
 };
 
+static const char * const spdif_out_ao_groups[] = {
+   "spdif_out_ao_6", "spdif_out_ao_13",
+};
+
 static struct meson_pmx_func meson_gxbb_periphs_functions[] = {
FUNCTION(gpio_periphs),
FUNCTION(emmc),
@@ -747,6 +763,7 @@ static struct meson_pmx_func meson_gxbb_periphs_functions[] 
= {
FUNCTION(hdmi_hpd),
FUNCTION(hdmi_i2c),
FUNCTION(i2s_out),
+   FUNCTION(spdif_out),
 };
 
 static struct meson_pmx_func meson_gxbb_aobus_functions[] = {
@@ -761,6 +778,7 @@ static struct meson_pmx_func meson_gxbb_aobus_functions[] = 
{
FUNCTION(pwm_ao_a_12),
FUNCTION(pwm_ao_b),
FUNCTION(i2s_out_ao),
+   FUNCTION(spdif_out_ao),
 };
 
 static struct meson_bank meson_gxbb_periphs_banks[] = {
-- 
2.9.3



[PATCH 3/8] pinctrl: meson: gxl: add i2s output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 drivers/pinctrl/meson/pinctrl-meson-gxl.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c 
b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
index a0a7936f8f0d..a022a9e49113 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxl.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
@@ -212,6 +212,14 @@ static const unsigned int hdmi_hpd_pins[]  = { 
PIN(GPIOH_0, EE_OFF) };
 static const unsigned int hdmi_sda_pins[]  = { PIN(GPIOH_1, EE_OFF) };
 static const unsigned int hdmi_scl_pins[]  = { PIN(GPIOH_2, EE_OFF) };
 
+static const unsigned int i2s_am_clk_pins[]= { PIN(GPIOH_6, EE_OFF) };
+static const unsigned int i2s_out_ao_clk_pins[]= { PIN(GPIOH_7, 
EE_OFF) };
+static const unsigned int i2s_out_lr_clk_pins[]= { PIN(GPIOH_8, 
EE_OFF) };
+static const unsigned int i2s_out_ch01_pins[]  = { PIN(GPIOH_9, EE_OFF) };
+static const unsigned int i2s_out_ch23_z_pins[]= { PIN(GPIOZ_5, 
EE_OFF) };
+static const unsigned int i2s_out_ch45_z_pins[]= { PIN(GPIOZ_6, 
EE_OFF) };
+static const unsigned int i2s_out_ch67_z_pins[]= { PIN(GPIOZ_7, 
EE_OFF) };
+
 static const struct pinctrl_pin_desc meson_gxl_aobus_pins[] = {
MESON_PIN(GPIOAO_0, 0),
MESON_PIN(GPIOAO_1, 0),
@@ -241,6 +249,9 @@ static const unsigned int pwm_ao_a_8_pins[] = { 
PIN(GPIOAO_8, 0) };
 
 static const unsigned int pwm_ao_b_pins[]  = { PIN(GPIOAO_9, 0) };
 
+static const unsigned int i2s_out_ch23_ao_pins[] = { PIN(GPIOAO_8, EE_OFF) };
+static const unsigned int i2s_out_ch45_ao_pins[] = { PIN(GPIOAO_9, EE_OFF) };
+
 static struct meson_pmx_group meson_gxl_periphs_groups[] = {
GPIO_GROUP(GPIOZ_0, EE_OFF),
GPIO_GROUP(GPIOZ_1, EE_OFF),
@@ -384,11 +395,18 @@ static struct meson_pmx_group meson_gxl_periphs_groups[] 
= {
GROUP(eth_txd2, 4,  11),
GROUP(eth_txd3, 4,  10),
GROUP(pwm_c,3,  20),
+   GROUP(i2s_out_ch23_z,   3,  26),
+   GROUP(i2s_out_ch45_z,   3,  25),
+   GROUP(i2s_out_ch67_z,   3,  24),
 
/* Bank H */
GROUP(hdmi_hpd, 6,  31),
GROUP(hdmi_sda, 6,  30),
GROUP(hdmi_scl, 6,  29),
+   GROUP(i2s_am_clk,   6,  26),
+   GROUP(i2s_out_ao_clk,   6,  25),
+   GROUP(i2s_out_lr_clk,   6,  24),
+   GROUP(i2s_out_ch01, 6,  23),
 
/* Bank DV */
GROUP(uart_tx_b,2,  16),
@@ -453,6 +471,8 @@ static struct meson_pmx_group meson_gxl_aobus_groups[] = {
GROUP(pwm_ao_a_3,   0,  22),
GROUP(pwm_ao_a_8,   0,  17),
GROUP(pwm_ao_b, 0,  3),
+   GROUP(i2s_out_ch23_ao,  1,  0),
+   GROUP(i2s_out_ch45_ao,  1,  1),
 };
 
 static const char * const gpio_periphs_groups[] = {
@@ -569,6 +589,11 @@ static const char * const hdmi_i2c_groups[] = {
"hdmi_sda", "hdmi_scl",
 };
 
+static const char * const i2s_out_groups[] = {
+   "i2s_am_clk", "i2s_out_ao_clk", "i2s_out_lr_clk",
+   "i2s_out_ch01", "i2s_out_ch23_z", "i2s_out_ch45_z", "i2s_out_ch67_z",
+};
+
 static const char * const gpio_aobus_groups[] = {
"GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3", "GPIOAO_4",
"GPIOAO_5", "GPIOAO_6", "GPIOAO_7", "GPIOAO_8", "GPIOAO_9",
@@ -594,6 +619,10 @@ static const char * const pwm_ao_b_groups[] = {
"pwm_ao_b",
 };
 
+static const char * const i2s_out_ao_groups[] = {
+   "i2s_out_ch23_ao", "i2s_out_ch45_ao",
+};
+
 static struct meson_pmx_func meson_gxl_periphs_functions[] = {
FUNCTION(gpio_periphs),
FUNCTION(emmc),
@@ -615,6 +644,7 @@ static struct meson_pmx_func meson_gxl_periphs_functions[] 
= {
FUNCTION(pwm_f),
FUNCTION(hdmi_hpd),
FUNCTION(hdmi_i2c),
+   FUNCTION(i2s_out),
 };
 
 static struct meson_pmx_func meson_gxl_aobus_functions[] = {
@@ -624,6 +654,7 @@ static struct meson_pmx_func meson_gxl_aobus_functions[] = {
FUNCTION(remote_input_ao),
FUNCTION(pwm_ao_a),
FUNCTION(pwm_ao_b),
+   FUNCTION(i2s_out_ao),
 };
 
 static struct meson_bank meson_gxl_periphs_banks[] = {
-- 
2.9.3



[PATCH 5/8] ARM64: dts: meson-gxbb: add i2s output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 63 +
 1 file changed, 63 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi 
b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 04b3324bc132..5ce70e1ec9ae 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -203,6 +203,48 @@
function = "pwm_ao_b";
};
};
+
+   i2s_am_clk_pins: i2s_am_clk {
+   mux {
+   groups = "i2s_am_clk";
+   function = "i2s_out_ao";
+   };
+   };
+
+   i2s_out_ao_clk_pins: i2s_out_ao_clk {
+   mux {
+   groups = "i2s_out_ao_clk";
+   function = "i2s_out_ao";
+   };
+   };
+
+   i2s_out_lr_clk_pins: i2s_out_lr_clk {
+   mux {
+   groups = "i2s_out_lr_clk";
+   function = "i2s_out_ao";
+   };
+   };
+
+   i2s_out_ch01_ao_pins: i2s_out_ch01_ao {
+   mux {
+   groups = "i2s_out_ch01_ao";
+   function = "i2s_out_ao";
+   };
+   };
+
+   i2s_out_ch23_ao_pins: i2s_out_ch23_ao {
+   mux {
+   groups = "i2s_out_ch23_ao";
+   function = "i2s_out_ao";
+   };
+   };
+
+   i2s_out_ch45_ao_pins: i2s_out_ch45_ao {
+   mux {
+   groups = "i2s_out_ch45_ao";
+   function = "i2s_out_ao";
+   };
+   };
};
 
clkc_AO: clock-controller@040 {
@@ -467,6 +509,27 @@
function = "hdmi_i2c";
};
};
+
+   i2sout_ch23_y_pins: i2sout_ch23_y {
+   mux {
+   groups = "i2sout_ch23_y";
+   function = "i2s_out";
+   };
+   };
+
+   i2sout_ch45_y_pins: i2sout_ch45_y {
+   mux {
+   groups = "i2sout_ch45_y";
+   function = "i2s_out";
+   };
+   };
+
+   i2sout_ch67_y_pins: i2sout_ch67_y {
+   mux {
+   groups = "i2sout_ch67_y";
+   function = "i2s_out";
+   };
+   };
};
 };
 
-- 
2.9.3



[PATCH 4/8] pinctrl: meson: gxl: add spdif output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 drivers/pinctrl/meson/pinctrl-meson-gxl.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c 
b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
index a022a9e49113..a5a9b4f78636 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxl.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
@@ -220,6 +220,8 @@ static const unsigned int i2s_out_ch23_z_pins[] = { 
PIN(GPIOZ_5, EE_OFF) };
 static const unsigned int i2s_out_ch45_z_pins[]= { PIN(GPIOZ_6, 
EE_OFF) };
 static const unsigned int i2s_out_ch67_z_pins[]= { PIN(GPIOZ_7, 
EE_OFF) };
 
+static const unsigned int spdif_out_h_pins[]   = { PIN(GPIOH_4, EE_OFF) };
+
 static const struct pinctrl_pin_desc meson_gxl_aobus_pins[] = {
MESON_PIN(GPIOAO_0, 0),
MESON_PIN(GPIOAO_1, 0),
@@ -252,6 +254,9 @@ static const unsigned int pwm_ao_b_pins[]   = { 
PIN(GPIOAO_9, 0) };
 static const unsigned int i2s_out_ch23_ao_pins[] = { PIN(GPIOAO_8, EE_OFF) };
 static const unsigned int i2s_out_ch45_ao_pins[] = { PIN(GPIOAO_9, EE_OFF) };
 
+static const unsigned int spdif_out_ao_6_pins[]= { PIN(GPIOAO_6, 
EE_OFF) };
+static const unsigned int spdif_out_ao_9_pins[]= { PIN(GPIOAO_9, 
EE_OFF) };
+
 static struct meson_pmx_group meson_gxl_periphs_groups[] = {
GPIO_GROUP(GPIOZ_0, EE_OFF),
GPIO_GROUP(GPIOZ_1, EE_OFF),
@@ -407,6 +412,7 @@ static struct meson_pmx_group meson_gxl_periphs_groups[] = {
GROUP(i2s_out_ao_clk,   6,  25),
GROUP(i2s_out_lr_clk,   6,  24),
GROUP(i2s_out_ch01, 6,  23),
+   GROUP(spdif_out_h,  6,  28),
 
/* Bank DV */
GROUP(uart_tx_b,2,  16),
@@ -473,6 +479,8 @@ static struct meson_pmx_group meson_gxl_aobus_groups[] = {
GROUP(pwm_ao_b, 0,  3),
GROUP(i2s_out_ch23_ao,  1,  0),
GROUP(i2s_out_ch45_ao,  1,  1),
+   GROUP(spdif_out_ao_6,   0,  16),
+   GROUP(spdif_out_ao_9,   0,  4),
 };
 
 static const char * const gpio_periphs_groups[] = {
@@ -594,6 +602,10 @@ static const char * const i2s_out_groups[] = {
"i2s_out_ch01", "i2s_out_ch23_z", "i2s_out_ch45_z", "i2s_out_ch67_z",
 };
 
+static const char * const spdif_out_groups[] = {
+   "spdif_out_h",
+};
+
 static const char * const gpio_aobus_groups[] = {
"GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3", "GPIOAO_4",
"GPIOAO_5", "GPIOAO_6", "GPIOAO_7", "GPIOAO_8", "GPIOAO_9",
@@ -623,6 +635,10 @@ static const char * const i2s_out_ao_groups[] = {
"i2s_out_ch23_ao", "i2s_out_ch45_ao",
 };
 
+static const char * const spdif_out_ao_groups[] = {
+   "spdif_out_ao_6", "spdif_out_ao_9",
+};
+
 static struct meson_pmx_func meson_gxl_periphs_functions[] = {
FUNCTION(gpio_periphs),
FUNCTION(emmc),
@@ -645,6 +661,7 @@ static struct meson_pmx_func meson_gxl_periphs_functions[] 
= {
FUNCTION(hdmi_hpd),
FUNCTION(hdmi_i2c),
FUNCTION(i2s_out),
+   FUNCTION(spdif_out),
 };
 
 static struct meson_pmx_func meson_gxl_aobus_functions[] = {
@@ -655,6 +672,7 @@ static struct meson_pmx_func meson_gxl_aobus_functions[] = {
FUNCTION(pwm_ao_a),
FUNCTION(pwm_ao_b),
FUNCTION(i2s_out_ao),
+   FUNCTION(spdif_out_ao),
 };
 
 static struct meson_bank meson_gxl_periphs_banks[] = {
-- 
2.9.3



Re: Dell Inspiron 5558/0VNM2T hangs at resume from suspend when USB 3 is enabled

2017-03-23 Thread Mathias Nyman

On 22.03.2017 19:51, Mathias Nyman wrote:

On 22.03.2017 00:52, Diego Viola wrote:

On Tue, Mar 21, 2017 at 12:29 PM, Diego Viola  wrote:

On Tue, Mar 21, 2017 at 10:04 AM, Diego Viola  wrote:

On Mon, Mar 20, 2017 at 8:15 PM, Diego Viola  wrote:

On Mon, Mar 20, 2017 at 3:27 PM, Diego Viola  wrote:

On Mon, Mar 20, 2017 at 1:32 PM, Mathias Nyman
 wrote:

On 20.03.2017 17:39, Diego Viola wrote:


On Mon, Mar 20, 2017 at 11:21 AM, Mathias Nyman
 wrote:


On 19.03.2017 23:29, Diego Viola wrote:



Still a problem with 4.11.0-rc2-ARCH+


xhci tracing can be added with:

mount -t debugfs none /sys/kernel/debug
echo xhci-hcd >> /sys/kernel/debug/tracing/set_event


Here's the log I was able to obtain today, dmesg + ftrace at the time
of the crash:

https://bugzilla.kernel.org/attachment.cgi?id=255419

USB keyboard and mouse was plugged when I reproduced this.

Please let me know if you need more info.



Thanks, I'm looking at the logs and so far the most suspicious looking entry is:

[  257.060941] rtsx_usb-254 0 119946155us : xhci_urb_enqueue: 
ep1out-bulk: urb 880105a93300 pipe 3221259520 length 0/12 sgs 0/0 stream 0 
flags 0001
[  257.063601] rtsx_usb-254 0 119946162us : xhci_urb_enqueue: 
ep0out-control: urb 880105a93300 pipe 2147484928 length 0/0 sgs 0/0 stream 
0 flags 0010

It enqueues the same URB, without ever giving it back or actually queuing any 
trbs for
the urb, wel,l it might just fail to enqueue it in the first place.

I need to search for a URB that has been dequeued but never given back in the 
trace


Ok, found a much more likely candidate:

[  258.004078] kworker/-544 0d..1 121599183us : xhci_urb_dequeue: 
ep1out-bulk: urb 880105a930c0 pipe 3221259520...

We try to kill this URB "880105a930c0", twice, and its never given back.
Trace is missing "xhci_dbg_cancel_urb: Cancel URB..." entry in log after
xhci_urb_dequeue, so it never got added to the list for cancellation in xhci 
driver.

xhci_urb_dequeue() has one place where it just returns an error without
giving back the urb or queuing it for cancellation.
This is in my opinion a bug in xhci_urb_dequeue()

rtsx_usb_ms is a good test for usb, it seems to be constantly queuing urbs at 
all
inappropriate times.

If I write a patch can you try it out?

-Mathias





Re: [RFC PATCH v0.2] PCI: Add support for tango PCIe host bridge

2017-03-23 Thread Mason
On 23/03/2017 15:22, Marc Zyngier wrote:

> On 23/03/17 13:05, Mason wrote:
> 
>> +#define MSI_COUNT 32
> 
> Is this something that is hardcoded? Unlikely to ever change?

The host bridge actually supports 256 MSIs.

IIUC, what you suggested on IRC is that I support 256 in the driver,
and only read the status for *enabled* MSIs.

Pseudo-code:

for every 32-bit blob in the enabled bitmap
  if the value is non-zero
lookup the corresponding status reg

Problem is that a BITMAP is unsigned long (as you point out below).
So I'm not sure how to iterate 32-bits at a time over the BITMAP.




>> +static void tango_msi_isr(struct irq_desc *desc)
>> +{
>> +struct irq_chip *chip = irq_desc_get_chip(desc);
>> +struct tango_pcie *pcie;
>> +unsigned long status, virq;
>> +int pos;
>> +
>> +chained_irq_enter(chip, desc);
>> +pcie = irq_desc_get_handler_data(desc);
>> +
>> +status = readl_relaxed(pcie->msi_status);
> 
> Please use types that unambiguously match that of the MMIO accessor (u32
> in this case). On a 64bit system, unsigned long is likely to be 64bit.
> You can assign it to an unsigned long before calling the
> for_each_set_bit operator.

OK. I'm aware that unsigned long is 64 bits on sane 64b platforms,
but since extending u32 to u64 would pad with zeros, I didn't expect
this to be an issue. I will change the code. Note: I copied the
code from the Altera driver.

>> +writel_relaxed(status, pcie->msi_status); /* clear IRQs */
> 
> Why isn't this your irq_ack method instead of open-coding it?

I based my driver on the Altera driver, and I did it like
I thought they did. I will try fixing my code.


>> +for_each_set_bit(pos, , MSI_COUNT) {
>> +virq = irq_find_mapping(pcie->irq_domain, pos);
>> +if (virq)
>> +generic_handle_irq(virq);
>> +else
>> +pr_err("Unhandled MSI: %d\n", pos);
> 
> Please rate-limit this.

I'll use pr_err_ratelimited


>> +static struct msi_domain_info msi_domain_info = {
>> +.flags  = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS,
> 
> No support for MSI-X? Why?

Good question.
https://en.wikipedia.org/wiki/Message_Signaled_Interrupts#MSI-X
My controller supports a single doorbell, and only 256 MSIs.
I thought that meant it didn't support MSI-X.


>> +static int tango_irq_domain_alloc(struct irq_domain *domain, unsigned int 
>> virq,
>> +unsigned int nr_irqs, void *args)
>> +{
>> +struct tango_pcie *pcie = domain->host_data;
>> +int pos, err = 0;
>> +u32 mask;
>> +
>> +if (nr_irqs != 1) /* When does that happen? */
>> +return -EINVAL;
> 
> Only if the end-point wants to use Multi-MSI. You don't advertise
> support for it, so it should never happen.

Should I keep the test or remove it?


>> +mutex_lock(>lock);
>> +
>> +mask = readl_relaxed(pcie->msi_mask);
> 
> Do you really need to read this from the HW each time you allocate an
> interrupt? That feels pretty crazy. You're much better off having an
> in-memory bitmap that will make things more efficient, and avoid the
> following bug...
> 
>> +pos = find_first_zero_bit(, MSI_COUNT);
> 
> ... where using a u32 as a bitmap is a very bad idea (because not the
> whole world is a 32bit, little endian platform).

I understand your point. This ties in to the ISR discussion.


>> +if (pos < MSI_COUNT)
>> +writel(mask | BIT(pos), pcie->msi_mask);
> 
> And it would make a lot more sense to move this write (which should be
> relaxed) to irq_unmask. Also, calling msi_mask for something that is an
> enable register is a bit counter intuitive.

I don't have as much experience as you.
I just used the names in the HW documentation.
I think it is the "mask" (as in bitmap) of enabled MSIs.
I will change "mask" to "enable".

Are you saying I should not use pci_msi_mask_irq and pci_msi_unmask_irq,
but register custom implementations? I should still call these in my
custom functions, right?


>> +else
>> +err = -ENOSPC;
>> +
>> +mutex_unlock(>lock);
>> +
>> +irq_domain_set_info(domain, virq, pos, _msi_chip,
>> +domain->host_data, handle_simple_irq, NULL, NULL);
> 
> And here, you're polluting the domain even if you failed to allocate the
> interrupt.

This bug is 100% mine. Will fix.

>> +
>> +return err;
>> +}
>> +
>> +static void tango_irq_domain_free(struct irq_domain *domain,
>> +   unsigned int virq, unsigned int nr_irqs)
>> +{
>> +struct irq_data *d = irq_domain_get_irq_data(domain, virq);
>> +struct tango_pcie *pcie = irq_data_get_irq_chip_data(d);
>> +int pos = d->hwirq;
>> +u32 mask;
>> +
>> +mutex_lock(>lock);
>> +
>> +mask = readl(pcie->msi_mask);
>> +writel(mask & ~BIT(pos), pcie->msi_mask);
> 
> Same as above, please move this to the irq_unmask method.

This one should be irq_mask, no?

Even If I move the MMIO write, it should be done under lock,
I 

[PATCH v5 1/4] syscalls: Restore address limit after a syscall

2017-03-23 Thread Thomas Garnier
This patch ensures a syscall does not return to user-mode with a kernel
address limit. If that happened, a process can corrupt kernel-mode
memory and elevate privileges.

For example, it would mitigation this bug:

- https://bugs.chromium.org/p/project-zero/issues/detail?id=990

The CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE option is also
added so each architecture can optimize this change.

Signed-off-by: Thomas Garnier 
---
Based on next-20170322
---
 arch/s390/Kconfig|  1 +
 include/linux/syscalls.h | 26 +-
 init/Kconfig |  7 +++
 kernel/sys.c |  7 +++
 4 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index a2dcef0aacc7..b73f5b87bc99 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -103,6 +103,7 @@ config S390
select ARCH_INLINE_WRITE_UNLOCK_BH
select ARCH_INLINE_WRITE_UNLOCK_IRQ
select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
+   select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE
select ARCH_SAVE_PAGE_KEYS if HIBERNATION
select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_SUPPORTS_NUMA_BALANCING
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 980c3c9b06f8..f9ff80fa92ff 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -191,6 +191,27 @@ extern struct trace_event_functions 
exit_syscall_print_funcs;
SYSCALL_METADATA(sname, x, __VA_ARGS__) \
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
 
+
+/*
+ * Called before coming back to user-mode. Returning to user-mode with an
+ * address limit different than USER_DS can allow to overwrite kernel memory.
+ */
+static inline void verify_pre_usermode_state(void) {
+   BUG_ON(!segment_eq(get_fs(), USER_DS));
+}
+
+#ifndef CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE
+#define __CHECK_USER_CALLER() \
+   bool user_caller = segment_eq(get_fs(), USER_DS)
+#define __VERIFY_PRE_USERMODE_STATE() \
+   if (user_caller) verify_pre_usermode_state()
+#else
+#define __CHECK_USER_CALLER()
+#define __VERIFY_PRE_USERMODE_STATE()
+asmlinkage void asm_verify_pre_usermode_state(void);
+#endif
+
+
 #define __PROTECT(...) asmlinkage_protect(__VA_ARGS__)
 #define __SYSCALL_DEFINEx(x, name, ...)
\
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))   \
@@ -199,7 +220,10 @@ extern struct trace_event_functions 
exit_syscall_print_funcs;
asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));  \
asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))   \
{   \
-   long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__));  \
+   long ret;   \
+   __CHECK_USER_CALLER();  \
+   ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__));   \
+   __VERIFY_PRE_USERMODE_STATE();  \
__MAP(x,__SC_TEST,__VA_ARGS__); \
__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__));   \
return ret; \
diff --git a/init/Kconfig b/init/Kconfig
index c859c993c26f..c4efc3a95e4a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1929,6 +1929,13 @@ config PROFILING
 config TRACEPOINTS
bool
 
+#
+# Set by each architecture that want to optimize how verify_pre_usermode_state
+# is called.
+#
+config ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE
+   bool
+
 source "arch/Kconfig"
 
 endmenu# General setup
diff --git a/kernel/sys.c b/kernel/sys.c
index 196c7134bee6..4ae278fcc290 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2459,3 +2459,10 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo 
__user *, info)
return 0;
 }
 #endif /* CONFIG_COMPAT */
+
+#ifdef CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE
+asmlinkage void asm_verify_pre_usermode_state(void)
+{
+   verify_pre_usermode_state();
+}
+#endif
-- 
2.12.1.500.gab5fba24ee-goog



[PATCH v5 3/4] arm/syscalls: Specific usage of verify_pre_usermode_state

2017-03-23 Thread Thomas Garnier
Implement specific usage of verify_pre_usermode_state for user-mode
returns for arm.
---
Based on next-20170322
---
 arch/arm/Kconfig   |  1 +
 arch/arm/kernel/entry-common.S | 16 +++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fcbc5ef1ec69..10c6dc3dfff9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -12,6 +12,7 @@ config ARM
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_MIGHT_HAVE_PC_PARPORT
+   select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
select ARCH_SUPPORTS_ATOMIC_RMW
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index eb5cd77bf1d8..88c72c4e44ad 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef CONFIG_AEABI
 #include 
 #endif
@@ -27,7 +28,6 @@
 
 #include "entry-header.S"
 
-
.align  5
 #if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING))
 /*
@@ -40,9 +40,12 @@ ret_fast_syscall:
  UNWIND(.fnstart   )
  UNWIND(.cantunwind)
disable_irq_notrace @ disable interrupts
+   ldr r2, [tsk, #TI_ADDR_LIMIT]
ldr r1, [tsk, #TI_FLAGS]@ re-check for syscall tracing
tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
bne fast_work_pending
+   cmp r2, #TASK_SIZE
+   blneaddr_limit_fail
 
/* perform architecture specific actions before user return */
arch_ret_to_user r1, lr
@@ -66,6 +69,7 @@ ret_fast_syscall:
  UNWIND(.cantunwind)
str r0, [sp, #S_R0 + S_OFF]!@ save returned r0
disable_irq_notrace @ disable interrupts
+   ldr r2, [tsk, #TI_ADDR_LIMIT]
ldr r1, [tsk, #TI_FLAGS]@ re-check for syscall tracing
tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
beq no_work_pending
@@ -82,6 +86,7 @@ slow_work_pending:
mov r2, why @ 'syscall'
bl  do_work_pending
cmp r0, #0
+   ldreq   r2, [tsk, #TI_ADDR_LIMIT]
beq no_work_pending
movlt   scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
ldmia   sp, {r0 - r6}   @ have to reload r0 - r6
@@ -99,9 +104,12 @@ ret_slow_syscall:
disable_irq_notrace @ disable interrupts
 ENTRY(ret_to_user_from_irq)
ldr r1, [tsk, #TI_FLAGS]
+   ldr r2, [tsk, #TI_ADDR_LIMIT]
tst r1, #_TIF_WORK_MASK
bne slow_work_pending
 no_work_pending:
+   cmp r2, #TASK_SIZE
+   blneaddr_limit_fail
asm_trace_hardirqs_on save = 0
 
/* perform architecture specific actions before user return */
@@ -125,6 +133,12 @@ ENTRY(ret_from_fork)
b   ret_slow_syscall
 ENDPROC(ret_from_fork)
 
+addr_limit_fail:
+   stmfd   sp!, {r0, lr}
+   bl  asm_verify_pre_usermode_state
+   ldmfd   sp!, {r0, lr}
+   ret lr
+
 /*=
  * SWI handler
  *-
-- 
2.12.1.500.gab5fba24ee-goog



RE: [PATCH] Add initial SX3000b platform code to MIPS arch

2017-03-23 Thread Amit Kama IL
Will be sending a revised version splitting the irqchip related code to a 
different patch and using a generic platform code...

-Original Message-
From: Amit Kama IL 
Sent: Wednesday, March 22, 2017 7:38 AM
To: 'r...@linux-mips.org' 
Cc: 'devicet...@vger.kernel.org' ; 
'linux-kernel@vger.kernel.org' ; 
'linux-m...@linux-mips.org' ; 't...@linutronix.de' 
; 'ja...@lakedaemon.net' ; 
'marc.zyng...@arm.com' ; 'linux-...@vger.kernel.org' 
; 'cor...@lwn.net' 
Subject: [PATCH] Add initial SX3000b platform code to MIPS arch

Add initial support for boards based on Satixfy's SX3000b (Catniss) SoC.
The SoC includes a MIPS interAptiv dual core 4 VPE processor and boots 
using device-tree.

Signed-off-by: Amit Kama 

The irqchip file (irq-sx3000b.c) is pertinent to the platform. 
IRQCHIP maintainers - is it possible to merge this through MIPS tree? 
 


diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
old mode 100666
new mode 100666
index a008a9f..1bcb300
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -551,6 +551,31 @@ config MACH_PIC32
  Microchip PIC32 is a family of general-purpose 32 bit MIPS core
  microcontrollers.

+config MACH_SX3000
+   bool "Satixfy SX3000 based boards"
+   select SYS_SUPPORTS_32BIT_KERNEL
+   select SYS_SUPPORTS_LITTLE_ENDIAN
+   select SYS_SUPPORTS_MIPS_CPS
+   select SYS_SUPPORTS_MULTITHREADING
+   select SYS_HAS_CPU_MIPS32_R2
+   select SYS_HAS_CPU_MIPS32_R3_5
+   select SYS_HAS_EARLY_PRINTK
+   select USE_GENERIC_EARLY_PRINTK_8250
+   select DMA_MAYBE_COHERENT
+   select ARCH_WANT_OPTIONAL_GPIOLIB
+   select LIBFDT
+   select USE_OF
+   select BUILTIN_DTB
+   select IRQ_MIPS_CPU
+   select MIPS_GIC
+   select SX3000_ICU
+   select MIPS_CPU_SCACHE
+   select CLKSRC_MIPS_GIC
+   select COMMON_CLK
+   select BOOT_RAW
+   help
+ This enables support for the Satixfy SX3000 SoC.
+
 config NEC_MARKEINS
bool "NEC EMMA2RH Mark-eins board"
select SOC_EMMA2RH
@@ -1022,6 +1047,7 @@ source "arch/mips/pmcs-msp71xx/Kconfig"
 source "arch/mips/ralink/Kconfig"
 source "arch/mips/sgi-ip27/Kconfig"
 source "arch/mips/sibyte/Kconfig"
+source "arch/mips/sx3000/Kconfig"
 source "arch/mips/txx9/Kconfig"
 source "arch/mips/vr41xx/Kconfig"
 source "arch/mips/cavium-octeon/Kconfig"
diff --git a/arch/mips/boot/dts/sx3000/Makefile 
b/arch/mips/boot/dts/sx3000/Makefile
new file mode 100666
index 000..8b73c39
--- /dev/null
+++ b/arch/mips/boot/dts/sx3000/Makefile
@@ -0,0 +1,13 @@
+dtb-$(CONFIG_SX3000_DEVBOARD)  += sx3000_devboard.dtb
+dtb-$(CONFIG_SX3000_BBB)   += sx3000_bbb.dtb
+dtb-$(SX3000_IDU3) += sx3000_idu3.dtb
+dtb-$(SX3000_IDU4) += sx3000_idu4.dtb
+
+
+obj-y  += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+
+# Force kbuild to make empty built-in.o if necessary
+obj-   += dummy.o
+
+always := $(dtb-y)
+clean-files:= *.dtb *.dtb.S
diff --git a/arch/mips/boot/dts/sx3000/sx3000.dtsi 
b/arch/mips/boot/dts/sx3000/sx3000.dtsi
new file mode 100666
index 000..8557282
--- /dev/null
+++ b/arch/mips/boot/dts/sx3000/sx3000.dtsi
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2016 Satixfy Technologies
+ * Author: Amit Kama 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "satixfy,sx3000";
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   cpu@0 {
+   device_type = "cpu";
+   compatible = "mti,interaptiv";
+   clocks  = <>;
+   reg = <0>;
+   };
+   };
+
+   gic: interrupt-controller@1d90 {
+   compatible = "mti,gic";
+   //reg = <0x1D90 0x2>;
+   memory-region = <_memory_mapped_area>;
+
+   interrupt-controller;
+   #interrupt-cells = <3>;
+   timer {
+   compatible = "mti,gic-timer";
+   interrupts = ;
+   clocks = <>;
+   };
+   };
+
+   icu: interrupt-controller@1d4d {
+   compatible = "sx,icu";
+   reg = <0x1D4D 0x1C0>;
+
+   interrupt-controller;
+   #interrupt-cells = <1>;
+
+   interrupt-parent = <>;
+   interrupts = ;
+   };
+
+   uart0: uart@1D4D09C0 {
+   

[PATCH -v3 0/8] PI vs SCHED_DEADLINE fixes

2017-03-23 Thread Peter Zijlstra
Now that this pesky little problem with futexes is (hopefully) dealt with;

  https://lkml.kernel.org/r/20170322103547.756091...@infradead.org

We can get on with fixing the actual bug this all started out with.

These patches, started by Xunlei Pang, rework the PI infrastructure a bit
fixing various problems it has, most notable a NULL deref in SCHED_DEADLINE.

Once this is sorted; we can look at improving the tracing thing (Daniel Bristot
and Julien Desfossez were working on that) and have a better foundation to look
at bandwidth inheritance (Juri and co.).



[PATCH -v3 1/8] rtmutex: Deboost before waking up the top waiter

2017-03-23 Thread Peter Zijlstra
From: Xunlei Pang 

We should deboost before waking the high-priority task, such that we
don't run two tasks with the same "state" (priority, deadline,
sched_class, etc).

In order to make sure the boosting task doesn't start running between
unlock and deboost (due to 'spurious' wakeup), we move the deboost
under the wait_lock, that way its serialized against the wait loop in
__rt_mutex_slowlock().

Doing the deboost early can however lead to priority-inversion if
current would get preempted after the deboost but before waking our
high-prio task, hence we disable preemption before doing deboost, and
enabling it after the wake up is over.

This gets us the right semantic order, but most importantly however;
this change ensures pointer stability for the next patch, where we
have rt_mutex_setprio() cache a pointer to the top-most waiter task.
If we, as before this change, do the wakeup first and then deboost,
this pointer might point into thin air.

[peterz: Changelog + patch munging]
Cc: Ingo Molnar 
Cc: Juri Lelli 
Acked-by: Steven Rostedt 
Suggested-by: Peter Zijlstra 
Signed-off-by: Xunlei Pang 
Signed-off-by: Peter Zijlstra (Intel) 
---

 kernel/futex.c  |5 ---
 kernel/locking/rtmutex.c|   59 +---
 kernel/locking/rtmutex_common.h |2 -
 3 files changed, 34 insertions(+), 32 deletions(-)

--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1465,10 +1465,7 @@ static int wake_futex_pi(u32 __user *uad
 out_unlock:
raw_spin_unlock_irq(_state->pi_mutex.wait_lock);
 
-   if (deboost) {
-   wake_up_q(_q);
-   rt_mutex_adjust_prio(current);
-   }
+   rt_mutex_postunlock(_q, deboost);
 
return ret;
 }
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -307,24 +307,6 @@ static void __rt_mutex_adjust_prio(struc
 }
 
 /*
- * Adjust task priority (undo boosting). Called from the exit path of
- * rt_mutex_slowunlock() and rt_mutex_slowlock().
- *
- * (Note: We do this outside of the protection of lock->wait_lock to
- * allow the lock to be taken while or before we readjust the priority
- * of task. We do not use the spin_xx_mutex() variants here as we are
- * outside of the debug path.)
- */
-void rt_mutex_adjust_prio(struct task_struct *task)
-{
-   unsigned long flags;
-
-   raw_spin_lock_irqsave(>pi_lock, flags);
-   __rt_mutex_adjust_prio(task);
-   raw_spin_unlock_irqrestore(>pi_lock, flags);
-}
-
-/*
  * Deadlock detection is conditional:
  *
  * If CONFIG_DEBUG_RT_MUTEXES=n, deadlock detection is only conducted
@@ -985,6 +967,7 @@ static void mark_wakeup_next_waiter(stru
 * lock->wait_lock.
 */
rt_mutex_dequeue_pi(current, waiter);
+   __rt_mutex_adjust_prio(current);
 
/*
 * As we are waking up the top waiter, and the waiter stays
@@ -1321,6 +1304,16 @@ static bool __sched rt_mutex_slowunlock(
 */
mark_wakeup_next_waiter(wake_q, lock);
 
+   /*
+* We should deboost before waking the top waiter task such that
+* we don't run two tasks with the 'same' priority. This however
+* can lead to prio-inversion if we would get preempted after
+* the deboost but before waking our high-prio task, hence the
+* preempt_disable before unlock. Pairs with preempt_enable() in
+* rt_mutex_postunlock();
+*/
+   preempt_disable();
+
raw_spin_unlock_irqrestore(>wait_lock, flags);
 
/* check PI boosting */
@@ -1370,6 +1363,18 @@ rt_mutex_fasttrylock(struct rt_mutex *lo
return slowfn(lock);
 }
 
+/*
+ * Undo pi boosting (if necessary) and wake top waiter.
+ */
+void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost)
+{
+   wake_up_q(wake_q);
+
+   /* Pairs with preempt_disable() in rt_mutex_slowunlock() */
+   if (deboost)
+   preempt_enable();
+}
+
 static inline void
 rt_mutex_fastunlock(struct rt_mutex *lock,
bool (*slowfn)(struct rt_mutex *lock,
@@ -1383,11 +1388,7 @@ rt_mutex_fastunlock(struct rt_mutex *loc
 
deboost = slowfn(lock, _q);
 
-   wake_up_q(_q);
-
-   /* Undo pi boosting if necessary: */
-   if (deboost)
-   rt_mutex_adjust_prio(current);
+   rt_mutex_postunlock(_q, deboost);
 }
 
 /**
@@ -1513,6 +1514,13 @@ bool __sched __rt_mutex_futex_unlock(str
}
 
mark_wakeup_next_waiter(wake_q, lock);
+   /*
+* We've already deboosted, retain preempt_disabled when dropping
+* the wait_lock to avoid inversion until the wakeup. Matched
+* by rt_mutex_postunlock();
+*/
+   preempt_disable();
+
return true; /* deboost and wakeups */
 }
 
@@ -1525,10 +1533,7 @@ void __sched rt_mutex_futex_unlock(struc
deboost = __rt_mutex_futex_unlock(lock, _q);

[PATCH -v3 7/8] rtmutex: Fix PI chain order integrity

2017-03-23 Thread Peter Zijlstra
rt_mutex_waiter::prio is a copy of task_struct::prio which is updated
during the PI chain walk, such that the PI chain order isn't messed up
by (asynchronous) task state updates.

Currently rt_mutex_waiter_less() uses task state for deadline tasks;
this is broken, since the task state can, as said above, change
asynchronously, causing the RB tree order to change without actual
tree update -> FAIL.

Fix this by also copying the deadline into the rt_mutex_waiter state
and updating it along with its prio field.

Ideally we would also force PI chain updates whenever DL tasks update
their deadline parameter, but for first approximation this is less
broken than it was.

Signed-off-by: Peter Zijlstra (Intel) 
---
 kernel/locking/rtmutex.c|   29 +++--
 kernel/locking/rtmutex_common.h |1 +
 2 files changed, 28 insertions(+), 2 deletions(-)

--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -172,8 +172,7 @@ rt_mutex_waiter_less(struct rt_mutex_wai
 * then right waiter has a dl_prio() too.
 */
if (dl_prio(left->prio))
-   return dl_time_before(left->task->dl.deadline,
- right->task->dl.deadline);
+   return dl_time_before(left->deadline, right->deadline);
 
return 0;
 }
@@ -584,7 +583,26 @@ static int rt_mutex_adjust_prio_chain(st
 
/* [7] Requeue the waiter in the lock waiter tree. */
rt_mutex_dequeue(lock, waiter);
+
+   /*
+* Update the waiter prio fields now that we're dequeued.
+*
+* These values can have changed through either:
+*
+*   sys_sched_set_scheduler() / sys_sched_setattr()
+*
+* or
+*
+*   DL CBS enforcement advancing the effective deadline.
+*
+* Even though pi_waiters also uses these fields, and that tree is only
+* updated in [11], we can do this here, since we hold [L], which
+* serializes all pi_waiters access and rb_erase() does not care about
+* the values of the node being removed.
+*/
waiter->prio = task->prio;
+   waiter->deadline = task->dl.deadline;
+
rt_mutex_enqueue(lock, waiter);
 
/* [8] Release the task */
@@ -711,6 +729,8 @@ static int rt_mutex_adjust_prio_chain(st
 static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct 
*task,
struct rt_mutex_waiter *waiter)
 {
+   lockdep_assert_held(>wait_lock);
+
/*
 * Before testing whether we can acquire @lock, we set the
 * RT_MUTEX_HAS_WAITERS bit in @lock->owner. This forces all
@@ -838,6 +858,8 @@ static int task_blocks_on_rt_mutex(struc
struct rt_mutex *next_lock;
int chain_walk = 0, res;
 
+   lockdep_assert_held(>wait_lock);
+
/*
 * Early deadlock detection. We really don't want the task to
 * enqueue on itself just to untangle the mess later. It's not
@@ -855,6 +877,7 @@ static int task_blocks_on_rt_mutex(struc
waiter->task = task;
waiter->lock = lock;
waiter->prio = task->prio;
+   waiter->deadline = task->dl.deadline;
 
/* Get the top priority waiter on the lock */
if (rt_mutex_has_waiters(lock))
@@ -972,6 +995,8 @@ static void remove_waiter(struct rt_mute
struct task_struct *owner = rt_mutex_owner(lock);
struct rt_mutex *next_lock;
 
+   lockdep_assert_held(>wait_lock);
+
raw_spin_lock(>pi_lock);
rt_mutex_dequeue(lock, waiter);
current->pi_blocked_on = NULL;
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
@@ -33,6 +33,7 @@ struct rt_mutex_waiter {
struct rt_mutex *deadlock_lock;
 #endif
int prio;
+   u64 deadline;
 };
 
 /*




[PATCH -v3 5/8] sched/rtmutex: Refactor rt_mutex_setprio()

2017-03-23 Thread Peter Zijlstra
With the introduction of SCHED_DEADLINE the whole notion that priority
is a single number is gone, therefore the @prio argument to
rt_mutex_setprio() doesn't make sense anymore.

So rework the code to pass a pi_task instead.

Note this also fixes a problem with pi_top_task caching; previously we
would not set the pointer (call rt_mutex_update_top_task) if the
priority didn't change, this could lead to a stale pointer.

As for the XXX, I think its fine to use pi_task->prio, because if it
differs from waiter->prio, a PI chain update is immenent.

Signed-off-by: Peter Zijlstra (Intel) 
---
 include/linux/sched/rt.h |   24 +++---
 kernel/locking/rtmutex.c |  112 ---
 kernel/sched/core.c  |   66 ++-
 3 files changed, 91 insertions(+), 111 deletions(-)

--- a/include/linux/sched/rt.h
+++ b/include/linux/sched/rt.h
@@ -18,28 +18,20 @@ static inline int rt_task(struct task_st
 }
 
 #ifdef CONFIG_RT_MUTEXES
-extern int rt_mutex_getprio(struct task_struct *p);
-extern void rt_mutex_setprio(struct task_struct *p, int prio);
-extern int rt_mutex_get_effective_prio(struct task_struct *task, int newprio);
-extern void rt_mutex_update_top_task(struct task_struct *p);
-extern struct task_struct *rt_mutex_get_top_task(struct task_struct *task);
+/*
+ * Must hold either p->pi_lock or task_rq(p)->lock.
+ */
+static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *p)
+{
+   return p->pi_top_task;
+}
+extern void rt_mutex_setprio(struct task_struct *p, struct task_struct 
*pi_task);
 extern void rt_mutex_adjust_pi(struct task_struct *p);
 static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
 {
return tsk->pi_blocked_on != NULL;
 }
 #else
-static inline int rt_mutex_getprio(struct task_struct *p)
-{
-   return p->normal_prio;
-}
-
-static inline int rt_mutex_get_effective_prio(struct task_struct *task,
- int newprio)
-{
-   return newprio;
-}
-
 static inline struct task_struct *rt_mutex_get_top_task(struct task_struct 
*task)
 {
return NULL;
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -322,67 +322,16 @@ rt_mutex_dequeue_pi(struct task_struct *
RB_CLEAR_NODE(>pi_tree_entry);
 }
 
-/*
- * Must hold both p->pi_lock and task_rq(p)->lock.
- */
-void rt_mutex_update_top_task(struct task_struct *p)
-{
-   if (!task_has_pi_waiters(p)) {
-   p->pi_top_task = NULL;
-   return;
-   }
-
-   p->pi_top_task = task_top_pi_waiter(p)->task;
-}
-
-/*
- * Calculate task priority from the waiter tree priority
- *
- * Return task->normal_prio when the waiter tree is empty or when
- * the waiter is not allowed to do priority boosting
- */
-int rt_mutex_getprio(struct task_struct *task)
-{
-   if (likely(!task_has_pi_waiters(task)))
-   return task->normal_prio;
-
-   return min(task_top_pi_waiter(task)->prio,
-  task->normal_prio);
-}
-
-/*
- * Must hold either p->pi_lock or task_rq(p)->lock.
- */
-struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
-{
-   return task->pi_top_task;
-}
-
-/*
- * Called by sched_setscheduler() to get the priority which will be
- * effective after the change.
- */
-int rt_mutex_get_effective_prio(struct task_struct *task, int newprio)
+static void rt_mutex_adjust_prio(struct task_struct *p)
 {
-   struct task_struct *top_task = rt_mutex_get_top_task(task);
+   struct task_struct *pi_task = NULL;
 
-   if (!top_task)
-   return newprio;
+   lockdep_assert_held(>pi_lock);
 
-   return min(top_task->prio, newprio);
-}
+   if (task_has_pi_waiters(p))
+   pi_task = task_top_pi_waiter(p)->task;
 
-/*
- * Adjust the priority of a task, after its pi_waiters got modified.
- *
- * This can be both boosting and unboosting. task->pi_lock must be held.
- */
-static void __rt_mutex_adjust_prio(struct task_struct *task)
-{
-   int prio = rt_mutex_getprio(task);
-
-   if (task->prio != prio || dl_prio(prio))
-   rt_mutex_setprio(task, prio);
+   rt_mutex_setprio(p, pi_task);
 }
 
 /*
@@ -742,7 +691,7 @@ static int rt_mutex_adjust_prio_chain(st
 */
rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
rt_mutex_enqueue_pi(task, waiter);
-   __rt_mutex_adjust_prio(task);
+   rt_mutex_adjust_prio(task);
 
} else if (prerequeue_top_waiter == waiter) {
/*
@@ -758,7 +707,7 @@ static int rt_mutex_adjust_prio_chain(st
rt_mutex_dequeue_pi(task, waiter);
waiter = rt_mutex_top_waiter(lock);
rt_mutex_enqueue_pi(task, waiter);
-   __rt_mutex_adjust_prio(task);
+   rt_mutex_adjust_prio(task);
} else {
/*
 * Nothing changed. No need to do any priority
@@ -966,7 

[PATCH -v3 4/8] rtmutex: Clean up

2017-03-23 Thread Peter Zijlstra
Previous patches changed the meaning of the return value of
rt_mutex_slowunlock(); update comments and code to reflect this.

Signed-off-by: Peter Zijlstra (Intel) 
---
 kernel/futex.c  |7 ---
 kernel/locking/rtmutex.c|   28 +---
 kernel/locking/rtmutex_common.h |2 +-
 3 files changed, 18 insertions(+), 19 deletions(-)

--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1394,7 +1394,7 @@ static int wake_futex_pi(u32 __user *uad
 {
u32 uninitialized_var(curval), newval;
struct task_struct *new_owner;
-   bool deboost = false;
+   bool postunlock = false;
DEFINE_WAKE_Q(wake_q);
int ret = 0;
 
@@ -1455,12 +1455,13 @@ static int wake_futex_pi(u32 __user *uad
/*
 * We've updated the uservalue, this unlock cannot fail.
 */
-   deboost = __rt_mutex_futex_unlock(_state->pi_mutex, _q);
+   postunlock = __rt_mutex_futex_unlock(_state->pi_mutex, _q);
 
 out_unlock:
raw_spin_unlock_irq(_state->pi_mutex.wait_lock);
 
-   rt_mutex_postunlock(_q, deboost);
+   if (postunlock)
+   rt_mutex_postunlock(_q);
 
return ret;
 }
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1330,7 +1330,8 @@ static inline int rt_mutex_slowtrylock(s
 
 /*
  * Slow path to release a rt-mutex.
- * Return whether the current task needs to undo a potential priority boosting.
+ *
+ * Return whether the current task needs to call rt_mutex_postunlock().
  */
 static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock,
struct wake_q_head *wake_q)
@@ -1401,8 +1402,7 @@ static bool __sched rt_mutex_slowunlock(
 
raw_spin_unlock_irqrestore(>wait_lock, flags);
 
-   /* check PI boosting */
-   return true;
+   return true; /* call rt_mutex_postunlock() */
 }
 
 /*
@@ -1449,15 +1449,14 @@ rt_mutex_fasttrylock(struct rt_mutex *lo
 }
 
 /*
- * Undo pi boosting (if necessary) and wake top waiter.
+ * Performs the wakeup of the the top-waiter and re-enables preemption.
  */
-void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost)
+void rt_mutex_postunlock(struct wake_q_head *wake_q)
 {
wake_up_q(wake_q);
 
/* Pairs with preempt_disable() in rt_mutex_slowunlock() */
-   if (deboost)
-   preempt_enable();
+   preempt_enable();
 }
 
 static inline void
@@ -1466,14 +1465,12 @@ rt_mutex_fastunlock(struct rt_mutex *loc
   struct wake_q_head *wqh))
 {
DEFINE_WAKE_Q(wake_q);
-   bool deboost;
 
if (likely(rt_mutex_cmpxchg_release(lock, current, NULL)))
return;
 
-   deboost = slowfn(lock, _q);
-
-   rt_mutex_postunlock(_q, deboost);
+   if (slowfn(lock, _q))
+   rt_mutex_postunlock(_q);
 }
 
 /**
@@ -1593,19 +1590,20 @@ bool __sched __rt_mutex_futex_unlock(str
 */
preempt_disable();
 
-   return true; /* deboost and wakeups */
+   return true; /* call postunlock() */
 }
 
 void __sched rt_mutex_futex_unlock(struct rt_mutex *lock)
 {
DEFINE_WAKE_Q(wake_q);
-   bool deboost;
+   bool postunlock;
 
raw_spin_lock_irq(>wait_lock);
-   deboost = __rt_mutex_futex_unlock(lock, _q);
+   postunlock = __rt_mutex_futex_unlock(lock, _q);
raw_spin_unlock_irq(>wait_lock);
 
-   rt_mutex_postunlock(_q, deboost);
+   if (postunlock)
+   rt_mutex_postunlock(_q);
 }
 
 /**
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
@@ -122,7 +122,7 @@ extern void rt_mutex_futex_unlock(struct
 extern bool __rt_mutex_futex_unlock(struct rt_mutex *lock,
 struct wake_q_head *wqh);
 
-extern void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost);
+extern void rt_mutex_postunlock(struct wake_q_head *wake_q);
 
 #ifdef CONFIG_DEBUG_RT_MUTEXES
 # include "rtmutex-debug.h"




[PATCH v3 2/7] arm64: marvell: enable the Armada 37xx pinctrl driver

2017-03-23 Thread Gregory CLEMENT
This commit makes sure the driver for the Armada 37xx pin controller is
enabled.

Signed-off-by: Gregory CLEMENT 
---
 arch/arm64/Kconfig.platforms | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 129cc5ae4091..f2bb1691264f 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -105,6 +105,8 @@ config ARCH_MVEBU
select ARMADA_37XX_CLK
select MVEBU_ODMI
select MVEBU_PIC
+   select PINCTRL
+   select PINCTRL_ARMADA_37XX
help
  This enables support for Marvell EBU familly, including:
   - Armada 3700 SoC Family
-- 
git-series 0.9.1


Re: [REGRESSION] 07ec51480b5e ("virtio_pci: use shared interrupts for virtqueues") causes crashes in guest

2017-03-23 Thread Richard W.M. Jones
On Thu, Mar 23, 2017 at 01:13:50PM +0800, Jason Wang wrote:
> >From 312859b596e83a2164a8430343d31fce2a5ad808 Mon Sep 17 00:00:00 2001
> From: Jason Wang 
> Date: Thu, 23 Mar 2017 13:07:16 +0800
> Subject: [PATCH] virtio_pci: fix out of bound access for msix_names
> 
> Signed-off-by: Jason Wang 

I tested this, and it does appear to fix the crashes in
vp_modern_find_vqs.  Therefore:

Tested-by: Richard W.M. Jones 

Thanks,

Rich.

>  drivers/virtio/virtio_pci_common.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_pci_common.c 
> b/drivers/virtio/virtio_pci_common.c
> index df548a6..5905349 100644
> --- a/drivers/virtio/virtio_pci_common.c
> +++ b/drivers/virtio/virtio_pci_common.c
> @@ -147,7 +147,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, 
> unsigned nvqs,
>  {
>   struct virtio_pci_device *vp_dev = to_vp_device(vdev);
>   const char *name = dev_name(_dev->vdev.dev);
> - int i, err = -ENOMEM, allocated_vectors, nvectors;
> + int i, j, err = -ENOMEM, allocated_vectors, nvectors;
>   unsigned flags = PCI_IRQ_MSIX;
>   bool shared = false;
>   u16 msix_vec;
> @@ -212,7 +212,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, 
> unsigned nvqs,
>   if (!vp_dev->msix_vector_map)
>   goto out_disable_config_irq;
>  
> - allocated_vectors = 1; /* vector 0 is the config interrupt */
> + allocated_vectors = j = 1; /* vector 0 is the config interrupt */
>   for (i = 0; i < nvqs; ++i) {
>   if (!names[i]) {
>   vqs[i] = NULL;
> @@ -236,18 +236,19 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, 
> unsigned nvqs,
>   continue;
>   }
>  
> - snprintf(vp_dev->msix_names[i + 1],
> + snprintf(vp_dev->msix_names[j],
>sizeof(*vp_dev->msix_names), "%s-%s",
>dev_name(_dev->vdev.dev), names[i]);
>   err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec),
> vring_interrupt, IRQF_SHARED,
> -   vp_dev->msix_names[i + 1], vqs[i]);
> +   vp_dev->msix_names[j], vqs[i]);
>   if (err) {
>   /* don't free this irq on error */
>   vp_dev->msix_vector_map[i] = VIRTIO_MSI_NO_VECTOR;
>   goto out_remove_vqs;
>   }
>   vp_dev->msix_vector_map[i] = msix_vec;
> + j++;
>  
>   /*
>* Use a different vector for each queue if they are available,
> -- 
> 2.7.4
> 


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html


[PATCH v3 0/7] Add support for pinctrl/gpio on Armada 37xx

2017-03-23 Thread Gregory CLEMENT
Hi,

In this third version I finally managed to use gpio-ranges from the
device tree. For the record, this series adds support for the pin and
gpio controllers present on the Armada 37xx SoCs.

Each Armada 37xx SoC comes with 2 pin controllers: one on the south
bridge (managing 28 pins) and one on the north bridge (managing 36 pins).

At the hardware level the controller configure the pins by group and not
pin by pin.

The gpio controller is also capable to handle interrupt from gpio.

Changelog

v2 -> v3
 - use gpio-ranges (patch 4)

 - Document gpio-ranges usage (patch 1)

 - do not use anymore a global pin index (patch 3)

v1 -> v2:
- Update binding documentation making clear that mfd and syscon must
  be used (patch 1).

- Split the fist patch adding pin controller support for Armada 37xx
  in arm64 part (for kconfig) and pinctrl part (patch 2 and 3)

- Add MFD_SYSCON dependency (patch 3)

- Add kerneldoc for the armada_37xx_pin_group struct (patch 3)

- Rename _add_function() to armada_37xx_add_function() (patch 3)

- Use an inline function to update the reg offset (patch 4)

- Rename gpiolib_register to gpiochip_register (patch 4)

- Add a comment about the two registers limit (patch 4)

- Add explicit gpio node in the device tree (patch 4)

- Convert the driver to use GPIOLIB_IRQCHIP (patch 5)

- Add a critical section when accessing the hardware registers (patch 5)

- Use the gpio subnode (patch 5)

Thanks,

Gregory

Gregory CLEMENT (7):
  pinctrl: dt-bindings: Add documentation for Armada 37xx pin controllers
  arm64: marvell: enable the Armada 37xx pinctrl driver
  pinctrl: armada-37xx: Add pin controller support for Armada 37xx
  pinctrl: armada-37xx: Add gpio support
  pinctrl: aramda-37xx: Add irqchip support
  ARM64: dts: marvell: Add pinctrl nodes for Armada 3700
  ARM64: dts: marvell: armada37xx: add pinctrl definition

 Documentation/devicetree/bindings/clock/armada3700-xtal-clock.txt |   
7 +-
 Documentation/devicetree/bindings/pinctrl/marvell,armada-37xx-pinctrl.txt | 
183 ++-
 arch/arm64/Kconfig.platforms  |   
2 +-
 arch/arm64/boot/dts/marvell/armada-3720-db.dts|   
8 +-
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi  |  
73 +-
 drivers/pinctrl/Makefile  |   
2 +-
 drivers/pinctrl/mvebu/Kconfig |   
7 +-
 drivers/pinctrl/mvebu/Makefile|   
3 +-
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c   | 
910 -
 9 files changed, 1187 insertions(+), 8 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/marvell,armada-37xx-pinctrl.txt
 create mode 100644 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c

base-commit: c1ae3cfa0e89fa1a7ecc4c99031f5e9ae99d9201
-- 
git-series 0.9.1


[PATCH v3 4/7] pinctrl: armada-37xx: Add gpio support

2017-03-23 Thread Gregory CLEMENT
GPIO management is pretty simple and is part of the same IP than the pin
controller for the Armada 37xx SoCs.  This patch adds the GPIO support to
the pinctrl-armada-37xx.c file, it also allows sharing common functions
between the gpiolib and the pinctrl drivers.

Signed-off-by: Gregory CLEMENT 
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 127 ++---
 1 file changed, 113 insertions(+), 14 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c 
b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index f2ff9801d0f4..31e921aa2f86 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -10,6 +10,7 @@
  * without any warranty of any kind, whether express or implied.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -24,6 +25,8 @@
 #include "../pinctrl-utils.h"
 
 #define OUTPUT_EN  0x0
+#define INPUT_VAL  0x10
+#define OUTPUT_VAL 0x18
 #define OUTPUT_CTL 0x20
 #define SELECTION  0x30
 
@@ -73,6 +76,7 @@ struct armada_37xx_pinctrl {
struct regmap   *regmap;
struct armada_37xx_pin_data *data;
struct device   *dev;
+   struct gpio_chipgpio_chip;
struct pinctrl_desc pctl;
struct pinctrl_dev  *pctl_dev;
struct armada_37xx_pin_group*groups;
@@ -310,51 +314,99 @@ static int armada_37xx_pmx_set(struct pinctrl_dev 
*pctldev,
return armada_37xx_pmx_set_by_name(pctldev, name, grp);
 }
 
-static int armada_37xx_pmx_direction_input(struct armada_37xx_pinctrl *info,
-  unsigned int offset)
+static inline void aramda_37xx_update_reg(unsigned int *reg,
+ unsigned int offset)
 {
-   unsigned int reg = OUTPUT_EN;
-   unsigned int mask;
-
+   /* We never have more than 2 registers */
if (offset >= GPIO_PER_REG) {
offset -= GPIO_PER_REG;
-   reg += sizeof(u32);
+   *reg += sizeof(u32);
}
+}
+
+static int armada_37xx_gpio_direction_input(struct gpio_chip *chip,
+   unsigned int offset)
+{
+   struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
+   unsigned int reg = OUTPUT_EN;
+   unsigned int mask;
+
+   aramda_37xx_update_reg(, offset);
mask = BIT(offset);
 
return regmap_update_bits(info->regmap, reg, mask, 0);
 }
 
+static int armada_37xx_gpio_get_direction(struct gpio_chip *chip,
+ unsigned int offset)
+{
+   struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
+   unsigned int reg = OUTPUT_EN;
+   unsigned int val, mask;
+
+   aramda_37xx_update_reg(, offset);
+   mask = BIT(offset);
+
+   regmap_read(info->regmap, reg, );
 
+   return !(val & mask);
+}
 
-static int armada_37xx_pmx_direction_output(struct armada_37xx_pinctrl *info,
-   unsigned int offset, int value)
+static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
+unsigned int offset, int value)
 {
+   struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
unsigned int reg = OUTPUT_EN;
unsigned int mask;
 
-   if (offset >= GPIO_PER_REG) {
-   offset -= GPIO_PER_REG;
-   reg += sizeof(u32);
-   }
+   aramda_37xx_update_reg(, offset);
mask = BIT(offset);
 
return regmap_update_bits(info->regmap, reg, mask, mask);
 }
 
+static int armada_37xx_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+   struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
+   unsigned int reg = INPUT_VAL;
+   unsigned int val, mask;
+
+   aramda_37xx_update_reg(, offset);
+   mask = BIT(offset);
+
+   regmap_read(info->regmap, reg, );
+
+   return (val & mask) != 0;
+}
+
+static void armada_37xx_gpio_set(struct gpio_chip *chip, unsigned int offset,
+int value)
+{
+   struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
+   unsigned int reg = OUTPUT_VAL;
+   unsigned int mask, val;
+
+   aramda_37xx_update_reg(, offset);
+   mask = BIT(offset);
+   val = value ? mask : 0;
+
+   regmap_update_bits(info->regmap, reg, mask, val);
+}
+
 static int armada_37xx_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
  struct pinctrl_gpio_range *range,
  unsigned int offset, bool input)
 {
struct armada_37xx_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
+   struct gpio_chip *chip = range->gc;
 
dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
offset, range->name, offset, input ? "input" : "output");
 
  

[PATCH v2 2/2] cpuidle: Validate cpu_dev in cpuidle_add_sysfs

2017-03-23 Thread Vaidyanathan Srinivasan
If a given cpu is not in cpu_present and cpu hotplug
is disabled, arch can skip setting up the cpu_dev.

Arch cpuidle driver should pass correct cpu mask
for registration, but failing to do so by the driver
causes error to propagate and crash like this:

[   30.076045] Unable to handle kernel paging request for
data at address 0x0048
[   30.076100] Faulting instruction address: 0xc07b2f30
cpu 0x4d: Vector: 300 (Data Access) at [c03feb18b670]
pc: c07b2f30: kobject_get+0x20/0x70
lr: c07b3c94: kobject_add_internal+0x54/0x3f0
sp: c03feb18b8f0
   msr: 90009033
   dar: 48
 dsisr: 4000
  current = 0xc03fd2ed8300
  paca= 0xcfbab500   softe: 0irq_happened: 0x01
pid   = 1, comm = swapper/0
Linux version 4.11.0-rc2-svaidy+ (sv@sagarika) (gcc version 6.2.0
20161005 (Ubuntu 6.2.0-5ubuntu12) ) #10 SMP Sun Mar 19 00:08:09 IST 2017
enter ? for help
[c03feb18b960] c07b3c94 kobject_add_internal+0x54/0x3f0
[c03feb18b9f0] c07b43a4 kobject_init_and_add+0x64/0xa0
[c03feb18ba70] c0e284f4 cpuidle_add_sysfs+0xb4/0x130
[c03feb18baf0] c0e26038 cpuidle_register_device+0x118/0x1c0
[c03feb18bb30] c0e26c48 cpuidle_register+0x78/0x120
[c03feb18bbc0] c168fd9c powernv_processor_idle_init+0x110/0x1c4
[c03feb18bc40] c000cff8 do_one_initcall+0x68/0x1d0
[c03feb18bd00] c16242f4 kernel_init_freeable+0x280/0x360
[c03feb18bdc0] c000d864 kernel_init+0x24/0x160
[c03feb18be30] c000b4e8 ret_from_kernel_thread+0x5c/0x74

Validating cpu_dev fixes the crash and reports correct error message like:

[   30.163506] Failed to register cpuidle device for cpu136
[   30.173329] Registration of powernv driver failed.

Signed-off-by: Vaidyanathan Srinivasan 
---
 drivers/cpuidle/sysfs.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index c5adc8c..f2c3bce 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -615,6 +615,18 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
int error;
 
+   /*
+* Return error if cpu_device is not setup for this cpu.  This
+* could happen if arch did not setup cpu_device since this
+* cpu is not in cpu_present mask and the driver did not send
+* correct cpu mask at registration.  Without this check we
+* would end up passing bogus value for _dev->kobj in
+* kobject_init_and_add().
+*/
+
+   if (!cpu_dev)
+   return -ENODEV;
+
kdev = kzalloc(sizeof(*kdev), GFP_KERNEL);
if (!kdev)
return -ENOMEM;
-- 
2.9.3



[PATCH v2 1/2] powerpc/powernv/cpuidle: Pass correct drv->cpumask for registration

2017-03-23 Thread Vaidyanathan Srinivasan
drv->cpumask defaults to cpu_possible_mask in __cpuidle_driver_init().
On PowerNV platform cpu_present could be less than cpu_possible in cases
where firmware detects the cpu, but it is not available to the OS.  When
CONFIG_HOTPLUG_CPU=n, such cpus are not hotplugable at runtime and hence
we skip creating cpu_device.

This breaks cpuidle on powernv where register_cpu() is not called for
cpus in cpu_possible_mask that cannot be hot-added at runtime.

Trying cpuidle_register_device() on cpu without cpu_device will cause
crash like this:

cpu 0xf: Vector: 380 (Data SLB Access) at [c00ff1503490]
pc: c022c8bc: string+0x34/0x60
lr: c022ed78: vsnprintf+0x284/0x42c
sp: c00ff1503710
   msr: 90009033
   dar: 60006000
  current = 0xc00ff148
  paca= 0xcfe82d00   softe: 0irq_happened: 0x01
pid   = 1, comm = swapper/8
Linux version 4.11.0-rc2 (sv@sagarika) (gcc version 4.9.4
(Buildroot 2017.02-4-gc28573e) ) #15 SMP Fri Mar 17 19:32:02 IST 2017
enter ? for help
[link register   ] c022ed78 vsnprintf+0x284/0x42c
[c00ff1503710] c022ebb8 vsnprintf+0xc4/0x42c (unreliable)
[c00ff1503800] c022ef40 vscnprintf+0x20/0x44
[c00ff1503830] c00ab61c vprintk_emit+0x94/0x2cc
[c00ff15038a0] c00acc9c vprintk_func+0x60/0x74
[c00ff15038c0] c0619694 printk+0x38/0x4c
[c00ff15038e0] c0224950 kobject_get+0x40/0x60
[c00ff1503950] c022507c kobject_add_internal+0x60/0x2c4
[c00ff15039e0] c0225350 kobject_init_and_add+0x70/0x78
[c00ff1503a60] c053c288 cpuidle_add_sysfs+0x9c/0xe0
[c00ff1503ae0] c053aeac cpuidle_register_device+0xd4/0x12c
[c00ff1503b30] c053b108 cpuidle_register+0x98/0xcc
[c00ff1503bc0] c085eaf0 powernv_processor_idle_init+0x140/0x1e0
[c00ff1503c60] c000cd60 do_one_initcall+0xc0/0x15c
[c00ff1503d20] c0833e84 kernel_init_freeable+0x1a0/0x25c
[c00ff1503dc0] c000d478 kernel_init+0x24/0x12c
[c00ff1503e30] c000b564 ret_from_kernel_thread+0x5c/0x78

This patch fixes the bug by passing correct cpumask from
powernv-cpuidle driver.

Signed-off-by: Vaidyanathan Srinivasan 
---
 drivers/cpuidle/cpuidle-powernv.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/cpuidle/cpuidle-powernv.c 
b/drivers/cpuidle/cpuidle-powernv.c
index a06df51..82f7b33 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -175,6 +175,24 @@ static int powernv_cpuidle_driver_init(void)
drv->state_count += 1;
}
 
+   /*
+* On PowerNV platform cpu_present may be less that cpu_possible in
+* cases where firmware detects the cpu, but it is not available to the
+* OS.  If CONFIG_HOTPLUG_CPU=n then such CPUs are not hotplugable at
+* runtime and hence cpu_devices are not created for those cpus by
+* generic topology_init().
+*
+* drv->cpumask defaults to cpu_possible_mask in
+* __cpuidle_driver_init().  This breaks cpuidle on powernv where
+* cpu_devices are not created for cpus in cpu_possible_mask that
+* cannot be hot-added later at runtime.
+*
+* Trying cpuidle_register_device() on a cpu without cpu_devices is
+* incorrect. Hence pass correct cpu mask to generic cpuidle driver.
+*/
+
+   drv->cpumask = (struct cpumask *)cpu_present_mask;
+
return 0;
 }
 
-- 
2.9.3



Re: [PATCH v2 1/2] powerpc/powernv/cpuidle: Pass correct drv->cpumask for registration

2017-03-23 Thread Rafael J. Wysocki
On Thu, Mar 23, 2017 at 4:22 PM, Vaidyanathan Srinivasan
 wrote:
> drv->cpumask defaults to cpu_possible_mask in __cpuidle_driver_init().
> On PowerNV platform cpu_present could be less than cpu_possible in cases
> where firmware detects the cpu, but it is not available to the OS.  When
> CONFIG_HOTPLUG_CPU=n, such cpus are not hotplugable at runtime and hence
> we skip creating cpu_device.
>
> This breaks cpuidle on powernv where register_cpu() is not called for
> cpus in cpu_possible_mask that cannot be hot-added at runtime.
>
> Trying cpuidle_register_device() on cpu without cpu_device will cause
> crash like this:
>
> cpu 0xf: Vector: 380 (Data SLB Access) at [c00ff1503490]
> pc: c022c8bc: string+0x34/0x60
> lr: c022ed78: vsnprintf+0x284/0x42c
> sp: c00ff1503710
>msr: 90009033
>dar: 60006000
>   current = 0xc00ff148
>   paca= 0xcfe82d00   softe: 0irq_happened: 0x01
> pid   = 1, comm = swapper/8
> Linux version 4.11.0-rc2 (sv@sagarika) (gcc version 4.9.4
> (Buildroot 2017.02-4-gc28573e) ) #15 SMP Fri Mar 17 19:32:02 IST 2017
> enter ? for help
> [link register   ] c022ed78 vsnprintf+0x284/0x42c
> [c00ff1503710] c022ebb8 vsnprintf+0xc4/0x42c (unreliable)
> [c00ff1503800] c022ef40 vscnprintf+0x20/0x44
> [c00ff1503830] c00ab61c vprintk_emit+0x94/0x2cc
> [c00ff15038a0] c00acc9c vprintk_func+0x60/0x74
> [c00ff15038c0] c0619694 printk+0x38/0x4c
> [c00ff15038e0] c0224950 kobject_get+0x40/0x60
> [c00ff1503950] c022507c kobject_add_internal+0x60/0x2c4
> [c00ff15039e0] c0225350 kobject_init_and_add+0x70/0x78
> [c00ff1503a60] c053c288 cpuidle_add_sysfs+0x9c/0xe0
> [c00ff1503ae0] c053aeac cpuidle_register_device+0xd4/0x12c
> [c00ff1503b30] c053b108 cpuidle_register+0x98/0xcc
> [c00ff1503bc0] c085eaf0 powernv_processor_idle_init+0x140/0x1e0
> [c00ff1503c60] c000cd60 do_one_initcall+0xc0/0x15c
> [c00ff1503d20] c0833e84 kernel_init_freeable+0x1a0/0x25c
> [c00ff1503dc0] c000d478 kernel_init+0x24/0x12c
> [c00ff1503e30] c000b564 ret_from_kernel_thread+0x5c/0x78
>
> This patch fixes the bug by passing correct cpumask from
> powernv-cpuidle driver.
>
> Signed-off-by: Vaidyanathan Srinivasan 

That needs to be ACKed by someone familiar with powernv.

> ---
>  drivers/cpuidle/cpuidle-powernv.c | 18 ++
>  1 file changed, 18 insertions(+)
>
> diff --git a/drivers/cpuidle/cpuidle-powernv.c 
> b/drivers/cpuidle/cpuidle-powernv.c
> index a06df51..82f7b33 100644
> --- a/drivers/cpuidle/cpuidle-powernv.c
> +++ b/drivers/cpuidle/cpuidle-powernv.c
> @@ -175,6 +175,24 @@ static int powernv_cpuidle_driver_init(void)
> drv->state_count += 1;
> }
>
> +   /*
> +* On PowerNV platform cpu_present may be less that cpu_possible in
> +* cases where firmware detects the cpu, but it is not available to 
> the
> +* OS.  If CONFIG_HOTPLUG_CPU=n then such CPUs are not hotplugable at
> +* runtime and hence cpu_devices are not created for those cpus by
> +* generic topology_init().
> +*
> +* drv->cpumask defaults to cpu_possible_mask in
> +* __cpuidle_driver_init().  This breaks cpuidle on powernv where
> +* cpu_devices are not created for cpus in cpu_possible_mask that
> +* cannot be hot-added later at runtime.
> +*
> +* Trying cpuidle_register_device() on a cpu without cpu_devices is
> +* incorrect. Hence pass correct cpu mask to generic cpuidle driver.
> +*/
> +
> +   drv->cpumask = (struct cpumask *)cpu_present_mask;
> +
> return 0;
>  }
>
> --
> 2.9.3
>


Re: [PATCH v2 3/5] mm: use a dedicated workqueue for the free workers

2017-03-23 Thread Dave Hansen
On 03/22/2017 01:41 AM, Aaron Lu wrote:
> On Wed, Mar 22, 2017 at 03:33:35PM +0900, Minchan Kim wrote:
>> On Wed, Mar 15, 2017 at 05:00:02PM +0800, Aaron Lu wrote:
>>> Introduce a workqueue for all the free workers so that user can fine
>>> tune how many workers can be active through sysfs interface: max_active.
>>> More workers will normally lead to better performance, but too many can
>>> cause severe lock contention.
>>
>> Let me ask a question.
>>
>> How well can workqueue distribute the jobs in multiple CPU?
> 
> I would say it's good enough for my needs.
> After all, it doesn't need many kworkers to achieve the 50% time
> decrease: 2-4 kworkers for EP and 4-8 kworkers for EX are enough from
> previous attched data.

It's also worth noting that we'd like to *also* like to look into
increasing how scalable freeing pages to a given zone is.


Re: deadlock in synchronize_srcu() in debugfs?

2017-03-23 Thread Paul E. McKenney
On Thu, Mar 23, 2017 at 03:54:46PM +0100, Johannes Berg wrote:
> Hi,
> 
> Before I go hunting - has anyone seen a deadlock in synchronize_srcu()
> in debugfs_remove() before? We're observing that with our (backported,
> but very recent) driver against 4.9 (and 4.10, I think), but there are
> no backports of any debugfs things so the backport itself doesn't seem
> like a likely problem.
> 
> sysrq-w shows a lot of tasks blocked on various locks (e.g. RTNL), but
> the ultimate problem is the wireless stack getting blocked on
> debugfs_remove_recursive(), in __synchronize_srcu(), in
> wait_for_completion() (while holding lots of locks, hence the other
> tasks getting stuck).

I have not seen this, but my usual question for __synchronize_srcu()
is if some other task is blocked holding srcu_read_lock() for that
same srcu_struct.

Thanx, Paul



Re: [PATCH v2 1/2] powerpc/powernv/cpuidle: Pass correct drv->cpumask for registration

2017-03-23 Thread Vaidyanathan Srinivasan
* Rafael J. Wysocki  [2017-03-23 16:28:31]:

> On Thu, Mar 23, 2017 at 4:22 PM, Vaidyanathan Srinivasan
>  wrote:
> > drv->cpumask defaults to cpu_possible_mask in __cpuidle_driver_init().
> > On PowerNV platform cpu_present could be less than cpu_possible in cases
> > where firmware detects the cpu, but it is not available to the OS.  When
> > CONFIG_HOTPLUG_CPU=n, such cpus are not hotplugable at runtime and hence
> > we skip creating cpu_device.
> >
> > This breaks cpuidle on powernv where register_cpu() is not called for
> > cpus in cpu_possible_mask that cannot be hot-added at runtime.
> >
> > Trying cpuidle_register_device() on cpu without cpu_device will cause
> > crash like this:
> >
> > cpu 0xf: Vector: 380 (Data SLB Access) at [c00ff1503490]
> > pc: c022c8bc: string+0x34/0x60
> > lr: c022ed78: vsnprintf+0x284/0x42c
> > sp: c00ff1503710
> >msr: 90009033
> >dar: 60006000
> >   current = 0xc00ff148
> >   paca= 0xcfe82d00   softe: 0irq_happened: 0x01
> > pid   = 1, comm = swapper/8
> > Linux version 4.11.0-rc2 (sv@sagarika) (gcc version 4.9.4
> > (Buildroot 2017.02-4-gc28573e) ) #15 SMP Fri Mar 17 19:32:02 IST 2017
> > enter ? for help
> > [link register   ] c022ed78 vsnprintf+0x284/0x42c
> > [c00ff1503710] c022ebb8 vsnprintf+0xc4/0x42c (unreliable)
> > [c00ff1503800] c022ef40 vscnprintf+0x20/0x44
> > [c00ff1503830] c00ab61c vprintk_emit+0x94/0x2cc
> > [c00ff15038a0] c00acc9c vprintk_func+0x60/0x74
> > [c00ff15038c0] c0619694 printk+0x38/0x4c
> > [c00ff15038e0] c0224950 kobject_get+0x40/0x60
> > [c00ff1503950] c022507c kobject_add_internal+0x60/0x2c4
> > [c00ff15039e0] c0225350 kobject_init_and_add+0x70/0x78
> > [c00ff1503a60] c053c288 cpuidle_add_sysfs+0x9c/0xe0
> > [c00ff1503ae0] c053aeac cpuidle_register_device+0xd4/0x12c
> > [c00ff1503b30] c053b108 cpuidle_register+0x98/0xcc
> > [c00ff1503bc0] c085eaf0 powernv_processor_idle_init+0x140/0x1e0
> > [c00ff1503c60] c000cd60 do_one_initcall+0xc0/0x15c
> > [c00ff1503d20] c0833e84 kernel_init_freeable+0x1a0/0x25c
> > [c00ff1503dc0] c000d478 kernel_init+0x24/0x12c
> > [c00ff1503e30] c000b564 ret_from_kernel_thread+0x5c/0x78
> >
> > This patch fixes the bug by passing correct cpumask from
> > powernv-cpuidle driver.
> >
> > Signed-off-by: Vaidyanathan Srinivasan 
> 
> That needs to be ACKed by someone familiar with powernv.

Previous version at
https://lists.ozlabs.org/pipermail/linuxppc-dev/2017-March/155587.html

I had not CCed linux-pm in the first post.

Michael and Mikey have reviewed the previous version.  Let me get an
ack for you to proceed with the merge.

Thanks,
Vaidy



Re: stmmac: Performance regression after commit aff3d9eff843 "net: stmmac: enable multiple buffers"

2017-03-23 Thread Joao Pinto
Às 10:56 AM de 3/23/2017, Joao Pinto escreveu:
> Às 10:51 AM de 3/23/2017, Giuseppe CAVALLARO escreveu:
>> On 3/23/2017 11:48 AM, Giuseppe CAVALLARO wrote:
>>> Hello
>>>
>>> On 3/23/2017 11:20 AM, Corentin Labbe wrote:
>>>>> I have a 4.21 QoS Core with 4 RX + 4 TX and detected no regression.
>>>>>> Could you please share the iperf cmds you are using in order for me to
>>>>> reproduce
>>>>>> in my side?
>>>

HW Version: 4.21 QoS Core in HAPS DX7 (FPGA)
The connection between the FPGA and PC where stmmac is running is PCIe.
My configurations are done in stmmac_pci. Here they are:

@@ -68,10 +70,52 @@ static void stmmac_default_data(struct plat_stmmacenet_data
*plat)
 {
plat->bus_id = 1;
plat->phy_addr = 0;
-   plat->interface = PHY_INTERFACE_MODE_GMII;
-   plat->clk_csr = 2;  /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
-   plat->has_gmac = 1;
-   plat->force_sf_dma_mode = 1;
+   plat->interface = PHY_INTERFACE_MODE_SGMII;
+   plat->clk_csr = 0x5;
+   plat->has_gmac = 0;
+   plat->has_gmac4 = 1;
+   plat->force_sf_dma_mode = 0;
+
+   plat->rx_queues_to_use = 4;
+   plat->tx_queues_to_use = 4;
+
+   plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
+
+   plat->rx_queues_cfg[0].mode_to_use = MTL_QUEUE_AVB;
+   plat->rx_queues_cfg[1].mode_to_use = MTL_QUEUE_DCB;
+   plat->rx_queues_cfg[2].mode_to_use = MTL_QUEUE_DCB;
+   plat->rx_queues_cfg[3].mode_to_use = MTL_QUEUE_DCB;
+
+   plat->tx_queues_cfg[0].mode_to_use = MTL_QUEUE_DCB;
+   plat->tx_queues_cfg[1].mode_to_use = MTL_QUEUE_AVB;
+   plat->tx_queues_cfg[2].mode_to_use = MTL_QUEUE_DCB;
+   plat->tx_queues_cfg[3].mode_to_use = MTL_QUEUE_DCB;
+
+   plat->tx_queues_cfg[1].send_slope = 0xCCC;
+   plat->tx_queues_cfg[1].idle_slope = 0x1333;
+   plat->tx_queues_cfg[1].high_credit = 0x4B;
+   plat->tx_queues_cfg[1].low_credit = 0xFFB5;
+
+   plat->rx_queues_cfg[0].chan = 0;
+   plat->rx_queues_cfg[1].chan = 1;
+   plat->rx_queues_cfg[2].chan = 2;
+   plat->rx_queues_cfg[3].chan = 3;
+
+   plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WRR;
+   plat->tx_queues_cfg[0].weight = 0x10;
+   plat->tx_queues_cfg[1].weight = 0x11;
+   plat->tx_queues_cfg[2].weight = 0x12;
+   plat->tx_queues_cfg[3].weight = 0x13;
+
+   /* Disable Priority config by default */
+   plat->tx_queues_cfg[0].use_prio = false;
+   plat->rx_queues_cfg[0].use_prio = false;
+
+   /* Disable RX queues routing by default */
+   plat->rx_queues_cfg[0].pkt_route = 0x0;
+   plat->rx_queues_cfg[1].pkt_route = 0x0;
+   plat->rx_queues_cfg[2].pkt_route = 0x0;
+   plat->rx_queues_cfg[3].pkt_route = 0x0;

plat->mdio_bus_data->phy_reset = NULL;
plat->mdio_bus_data->phy_mask = 0;
@@ -83,22 +127,14 @@ static void stmmac_default_data(struct plat_stmmacenet_data
*plat)
/* Set default value for multicast hash bins */
plat->multicast_filter_bins = HASH_TABLE_SIZE;

+   plat->dma_cfg->fixed_burst = 0;
+   plat->dma_cfg->aal = 0;
+
/* Set default value for unicast filter entries */
plat->unicast_filter_entries = 1;

/* Set the maxmtu to a default of JUMBO_LEN */
plat->maxmtu = JUMBO_LEN;
-
-   /* Set default number of RX and TX queues to use */
-   plat->tx_queues_to_use = 1;
-   plat->rx_queues_to_use = 1;
-
-   /* Disable Priority config by default */
-   plat->tx_queues_cfg[0].use_prio = false;
-   plat->rx_queues_cfg[0].use_prio = false;
-
-   /* Disable RX queues routing by default */
-   plat->rx_queues_cfg[0].pkt_route = 0x0;
 }


*** TESTS ***


*TEST 1: File (linux-next tarball) transfer of ~1.4G by scp to the DUT*

scp net-next-20170323.tar.gz x@XXX:/home/synopsys/
The authenticity of host 'X' can't be established.
ECDSA key fingerprint is SHA256:/XX.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'XX' (ECDSA) to the list of known hosts.
XX@X's password:
net-next20170323.tar.gz

 100% 1366MB  79.3MB/s   00:17

ifconfig after transfer:

eth1  Link encap:Ethernet  HWaddr 
  inet addr:  Bcast:  Mask:
  inet6 addr: X Scope:Link
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  RX packets:1026614 errors:0 dropped:0 overruns:0 frame:0
  TX packets:56804 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:1502856063 (1.5 GB)  TX bytes:4224767 (4.2 MB)
  Interrupt:16

*stmmac Log after transfer:

#:~/temp$ dmesg | grep stmmac
[0.

netlink: NULL timer crash

2017-03-23 Thread Dmitry Vyukov
Hello,

The following program triggers call of NULL timer func:

https://gist.githubusercontent.com/dvyukov/c210d01c74b911273469a93862ea7788/raw/2a3182772a6a6e20af3e71c02c2a1c2895d803fb/gistfile1.txt


BUG: unable to handle kernel NULL pointer dereference at   (null)
IP:   (null)
PGD 0
Oops: 0010 [#1] SMP KASAN
Modules linked in:
CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.11.0-rc3+ #365
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: 88006c634300 task.stack: 88006c64
RIP: 0010:  (null)
RSP: 0018:88006d1077c8 EFLAGS: 00010246
RAX: dc00 RBX: 880062bddb00 RCX: 8154e161
RDX: 1090c1f1 RSI:  RDI: 880062bddb00
RBP: 88006d1077e8 R08: fbfff0a936a8 R09: 0001
R10: 0001 R11: fbfff0a936a7 R12: 84860f80
R13:  R14: 880062bddb60 R15: 11000da20f05
FS:  () GS:88006d10() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2:  CR3: 04e21000 CR4: 001406e0
Call Trace:
 
 neigh_timer_handler+0x365/0xd40 net/core/neighbour.c:944
 call_timer_fn+0x232/0x8c0 kernel/time/timer.c:1268
 expire_timers kernel/time/timer.c:1307 [inline]
 __run_timers+0x6f7/0xbd0 kernel/time/timer.c:1601
 run_timer_softirq+0x21/0x80 kernel/time/timer.c:1614
 __do_softirq+0x2d6/0xb54 kernel/softirq.c:284
 invoke_softirq kernel/softirq.c:364 [inline]
 irq_exit+0x1b1/0x1e0 kernel/softirq.c:405
 exiting_irq arch/x86/include/asm/apic.h:657 [inline]
 smp_apic_timer_interrupt+0x76/0xa0 arch/x86/kernel/apic/apic.c:962
 apic_timer_interrupt+0x93/0xa0 arch/x86/entry/entry_64.S:487
RIP: 0010:native_safe_halt+0x6/0x10 arch/x86/include/asm/irqflags.h:53
RSP: 0018:88006c647dc0 EFLAGS: 0286 ORIG_RAX: ff10
RAX: dc00 RBX: 11000d8c8fbb RCX: 
RDX: 109d8ed4 RSI: 0001 RDI: 84ec76a0
RBP: 88006c647dc0 R08: ed000d8c6861 R09: 
R10:  R11:  R12: fbfff09d8ed2
R13: 88006c647e78 R14: 84ec7690 R15: 0002
 
 arch_safe_halt arch/x86/include/asm/paravirt.h:98 [inline]
 default_idle+0xba/0x450 arch/x86/kernel/process.c:275
 arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:266
 default_idle_call+0x37/0x80 kernel/sched/idle.c:97
 cpuidle_idle_call kernel/sched/idle.c:155 [inline]
 do_idle+0x230/0x380 kernel/sched/idle.c:244
 cpu_startup_entry+0x18/0x20 kernel/sched/idle.c:346
 start_secondary+0x2a7/0x340 arch/x86/kernel/smpboot.c:275
 start_cpu+0x14/0x14 arch/x86/kernel/head_64.S:306
Code:  Bad RIP value.
RIP:   (null) RSP: 88006d1077c8
CR2: 
---[ end trace 845120b8a0d21411 ]---

On commit 093b995e3b55a0ae0670226ddfcb05bfbf0099ae


Re: [PATCH] hangcheck-timer: Fix typo in comment

2017-03-23 Thread Greg Kroah-Hartman
On Thu, Mar 23, 2017 at 05:08:00PM +0800, Shile Zhang wrote:
> Fix the typo "alloted" -> "allotted" in comment.
> 
> Signed-off-by: Shile Zhang 
> ---
>  drivers/char/hangcheck-timer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

You sent me two different patches, with the same subject, yet they did
different things, so I have no idea what to do with them here :(

Please resend, the correct one, as a v2 patch, with the needed v2
information, and I'll be glad to consider it.

thanks,

greg k-h


[RFC PATCH 1/2] mm/hugetlb.c: add hstate parameter to huge_pte_offset()

2017-03-23 Thread Punit Agrawal
A poisoned or migrated hugepage is stored as a swap entry in the page
tables. On architectures that support hugepages consisting of contiguous
page table entries (such as on arm64) this leads to ambiguity in
determining the right page table entry to return in huge_pte_offset()
when a poisoned entry is encountered.

Let's remove the ambiguity by adding a hstate parameter to convey
additional information about the requested address. Also fixup the
definition/usage of huge_pte_offset() throughout the tree.

Signed-off-by: Punit Agrawal 
---
 arch/arm64/mm/hugetlbpage.c   |  2 +-
 arch/ia64/mm/hugetlbpage.c|  4 ++--
 arch/metag/mm/hugetlbpage.c   |  2 +-
 arch/mips/mm/hugetlbpage.c|  2 +-
 arch/parisc/mm/hugetlbpage.c  |  2 +-
 arch/powerpc/mm/hugetlbpage.c |  2 +-
 arch/s390/mm/hugetlbpage.c|  2 +-
 arch/sh/mm/hugetlbpage.c  |  2 +-
 arch/sparc/mm/hugetlbpage.c   |  2 +-
 arch/tile/mm/hugetlbpage.c|  2 +-
 arch/x86/mm/hugetlbpage.c |  2 +-
 fs/userfaultfd.c  |  7 +--
 include/linux/hugetlb.h   |  2 +-
 mm/hugetlb.c  | 18 +-
 mm/page_vma_mapped.c  |  2 +-
 mm/pagewalk.c |  2 +-
 16 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index e2106932daa0..75d8cc3e138b 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -189,7 +189,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
return pte;
 }
 
-pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, struct hstate 
*h)
 {
pgd_t *pgd;
pud_t *pud;
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 85de86d36fdf..09c865be3cfe 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -44,7 +44,7 @@ huge_pte_alloc(struct mm_struct *mm, unsigned long addr, 
unsigned long sz)
 }
 
 pte_t *
-huge_pte_offset (struct mm_struct *mm, unsigned long addr)
+huge_pte_offset (struct mm_struct *mm, unsigned long addr, struct hstate *h)
 {
unsigned long taddr = htlbpage_to_page(addr);
pgd_t *pgd;
@@ -92,7 +92,7 @@ struct page *follow_huge_addr(struct mm_struct *mm, unsigned 
long addr, int writ
if (REGION_NUMBER(addr) != RGN_HPAGE)
return ERR_PTR(-EINVAL);
 
-   ptep = huge_pte_offset(mm, addr);
+   ptep = huge_pte_offset(mm, addr, size_to_hstate(HPAGE_SIZE));
if (!ptep || pte_none(*ptep))
return NULL;
page = pte_page(*ptep);
diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
index db1b7da91e4f..2c3b34189d29 100644
--- a/arch/metag/mm/hugetlbpage.c
+++ b/arch/metag/mm/hugetlbpage.c
@@ -74,7 +74,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
return pte;
 }
 
-pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, struct hstate 
*h)
 {
pgd_t *pgd;
pud_t *pud;
diff --git a/arch/mips/mm/hugetlbpage.c b/arch/mips/mm/hugetlbpage.c
index 74aa6f62468f..e66f47074ea4 100644
--- a/arch/mips/mm/hugetlbpage.c
+++ b/arch/mips/mm/hugetlbpage.c
@@ -36,7 +36,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long 
addr,
return pte;
 }
 
-pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, struct hstate 
*h)
 {
pgd_t *pgd;
pud_t *pud;
diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c
index aa50ac090e9b..c146ee7d80c7 100644
--- a/arch/parisc/mm/hugetlbpage.c
+++ b/arch/parisc/mm/hugetlbpage.c
@@ -69,7 +69,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
return pte;
 }
 
-pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, struct hstate 
*h)
 {
pgd_t *pgd;
pud_t *pud;
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 8c3389cbcd12..9fddb22c60d9 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -55,7 +55,7 @@ static unsigned nr_gpages;
 
 #define hugepd_none(hpd)   (hpd_val(hpd) == 0)
 
-pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, struct hstate 
*h)
 {
/* Only called for hugetlbfs pages, hence can ignore THP */
return __find_linux_pte_or_hugepte(mm->pgd, addr, NULL, NULL);
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index 9b4050caa4e9..63061fcb0560 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -176,7 +176,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
return (pte_t *) pmdp;
 }
 
-pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+pte_t *huge_pte_offset(struct mm_struct *mm, 

Re: net/kcm: use-after-free in kcm_wq

2017-03-23 Thread Dmitry Vyukov
On Fri, Mar 3, 2017 at 9:03 PM, Cong Wang  wrote:
> On Fri, Mar 3, 2017 at 2:11 AM, Dmitry Vyukov  wrote:
>> Also like this one:
>>
>> ==
>> BUG: KASAN: use-after-free in atomic_long_read
>> include/linux/compiler.h:254 [inline] at addr 8800538aba60
>> BUG: KASAN: use-after-free in get_work_pool+0x2f2/0x340
>> kernel/workqueue.c:709 at addr 8800538aba60
>> Read of size 8 by task syz-executor6/7965
>> CPU: 2 PID: 7965 Comm: syz-executor6 Not tainted 4.10.0+ #248
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
>> Call Trace:
>>  __dump_stack lib/dump_stack.c:15 [inline]
>>  dump_stack+0x2ee/0x3ef lib/dump_stack.c:51
>>  kasan_object_err+0x1c/0x70 mm/kasan/report.c:166
>>  print_address_description mm/kasan/report.c:204 [inline]
>>  kasan_report_error mm/kasan/report.c:288 [inline]
>>  kasan_report.part.2+0x198/0x440 mm/kasan/report.c:310
>>  kasan_report mm/kasan/report.c:331 [inline]
>>  __asan_report_load8_noabort+0x29/0x30 mm/kasan/report.c:331
>>  atomic_long_read include/linux/compiler.h:254 [inline]
>>  get_work_pool+0x2f2/0x340 kernel/workqueue.c:709
>>  __queue_work+0x2b3/0x1210 kernel/workqueue.c:1401
>>  queue_work_on+0x2e9/0x330 kernel/workqueue.c:1486
>>  queue_work include/linux/workqueue.h:487 [inline]
>>  strp_check_rcv+0x25/0x30 net/strparser/strparser.c:494
>
>
> It is not kcm_wq, it is strp_wq, and the work struct is strp->rx_work
> which lives in struct kcm_psock. The work is cancelled by strp_done(),
> it seems get queued again after strp_done()...


on 093b995e3b55a0ae0670226ddfcb05bfbf0099ae:

==
BUG: KASAN: use-after-free in worker_thread+0x1024/0x1340
kernel/workqueue.c:2229 at addr 88006d164ae0
Read of size 8 by task kworker/u8:3/25139
CPU: 2 PID: 25139 Comm: kworker/u8:3 Not tainted 4.11.0-rc3+ #364
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x1b8/0x28d lib/dump_stack.c:52
 kasan_object_err+0x1c/0x70 mm/kasan/report.c:166
 print_address_description mm/kasan/report.c:210 [inline]
 kasan_report_error mm/kasan/report.c:294 [inline]
 kasan_report.part.2+0x1be/0x480 mm/kasan/report.c:316
 kasan_report mm/kasan/report.c:337 [inline]
 __asan_report_load8_noabort+0x29/0x30 mm/kasan/report.c:337
 worker_thread+0x1024/0x1340 kernel/workqueue.c:2229
 kthread+0x359/0x420 kernel/kthread.c:229
 ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
Object at 88006d1649c0, in cache kcm_psock_cache size: 616
Allocated:
PID = 25123
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x43/0xd0 mm/kasan/kasan.c:517
 set_track mm/kasan/kasan.c:529 [inline]
 kasan_kmalloc+0xbc/0xf0 mm/kasan/kasan.c:620
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:559
 kmem_cache_alloc+0x110/0x720 mm/slab.c:3572
 kmem_cache_zalloc include/linux/slab.h:653 [inline]
 kcm_attach net/kcm/kcmsock.c:1386 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1457 [inline]
 kcm_ioctl+0x2bc/0x17e0 net/kcm/kcmsock.c:1692
 sock_do_ioctl+0x65/0xb0 net/socket.c:895
 sock_ioctl+0x2c2/0x440 net/socket.c:993
 vfs_ioctl fs/ioctl.c:45 [inline]
 do_vfs_ioctl+0x1af/0x16d0 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 entry_SYSCALL_64_fastpath+0x1f/0xc2
Freed:
PID = 25139
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x43/0xd0 mm/kasan/kasan.c:517
 set_track mm/kasan/kasan.c:529 [inline]
 kasan_slab_free+0x81/0xc0 mm/kasan/kasan.c:593
 __cache_free mm/slab.c:3514 [inline]
 kmem_cache_free+0x71/0x240 mm/slab.c:3774
 unreserve_psock+0x5d4/0x7b0 net/kcm/kcmsock.c:547
 kcm_write_msgs+0xba6/0x1ba0 net/kcm/kcmsock.c:590
 kcm_tx_work+0x32/0x1f0 net/kcm/kcmsock.c:731
 process_one_work+0xb20/0x1b40 kernel/workqueue.c:2097
 worker_thread+0x1b4/0x1340 kernel/workqueue.c:2231
 kthread+0x359/0x420 kernel/kthread.c:229
 ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
Memory state around the buggy address:
 88006d164980: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 88006d164a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>88006d164a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
   ^
 88006d164b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 88006d164b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==


[RFC PATCH 2/2] arm64: hugetlbpages: Correctly handle swap entries in huge_pte_offset()

2017-03-23 Thread Punit Agrawal
huge_pte_offset() does not correctly handle poisoned or migration page
table entries. Not knowing the size of the hugepage entry being
requested only compounded the problem.

The recently added hstate parameter can be used to determine the size of
hugepage being accessed. Use the size to find the correct page table
entry to return when coming across a swap page table entry.

Signed-off-by: Punit Agrawal 
Cc: David Woods 
---
 arch/arm64/mm/hugetlbpage.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 75d8cc3e138b..db108fa6e197 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -191,38 +191,39 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
 
 pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, struct hstate 
*h)
 {
+   unsigned long sz = huge_page_size(h);
pgd_t *pgd;
pud_t *pud;
-   pmd_t *pmd = NULL;
-   pte_t *pte = NULL;
+   pmd_t *pmd;
+   pte_t *pte;
 
pgd = pgd_offset(mm, addr);
pr_debug("%s: addr:0x%lx pgd:%p\n", __func__, addr, pgd);
if (!pgd_present(*pgd))
return NULL;
+
pud = pud_offset(pgd, addr);
-   if (!pud_present(*pud))
+   if (pud_none(*pud) && sz != PUD_SIZE)
return NULL;
-
-   if (pud_huge(*pud))
+   else if (!pud_table(*pud))
return (pte_t *)pud;
+
+   if (sz == CONT_PMD_SIZE)
+   addr &= CONT_PMD_MASK;
+
pmd = pmd_offset(pud, addr);
-   if (!pmd_present(*pmd))
+   if (pmd_none(*pmd) &&
+   !(sz == PMD_SIZE || sz == CONT_PMD_SIZE))
return NULL;
-
-   if (pte_cont(pmd_pte(*pmd))) {
-   pmd = pmd_offset(
-   pud, (addr & CONT_PMD_MASK));
-   return (pte_t *)pmd;
-   }
-   if (pmd_huge(*pmd))
+   else if (!pmd_table(*pmd))
return (pte_t *)pmd;
-   pte = pte_offset_kernel(pmd, addr);
-   if (pte_present(*pte) && pte_cont(*pte)) {
+
+   if (sz == CONT_PTE_SIZE) {
pte = pte_offset_kernel(
pmd, (addr & CONT_PTE_MASK));
return pte;
}
+
return NULL;
 }
 
-- 
2.11.0



[RFC PATCH v0.2] PCI: Add support for tango PCIe host bridge

2017-03-23 Thread Mason
I think this version is ready for review.
It has all the required bits and pieces.
I still have a few questions, embedded as comments in the code.
(Missing are ancillary changes to Kconfig, Makefile)
---
 drivers/pci/host/pcie-tango.c | 350 ++
 1 file changed, 350 insertions(+)
 create mode 100644 drivers/pci/host/pcie-tango.c

diff --git a/drivers/pci/host/pcie-tango.c b/drivers/pci/host/pcie-tango.c
new file mode 100644
index ..b2e6448aed2d
--- /dev/null
+++ b/drivers/pci/host/pcie-tango.c
@@ -0,0 +1,350 @@
+#include 
+#include 
+#include 
+#include 
+
+#define MSI_COUNT 32
+
+struct tango_pcie {
+   void __iomem *mux;
+   void __iomem *msi_status;
+   void __iomem *msi_mask;
+   phys_addr_t msi_doorbell;
+   struct mutex lock; /* lock for updating msi_mask */
+   struct irq_domain *irq_domain;
+   struct irq_domain *msi_domain;
+   int irq;
+};
+
+/*** MSI CONTROLLER SUPPORT ***/
+
+static void tango_msi_isr(struct irq_desc *desc)
+{
+   struct irq_chip *chip = irq_desc_get_chip(desc);
+   struct tango_pcie *pcie;
+   unsigned long status, virq;
+   int pos;
+
+   chained_irq_enter(chip, desc);
+   pcie = irq_desc_get_handler_data(desc);
+
+   status = readl_relaxed(pcie->msi_status);
+   writel_relaxed(status, pcie->msi_status); /* clear IRQs */
+
+   for_each_set_bit(pos, , MSI_COUNT) {
+   virq = irq_find_mapping(pcie->irq_domain, pos);
+   if (virq)
+   generic_handle_irq(virq);
+   else
+   pr_err("Unhandled MSI: %d\n", pos);
+   }
+
+   chained_irq_exit(chip, desc);
+}
+
+static struct irq_chip tango_msi_irq_chip = {
+   .name = "MSI",
+   .irq_mask = pci_msi_mask_irq,
+   .irq_unmask = pci_msi_unmask_irq,
+};
+
+static struct msi_domain_info msi_domain_info = {
+   .flags  = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS,
+   .chip   = _msi_irq_chip,
+};
+
+static void tango_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
+{
+   struct tango_pcie *pcie = irq_data_get_irq_chip_data(data);
+
+   msg->address_lo = lower_32_bits(pcie->msi_doorbell);
+   msg->address_hi = upper_32_bits(pcie->msi_doorbell);
+   msg->data = data->hwirq;
+}
+
+static int tango_set_affinity(struct irq_data *irq_data,
+   const struct cpumask *mask, bool force)
+{
+return -EINVAL;
+}
+
+static struct irq_chip tango_msi_chip = {
+   .name   = "MSI",
+   .irq_compose_msi_msg= tango_compose_msi_msg,
+   .irq_set_affinity   = tango_set_affinity,
+};
+
+static int tango_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
+   unsigned int nr_irqs, void *args)
+{
+   struct tango_pcie *pcie = domain->host_data;
+   int pos, err = 0;
+   u32 mask;
+
+   if (nr_irqs != 1) /* When does that happen? */
+   return -EINVAL;
+
+   mutex_lock(>lock);
+
+   mask = readl_relaxed(pcie->msi_mask);
+   pos = find_first_zero_bit(, MSI_COUNT);
+   if (pos < MSI_COUNT)
+   writel(mask | BIT(pos), pcie->msi_mask);
+   else
+   err = -ENOSPC;
+
+   mutex_unlock(>lock);
+
+   irq_domain_set_info(domain, virq, pos, _msi_chip,
+   domain->host_data, handle_simple_irq, NULL, NULL);
+
+   return err;
+}
+
+static void tango_irq_domain_free(struct irq_domain *domain,
+  unsigned int virq, unsigned int nr_irqs)
+{
+   struct irq_data *d = irq_domain_get_irq_data(domain, virq);
+   struct tango_pcie *pcie = irq_data_get_irq_chip_data(d);
+   int pos = d->hwirq;
+   u32 mask;
+
+   mutex_lock(>lock);
+
+   mask = readl(pcie->msi_mask);
+   writel(mask & ~BIT(pos), pcie->msi_mask);
+
+   mutex_unlock(>lock);
+}
+
+static const struct irq_domain_ops msi_domain_ops = {
+   .alloc  = tango_irq_domain_alloc,
+   .free   = tango_irq_domain_free,
+};
+
+static int tango_msi_remove(struct platform_device *pdev)
+{
+   struct tango_pcie *msi = platform_get_drvdata(pdev);
+
+   irq_set_chained_handler(msi->irq, NULL);
+   irq_set_handler_data(msi->irq, NULL);
+   /* irq_set_chained_handler_and_data(msi->irq, NULL, NULL); instead? */
+
+   irq_domain_remove(msi->msi_domain);
+   irq_domain_remove(msi->irq_domain);
+
+   return 0;
+}
+
+static int tango_msi_probe(struct platform_device *pdev, struct tango_pcie 
*pcie)
+{
+   int virq;
+   struct fwnode_handle *fwnode = of_node_to_fwnode(pdev->dev.of_node);
+   struct irq_domain *msi_dom, *irq_dom;
+
+   mutex_init(>lock);
+   writel(0, pcie->msi_mask);
+
+   /* Why is fwnode for this call? */
+   irq_dom = irq_domain_add_linear(NULL, MSI_COUNT, _domain_ops, pcie);
+   if (!irq_dom) {
+   pr_err("Failed to create IRQ domain\n");
+   

security, hugetlbfs: write to user memory in hugetlbfs_destroy_inode

2017-03-23 Thread Dmitry Vyukov
Hello,

I've got the following report while running syzkaller fuzzer on
093b995e3b55a0ae0670226ddfcb05bfbf0099ae. Note the preceding injected
kmalloc failure in inode_alloc_security, most likely it's the root
cause.


FAULT_INJECTION: forcing a failure.
name failslab, interval 1, probability 0, space 0, times 0
CPU: 3 PID: 14086 Comm: syz-executor6 Not tainted 4.11.0-rc3+ #364
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x1b8/0x28d lib/dump_stack.c:52
 fail_dump lib/fault-inject.c:45 [inline]
 should_fail+0x78a/0x870 lib/fault-inject.c:154
 should_failslab+0xec/0x120 mm/failslab.c:31
 slab_pre_alloc_hook mm/slab.h:434 [inline]
 slab_alloc mm/slab.c:3394 [inline]
 kmem_cache_alloc+0x200/0x720 mm/slab.c:3570
 kmem_cache_zalloc include/linux/slab.h:653 [inline]
 inode_alloc_security security/selinux/hooks.c:221 [inline]
 selinux_inode_alloc_security+0xf9/0x390 security/selinux/hooks.c:2833
 security_inode_alloc+0x90/0xd0 security/security.c:387
 inode_init_always+0x5af/0xc20 fs/inode.c:166
 alloc_inode+0x82/0x180 fs/inode.c:214
 new_inode_pseudo+0x69/0x190 fs/inode.c:889
 new_inode+0x1c/0x40 fs/inode.c:918
 hugetlbfs_get_inode+0x40/0x420 fs/hugetlbfs/inode.c:734
 hugetlb_file_setup+0x329/0x9f0 fs/hugetlbfs/inode.c:1282
 newseg+0x422/0xd30 ipc/shm.c:575
 ipcget_new ipc/util.c:285 [inline]
 ipcget+0x21e/0x580 ipc/util.c:639
 SYSC_shmget ipc/shm.c:673 [inline]
 SyS_shmget+0x158/0x230 ipc/shm.c:657
 entry_SYSCALL_64_fastpath+0x1f/0xc2
RIP: 0033:0x445b79
RSP: 002b:7f9dcc5df858 EFLAGS: 0282 ORIG_RAX: 001d
RAX: ffda RBX: 00708000 RCX: 00445b79
RDX: 0800 RSI: 3000 RDI: 
RBP: 0086 R08:  R09: 
R10: 20207000 R11: 0282 R12: 004a7e31
R13:  R14: 7f9dcc5df618 R15: 7f9dcc5df788
==
BUG: KASAN: user-memory-access in atomic_inc
include/asm-generic/atomic-instrumented.h:87 [inline] at addr
00131730bd7a
BUG: KASAN: user-memory-access in __lock_acquire+0x21a/0x3a80
kernel/locking/lockdep.c:3239 at addr 00131730bd7a
Write of size 4 by task syz-executor6/14086
CPU: 3 PID: 14086 Comm: syz-executor6 Not tainted 4.11.0-rc3+ #364
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x1b8/0x28d lib/dump_stack.c:52
 kasan_report_error mm/kasan/report.c:291 [inline]
 kasan_report.part.2+0x34a/0x480 mm/kasan/report.c:316
 kasan_report+0x21/0x30 mm/kasan/report.c:303
 check_memory_region_inline mm/kasan/kasan.c:326 [inline]
 check_memory_region+0x137/0x190 mm/kasan/kasan.c:333
 kasan_check_write+0x14/0x20 mm/kasan/kasan.c:344
 atomic_inc include/asm-generic/atomic-instrumented.h:87 [inline]
 __lock_acquire+0x21a/0x3a80 kernel/locking/lockdep.c:3239
 lock_acquire+0x1ee/0x590 kernel/locking/lockdep.c:3762
 __raw_write_lock include/linux/rwlock_api_smp.h:210 [inline]
 _raw_write_lock+0x33/0x50 kernel/locking/spinlock.c:295
 mpol_free_shared_policy+0x43/0xb0 mm/mempolicy.c:2536
 hugetlbfs_destroy_inode+0xca/0x120 fs/hugetlbfs/inode.c:952
 alloc_inode+0x10d/0x180 fs/inode.c:216
 new_inode_pseudo+0x69/0x190 fs/inode.c:889
 new_inode+0x1c/0x40 fs/inode.c:918
 hugetlbfs_get_inode+0x40/0x420 fs/hugetlbfs/inode.c:734
 hugetlb_file_setup+0x329/0x9f0 fs/hugetlbfs/inode.c:1282
 newseg+0x422/0xd30 ipc/shm.c:575
 ipcget_new ipc/util.c:285 [inline]
 ipcget+0x21e/0x580 ipc/util.c:639
 SYSC_shmget ipc/shm.c:673 [inline]
 SyS_shmget+0x158/0x230 ipc/shm.c:657
 entry_SYSCALL_64_fastpath+0x1f/0xc2
RIP: 0033:0x445b79
RSP: 002b:7f9dcc5df858 EFLAGS: 0282 ORIG_RAX: 001d
RAX: ffda RBX: 00708000 RCX: 00445b79
RDX: 0800 RSI: 3000 RDI: 
RBP: 0086 R08:  R09: 
R10: 20207000 R11: 0282 R12: 004a7e31
R13:  R14: 7f9dcc5df618 R15: 7f9dcc5df788
==


[PATCH] staging: media: atomisp: use kvmalloc and kvfree

2017-03-23 Thread Geliang Tang
Use kvmalloc() and kvfree() instead of open-coding.

Signed-off-by: Geliang Tang 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..c7b9320 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -90,10 +90,7 @@ union host {
 void *atomisp_kernel_malloc(size_t bytes)
 {
/* vmalloc() is preferable if allocating more than 1 page */
-   if (bytes > PAGE_SIZE)
-   return vmalloc(bytes);
-
-   return kmalloc(bytes, GFP_KERNEL);
+   return kvmalloc(bytes, GFP_KERNEL);
 }
 
 /*
@@ -118,10 +115,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
 void atomisp_kernel_free(void *ptr)
 {
/* Verify if buffer was allocated by vmalloc() or kmalloc() */
-   if (is_vmalloc_addr(ptr))
-   vfree(ptr);
-   else
-   kfree(ptr);
+   kvfree(ptr);
 }
 
 /*
-- 
2.9.3



[PATCH] staging: media: atomisp: fix build error

2017-03-23 Thread Geliang Tang
Fix the following build error:

  CC  drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.o
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c:52:2:
 error: excess elements in array initializer [-Werror]
  "i", /* ion */
  ^~~
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c:52:2:
 note: (near initialization for ‘hmm_bo_type_strings’)
cc1: all warnings being treated as errors
scripts/Makefile.build:294: recipe for target
'drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.o' failed

Signed-off-by: Geliang Tang 
---
 drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
index a362b49..e78f02f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
@@ -49,7 +49,9 @@ const char *hmm_bo_type_strings[HMM_BO_LAST] = {
"p", /* private */
"s", /* shared */
"u", /* user */
+#ifdef CONFIG_ION
"i", /* ion */
+#endif
 };
 
 static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
-- 
2.9.3



Re: [PATCH 05/11] staging: speakup: Remove multiple assignments

2017-03-23 Thread Greg KH
On Tue, Mar 21, 2017 at 05:12:29PM +0530, Arushi Singhal wrote:
> This patch fixes the checkpatch.pl warning "multiple assignments
> should be avoided."
> 
> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/speakup/main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
> index 21e76b031449..c10445624e92 100644
> --- a/drivers/staging/speakup/main.c
> +++ b/drivers/staging/speakup/main.c
> @@ -2106,7 +2106,8 @@ speakup_key(struct vc_data *vc, int shift_state, int 
> keycode, u_short keysym,
>   spk_keydown = 0;
>   goto out;
>   }
> - value = spk_lastkey = pad_chars[value];
> + value = pad_chars[value];
> + spk_lastkey = value;

Also harder to read now :(



Re: [PATCH 02/11] staging: speakup: Remove multiple assignments

2017-03-23 Thread Greg KH
On Tue, Mar 21, 2017 at 05:12:26PM +0530, Arushi Singhal wrote:
> This patch fixes the checkpatch.pl warning "multiple assignments
> should be avoided."
> 
> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/speakup/main.c | 18 --
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
> index f71206878363..f8fccc8bf6b2 100644
> --- a/drivers/staging/speakup/main.c
> +++ b/drivers/staging/speakup/main.c
> @@ -270,9 +270,12 @@ static unsigned char get_attributes(struct vc_data *vc, 
> u16 *pos)
>  
>  static void speakup_date(struct vc_data *vc)
>  {
> - spk_x = spk_cx = vc->vc_x;
> - spk_y = spk_cy = vc->vc_y;
> - spk_pos = spk_cp = vc->vc_pos;
> + spk_x = vc->vc_x;
> + spk_cx = spk_x;
> + spk_y = vc->vc_y;
> + spk_cy = spk_y;
> + spk_pos = vc->vc_pos;
> + spk_cp = spk_pos;

Ick, this is harder to read now, don't you think?

not good.

greg k-h


Re: [PATCH] hibernation: on 32-bit x86, disabled in favor of KASLR

2017-03-23 Thread Evgenii Shatokhin

On 23.03.2017 03:27, Kees Cook wrote:

This is a modified revert of commit 65fe935dd238 ("x86/KASLR, x86/power:
Remove x86 hibernation restrictions"), since it appears that 32-bit
hibernation still can't support KASLR. 64-bit is fine. Since people have
been running with KASLR by default on 32-bit since v4.8, this disables
hibernation (with a warning). Booting with "nokaslr" will disable KASLR
and enable hibernation.

Reported-by: Evgenii Shatokhin 
Signed-off-by: Kees Cook 
Cc: sta...@vger.kernel.org # v4.8+


The patch does not work as intended on my system, unfortunately.

I tried the mainline kernel v4.11-rc3 and added this patch. With 
"nokaslr" in the kernel command line, the system fails to hibernate. It 
complains this way in the log:


<...>
kernel: PM: writing image.
kernel: PM: Cannot find swap device, try swapon -a.
kernel: PM: Cannot get swap writer
kernel: PM: Basic memory bitmaps freed
kernel: Restarting tasks ... done.
systemd[1]: Time has been changed
systemd[3948]: Time has been changed
systemd[14825]: Time has been changed
systemd[1]: systemd-hibernate.service: main process exited, code=exited, 
status=1/FAILURE

systemd[1]: Failed to start Hibernate.
<...>

The swap device (swap file, actually) is available, however:
-
# swapon -s
Filename  Type  SizeUsed  Priority
/swap file  6297596 0 -1
-

I built the same kernel without this patch then, added "nokaslr" in the 
kernel command line again, and the system hibernates and resumes fine.



---
  Documentation/admin-guide/kernel-parameters.txt |  5 +
  arch/x86/boot/compressed/kaslr.c|  3 +++
  kernel/power/hibernate.c| 18 +-
  3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 2ba45caabada..6f899c7f587d 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1725,6 +1725,11 @@
kernel and module base offset ASLR (Address Space
Layout Randomization).

+   On 32-bit x86 with CONFIG_HIBERNATION, hibernation
+   is disabled if KASLR is enabled. If "nokaslr" is
+   specified, KASLR will be diabled and hibernation
+   will be enabled.
+
keepinitrd  [HW,ARM]

kernelcore= [KNL,X86,IA-64,PPC]
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 8b7c9e75edcb..b694af45f1e0 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -572,6 +572,9 @@ void choose_random_location(unsigned long input,
return;
}

+   if (IS_ENABLED(CONFIG_X86_32) && IS_ENABLED(CONFIG_HIBERNATION))
+   warn("KASLR active: hibernation disabled on 32-bit x86.");
+
boot_params->hdr.loadflags |= KASLR_FLAG;

/* Prepare to add new identity pagetables on demand. */
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index a8b978c35a6a..1d8f1fe1b7f4 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -37,9 +37,14 @@
  #include "power.h"


-static int nocompress;
+#if defined(CONFIG_X86_32) && defined(CONFIG_RANDOMIZE_BASE)
+static int noresume = 1;
+static int nohibernate = 1;
+#else
  static int noresume;
  static int nohibernate;
+#endif
+static int nocompress;
  static int resume_wait;
  static unsigned int resume_delay;
  static char resume_file[256] = CONFIG_PM_STD_PARTITION;
@@ -1194,3 +1199,14 @@ __setup("hibernate=", hibernate_setup);
  __setup("resumewait", resumewait_setup);
  __setup("resumedelay=", resumedelay_setup);
  __setup("nohibernate", nohibernate_setup);
+
+/* Allow hibernation to be disabled in favor of KASLR on 32-bit x86. */
+#if defined(CONFIG_X86_32) && defined(CONFIG_RANDOMIZE_BASE)
+static int __init nokaslr_hibernate_setup(char *str)
+{
+   noresume = 0;
+   nohibernate = 0;
+   return 1;
+}
+__setup("nokaslr", nokaslr_hibernate_setup);
+#endif





Re: [PATCH 2/5] mfd: intel_soc_pmic: Select designware i2c-bus driver

2017-03-23 Thread Lee Jones
On Wed, 22 Mar 2017, Andy Shevchenko wrote:

> On Wed, 2017-03-22 at 12:29 +0100, Hans de Goede wrote:
> > The Crystal Cove PMIC provides an ACPI OPRegion handler, which must be
> > available before other drivers using it are loaded, which is why
> > INTEL_SOC_PMIC is a bool.
> > 
> > Just having the driver is not enough, the driver for the i2c-bus must
> > also be built in, to ensure this, this patch adds a select for it.
> > 
> 
> > While at it this patch also changes the human readable name of the
> > Kconfig
> > option to make clear the INTEL_SOC_PMIC option selects support for the
> > Intel Crystal Cove PMIC and documents why this is a bool.
> 
> The above is what my patch does, I'm okay if the change is going with
> this series as long as Lee is on the same side. Otherwise I would prefer
> to go my changes first.

I think this set is going to need to be rebase on top of MFD.

> > Cc: Andy Shevchenko 
> > Signed-off-by: Hans de Goede 
> > ---
> > Note this patch will partially conflicts with (contains the same
> > changes as)
> > a patch in Andy Shevchenko's tree.
> > ---
> >  drivers/mfd/Kconfig | 7 +--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> > index d427a10..0c6a967 100644
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -425,14 +425,17 @@ config LPC_SCH
> >       System Management Bus and General Purpose I/O.
> >  
> >  config INTEL_SOC_PMIC
> > -   bool "Support for Intel Atom SoC PMIC"
> > +   # This is a bool as it provides an ACPI Opregion which must
> > be
> > +   # available as soon as possible
> > +   bool "Support for Intel Crystal Cove PMIC"
> >     depends on GPIOLIB
> >     depends on I2C=y
> >     select MFD_CORE
> >     select REGMAP_I2C
> >     select REGMAP_IRQ
> > +   select I2C_DESIGNWARE_PLATFORM
> >     help
> > -     Select this option to enable support for the PMIC device
> > +     Select this option to enable support for the Crystal Cove
> > PMIC
> >       on some Intel SoC systems. The PMIC provides ADC, GPIO,
> >       thermal, charger and related power management functions
> >       on these systems.
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


[PATCH 1/8] pinctrl: meson: gxbb: add i2s output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 31 ++
 1 file changed, 31 insertions(+)

diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c 
b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
index 7671424d46cb..8d5dd4772042 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
@@ -236,6 +236,10 @@ static const unsigned int hdmi_hpd_pins[]  = { 
PIN(GPIOH_0, EE_OFF) };
 static const unsigned int hdmi_sda_pins[]  = { PIN(GPIOH_1, EE_OFF) };
 static const unsigned int hdmi_scl_pins[]  = { PIN(GPIOH_2, EE_OFF) };
 
+static const unsigned int i2s_out_ch23_y_pins[]= { PIN(GPIOY_8, 
EE_OFF) };
+static const unsigned int i2s_out_ch45_y_pins[]= { PIN(GPIOY_9, 
EE_OFF) };
+static const unsigned int i2s_out_ch67_y_pins[]= { PIN(GPIOY_10, 
EE_OFF) };
+
 static const struct pinctrl_pin_desc meson_gxbb_aobus_pins[] = {
MESON_PIN(GPIOAO_0, 0),
MESON_PIN(GPIOAO_1, 0),
@@ -274,6 +278,13 @@ static const unsigned int pwm_ao_a_6_pins[]= { 
PIN(GPIOAO_6, 0) };
 static const unsigned int pwm_ao_a_12_pins[]   = { PIN(GPIOAO_12, 0) };
 static const unsigned int pwm_ao_b_pins[]  = { PIN(GPIOAO_13, 0) };
 
+static const unsigned int i2s_am_clk_pins[] = { PIN(GPIOAO_8, 0) };
+static const unsigned int i2s_out_ao_clk_pins[] = { PIN(GPIOAO_9, 0) };
+static const unsigned int i2s_out_lr_clk_pins[] = { PIN(GPIOAO_10, 0) 
};
+static const unsigned int i2s_out_ch01_ao_pins[] = { PIN(GPIOAO_11, 0) };
+static const unsigned int i2s_out_ch23_ao_pins[] = { PIN(GPIOAO_12, 0) };
+static const unsigned int i2s_out_ch45_ao_pins[] = { PIN(GPIOAO_13, 0) };
+
 static struct meson_pmx_group meson_gxbb_periphs_groups[] = {
GPIO_GROUP(GPIOZ_0, EE_OFF),
GPIO_GROUP(GPIOZ_1, EE_OFF),
@@ -426,6 +437,9 @@ static struct meson_pmx_group meson_gxbb_periphs_groups[] = 
{
GROUP(uart_rx_c,1,  16),
GROUP(pwm_a_y,  1,  21),
GROUP(pwm_f_y,  1,  20),
+   GROUP(i2s_out_ch23_y,   1,  5),
+   GROUP(i2s_out_ch45_y,   1,  6),
+   GROUP(i2s_out_ch67_y,   1,  7),
 
/* Bank Z */
GROUP(eth_mdio, 6,  1),
@@ -523,6 +537,12 @@ static struct meson_pmx_group meson_gxbb_aobus_groups[] = {
GROUP(pwm_ao_a_6,   0,  18),
GROUP(pwm_ao_a_12,  0,  17),
GROUP(pwm_ao_b, 0,  3),
+   GROUP(i2s_am_clk,   0,  30),
+   GROUP(i2s_out_ao_clk,   0,  29),
+   GROUP(i2s_out_lr_clk,   0,  28),
+   GROUP(i2s_out_ch01_ao,  0,  27),
+   GROUP(i2s_out_ch23_ao,  1,  0),
+   GROUP(i2s_out_ch45_ao,  1,  1),
 };
 
 static const char * const gpio_periphs_groups[] = {
@@ -652,6 +672,10 @@ static const char * const hdmi_i2c_groups[] = {
"hdmi_sda", "hdmi_scl",
 };
 
+static const char * const i2s_out_groups[] = {
+   "i2s_out_ch23_y", "i2s_out_ch45_y", "i2s_out_ch67_y",
+};
+
 static const char * const gpio_aobus_groups[] = {
"GPIOAO_0", "GPIOAO_1", "GPIOAO_2", "GPIOAO_3", "GPIOAO_4",
"GPIOAO_5", "GPIOAO_6", "GPIOAO_7", "GPIOAO_8", "GPIOAO_9",
@@ -694,6 +718,11 @@ static const char * const pwm_ao_b_groups[] = {
"pwm_ao_b",
 };
 
+static const char * const i2s_out_ao_groups[] = {
+   "i2s_am_clk", "i2s_out_ao_clk", "i2s_out_lr_clk",
+   "i2s_out_ch01_ao", "i2s_out_ch23_ao", "i2s_out_ch45_ao",
+};
+
 static struct meson_pmx_func meson_gxbb_periphs_functions[] = {
FUNCTION(gpio_periphs),
FUNCTION(emmc),
@@ -717,6 +746,7 @@ static struct meson_pmx_func meson_gxbb_periphs_functions[] 
= {
FUNCTION(pwm_f_y),
FUNCTION(hdmi_hpd),
FUNCTION(hdmi_i2c),
+   FUNCTION(i2s_out),
 };
 
 static struct meson_pmx_func meson_gxbb_aobus_functions[] = {
@@ -730,6 +760,7 @@ static struct meson_pmx_func meson_gxbb_aobus_functions[] = 
{
FUNCTION(pwm_ao_a_6),
FUNCTION(pwm_ao_a_12),
FUNCTION(pwm_ao_b),
+   FUNCTION(i2s_out_ao),
 };
 
 static struct meson_bank meson_gxbb_periphs_banks[] = {
-- 
2.9.3



Re: [PATCH v3 04/11] Documentation: DT: bindings: mfd: add A33 GPADC binding

2017-03-23 Thread Lee Jones
On Tue, 21 Mar 2017, Quentin Schulz wrote:

> This patch adds documentation for the A33 GPADC binding.
> 
> Signed-off-by: Quentin Schulz 
> ---
> 
> v3:
>   - fixed missing allwinner in front of compatible,
>   - updated compatible to allwinner,sun8i-a33-ths to better reflect the
>   datasheet's name,
>   - updated example's DT node name and label to ths,
> 
> added in v2
> 
>  .../devicetree/bindings/mfd/sun4i-gpadc.txt| 59 
> ++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt

This is going to need a DT Ack.

> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt 
> b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> new file mode 100644
> index 000..badff36
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> @@ -0,0 +1,59 @@
> +Allwinner SoCs' GPADC Device Tree bindings
> +--
> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> +and sometimes as a touchscreen controller.
> +
> +Required properties:
> +  - compatible: "allwinner,sun8i-a33-ths",
> +  - reg: mmio address range of the chip,
> +  - #thermal-sensor-cells: shall be 0,
> +  - #io-channel-cells: shall be 0,
> +
> +Example:
> + ths: ths@01c25000 {
> + compatible = "allwinner,sun8i-a33-ths";
> + reg = <0x01c25000 0x100>;
> + #thermal-sensor-cells = <0>;
> + #io-channel-cells = <0>;
> + };
> +
> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
> +
> +sun4i resistive touchscreen controller
> +--
> +
> +Required properties:
> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
> +   "allwinner,sun6i-a31-ts"
> + - reg: mmio address range of the chip
> + - interrupts: interrupt to which the chip is connected
> + - #thermal-sensor-cells: shall be 0
> +
> +Optional properties:
> + - allwinner,ts-attached  : boolean indicating that an actual touchscreen
> +is attached to the controller
> + - allwinner,tp-sensitive-adjust : integer (4 bits)
> +adjust sensitivity of pen down detection
> +between 0 (least sensitive) and 15
> +(defaults to 15)
> + - allwinner,filter-type  : integer (2 bits)
> +select median and averaging filter
> +samples used for median / averaging filter
> +0: 4/2
> +1: 5/3
> +2: 8/4
> +3: 16/8
> +(defaults to 1)
> +
> +Example:
> +
> + rtp: rtp@01c25000 {
> + compatible = "allwinner,sun4i-a10-ts";
> + reg = <0x01c25000 0x100>;
> + interrupts = <29>;
> + allwinner,ts-attached;
> + #thermal-sensor-cells = <0>;
> + /* sensitive/noisy touch panel */
> + allwinner,tp-sensitive-adjust = <0>;
> + allwinner,filter-type = <3>;
> + };

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


[PATCH 6/8] ARM64: dts: meson-gxbb: add spdif output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi 
b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 5ce70e1ec9ae..e5fd88e2c5f7 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -245,6 +245,20 @@
function = "i2s_out_ao";
};
};
+
+   spdif_out_ao_6_pins: spdif_out_ao_6 {
+   mux {
+   groups = "spdif_out_ao_6";
+   function = "spdif_out_ao";
+   };
+   };
+
+   spdif_out_ao_13_pins: spdif_out_ao_13 {
+   mux {
+   groups = "spdif_out_ao_13";
+   function = "spdif_out_ao";
+   };
+   };
};
 
clkc_AO: clock-controller@040 {
@@ -530,6 +544,13 @@
function = "i2s_out";
};
};
+
+   spdif_out_y_pins: spdif_out_y {
+   mux {
+   groups = "spdif_out_y";
+   function = "spdif_out";
+   };
+   };
};
 };
 
-- 
2.9.3



[PATCH 8/8] ARM64: dts: meson-gxl: add spdif output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi 
b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
index 88ad3490c124..8f57e74b719c 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
@@ -138,6 +138,20 @@
function = "i2s_out_ao";
};
};
+
+   spdif_out_ao_6_pins: spdif_out_ao_6 {
+   mux {
+   groups = "spdif_out_ao_6";
+   function = "spdif_out_ao";
+   };
+   };
+
+   spdif_out_ao_9_pins: spdif_out_ao_9 {
+   mux {
+   groups = "spdif_out_ao_9";
+   function = "spdif_out_ao";
+   };
+   };
};
 };
 
@@ -359,6 +373,13 @@
function = "i2s_out";
};
};
+
+   spdif_out_h_pins: spdif_out_ao_h {
+   mux {
+   groups = "spdif_out_h";
+   function = "spdif_out";
+   };
+   };
};
 
eth-phy-mux {
-- 
2.9.3



[PATCH 7/8] ARM64: dts: meson-gxl: add i2s output pins

2017-03-23 Thread Jerome Brunet
Signed-off-by: Jerome Brunet 
---
 arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 62 ++
 1 file changed, 62 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi 
b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
index fe11b5fc61f7..88ad3490c124 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
@@ -124,6 +124,20 @@
function = "pwm_ao_b";
};
};
+
+   i2s_out_ch23_ao_pins: i2s_out_ch23_ao {
+   mux {
+   groups = "i2s_out_ch23_ao";
+   function = "i2s_out_ao";
+   };
+   };
+
+   i2s_out_ch45_ao_pins: i2s_out_ch45_ao {
+   mux {
+   groups = "i2s_out_ch45_ao";
+   function = "i2s_out_ao";
+   };
+   };
};
 };
 
@@ -297,6 +311,54 @@
function = "hdmi_i2c";
};
};
+
+   i2s_am_clk_pins: i2s_am_clk {
+   mux {
+   groups = "i2s_am_clk";
+   function = "i2s_out";
+   };
+   };
+
+   i2s_out_ao_clk_pins: i2s_out_ao_clk {
+   mux {
+   groups = "i2s_out_ao_clk";
+   function = "i2s_out";
+   };
+   };
+
+   i2s_out_lr_clk_pins: i2s_out_lr_clk {
+   mux {
+   groups = "i2s_out_lr_clk";
+   function = "i2s_out";
+   };
+   };
+
+   i2s_out_ch01_pins: i2s_out_ch01 {
+   mux {
+   groups = "i2s_out_ch01";
+   function = "i2s_out";
+   };
+   };
+   i2sout_ch23_z_pins: i2sout_ch23_z {
+   mux {
+   groups = "i2sout_ch23_z";
+   function = "i2s_out";
+   };
+   };
+
+   i2sout_ch45_z_pins: i2sout_ch45_z {
+   mux {
+   groups = "i2sout_ch45_z";
+   function = "i2s_out";
+   };
+   };
+
+   i2sout_ch67_z_pins: i2sout_ch67_z {
+   mux {
+   groups = "i2sout_ch67_z";
+   function = "i2s_out";
+   };
+   };
};
 
eth-phy-mux {
-- 
2.9.3



Re: [tip:sched/urgent] sched/clock: Fix clear_sched_clock_stable() preempt wobbly

2017-03-23 Thread Paul E. McKenney
On Thu, Mar 23, 2017 at 02:10:47AM -0700, tip-bot for Peter Zijlstra wrote:
> Commit-ID:  71fdb70eb48784c1f28cdf2e67c4c587dd7f2594
> Gitweb: http://git.kernel.org/tip/71fdb70eb48784c1f28cdf2e67c4c587dd7f2594
> Author: Peter Zijlstra 
> AuthorDate: Mon, 13 Mar 2017 13:46:21 +0100
> Committer:  Ingo Molnar 
> CommitDate: Thu, 23 Mar 2017 07:31:48 +0100
> 
> sched/clock: Fix clear_sched_clock_stable() preempt wobbly
> 
> Paul reported a problems with clear_sched_clock_stable(). Since we run
> all of __clear_sched_clock_stable() from workqueue context, there's a
> preempt problem.
> 
> Solve it by only running the static_key_disable() from workqueue.
> 
> Reported-by: Paul E. McKenney 
> Signed-off-by: Peter Zijlstra (Intel) 
> Cc: Linus Torvalds 
> Cc: Mike Galbraith 
> Cc: Peter Zijlstra 
> Cc: Thomas Gleixner 
> Cc: fweis...@gmail.com
> Link: 
> http://lkml.kernel.org/r/20170313124621.ga3...@twins.programming.kicks-ass.net
> Signed-off-by: Ingo Molnar 

For whatever it is worth given that it is already in -tip:

Tested-by: Paul E. McKenney 

> ---
>  kernel/sched/clock.c | 17 -
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
> index a08795e..fec0f58 100644
> --- a/kernel/sched/clock.c
> +++ b/kernel/sched/clock.c
> @@ -141,7 +141,14 @@ static void __set_sched_clock_stable(void)
>   tick_dep_clear(TICK_DEP_BIT_CLOCK_UNSTABLE);
>  }
> 
> -static void __clear_sched_clock_stable(struct work_struct *work)
> +static void __sched_clock_work(struct work_struct *work)
> +{
> + static_branch_disable(&__sched_clock_stable);
> +}
> +
> +static DECLARE_WORK(sched_clock_work, __sched_clock_work);
> +
> +static void __clear_sched_clock_stable(void)
>  {
>   struct sched_clock_data *scd = this_scd();
> 
> @@ -160,11 +167,11 @@ static void __clear_sched_clock_stable(struct 
> work_struct *work)
>   scd->tick_gtod, gtod_offset,
>   scd->tick_raw,  raw_offset);
> 
> - static_branch_disable(&__sched_clock_stable);
>   tick_dep_set(TICK_DEP_BIT_CLOCK_UNSTABLE);
> -}
> 
> -static DECLARE_WORK(sched_clock_work, __clear_sched_clock_stable);
> + if (sched_clock_stable())
> + schedule_work(_clock_work);
> +}
> 
>  void clear_sched_clock_stable(void)
>  {
> @@ -173,7 +180,7 @@ void clear_sched_clock_stable(void)
>   smp_mb(); /* matches sched_clock_init_late() */
> 
>   if (sched_clock_running == 2)
> - schedule_work(_clock_work);
> + __clear_sched_clock_stable();
>  }
> 
>  void sched_clock_init_late(void)
> 



<    2   3   4   5   6   7   8   9   10   11   >