Re: [PATCH v2] HID: udraw: Add support for the uDraw tablet for PS3

2016-11-12 Thread Bastien Nocera
On Tue, 2016-11-08 at 14:30 +0100, Bastien Nocera wrote:
> On Tue, 2016-11-08 at 14:23 +0100, Jiri Kosina wrote:
> > 

> > Hi Bastien,
> > 
> > overall the driver looks ok to me, thanks. Probably the only
> > concern
> > I'd 
> > have -- traditionally, we've always been naming drivers by the
> > vendor, as 
> > it turned out that over time they get extended by adding support
> > for 
> > multiple devices with the same vendor, and usually there is quite
> > some 
> > overlap in shared code.
> 
> In that particular case, I'd rather it got renamed to "hid-udraw-ps3"
> in this case. The XBox 360 and Wii versions use completely different
> protocols:
> http://brandonw.net/udraw/
> 
> The XBox 360 version is more likely to be integrated in with other
> XBox
> pads, and the Wii version along with other Wii Bluetooth remotes.
> 
> > Hence I'd propose to call this driver hid-thq (if that's really
> > the 
> > vendor's proper name, doesn't seem to be present in latest usb.ids 
> > release).
> 
> THQ went under in 2012, as a result of making too many of those
> drawing
> tablets:
> https://en.wikipedia.org/wiki/THQ
> 
> I'm fine with it either way. Just let me know which one you prefer.

So, any preference? The sooner you make that choice, the sooner I can
send an updated patch and push this into my distribution's kernel. I
have a machine waiting on the hardware driver for control :)

Cheers


[PATCH] [media] zoran: fix spelling mistake in dprintk message

2016-11-12 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake "unnsupported" to "unsupported"
in debug message.

Signed-off-by: Colin Ian King 
---
 drivers/media/pci/zoran/zoran_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/zoran/zoran_driver.c 
b/drivers/media/pci/zoran/zoran_driver.c
index d6b631a..2170e17 100644
--- a/drivers/media/pci/zoran/zoran_driver.c
+++ b/drivers/media/pci/zoran/zoran_driver.c
@@ -1488,7 +1488,7 @@ zoran_set_input (struct zoran *zr,
if (input < 0 || input >= zr->card.inputs) {
dprintk(1,
KERN_ERR
-   "%s: %s - unnsupported input %d\n",
+   "%s: %s - unsupported input %d\n",
ZR_DEVNAME(zr), __func__, input);
return -EINVAL;
}
-- 
2.10.2



[PATCH] [STYLE 2/2]staging:speakup:speakup_spkout.c Spaces preferred around

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to: CHECK: spaces preferred around that '|'

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/speakup_spkout.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/speakup/speakup_spkout.c 
b/drivers/staging/speakup/speakup_spkout.c
index 2146fff..93b4530 100644
--- a/drivers/staging/speakup/speakup_spkout.c
+++ b/drivers/staging/speakup/speakup_spkout.c
@@ -43,30 +43,30 @@ static struct var_t vars[] = {
 /* These attributes will appear in /sys/accessibility/speakup/spkout. */
 
 static struct kobj_attribute caps_start_attribute =
-   __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(caps_start, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute caps_stop_attribute =
-   __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(caps_stop, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute pitch_attribute =
-   __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(pitch, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute punct_attribute =
-   __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(punct, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute rate_attribute =
-   __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(rate, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute tone_attribute =
-   __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(tone, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute vol_attribute =
-   __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(vol, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 
 static struct kobj_attribute delay_time_attribute =
-   __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(delay_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute direct_attribute =
-   __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(direct, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute full_time_attribute =
-   __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(full_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute jiffy_delta_attribute =
-   __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(jiffy_delta, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute trigger_time_attribute =
-   __ATTR(trigger_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(trigger_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 
 /*
  * Create a group of attributes so that we can create and destroy them all
-- 
2.1.4



Re: [PATCH v4 8/8] iio: envelope-detector: ADC driver based on a DAC and a comparator

2016-11-12 Thread Jonathan Cameron
On 08/11/16 17:03, Peter Rosin wrote:
> On 2016-11-08 16:59, Thomas Gleixner wrote:
>> On Tue, 8 Nov 2016, Peter Rosin wrote:
>>> +/*
>>> + * The envelope_detector_comp_latch function works together with the 
>>> compare
>>> + * interrupt service routine below (envelope_detector_comp_isr) as a latch
>>> + * (one-bit memory) for if the interrupt has triggered since last calling
>>> + * this function.
>>> + * The ..._comp_isr function disables the interrupt so that the cpu does 
>>> not
>>> + * need to service a possible interrupt flood from the comparator when 
>>> no-one
>>> + * cares anyway, and this ..._comp_latch function reenables them again if
>>> + * needed.
>>> + */
>>> +static int envelope_detector_comp_latch(struct envelope *env)
>>> +{
>>> +   int comp;
>>> +
>>> +   spin_lock_irq(>comp_lock);
>>> +   comp = env->comp;
>>> +   env->comp = 0;
>>> +   spin_unlock_irq(>comp_lock);
>>> +
>>> +   if (!comp)
>>> +   return 0;
>>> +
>>> +   /*
>>> +* The irq was disabled, and is reenabled just now.
>>> +* But there might have been a pending irq that
>>> +* happened while the irq was disabled that fires
>>> +* just as the irq is reenabled. That is not what
>>> +* is desired.
>>> +*/
>>> +   enable_irq(env->comp_irq);
>>> +
>>> +   /* So, synchronize this possibly pending irq... */
>>> +   synchronize_irq(env->comp_irq);
>>> +
>>> +   /* ...and redo the whole dance. */
>>> +   spin_lock_irq(>comp_lock);
>>> +   comp = env->comp;
>>> +   env->comp = 0;
>>> +   spin_unlock_irq(>comp_lock);
>>> +
>>> +   if (comp)
>>> +   enable_irq(env->comp_irq);
>>
>> So you need that whole dance including the delayed work because you cannot
>> call iio_write_channel_raw() from hard interrupt context, right?
> 
> It's not the "cannot call from hard irq context" that made me do that, it's...
> 
>> So you might just register a threaded interrupt handler, which should make
>> this whole thing way simpler.
>>
>>  devm_request_threaded_irq(dev, irq, NULL, your_isr, IRQF_ONESHOT, ...);
>>
>> The core will mask the interrupt line until the threaded handler is
>> finished. The threaded handler is invoked with preemption enabled, so you
>> can sleep there as long as you want. So you can do everything in your
>> handler and the above dance is just not required.
> 
> ...that I couldn't work out how to reenable a oneshot irq once it had fired,
> short of freeing the irq and requesting it again. That seemed entirely
> bogus, the driver shouldn't risk losing a resource like that so I don't know
> what I didn't see? Or maybe it was that I had a hard time resolving the race
> between the irq and the timeout in a nice way. I honestly don't remember
> why exactly I abandoned oneshot irqs, but this enable/sync/enable dance
> was much nicer than what I came up with for the oneshot irq solution I
> originally worked on.
> 
> Or maybe I had problems with the possibly pending irq also when using a
> oneshot irq, but didn't realize it? That was something I discovered quite
> late in the process, some time after moving away from oneshot irqs. Are
> pending irqs cleared when requesting (or reenabling, however that is done)
> a oneshot irq?
> 
> Anyway, I do not want the interrupt to be serviced when no one is interested,
> since I'm afraid that nasty input might generate a flood of interrupts that
> might disturb other things that the cpu is doing. Which means that I need
> to enable/disable the interrupt as needed.
> 
> However, what *I* thought Jonathan wanted input on was the part where the
> interrupt edge/level is flipped when requesting "inverted" signals in
> envelope_store_invert(). That could perhaps be seen as unorthodox and in
> need of more eyes?
Nope, as far as I can recall it was precisely this dance that was 
I wanted Thomas to comment on :)  The inverted bit isn't as novel as
this ;)

Anyhow, thread ended up with a good conclusion so I'm happy.

Jonathan
> 
> Cheers,
> Peter
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



Re: [PATCH v4 8/8] iio: envelope-detector: ADC driver based on a DAC and a comparator

2016-11-12 Thread Jonathan Cameron
On 11/11/16 11:37, Peter Rosin wrote:
> On 2016-11-09 16:06, Thomas Gleixner wrote:
>> On Wed, 9 Nov 2016, Peter Rosin wrote:
>>> On 2016-11-08 22:47, Thomas Gleixner wrote:
 I don't think you need extra race handling with that, but I might be wrong
 as usual.
>>>
>>> There's obviously no way to determine which of the timeout or the
>>> interrupt that happens first without some race handling, so I don't
>>> know what you mean? If the timeout happens first, there is also a
>>> need to handle late hits from the irq that might come in during the
>>> preparation for the next step in the binary search. It gets messy
>>> quickly compared to the simplicity of the current implementation.
>>
>> Gah, forgot about that timeout thingy. Fair enough.
>>
>> Feel free to add an 
>>
>> Acked-by: Thomas Gleixner 
> 
> Thanks for looking!
Applied to the togreg branch of iio.git and pushed out
as testing for the autobuilders to play with.

Excellent patch set.

Thanks,

Jonathan
> 
> Cheers,
> Peter
> 



[PATCH] [STYLE 1/2]staging:speakup:speakup_txprt.c Block comment align

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to: WARNING: Block comments should align the * on each line
Modified multiline comment to single
Removed blank line at end

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/speakup_txprt.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/speakup/speakup_txprt.c 
b/drivers/staging/speakup/speakup_txprt.c
index fd98d4f..4d33e72 100644
--- a/drivers/staging/speakup/speakup_txprt.c
+++ b/drivers/staging/speakup/speakup_txprt.c
@@ -1,6 +1,6 @@
 /*
  * originally written by: Kirk Reiser 
-* this version considerably modified by David Borowski, david...@rogers.com
+ * this version considerably modified by David Borowski, david...@rogers.com
  *
  * Copyright (C) 1998-99  Kirk Reiser.
  * Copyright (C) 2003 David Borowski.
@@ -36,9 +36,8 @@ static struct var_t vars[] = {
V_LAST_VAR
 };
 
-/*
- * These attributes will appear in /sys/accessibility/speakup/txprt.
- */
+/* These attributes will appear in /sys/accessibility/speakup/txprt. */
+
 static struct kobj_attribute caps_start_attribute =
__ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute caps_stop_attribute =
@@ -130,4 +129,3 @@ MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Transport synthesizers");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-- 
2.1.4



[PATCH] amdkfd: fix spelling mistake in kfd_ioctl_dbg_unrgesiter

2016-11-12 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake, rename kfd_ioctl_dbg_unrgesiter
to kfd_ioctl_dbg_unregister

Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index ee3e04e..6316aad 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -486,7 +486,7 @@ static int kfd_ioctl_dbg_register(struct file *filep,
return status;
 }
 
-static int kfd_ioctl_dbg_unrgesiter(struct file *filep,
+static int kfd_ioctl_dbg_unregister(struct file *filep,
struct kfd_process *p, void *data)
 {
struct kfd_ioctl_dbg_unregister_args *args = data;
@@ -498,7 +498,7 @@ static int kfd_ioctl_dbg_unrgesiter(struct file *filep,
return -EINVAL;
 
if (dev->device_info->asic_family == CHIP_CARRIZO) {
-   pr_debug("kfd_ioctl_dbg_unrgesiter not supported on CZ\n");
+   pr_debug("kfd_ioctl_dbg_unregister not supported on CZ\n");
return -EINVAL;
}
 
@@ -892,7 +892,7 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
kfd_ioctl_dbg_register, 0),
 
AMDKFD_IOCTL_DEF(AMDKFD_IOC_DBG_UNREGISTER,
-   kfd_ioctl_dbg_unrgesiter, 0),
+   kfd_ioctl_dbg_unregister, 0),
 
AMDKFD_IOCTL_DEF(AMDKFD_IOC_DBG_ADDRESS_WATCH,
kfd_ioctl_dbg_address_watch, 0),
-- 
2.10.2



[PATCH] [STYLE 2/2]staging:speakup:speakup_txprt.c Spaces preferred around

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to: CHECK: spaces preferred around that '|'

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/speakup_txprt.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/speakup/speakup_txprt.c 
b/drivers/staging/speakup/speakup_txprt.c
index 4d33e72..6ac1f9e 100644
--- a/drivers/staging/speakup/speakup_txprt.c
+++ b/drivers/staging/speakup/speakup_txprt.c
@@ -39,28 +39,28 @@ static struct var_t vars[] = {
 /* These attributes will appear in /sys/accessibility/speakup/txprt. */
 
 static struct kobj_attribute caps_start_attribute =
-   __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(caps_start, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute caps_stop_attribute =
-   __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(caps_stop, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute pitch_attribute =
-   __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(pitch, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute rate_attribute =
-   __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(rate, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute tone_attribute =
-   __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(tone, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute vol_attribute =
-   __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(vol, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 
 static struct kobj_attribute delay_time_attribute =
-   __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(delay_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute direct_attribute =
-   __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(direct, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute full_time_attribute =
-   __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(full_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute jiffy_delta_attribute =
-   __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(jiffy_delta, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 static struct kobj_attribute trigger_time_attribute =
-   __ATTR(trigger_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(trigger_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
 
 /*
  * Create a group of attributes so that we can create and destroy them all
-- 
2.1.4



[PATCH] drm/vc4: Add threading support

2016-11-12 Thread Eric Anholt
From: Jonas Pfeil 

Add support for threaded fragment shaders.  The validation code checks
for thread switch signals and ensures that the registers of the other
thread are not touched, and that our clamps are not live across thread
switches.  It also checks that the threading and branching
instructions do not interfere.

(Original patch by Jonas, changes by anholt for style cleanup,
removing validation the kernel doesn't need to do, and adding the flag
for userspace).

Signed-off-by: Jonas Pfeil 
Signed-off-by: Eric Anholt 
---
 drivers/gpu/drm/vc4/vc4_drv.c  |  1 +
 drivers/gpu/drm/vc4/vc4_drv.h  |  2 +
 drivers/gpu/drm/vc4/vc4_validate.c | 17 +---
 drivers/gpu/drm/vc4/vc4_validate_shaders.c | 62 ++
 include/uapi/drm/vc4_drm.h |  1 +
 5 files changed, 78 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 drivers/gpu/drm/vc4/vc4_validate.c
 mode change 100644 => 100755 drivers/gpu/drm/vc4/vc4_validate_shaders.c

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 7abfe088f2d1..86aabf6d0f79 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -82,6 +82,7 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void 
*data,
break;
case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
case DRM_VC4_PARAM_SUPPORTS_ETC1:
+   case DRM_VC4_PARAM_SUPPORTS_THREADED_FS:
args->value = true;
break;
default:
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 7c1e4d97486f..fef172804345 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -381,6 +381,8 @@ struct vc4_validated_shader_info {
 
uint32_t num_uniform_addr_offsets;
uint32_t *uniform_addr_offsets;
+
+   bool is_threaded;
 };
 
 /**
diff --git a/drivers/gpu/drm/vc4/vc4_validate.c 
b/drivers/gpu/drm/vc4/vc4_validate.c
old mode 100644
new mode 100755
index e18f88203d32..9fd171c361c2
--- a/drivers/gpu/drm/vc4/vc4_validate.c
+++ b/drivers/gpu/drm/vc4/vc4_validate.c
@@ -789,11 +789,6 @@ validate_gl_shader_rec(struct drm_device *dev,
exec->shader_rec_v += roundup(packet_size, 16);
exec->shader_rec_size -= packet_size;
 
-   if (!(*(uint16_t *)pkt_u & VC4_SHADER_FLAG_FS_SINGLE_THREAD)) {
-   DRM_ERROR("Multi-threaded fragment shaders not supported.\n");
-   return -EINVAL;
-   }
-
for (i = 0; i < shader_reloc_count; i++) {
if (src_handles[i] > exec->bo_count) {
DRM_ERROR("Shader handle %d too big\n", src_handles[i]);
@@ -810,6 +805,18 @@ validate_gl_shader_rec(struct drm_device *dev,
return -EINVAL;
}
 
+   if (((*(uint16_t *)pkt_u & VC4_SHADER_FLAG_FS_SINGLE_THREAD) == 0) !=
+   to_vc4_bo([0]->base)->validated_shader->is_threaded) {
+   DRM_ERROR("Thread mode of CL and FS do not match\n");
+   return -EINVAL;
+   }
+
+   if (to_vc4_bo([1]->base)->validated_shader->is_threaded ||
+   to_vc4_bo([2]->base)->validated_shader->is_threaded) {
+   DRM_ERROR("cs and vs cannot be threaded\n");
+   return -EINVAL;
+   }
+
for (i = 0; i < shader_reloc_count; i++) {
struct vc4_validated_shader_info *validated_shader;
uint32_t o = shader_reloc_offsets[i];
diff --git a/drivers/gpu/drm/vc4/vc4_validate_shaders.c 
b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
old mode 100644
new mode 100755
index 917321ce832f..90e94ef116b2
--- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c
+++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
@@ -83,6 +83,13 @@ struct vc4_shader_validation_state {
 * basic blocks.
 */
bool needs_uniform_address_for_loop;
+
+   /* Set when we find an instruction writing the top half of the
+* register files.  If we allowed writing the unusable regs in
+* a threaded shader, then the other shader running on our
+* QPU's clamp validation would be invalid.
+*/
+   bool all_registers_used;
 };
 
 static uint32_t
@@ -119,6 +126,13 @@ raddr_add_a_to_live_reg_index(uint64_t inst)
 }
 
 static bool
+live_reg_is_upper_half(uint32_t lri)
+{
+   return  (lri >= 16 && lri < 32) ||
+   (lri >= 32 + 16 && lri < 32 + 32);
+}
+
+static bool
 is_tmu_submit(uint32_t waddr)
 {
return (waddr == QPU_W_TMU0_S ||
@@ -390,6 +404,9 @@ check_reg_write(struct vc4_validated_shader_info 
*validated_shader,
} else {
validation_state->live_immediates[lri] = ~0;
}
+
+   if (live_reg_is_upper_half(lri))
+   validation_state->all_registers_used = true;
}
 
switch (waddr) {
@@ -597,6 +614,11 @@ check_instruction_reads(struct vc4_validated_shader_info 
*validated_shader,

[PATCH] drm/sun4i: constify component_ops structures

2016-11-12 Thread Julia Lawall
These component_ops structures are only used as the second argument to
component_add and component_del, which are declared as const, so the
structures can be declared as const as well.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@r disable optional_qualifier@
identifier i;
position p;
@@

static struct component_ops i@p = { ... };

@ok1@
identifier r.i;
expression e1;
position p;
@@

component_add(e1,@p)

@ok2@
identifier r.i;
expression e1;
position p;
@@

component_del(e1, @p)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct component_ops e;
@@

e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@

static
+const
 struct component_ops i = { ... };
// 

The result of the size command before the change is (arm):

   text   data bss dec  hex filename
   5266236   85510 1586 sun4i_backend.o
   6393236   86637 19ed sun4i_tcon.o
   3700368   84076  fec sun4i_tv.o
   1668108   01776  6f0 sun6i_drc.o

and after the change:

   text   data bss dec hex filename
   5274228   855101586 sun4i_backend.o
   6401228   8663719ed sun4i_tcon.o
   3708360   84076 fec sun4i_tv.o
   1676100   01776 6f0 sun6i_drc.o

Signed-off-by: Julia Lawall 

---
 drivers/gpu/drm/sun4i/sun4i_backend.c |2 +-
 drivers/gpu/drm/sun4i/sun4i_tcon.c|2 +-
 drivers/gpu/drm/sun4i/sun4i_tv.c  |2 +-
 drivers/gpu/drm/sun4i/sun6i_drc.c |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c 
b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 7eb2a96..2e08f96 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -409,7 +409,7 @@ static void sun4i_backend_unbind(struct device *dev, struct 
device *master,
reset_control_assert(backend->reset);
 }
 
-static struct component_ops sun4i_backend_ops = {
+static const struct component_ops sun4i_backend_ops = {
.bind   = sun4i_backend_bind,
.unbind = sun4i_backend_unbind,
 };
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index c6afb24..ea2906f 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -545,7 +545,7 @@ static void sun4i_tcon_unbind(struct device *dev, struct 
device *master,
sun4i_tcon_free_clocks(tcon);
 }
 
-static struct component_ops sun4i_tcon_ops = {
+static const struct component_ops sun4i_tcon_ops = {
.bind   = sun4i_tcon_bind,
.unbind = sun4i_tcon_unbind,
 };
diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c
index 1dd3d9e..d430b331 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
@@ -667,7 +667,7 @@ static void sun4i_tv_unbind(struct device *dev, struct 
device *master,
clk_disable_unprepare(tv->clk);
 }
 
-static struct component_ops sun4i_tv_ops = {
+static const struct component_ops sun4i_tv_ops = {
.bind   = sun4i_tv_bind,
.unbind = sun4i_tv_unbind,
 };
diff --git a/drivers/gpu/drm/sun4i/sun6i_drc.c 
b/drivers/gpu/drm/sun4i/sun6i_drc.c
index 6ef707c..09bba85 100644
--- a/drivers/gpu/drm/sun4i/sun6i_drc.c
+++ b/drivers/gpu/drm/sun4i/sun6i_drc.c
@@ -80,7 +80,7 @@ static void sun6i_drc_unbind(struct device *dev, struct 
device *master,
reset_control_assert(drc->reset);
 }
 
-static struct component_ops sun6i_drc_ops = {
+static const struct component_ops sun6i_drc_ops = {
.bind   = sun6i_drc_bind,
.unbind = sun6i_drc_unbind,
 };



Re: [PATCH 2/6] pinctrl: rockchip: add support for rk1108

2016-11-12 Thread 陈豪
2016-11-03 20:34 GMT+08:00 Andy Yan :
> Add basic support for rk1108 soc
>
> Signed-off-by: Andy Yan 
> ---
>
>  drivers/pinctrl/pinctrl-rockchip.c | 27 ++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c 
> b/drivers/pinctrl/pinctrl-rockchip.c
> index 49bf7dc..9f324b1 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -59,6 +59,7 @@
>  #define GPIO_LS_SYNC   0x60
>
>  enum rockchip_pinctrl_type {
> +   RK1108,
> RK2928,
> RK3066B,
> RK3188,
> @@ -1123,6 +1124,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank 
> *bank, int pin_num)
> return !(data & BIT(bit))
> ? PIN_CONFIG_BIAS_PULL_PIN_DEFAULT
> : PIN_CONFIG_BIAS_DISABLE;
> +   case RK1108:
> case RK3188:
> case RK3288:
> case RK3368:
> @@ -1169,6 +1171,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank 
> *bank,
>
> spin_unlock_irqrestore(>slock, flags);
> break;
> +   case RK1108:
> case RK3188:
> case RK3288:
> case RK3368:
> @@ -1358,6 +1361,7 @@ static bool rockchip_pinconf_pull_valid(struct 
> rockchip_pin_ctrl *ctrl,
> pull == PIN_CONFIG_BIAS_DISABLE);
> case RK3066B:
> return pull ? false : true;
> +   case RK1108:
> case RK3188:
> case RK3288:
> case RK3368:
> @@ -1385,7 +1389,6 @@ static int rockchip_pinconf_set(struct pinctrl_dev 
> *pctldev, unsigned int pin,
> for (i = 0; i < num_configs; i++) {
> param = pinconf_to_config_param(configs[i]);
> arg = pinconf_to_config_argument(configs[i]);
> -
> switch (param) {
> case PIN_CONFIG_BIAS_DISABLE:
> rc =  rockchip_set_pull(bank, pin - bank->pin_base,
> @@ -2455,6 +2458,26 @@ static int rockchip_pinctrl_probe(struct 
> platform_device *pdev)
> return 0;
>  }
>
> +static struct rockchip_pin_bank rk1108_pin_banks[] = {
> +   PIN_BANK_IOMUX_FLAGS(0, 32, "gpio0", IOMUX_SOURCE_PMU,
> +IOMUX_SOURCE_PMU,
> +IOMUX_SOURCE_PMU,
> +IOMUX_SOURCE_PMU),
> +   PIN_BANK_IOMUX_FLAGS(1, 32, "gpio1", 0, 0, 0, 0),
> +   PIN_BANK_IOMUX_FLAGS(2, 32, "gpio2", 0, 0, 0, 0),
> +   PIN_BANK_IOMUX_FLAGS(3, 32, "gpio3", 0, 0, 0, 0),
> +};
> +
> +static struct rockchip_pin_ctrl rk1108_pin_ctrl = {
> +   .pin_banks  = rk1108_pin_banks,
> +   .nr_banks   = ARRAY_SIZE(rk1108_pin_banks),
> +   .label  = "RK1108-GPIO",
> +   .type   = RK1108,
> +   .grf_mux_offset = 0x10,
> +   .pmu_mux_offset = 0x0,
> +   .pull_calc_reg  = rk3288_calc_pull_reg_and_bit,
> +};
> +
>  static struct rockchip_pin_bank rk2928_pin_banks[] = {
> PIN_BANK(0, 32, "gpio0"),
> PIN_BANK(1, 32, "gpio1"),
> @@ -2684,6 +2707,8 @@ static struct rockchip_pin_ctrl rk3399_pin_ctrl = {
>  };
>
>  static const struct of_device_id rockchip_pinctrl_dt_match[] = {
> +   { .compatible = "rockchip,rk1108-pinctrl",
> +   .data = (void *)_pin_ctrl },
> { .compatible = "rockchip,rk2928-pinctrl",
> .data = (void *)_pin_ctrl },
> { .compatible = "rockchip,rk3036-pinctrl",
> --
> 2.7.4
>
>

rk3288_calc_pull_reg_and_bit can't be used directly in rk1108.
rk1108 have a different PULL_PMU_OFFSET and PULL_OFFSET.


[PATCH] [STYLE]staging:speakup:spk_priv_keyinfo.h Spaces preferred around

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: spaces preferred around that '+'

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/spk_priv_keyinfo.h | 44 +++---
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/speakup/spk_priv_keyinfo.h 
b/drivers/staging/speakup/spk_priv_keyinfo.h
index 130e9cb..29bbcc0 100644
--- a/drivers/staging/speakup/spk_priv_keyinfo.h
+++ b/drivers/staging/speakup/spk_priv_keyinfo.h
@@ -80,27 +80,27 @@
 
 /* keys for setting variables, must be ordered same as the enum for var_ids */
 /* with dec being even and inc being 1 greater */
-#define SPELL_DELAY_DEC (VAR_START+0)
-#define SPELL_DELAY_INC (SPELL_DELAY_DEC+1)
-#define PUNC_LEVEL_DEC (SPELL_DELAY_DEC+2)
-#define PUNC_LEVEL_INC (PUNC_LEVEL_DEC+1)
-#define READING_PUNC_DEC (PUNC_LEVEL_DEC+2)
-#define READING_PUNC_INC (READING_PUNC_DEC+1)
-#define ATTRIB_BLEEP_DEC (READING_PUNC_DEC+2)
-#define ATTRIB_BLEEP_INC (ATTRIB_BLEEP_DEC+1)
-#define BLEEPS_DEC (ATTRIB_BLEEP_DEC+2)
-#define BLEEPS_INC (BLEEPS_DEC+1)
-#define RATE_DEC (BLEEPS_DEC+2)
-#define RATE_INC (RATE_DEC+1)
-#define PITCH_DEC (RATE_DEC+2)
-#define PITCH_INC (PITCH_DEC+1)
-#define VOL_DEC (PITCH_DEC+2)
-#define VOL_INC (VOL_DEC+1)
-#define TONE_DEC (VOL_DEC+2)
-#define TONE_INC (TONE_DEC+1)
-#define PUNCT_DEC (TONE_DEC+2)
-#define PUNCT_INC (PUNCT_DEC+1)
-#define VOICE_DEC (PUNCT_DEC+2)
-#define VOICE_INC (VOICE_DEC+1)
+#define SPELL_DELAY_DEC (VAR_START + 0)
+#define SPELL_DELAY_INC (SPELL_DELAY_DEC + 1)
+#define PUNC_LEVEL_DEC (SPELL_DELAY_DEC + 2)
+#define PUNC_LEVEL_INC (PUNC_LEVEL_DEC + 1)
+#define READING_PUNC_DEC (PUNC_LEVEL_DEC + 2)
+#define READING_PUNC_INC (READING_PUNC_DEC + 1)
+#define ATTRIB_BLEEP_DEC (READING_PUNC_DEC + 2)
+#define ATTRIB_BLEEP_INC (ATTRIB_BLEEP_DEC + 1)
+#define BLEEPS_DEC (ATTRIB_BLEEP_DEC + 2)
+#define BLEEPS_INC (BLEEPS_DEC + 1)
+#define RATE_DEC (BLEEPS_DEC + 2)
+#define RATE_INC (RATE_DEC + 1)
+#define PITCH_DEC (RATE_DEC + 2)
+#define PITCH_INC (PITCH_DEC + 1)
+#define VOL_DEC (PITCH_DEC + 2)
+#define VOL_INC (VOL_DEC + 1)
+#define TONE_DEC (VOL_DEC + 2)
+#define TONE_INC (TONE_DEC + 1)
+#define PUNCT_DEC (TONE_DEC + 2)
+#define PUNCT_INC (PUNCT_DEC + 1)
+#define VOICE_DEC (PUNCT_DEC + 2)
+#define VOICE_INC (VOICE_DEC + 1)
 
 #endif
-- 
2.1.4



[PATCH] net: ethernet: ixp4xx_eth: fix spelling mistake in debug message

2016-11-12 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake "successed" to "succeeded"
in debug message.  Also unwrap multi-line literal string.

Signed-off-by: Colin Ian King 
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c 
b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 46cc33b..07d862d 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -708,8 +708,7 @@ static int eth_poll(struct napi_struct *napi, int budget)
if (!qmgr_stat_below_low_watermark(rxq) &&
napi_reschedule(napi)) { /* not empty again */
 #if DEBUG_RX
-   printk(KERN_DEBUG "%s: eth_poll"
-  " napi_reschedule successed\n",
+   printk(KERN_DEBUG "%s: eth_poll napi_reschedule 
succeeded\n",
   dev->name);
 #endif
qmgr_disable_irq(rxq);
-- 
2.10.2



[PATCH] [STYLE]staging:speakup:spk_types.h Align match parenthesis

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: Alignment should match open parenthesis

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/spk_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/spk_types.h 
b/drivers/staging/speakup/spk_types.h
index e8ff5d7..7c635d4 100644
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -169,7 +169,7 @@ struct spk_synth {
int (*probe)(struct spk_synth *synth);
void (*release)(void);
const char *(*synth_immediate)(struct spk_synth *synth,
-   const char *buff);
+  const char *buff);
void (*catch_up)(struct spk_synth *synth);
void (*flush)(struct spk_synth *synth);
int (*is_alive)(struct spk_synth *synth);
-- 
2.1.4



[PATCH] [STYLE 1/5]staging:speakup:synth.c Modified block text

2016-11-12 Thread Walt Feasel
Modified block comment for alignment consistency

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 54b2f39..29efdb1 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -8,7 +8,7 @@
 #include/* for loops_per_sec */
 #include 
 #include 
-#include  /* for copy_from_user */
+#include  /* for copy_from_user */
 #include 
 #include 
 #include 
-- 
2.1.4



[PATCH v2] [STYLE 1/5]staging:speakup:synth.c Modified block text

2016-11-12 Thread Walt Feasel
Modified block comment for alignment consistency

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 54b2f39..800fbbf 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -8,7 +8,7 @@
 #include/* for loops_per_sec */
 #include 
 #include 
-#include  /* for copy_from_user */
+#include  /* for copy_from_user */
 #include 
 #include 
 #include 
-- 
2.1.4



[PATCH] misc: ibmasm: fix typo in error message

2016-11-12 Thread Colin King
From: Colin Ian King 

Trivial fix to typo "repsonse" to "response" in error message.

Signed-off-by: Colin Ian King 
---
 drivers/misc/ibmasm/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index 6b3bf9a..c5a456b 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -170,7 +170,7 @@ static void ibmasm_remove_one(struct pci_dev *pdev)
ibmasm_unregister_uart(sp);
dbg("Sending OS down message\n");
if (ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN))
-   err("failed to get repsonse to 'Send OS State' command\n");
+   err("failed to get response to 'Send OS State' command\n");
dbg("Disabling heartbeats\n");
ibmasm_heartbeat_exit(sp);
dbg("Disabling interrupts\n");
-- 
2.10.2



Re: [PATCH] Fix: disable sys_membarrier when nohz_full is enabled

2016-11-12 Thread Paul E. McKenney
On Tue, Nov 08, 2016 at 11:15:51AM +, Mathieu Desnoyers wrote:
> - On Nov 7, 2016, at 3:03 PM, Paul E. McKenney paul...@linux.vnet.ibm.com 
> wrote:
> 
> > On Mon, Nov 07, 2016 at 06:10:14PM +, Mathieu Desnoyers wrote:
> >> 
> >> - On Nov 7, 2016, at 1:06 PM, Paul E. McKenney 
> >> paul...@linux.vnet.ibm.com
> >> wrote:
> >> 
> >> > On Mon, Nov 07, 2016 at 05:08:59PM +, Mathieu Desnoyers wrote:
> >> >> - On Nov 3, 2016, at 1:49 PM, Paul E. McKenney 
> >> >> paul...@linux.vnet.ibm.com
> >> >> wrote:
> >> >> 
> >> >> > On Thu, Nov 03, 2016 at 10:29:28AM -0600, Mathieu Desnoyers wrote:
> >> >> >> Userspace applications should be allowed to expect the membarrier 
> >> >> >> system
> >> >> >> call with MEMBARRIER_CMD_SHARED command to issue memory barriers on
> >> >> >> nohz_full CPUs, but synchronize_sched() does not take those into
> >> >> >> account.
> >> >> >> 
> >> >> >> Given that we do not want unrelated processes to be able to affect
> >> >> >> real-time sensitive nohz_full CPUs, simply return ENOSYS when 
> >> >> >> membarrier
> >> >> >> is invoked on a kernel with enabled nohz_full CPUs.
> >> >> >> 
> >> >> >> Signed-off-by: Mathieu Desnoyers 
> >> >> >> CC: "Paul E. McKenney" 
> >> >> > 
> >> >> > Acked-by: "Paul E. McKenney" 
> >> >> 
> >> >> Hi Paul,
> >> >> 
> >> >> Do you plan to pick it up through your tree, or I should sent
> >> >> it directly to Linus ?
> >> > 
> >> > Your choice.  I believe that the original went some other way, but I
> >> > would be fine carrying this one.
> >> 
> >> Not sure what you mean by "the original" ? And which other way ?
> >> I have not been notified about this.
> > 
> > If I remember correctly, you sent the original sys_membarrier()
> > patch through akpm or similar.
> 
> Ah right, the original implementation, yes.
> 
> > 
> >> If you can carry this patch it would be very much appreciated,
> > 
> > Will do!
> 
> Especially since the regression is somewhat related to RCU
> behavior wrt nohz_full, getting it through your tree seems
> relevant.

I have it queued for 4.11, thank you!

Thanx, Paul



Re: [PATCH 03/12] block: floppy: use bio_add_page()

2016-11-12 Thread Christoph Hellwig
Looks fine,

Reviewed-by: Christoph Hellwig 


Re: [PATCH 01/12] block: bio: pass bvec table to bio_init()

2016-11-12 Thread Christoph Hellwig
On Fri, Nov 11, 2016 at 08:05:29PM +0800, Ming Lei wrote:
> Some drivers often use external bvec table, so introduce
> this helper for this case. It is always safe to access the
> bio->bi_io_vec in this way for this case.
> 
> After converting to this usage, it will becomes a bit easier
> to evaluate the remaining direct access to bio->bi_io_vec,
> so it can help to prepare for the following multipage bvec
> support.
> 
> Signed-off-by: Ming Lei 
> ---
>  block/bio.c   |  8 ++--
>  drivers/block/floppy.c|  3 +--
>  drivers/md/bcache/io.c|  4 +---
>  drivers/md/bcache/journal.c   |  4 +---
>  drivers/md/bcache/movinggc.c  |  6 ++
>  drivers/md/bcache/request.c   |  2 +-
>  drivers/md/bcache/super.c | 12 +++-
>  drivers/md/bcache/writeback.c |  5 ++---
>  drivers/md/dm-bufio.c |  4 +---
>  drivers/md/dm.c   |  2 +-
>  drivers/md/multipath.c|  2 +-
>  drivers/md/raid5-cache.c  |  2 +-
>  drivers/md/raid5.c|  9 ++---
>  drivers/nvme/target/io-cmd.c  |  4 +---
>  fs/logfs/dev_bdev.c   |  4 +---
>  include/linux/bio.h   |  3 ++-
>  16 files changed, 27 insertions(+), 47 deletions(-)
> 
> diff --git a/block/bio.c b/block/bio.c
> index 2cf6ebabc68c..de257ced69b1 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -270,11 +270,15 @@ static void bio_free(struct bio *bio)
>   }
>  }
>  
> -void bio_init(struct bio *bio)
> +void bio_init(struct bio *bio, struct bio_vec *table,
> +   unsigned short max_vecs)
>  {
>   memset(bio, 0, sizeof(*bio));
>   atomic_set(>__bi_remaining, 1);
>   atomic_set(>__bi_cnt, 1);
> +
> + bio->bi_io_vec = table;
> + bio->bi_max_vecs = max_vecs;
>  }
>  EXPORT_SYMBOL(bio_init);
>  
> @@ -480,7 +484,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int 
> nr_iovecs, struct bio_set *bs)
>   return NULL;
>  
>   bio = p + front_pad;
> - bio_init(bio);
> + bio_init(bio, NULL, 0);
>  
>   if (nr_iovecs > inline_vecs) {
>   unsigned long idx = 0;
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index e3d8e4ced4a2..6a3ff2b2e3ae 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -3806,8 +3806,7 @@ static int __floppy_read_block_0(struct block_device 
> *bdev, int drive)
>  
>   cbdata.drive = drive;
>  
> - bio_init();
> - bio.bi_io_vec = _vec;
> + bio_init(, _vec, 1);
>   bio_vec.bv_page = page;
>   bio_vec.bv_len = size;
>   bio_vec.bv_offset = 0;
> diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
> index e97b0acf7b8d..db45a88c0ce9 100644
> --- a/drivers/md/bcache/io.c
> +++ b/drivers/md/bcache/io.c
> @@ -24,9 +24,7 @@ struct bio *bch_bbio_alloc(struct cache_set *c)
>   struct bbio *b = mempool_alloc(c->bio_meta, GFP_NOIO);
>   struct bio *bio = >bio;
>  
> - bio_init(bio);
> - bio->bi_max_vecs = bucket_pages(c);
> - bio->bi_io_vec   = bio->bi_inline_vecs;
> + bio_init(bio, bio->bi_inline_vecs, bucket_pages(c));
>  
>   return bio;
>  }
> diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
> index 6925023e12d4..1198e53d5670 100644
> --- a/drivers/md/bcache/journal.c
> +++ b/drivers/md/bcache/journal.c
> @@ -448,13 +448,11 @@ static void do_journal_discard(struct cache *ca)
>  
>   atomic_set(>discard_in_flight, DISCARD_IN_FLIGHT);
>  
> - bio_init(bio);
> + bio_init(bio, bio->bi_inline_vecs, 1);
>   bio_set_op_attrs(bio, REQ_OP_DISCARD, 0);
>   bio->bi_iter.bi_sector  = bucket_to_sector(ca->set,
>   ca->sb.d[ja->discard_idx]);
>   bio->bi_bdev= ca->bdev;
> - bio->bi_max_vecs= 1;
> - bio->bi_io_vec  = bio->bi_inline_vecs;
>   bio->bi_iter.bi_size= bucket_bytes(ca);
>   bio->bi_end_io  = journal_discard_endio;
>  
> diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
> index 5c4bddecfaf0..13b8a907006d 100644
> --- a/drivers/md/bcache/movinggc.c
> +++ b/drivers/md/bcache/movinggc.c
> @@ -77,15 +77,13 @@ static void moving_init(struct moving_io *io)
>  {
>   struct bio *bio = >bio.bio;
>  
> - bio_init(bio);
> + bio_init(bio, bio->bi_inline_vecs,
> +  DIV_ROUND_UP(KEY_SIZE(>w->key), PAGE_SECTORS));
>   bio_get(bio);
>   bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));
>  
>   bio->bi_iter.bi_size= KEY_SIZE(>w->key) << 9;
> - bio->bi_max_vecs= DIV_ROUND_UP(KEY_SIZE(>w->key),
> -PAGE_SECTORS);
>   bio->bi_private = >cl;
> - bio->bi_io_vec  = bio->bi_inline_vecs;
>   bch_bio_map(bio, NULL);
>  }
>  
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index 0d99b5f4b3e6..f49c5417527d 100644
> --- 

Re: [PATCH v3 3/3] Coccinelle: misc: Add support for devm variant in all modes

2016-11-12 Thread Julia Lawall
On Mon, 24 Oct 2016, Vaishali Thakkar wrote:

> Add missing support for the devm_request_threaded_irq in
> the rules of context, report and org modes.
>
> Misc:
> 
> To be consistent with other scripts, change confidence level
> of the script to 'Moderate'.
>
> Signed-off-by: Vaishali Thakkar 

Acked-by: Julia Lawall 


> ---
> Changes since v2:
>   - Add missing initialization of metavariables
> Changes since v1:
>   - Split patch in to the patchset
> ---
>  scripts/coccinelle/misc/irqf_oneshot.cocci | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci 
> b/scripts/coccinelle/misc/irqf_oneshot.cocci
> index e53372e..ca78125 100644
> --- a/scripts/coccinelle/misc/irqf_oneshot.cocci
> +++ b/scripts/coccinelle/misc/irqf_oneshot.cocci
> @@ -5,7 +5,7 @@
>  /// So pass the IRQF_ONESHOT flag in this case.
>  ///
>  //
> -// Confidence: Good
> +// Confidence: Moderate
>  // Comments:
>  // Options: --no-includes
>
> @@ -87,16 +87,26 @@ devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
>  )
>
>  @depends on context@
> +expression dev;
>  expression irq;
>  position p != {r1.p,r2.p};
>  @@
> +(
>  *request_threaded_irq@p(irq, NULL, ...)
> +|
> +*devm_request_threaded_irq@p(dev, irq, NULL, ...)
> +)
>
>  @match depends on report || org@
> +expression dev;
>  expression irq;
>  position p != {r1.p,r2.p};
>  @@
> +(
>  request_threaded_irq@p(irq, NULL, ...)
> +|
> +devm_request_threaded_irq@p(dev, irq, NULL, ...)
> +)
>
>  @script:python depends on org@
>  p << match.p;
> --
> 2.1.4
>
>


Re: [PATCH v3 2/3] Coccinelle: misc: Improve the result given by context mode

2016-11-12 Thread Julia Lawall
On Mon, 24 Oct 2016, Vaishali Thakkar wrote:

> To eliminate false positives given by the context mode, add
> necessary arguments for the function request_threaded_irq.
>
> Signed-off-by: Vaishali Thakkar 

Acked-by: Julia Lawall 

> ---
> Changes since v2:
>   - Add missing declaration of metavariable irq
> Changes since v1:
>   - Split patch in to the patch set
> ---
>  scripts/coccinelle/misc/irqf_oneshot.cocci | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci 
> b/scripts/coccinelle/misc/irqf_oneshot.cocci
> index a8537fb..e53372e 100644
> --- a/scripts/coccinelle/misc/irqf_oneshot.cocci
> +++ b/scripts/coccinelle/misc/irqf_oneshot.cocci
> @@ -87,9 +87,10 @@ devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
>  )
>
>  @depends on context@
> +expression irq;
>  position p != {r1.p,r2.p};
>  @@
> -*request_threaded_irq@p(...)
> +*request_threaded_irq@p(irq, NULL, ...)
>
>  @match depends on report || org@
>  expression irq;
> --
> 2.1.4
>
>


[PATCH] [STYLE 2/5]staging:speakup:synth.c Logical continuation previous

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: Logical continuations should be on the previous line

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/synth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 800fbbf..a53bdce 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -406,8 +406,8 @@ static int do_synth_init(struct spk_synth *in_synth)
speakup_register_var(var);
if (!spk_quiet_boot)
synth_printf("%s found\n", synth->long_name);
-   if (synth->attributes.name
-   && sysfs_create_group(speakup_kobj, >attributes) < 0)
+   if (synth->attributes.name &&
+   sysfs_create_group(speakup_kobj, >attributes) < 0)
return -ENOMEM;
synth_flags = synth->flags;
wake_up_interruptible_all(_event);
-- 
2.1.4



Re: [PATCH] locktorture: Fix potential memory leak with rw lock test

2016-11-12 Thread Paul E. McKenney
On Thu, Nov 10, 2016 at 01:06:39PM -0800, Yang Shi wrote:
> When running locktorture module with the below commands with kmemleak enabled:
> 
> $ modprobe locktorture torture_type=rw_lock_irq
> $ rmmod locktorture
> 
> The below kmemleak got caught:
> 
> root@10:~# echo scan > /sys/kernel/debug/kmemleak
> [  323.197029] kmemleak: 2 new suspected memory leaks (see 
> /sys/kernel/debug/kmemleak)
> root@10:~# cat /sys/kernel/debug/kmemleak
> unreferenced object 0xffc07592d500 (size 128):
>   comm "modprobe", pid 368, jiffies 4294924118 (age 205.824s)
>   hex dump (first 32 bytes):
> 00 00 00 00 00 00 00 00 c3 7b 02 00 00 00 00 00  .{..
> 00 00 00 00 00 00 00 00 d7 9b 02 00 00 00 00 00  
>   backtrace:
> [] create_object+0x110/0x288
> [] kmemleak_alloc+0x58/0xa0
> [] __kmalloc+0x234/0x318
> [] 0xff80006fa130
> [] do_one_initcall+0x44/0x138
> [] do_init_module+0x68/0x1cc
> [] load_module+0x1a68/0x22e0
> [] SyS_finit_module+0xe0/0xf0
> [] el0_svc_naked+0x24/0x28
> [] 0x
> unreferenced object 0xffc07592d480 (size 128):
>   comm "modprobe", pid 368, jiffies 4294924118 (age 205.824s)
>   hex dump (first 32 bytes):
> 00 00 00 00 00 00 00 00 3b 6f 01 00 00 00 00 00  ;o..
> 00 00 00 00 00 00 00 00 23 6a 01 00 00 00 00 00  #j..
>   backtrace:
> [] create_object+0x110/0x288
> [] kmemleak_alloc+0x58/0xa0
> [] __kmalloc+0x234/0x318
> [] 0xff80006fa22c
> [] do_one_initcall+0x44/0x138
> [] do_init_module+0x68/0x1cc
> [] load_module+0x1a68/0x22e0
> [] SyS_finit_module+0xe0/0xf0
> [] el0_svc_naked+0x24/0x28
> [] 0x
> 
> It is because cxt.lwsa and cxt.lrsa don't get freed in module_exit, so free
> them in lock_torture_cleanup() and free writer_tasks if reader_tasks is
> failed at memory allocation.
> 
> Signed-off-by: Yang Shi 

Good catch!  Queued for review and testing.

Thanx, Paul

> ---
>  kernel/locking/locktorture.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
> index f8c5af5..d3de04b 100644
> --- a/kernel/locking/locktorture.c
> +++ b/kernel/locking/locktorture.c
> @@ -780,6 +780,10 @@ static void lock_torture_cleanup(void)
>   else
>   lock_torture_print_module_parms(cxt.cur_ops,
>   "End of test: SUCCESS");
> +
> + kfree(cxt.lwsa);
> + kfree(cxt.lrsa);
> +
>  end:
>   torture_cleanup_end();
>  }
> @@ -924,6 +928,8 @@ static int __init lock_torture_init(void)
>  GFP_KERNEL);
>   if (reader_tasks == NULL) {
>   VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory");
> + kfree(writer_tasks);
> + writer_tasks = NULL;
>   firsterr = -ENOMEM;
>   goto unwind;
>   }
> -- 
> 2.0.2
> 



[PATCH] [STYLE 3/5]staging:speakup:synth.c Space preferred around

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: spaces preferred around that '/,+,-'

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/synth.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index a53bdce..aac3f3b 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -303,11 +303,11 @@ void spk_get_index_count(int *linecount, int *sentcount)
sentence_count = ind % 10;
 
if ((ind / 10) <= synth->indexing.currindex)
-   index_count = synth->indexing.currindex-(ind/10);
+   index_count = synth->indexing.currindex - (ind / 10);
else
index_count = synth->indexing.currindex
-   -synth->indexing.lowindex
-   + synth->indexing.highindex-(ind/10)+1;
+   - synth->indexing.lowindex
+   + synth->indexing.highindex - (ind / 10) + 1;
 
}
*sentcount = sentence_count;
@@ -476,10 +476,10 @@ void synth_remove(struct spk_synth *in_synth)
break;
}
for ( ; synths[i] != NULL; i++) /* compress table */
-   synths[i] = synths[i+1];
+   synths[i] = synths[i + 1];
module_status = 0;
mutex_unlock(_mutex);
 }
 EXPORT_SYMBOL_GPL(synth_remove);
 
-short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM };
+short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM };
-- 
2.1.4



Re: [PATCH v3 1/3] Coccinelle: misc: Improve the matching of rules

2016-11-12 Thread Julia Lawall


On Mon, 24 Oct 2016, Vaishali Thakkar wrote:

> Currently because of the left associativity of the operators, pattern
> IRQF_ONESHOT | flags does not match with the pattern when we have more
> than one flag after the disjunction. This eventually results in giving
> false positives by the script. This patch eliminates these FPs by
> improving the rule.
>
> Signed-off-by: Vaishali Thakkar 
> ---
> Changes since v2:
>   - No change in this patch
> Changes since v1:
>   - Splitted patch in the patchset
> ---
>  scripts/coccinelle/misc/irqf_oneshot.cocci | 30 
> --
>  1 file changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci 
> b/scripts/coccinelle/misc/irqf_oneshot.cocci
> index b421150..a8537fb 100644
> --- a/scripts/coccinelle/misc/irqf_oneshot.cocci
> +++ b/scripts/coccinelle/misc/irqf_oneshot.cocci
> @@ -18,13 +18,12 @@ virtual report
>  expression dev;
>  expression irq;
>  expression thread_fn;
> -expression flags;
>  position p;
>  @@
>  (
>  request_threaded_irq@p(irq, NULL, thread_fn,
>  (
> -flags | IRQF_ONESHOT
> +IRQF_ONESHOT | ...
>  |
>  IRQF_ONESHOT
>  )
> @@ -32,20 +31,39 @@ IRQF_ONESHOT
>  |
>  devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
>  (
> -flags | IRQF_ONESHOT
> +IRQF_ONESHOT | ...
>  |
>  IRQF_ONESHOT
>  )
>  , ...)
>  )
>
> -@depends on patch@
> +@r2@
>  expression dev;
>  expression irq;
>  expression thread_fn;
>  expression flags;
> +expression ret;
>  position p != r1.p;
>  @@
> +flags = IRQF_ONESHOT | ...;
> +(
> +ret = request_threaded_irq@p(irq, NULL, thread_fn, flags, ...);
> +|
> +ret = devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, flags, ...);
> +|
> +return request_threaded_irq@p(irq, NULL, thread_fn, flags, ...);
> +|
> +return devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, flags, ...);
> +)

This rule needs some improvement.

flags = IRQF_ONESHOT | ...;

should be replaced by:

(
flags = IRQF_ONESHOT | ...
|
flags |= IRQF_ONESHOT | ...
)
... when != flags = e

where e should be a new expression metavariable.  This effects a number of
changes.  1) Dropping the ; after the assignment allows an isomorphism to
trigger that allows it to match a variable declaration as well, 2)
IRQF_ONESHOT can be added after the original initialization by a |=, 3)
there can be some instructions between the initialization of flags and the
use.

Afterwards, the big disjunction with the irq calls is too specific.
In particular, these calls can also occur in an if test.  The disjunction
should be replaced by the following:

(
request_threaded_irq@p(irq, NULL, thread_fn, flags, ...)
|
devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, flags, ...)
)

julia


> +
> +@depends on patch@
> +expression dev;
> +expression irq;
> +expression thread_fn;
> +expression flags;
> +position p != {r1.p,r2.p};
> +@@
>  (
>  request_threaded_irq@p(irq, NULL, thread_fn,
>  (
> @@ -69,13 +87,13 @@ devm_request_threaded_irq@p(dev, irq, NULL, thread_fn,
>  )
>
>  @depends on context@
> -position p != r1.p;
> +position p != {r1.p,r2.p};
>  @@
>  *request_threaded_irq@p(...)
>
>  @match depends on report || org@
>  expression irq;
> -position p != r1.p;
> +position p != {r1.p,r2.p};
>  @@
>  request_threaded_irq@p(irq, NULL, ...)
>
> --
> 2.1.4
>
>


[PATCH] [STYLE 4/5]staging:speakup:synth.c Align match parenthesis

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: Alignment should match open parenthesis

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/synth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index aac3f3b..57ab7a2 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -66,8 +66,8 @@ int spk_serial_synth_probe(struct spk_synth *synth)
pr_info("%s: not found\n", synth->long_name);
return -ENODEV;
}
-   pr_info("%s: ttyS%i, Driver Version %s\n",
-   synth->long_name, synth->ser, synth->version);
+   pr_info("%s: ttyS%i, Driver Version %s\n", synth->long_name, synth->ser,
+   synth->version);
synth->alive = 1;
return 0;
 }
-- 
2.1.4



[PATCH] [STYLE 5/5]staging:speakup:synth.c Blankline before close }

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/synth.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 57ab7a2..7b84513 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -308,7 +308,6 @@ void spk_get_index_count(int *linecount, int *sentcount)
index_count = synth->indexing.currindex
- synth->indexing.lowindex
+ synth->indexing.highindex - (ind / 10) + 1;
-
}
*sentcount = sentence_count;
*linecount = index_count;
-- 
2.1.4



[PATCH] [STYLE 1/2]staging:speakup:thread.c Modified block comment

2016-11-12 Thread Walt Feasel
Modified block comment to multiline style

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/thread.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/thread.c b/drivers/staging/speakup/thread.c
index 90c383e..e4de7dc 100644
--- a/drivers/staging/speakup/thread.c
+++ b/drivers/staging/speakup/thread.c
@@ -47,7 +47,8 @@ int speakup_thread(void *data)
if (our_sound.active)
kd_mksound(our_sound.freq, our_sound.jiffies);
if (synth && synth->catch_up && synth->alive) {
-   /* It is up to the callee to take the lock, so that it
+   /*
+* It is up to the callee to take the lock, so that it
 * can sleep whenever it likes
 */
synth->catch_up(synth);
-- 
2.1.4



Re: Source address fib invalidation on IPv6

2016-11-12 Thread David Ahern
On 11/12/16 8:40 AM, Jason A. Donenfeld wrote:
> Hi again,
> 
> I've done some pretty in depth debugging now to determine exactly what
> the behavior of ipv6_stub->ipv6_dst_lookup is. First I'll start with
> ip_route_output_flow, which I believe to be well behaved, and then
> I'll show ipv6_stub->ipv6_dst_lookup, which seems ill-behaved:
> 
> Userspace:
> ip addr add 192.168.1.2/24 dev eth0
> Kernelspace:
> struct flowi4 fl = {
>.saddr = 192.168.1.2,
>.daddr = 192.168.1.99,
> };
> rt = ip_route_output_flow(sock_net(sock), , sock);
> // rt returns valid rt for routing to 192.168.1.99 from
> 192.168.1.2 using eth0
> Userspace:
> ip addr add 192.168.1.3/24 dev eth0
> ip addr del 192.168.1.2/24 dev eth0
> Kernelspace:
> struct flowi4 fl = {
>.saddr = 192.168.1.2,
>.daddr = 192.168.1.99,
> };
> rt = ip_route_output_flow(sock_net(sock), , sock);
> // PTR_ERR(rt) == -EINVAL

I believe that is coming from __ip_route_output_key_hash(), line 2232 with 
__ip_dev_find not finding a device with that address. 

Not applicable for your use case, but __ip_dev_find does not have any checks on 
which L3 domain the device belongs to so the check does not handle VRF for 
example. I'll take a look at fixing this next week.

> 
> This seems correct behavior to me, since no interface has 192.168.1.2
> as a source address.
> 
> Now for the incorrect IPv6 behavior:
> 
> Userspace:
> ip -6 addr add abcd::2/96 dev eth0
> Kernelspace:
> struct flowi6 fl = {
>.saddr = abcd::2,
>.daddr = abcd::99,
> };
> ret = ipv6_stub->ipv6_dst_lookup(sock_net(sock), sock, , );
> // ret is 0, and dst is a non-null dst routing to abcd::99 from
> abcd::2 using eth0
> Userspace:
> ip -6 addr add abcd::3/96 dev eth0
> ip -6 addr del abcd::2/96 dev eth0
> Kernelspace:
> struct flowi6 fl = {
>.saddr = abcd::2,
>.daddr = abcd::99,
> };
> ret = ipv6_stub->ipv6_dst_lookup(sock_net(sock), sock, , );
> // ret is 0, and dst is a non-null dst routing to abcd::99 from
> abcd::2 using eth0 **INCORRECT BEHAVIOR!**
> 
> This seems *INCORRECT* behavior to me, since no interface has abcd::2
> as a source address.

Gotcha. I don't see any checks that the saddr is valid similar to what IPv4 
does.

I think the right place to add a check is in ip6_dst_lookup_tail():
if (!ipv6_addr_any(>saddr)) {
// saddr is valid for L3 domain
}




[PATCH] [STYLE 2/2]staging:speakup:thread.c Align match parenthesis

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to: CHECK: Alignment should match open parenthesis

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/thread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/thread.c b/drivers/staging/speakup/thread.c
index e4de7dc..8c64f1a 100644
--- a/drivers/staging/speakup/thread.c
+++ b/drivers/staging/speakup/thread.c
@@ -27,7 +27,7 @@ int speakup_thread(void *data)
our_sound = spk_unprocessed_sound;
spk_unprocessed_sound.active = 0;
prepare_to_wait(_event, ,
-   TASK_INTERRUPTIBLE);
+   TASK_INTERRUPTIBLE);
should_break = kthread_should_stop() ||
our_sound.active ||
(synth && synth->catch_up && synth->alive &&
-- 
2.1.4



[PATCH v4 23/26] staging: iio: tsl2583: remove unnecessary memset call

2016-11-12 Thread Brian Masney
The entries in the lux table (als_device_lux) can be updated via sysfs
through the function in_illuminance_lux_table_store(). The last row in
the table must be terminated with values that are zero. The sysfs code
already ensures that the last row is all zeros. The call to memset to
clear out the table is not needed so this patch removes the unnecessary
call.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 9db191f..712f753 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -591,9 +591,6 @@ static ssize_t in_illuminance_lux_table_store(struct device 
*dev,
goto done;
}
 
-   /* Zero out the table */
-   memset(chip->als_settings.als_device_lux, 0,
-  sizeof(chip->als_settings.als_device_lux));
memcpy(chip->als_settings.als_device_lux, [1],
   value[0] * sizeof(value[1]));
 
-- 
2.7.4



[PATCH v4 26/26] staging: iio: tsl2583: move out of staging

2016-11-12 Thread Brian Masney
Move tsl2580, tsl2581, tsl2583 driver out of staging into mainline.

Signed-off-by: Brian Masney 
---
 .../ABI/testing/sysfs-bus-iio-light-tsl2583|  20 +
 drivers/iio/light/Kconfig  |   7 +
 drivers/iio/light/Makefile |   1 +
 drivers/iio/light/tsl2583.c| 913 +
 .../light/sysfs-bus-iio-light-tsl2583  |  20 -
 drivers/staging/iio/light/Kconfig  |   7 -
 drivers/staging/iio/light/Makefile |   1 -
 drivers/staging/iio/light/tsl2583.c| 913 -
 8 files changed, 941 insertions(+), 941 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583
 create mode 100644 drivers/iio/light/tsl2583.c
 delete mode 100644 
drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
 delete mode 100644 drivers/staging/iio/light/tsl2583.c

diff --git a/Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583 
b/Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583
new file mode 100644
index 000..a2e1996
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583
@@ -0,0 +1,20 @@
+What:  /sys/bus/iio/devices/device[n]/in_illuminance_calibrate
+KernelVersion: 2.6.37
+Contact:   linux-...@vger.kernel.org
+Description:
+   This property causes an internal calibration of the als gain 
trim
+   value which is later used in calculating illuminance in lux.
+
+What:  /sys/bus/iio/devices/device[n]/in_illuminance_lux_table
+KernelVersion: 2.6.37
+Contact:   linux-...@vger.kernel.org
+Description:
+   This property gets/sets the table of coefficients
+   used in calculating illuminance in lux.
+
+What:  /sys/bus/iio/devices/device[n]/in_illuminance_input_target
+KernelVersion: 2.6.37
+Contact:   linux-...@vger.kernel.org
+Description:
+   This property is the known externally illuminance (in lux).
+   It is used in the process of calibrating the device accuracy.
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index d011720..298ea50 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -338,6 +338,13 @@ config SENSORS_TSL2563
 This driver can also be built as a module.  If so, the module
 will be called tsl2563.
 
+config TSL2583
+   tristate "TAOS TSL2580, TSL2581 and TSL2583 light-to-digital converters"
+   depends on I2C
+   help
+Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices.
+Access ALS data via iio, sysfs.
+
 config TSL4531
tristate "TAOS TSL4531 ambient light sensors"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index 15f24c5..4de5200 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_SI1145)  += si1145.o
 obj-$(CONFIG_STK3310)  += stk3310.o
 obj-$(CONFIG_TCS3414)  += tcs3414.o
 obj-$(CONFIG_TCS3472)  += tcs3472.o
+obj-$(CONFIG_TSL2583)  += tsl2583.o
 obj-$(CONFIG_TSL4531)  += tsl4531.o
 obj-$(CONFIG_US5182D)  += us5182d.o
 obj-$(CONFIG_VCNL4000) += vcnl4000.o
diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c
new file mode 100644
index 000..ca26444
--- /dev/null
+++ b/drivers/iio/light/tsl2583.c
@@ -0,0 +1,913 @@
+/*
+ * Device driver for monitoring ambient light intensity (lux)
+ * within the TAOS tsl258x family of devices (tsl2580, tsl2581, tsl2583).
+ *
+ * Copyright (c) 2011, TAOS Corporation.
+ * Copyright (c) 2016 Brian Masney 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Device Registers and Masks */
+#define TSL2583_CNTRL  0x00
+#define TSL2583_ALS_TIME   0X01
+#define TSL2583_INTERRUPT  0x02
+#define TSL2583_GAIN   0x07
+#define TSL2583_REVID  0x11
+#define TSL2583_CHIPID 0x12
+#define TSL2583_ALS_CHAN0LO0x14
+#define TSL2583_ALS_CHAN0HI0x15
+#define TSL2583_ALS_CHAN1LO0x16
+#define TSL2583_ALS_CHAN1HI0x17
+#define TSL2583_TMR_LO 0x18
+#define TSL2583_TMR_HI 0x19
+
+/* tsl2583 cmd reg masks */
+#define TSL2583_CMD_REG   

[PATCH v4 24/26] staging: iio: tsl2583: remove unnecessary variable initialization

2016-11-12 Thread Brian Masney
The ret variable in tsl2583_suspend() and tsl2583_resume() was
initialized to 0. This is not necessary so this patch removes the
initialization.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 712f753..b787952 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -849,7 +849,7 @@ static int __maybe_unused tsl2583_suspend(struct device 
*dev)
 {
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct tsl2583_chip *chip = iio_priv(indio_dev);
-   int ret = 0;
+   int ret;
 
mutex_lock(>als_mutex);
 
@@ -865,7 +865,7 @@ static int __maybe_unused tsl2583_resume(struct device *dev)
 {
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct tsl2583_chip *chip = iio_priv(indio_dev);
-   int ret = 0;
+   int ret;
 
mutex_lock(>als_mutex);
 
-- 
2.7.4



[PATCH v4 25/26] staging: iio: tsl2583: add copyright and MODULE_AUTHOR

2016-11-12 Thread Brian Masney
Add Brian Masney's copyright to the header and to the MODULE_AUTHOR
for all of the staging cleanups that has been done to this driver.

The original MODULE_AUTHOR() did not have a space between his name and
email address. This patch also adds the missing space.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index b787952..ca26444 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -3,6 +3,7 @@
  * within the TAOS tsl258x family of devices (tsl2580, tsl2581, tsl2583).
  *
  * Copyright (c) 2011, TAOS Corporation.
+ * Copyright (c) 2016 Brian Masney 
  *
  * 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
@@ -906,6 +907,7 @@ static struct i2c_driver tsl2583_driver = {
 };
 module_i2c_driver(tsl2583_driver);
 
-MODULE_AUTHOR("J. August Brenner");
+MODULE_AUTHOR("J. August Brenner ");
+MODULE_AUTHOR("Brian Masney ");
 MODULE_DESCRIPTION("TAOS tsl2583 ambient light sensor driver");
 MODULE_LICENSE("GPL");
-- 
2.7.4



[PATCH v4 22/26] staging: iio: tsl2583: remove comment for tsl2583_probe()

2016-11-12 Thread Brian Masney
The comment for tsl2583_probe() does not provide any useful value.
This patch removes the comment.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 727ed49..9db191f 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -782,10 +782,6 @@ static const struct iio_info tsl2583_info = {
.write_raw = tsl2583_write_raw,
 };
 
-/*
- * Client probe function - When a valid device is found, the driver's device
- * data structure is updated, and initialization completes successfully.
- */
 static int tsl2583_probe(struct i2c_client *clientp,
 const struct i2c_device_id *idp)
 {
-- 
2.7.4



[PATCH v4 21/26] staging: iio: tsl2583: clarified comment about clearing interrupts

2016-11-12 Thread Brian Masney
The comment that describes the code that clears the interrupt bit was
vague and didn't provide much value. This patch adds more detail about
why that bit needs to be cleared.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 806cb0a..727ed49 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -205,8 +205,9 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
}
 
/*
-* clear status, really interrupt status (interrupts are off), but
-* we use the bit anyway - don't forget 0x80 - this is a command
+* Clear the pending interrupt status bit on the chip to allow the next
+* integration cycle to start. This has to be done even though this
+* driver currently does not support interrupts.
 */
ret = i2c_smbus_write_byte(chip->client,
   (TSL2583_CMD_REG | TSL2583_CMD_SPL_FN |
-- 
2.7.4



[PATCH v4 20/26] staging: iio: tsl2583: add tsl2583 to list of supported devices in the header

2016-11-12 Thread Brian Masney
The header only listed the tsl2580 and tsl2581 devices as supported by
this driver. This patch adds the tsl2583 since it is also supported by
this driver.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 3818ffa..806cb0a 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -1,6 +1,6 @@
 /*
  * Device driver for monitoring ambient light intensity (lux)
- * within the TAOS tsl258x family of devices (tsl2580, tsl2581).
+ * within the TAOS tsl258x family of devices (tsl2580, tsl2581, tsl2583).
  *
  * Copyright (c) 2011, TAOS Corporation.
  *
-- 
2.7.4



[PATCH v4 16/26] staging: iio: tsl2583: change tsl2583_als_calibrate() to return 0 on success

2016-11-12 Thread Brian Masney
tsl2583_als_calibrate() returns the newly computed gain_trim if the
calibration was successful. This function is only called by
in_illuminance_calibrate_store() and the return value inside that
sysfs attribute is only checked to see if an error was returned.
This patch changes tsl2583_als_calibrate() to return 0 on success.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index bcdf095..fc58074 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -348,7 +348,7 @@ static int tsl2583_als_calibrate(struct iio_dev *indio_dev)
 
chip->als_settings.als_gain_trim = (int)gain_trim_val;
 
-   return (int)gain_trim_val;
+   return 0;
 }
 
 static int tsl2583_set_als_time(struct tsl2583_chip *chip)
-- 
2.7.4



[PATCH v4 19/26] staging: iio: tsl2583: move from a global to a per device lux table

2016-11-12 Thread Brian Masney
The driver contains a global lux table that can be updated via sysfs.
Change this to a per device lux table so that multiple devices can be
hooked up to the same system with different lux tables.

There are 10 entries, plus 1 for the termination segment, set aside for
the entries in the lux table. When updating the lux table via sysfs,
only 9 entries, plus the terminator, could be added. This changes
the code to allow for the 10 entries, plus the terminator.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 80 +
 1 file changed, 46 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 78967dc..3818ffa 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -70,11 +70,34 @@ struct tsl2583_als_info {
u16 lux;
 };
 
+struct tsl2583_lux {
+   unsigned int ratio;
+   unsigned int ch0;
+   unsigned int ch1;
+};
+
+static const struct tsl2583_lux tsl2583_default_lux[] = {
+   {  9830,  8520, 15729 },
+   { 12452, 10807, 23344 },
+   { 14746,  6383, 11705 },
+   { 17695,  4063,  6554 },
+   { 0, 0, 0 }  /* Termination segment */
+};
+
+#define TSL2583_MAX_LUX_TABLE_ENTRIES 11
+
 struct tsl2583_settings {
int als_time;
int als_gain;
int als_gain_trim;
int als_cal_target;
+
+   /*
+* This structure is intentionally large to accommodate updates via
+* sysfs. Sized to 11 = max 10 segments + 1 termination segment.
+* Assumption is that one and only one type of glass used.
+*/
+   struct tsl2583_lux als_device_lux[TSL2583_MAX_LUX_TABLE_ENTRIES];
 };
 
 struct tsl2583_chip {
@@ -87,24 +110,6 @@ struct tsl2583_chip {
bool suspended;
 };
 
-struct tsl2583_lux {
-   unsigned int ratio;
-   unsigned int ch0;
-   unsigned int ch1;
-};
-
-/*
- * This structure is intentionally large to accommodate updates via sysfs.
- * Sized to 11 = max 10 segments + 1 termination segment. Assumption is that
- * one and only one type of glass used.
- */
-static struct tsl2583_lux tsl2583_device_lux[11] = {
-   {  9830,  8520, 15729 },
-   { 12452, 10807, 23344 },
-   { 14746,  6383, 11705 },
-   { 17695,  4063,  6554 },
-};
-
 struct gainadj {
s16 ch0;
s16 ch1;
@@ -142,6 +147,10 @@ static void tsl2583_defaults(struct tsl2583_chip *chip)
 
/* Known external ALS reading used for calibration */
chip->als_settings.als_cal_target = 130;
+
+   /* Default lux table. */
+   memcpy(chip->als_settings.als_device_lux, tsl2583_default_lux,
+  sizeof(tsl2583_default_lux));
 }
 
 /*
@@ -151,7 +160,7 @@ static void tsl2583_defaults(struct tsl2583_chip *chip)
  * Time scale factor array values are adjusted based on the integration time.
  * The raw values are multiplied by a scale factor, and device gain is obtained
  * using gain index. Limit checks are done next, then the ratio of a multiple
- * of ch1 value, to the ch0 value, is calculated. The array 
tsl2583_device_lux[]
+ * of ch1 value, to the ch0 value, is calculated. The array als_device_lux[]
  * declared above is then scanned to find the first ratio value that is just
  * above the ratio we just calculated. The ch0 and ch1 multiplier constants in
  * the array are then used along with the time scale factor array values, to
@@ -233,7 +242,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
ratio = (ch1 << 15) / ch0;
 
/* convert to unscaled lux using the pointer to the table */
-   for (p = (struct tsl2583_lux *)tsl2583_device_lux;
+   for (p = (struct tsl2583_lux *)chip->als_settings.als_device_lux;
 p->ratio != 0 && p->ratio < ratio; p++)
;
 
@@ -270,7 +279,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
 
/*
 * Adjust for active gain scale.
-* The tsl2583_device_lux tables above have a factor of 8192 built in,
+* The tsl2583_default_lux tables above have a factor of 8192 built in,
 * so we need to shift right.
 * User-specified gain provides a multiplier.
 * Apply user-specified gain before shifting right to retain precision.
@@ -522,15 +531,17 @@ static ssize_t in_illuminance_lux_table_show(struct 
device *dev,
 struct device_attribute *attr,
 char *buf)
 {
+   struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+   struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned int i;
int offset = 0;
 
-   for (i = 0; i < ARRAY_SIZE(tsl2583_device_lux); i++) {
+   for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) {
offset += sprintf(buf + offset, "%u,%u,%u,",
- tsl2583_device_lux[i].ratio,
- 

[PATCH v4 15/26] staging: iio: tsl2583: moved code block inside else statement

2016-11-12 Thread Brian Masney
The check for ch1lux > ch0lux inside tsl2583_get_lux is only valid if
the ratio is not equal to zero. Move the code block inside the else
statement. This does away with the need to initialize the variables to
zero.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index dbb7f6a..bcdf095 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -167,8 +167,6 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
struct tsl2583_lux *p;
struct tsl2583_chip *chip = iio_priv(indio_dev);
int i, ret;
-   u32 ch0lux = 0;
-   u32 ch1lux = 0;
 
ret = i2c_smbus_read_byte_data(chip->client, TSL2583_CMD_REG);
if (ret < 0) {
@@ -242,22 +240,25 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
if (p->ratio == 0) {
lux = 0;
} else {
+   u32 ch0lux, ch1lux;
+
ch0lux = ((ch0 * p->ch0) +
  (gainadj[chip->als_settings.als_gain].ch0 >> 1))
 / gainadj[chip->als_settings.als_gain].ch0;
ch1lux = ((ch1 * p->ch1) +
  (gainadj[chip->als_settings.als_gain].ch1 >> 1))
 / gainadj[chip->als_settings.als_gain].ch1;
-   lux = ch0lux - ch1lux;
-   }
 
-   /* note: lux is 31 bit max at this point */
-   if (ch1lux > ch0lux) {
-   dev_dbg(>client->dev, "%s: No Data - Returning 0\n",
-   __func__);
-   ret = 0;
-   chip->als_cur_info.lux = 0;
-   goto done;
+   /* note: lux is 31 bit max at this point */
+   if (ch1lux > ch0lux) {
+   dev_dbg(>client->dev, "%s: No Data - Returning 
0\n",
+   __func__);
+   ret = 0;
+   chip->als_cur_info.lux = 0;
+   goto done;
+   }
+
+   lux = ch0lux - ch1lux;
}
 
/* adjust for active time scale */
-- 
2.7.4



[PATCH v4 13/26] staging: iio: tsl2583: fix multiline comment syntax

2016-11-12 Thread Brian Masney
The definition of the tsl2583_device_lux struct has a series of single
line comments. There are two other cases where the multiline comments
did not have an initial blank line. Change these comments to use the
proper multiline syntax.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 8303753..52a39a6 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -93,9 +93,11 @@ struct tsl2583_lux {
unsigned int ch1;
 };
 
-/* This structure is intentionally large to accommodate updates via sysfs. */
-/* Sized to 11 = max 10 segments + 1 termination segment */
-/* Assumption is one and only one type of glass used  */
+/*
+ * This structure is intentionally large to accommodate updates via sysfs.
+ * Sized to 11 = max 10 segments + 1 termination segment. Assumption is that
+ * one and only one type of glass used.
+ */
 static struct tsl2583_lux tsl2583_device_lux[11] = {
{  9830,  8520, 15729 },
{ 12452, 10807, 23344 },
@@ -261,7 +263,8 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
lux = (lux + (chip->als_time_scale >> 1)) /
chip->als_time_scale;
 
-   /* Adjust for active gain scale.
+   /*
+* Adjust for active gain scale.
 * The tsl2583_device_lux tables above have a factor of 8192 built in,
 * so we need to shift right.
 * User-specified gain provides a multiplier.
@@ -553,7 +556,8 @@ static ssize_t in_illuminance_lux_table_store(struct device 
*dev,
 
get_options(buf, ARRAY_SIZE(value), value);
 
-   /* We now have an array of ints starting at value[1], and
+   /*
+* We now have an array of ints starting at value[1], and
 * enumerated by value[0].
 * We expect each group of three ints is one table entry,
 * and the last table entry is all 0.
-- 
2.7.4



[PATCH] [STYLE 2/2]staging:speakup:varhandlers.c Align match parenthesis

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: Alignment should match open parenthesis

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/varhandlers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/varhandlers.c 
b/drivers/staging/speakup/varhandlers.c
index 5ab7245..ab7000d 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -237,8 +237,8 @@ int spk_set_num_var(int input, struct st_var_header *var, 
int how)
if (!var_data->u.n.out_str)
l = sprintf(cp, var_data->u.n.synth_fmt, (int)val);
else
-   l = sprintf(cp,
-   var_data->u.n.synth_fmt, var_data->u.n.out_str[val]);
+   l = sprintf(cp, var_data->u.n.synth_fmt,
+   var_data->u.n.out_str[val]);
synth_printf("%s", cp);
return 0;
 }
-- 
2.1.4



[PATCH v4 02/26] staging: iio: tsl2583: remove unnecessary chip status check in taos_get_lux

2016-11-12 Thread Brian Masney
taos_get_lux checks to see if the chip is in a working state. This
check is not necessary since it is only called from tsl2583_read_raw
and in_illuminance_calibrate_store (via taos_als_calibrate). The chip
state is already checked by these functions.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index de54e74..a550023 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -178,13 +178,6 @@ static int taos_get_lux(struct iio_dev *indio_dev)
u32 ch0lux = 0;
u32 ch1lux = 0;
 
-   if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
-   /* device is not enabled */
-   dev_err(>client->dev, "taos_get_lux device is not 
enabled\n");
-   ret = -EBUSY;
-   goto done;
-   }
-
ret = i2c_smbus_read_byte_data(chip->client, TSL258X_CMD_REG);
if (ret < 0) {
dev_err(>client->dev, "taos_get_lux failed to read 
CMD_REG\n");
-- 
2.7.4



[PATCH v4 18/26] staging: iio: tsl2583: don't assume an unsigned int is 32 bits

2016-11-12 Thread Brian Masney
in_illuminance_lux_table_store assumes that an unsigned int is 32 bits.
Replace this with sizeof(value[1]).

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index fe9d777..78967dc 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -582,7 +582,7 @@ static ssize_t in_illuminance_lux_table_store(struct device 
*dev,
 
/* Zero out the table */
memset(tsl2583_device_lux, 0, sizeof(tsl2583_device_lux));
-   memcpy(tsl2583_device_lux, [1], value[0] * 4);
+   memcpy(tsl2583_device_lux, [1], value[0] * sizeof(value[1]));
 
ret = len;
 
-- 
2.7.4



[PATCH v4 01/26] staging: iio: tsl2583: check if chip is in a working state in in_illuminance_calibrate_store

2016-11-12 Thread Brian Masney
in_illuminance_calibrate_store() did not check to see if the chip is
in a working state. This patch adds the proper check. The return value
from taos_als_calibrate() was also not checked in this function, so the
proper check was also added while changes are being made here.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 1a7be12..de54e74 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -501,16 +501,27 @@ static ssize_t in_illuminance_calibrate_store(struct 
device *dev,
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
-   int value;
+   int value, ret;
 
if (kstrtoint(buf, 0, ) || value != 1)
return -EINVAL;
 
mutex_lock(>als_mutex);
-   taos_als_calibrate(indio_dev);
+
+   if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+   ret = -EBUSY;
+   goto done;
+   }
+
+   ret = taos_als_calibrate(indio_dev);
+   if (ret < 0)
+   goto done;
+
+   ret = len;
+done:
mutex_unlock(>als_mutex);
 
-   return len;
+   return ret;
 }
 
 static ssize_t in_illuminance_lux_table_show(struct device *dev,
-- 
2.7.4



[PATCH v4 08/26] staging: iio: tsl2583: unify function and variable prefix to tsl2583_

2016-11-12 Thread Brian Masney
Some functions and variables were prefixed with either taos, tsl258x,
taos2583, or tsl2583. Change everything to use the tsl2583 prefix since
that is the name of the .c file. The taos_settings member inside the
taos_settings struct was renamed to als_settings.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 214 ++--
 1 file changed, 107 insertions(+), 107 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 5d74e0c1..5a82a26 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -28,35 +28,35 @@
 #include 
 
 /* Device Registers and Masks */
-#define TSL258X_CNTRL  0x00
-#define TSL258X_ALS_TIME   0X01
-#define TSL258X_INTERRUPT  0x02
-#define TSL258X_GAIN   0x07
-#define TSL258X_REVID  0x11
-#define TSL258X_CHIPID 0x12
-#define TSL258X_ALS_CHAN0LO0x14
-#define TSL258X_ALS_CHAN0HI0x15
-#define TSL258X_ALS_CHAN1LO0x16
-#define TSL258X_ALS_CHAN1HI0x17
-#define TSL258X_TMR_LO 0x18
-#define TSL258X_TMR_HI 0x19
+#define TSL2583_CNTRL  0x00
+#define TSL2583_ALS_TIME   0X01
+#define TSL2583_INTERRUPT  0x02
+#define TSL2583_GAIN   0x07
+#define TSL2583_REVID  0x11
+#define TSL2583_CHIPID 0x12
+#define TSL2583_ALS_CHAN0LO0x14
+#define TSL2583_ALS_CHAN0HI0x15
+#define TSL2583_ALS_CHAN1LO0x16
+#define TSL2583_ALS_CHAN1HI0x17
+#define TSL2583_TMR_LO 0x18
+#define TSL2583_TMR_HI 0x19
 
 /* tsl2583 cmd reg masks */
-#define TSL258X_CMD_REG0x80
-#define TSL258X_CMD_SPL_FN 0x60
-#define TSL258X_CMD_ALS_INT_CLR0X01
+#define TSL2583_CMD_REG0x80
+#define TSL2583_CMD_SPL_FN 0x60
+#define TSL2583_CMD_ALS_INT_CLR0X01
 
 /* tsl2583 cntrl reg masks */
-#define TSL258X_CNTL_ADC_ENBL  0x02
-#define TSL258X_CNTL_PWR_OFF   0x00
-#define TSL258X_CNTL_PWR_ON0x01
+#define TSL2583_CNTL_ADC_ENBL  0x02
+#define TSL2583_CNTL_PWR_OFF   0x00
+#define TSL2583_CNTL_PWR_ON0x01
 
 /* tsl2583 status reg masks */
-#define TSL258X_STA_ADC_VALID  0x01
-#define TSL258X_STA_ADC_INTR   0x10
+#define TSL2583_STA_ADC_VALID  0x01
+#define TSL2583_STA_ADC_INTR   0x10
 
 /* Lux calculation constants */
-#defineTSL258X_LUX_CALC_OVER_FLOW  65535
+#defineTSL2583_LUX_CALC_OVER_FLOW  65535
 
 #define TSL2583_INTERRUPT_DISABLED 0x00
 
@@ -64,13 +64,13 @@
 #define TSL2583_CHIP_ID_MASK   0xf0
 
 /* Per-device data */
-struct taos_als_info {
+struct tsl2583_als_info {
u16 als_ch0;
u16 als_ch1;
u16 lux;
 };
 
-struct taos_settings {
+struct tsl2583_settings {
int als_time;
int als_gain;
int als_gain_trim;
@@ -80,14 +80,14 @@ struct taos_settings {
 struct tsl2583_chip {
struct mutex als_mutex;
struct i2c_client *client;
-   struct taos_als_info als_cur_info;
-   struct taos_settings taos_settings;
+   struct tsl2583_als_info als_cur_info;
+   struct tsl2583_settings als_settings;
int als_time_scale;
int als_saturation;
bool suspended;
 };
 
-struct taos_lux {
+struct tsl2583_lux {
unsigned int ratio;
unsigned int ch0;
unsigned int ch1;
@@ -96,7 +96,7 @@ struct taos_lux {
 /* This structure is intentionally large to accommodate updates via sysfs. */
 /* Sized to 11 = max 10 segments + 1 termination segment */
 /* Assumption is one and only one type of glass used  */
-static struct taos_lux taos_device_lux[11] = {
+static struct tsl2583_lux tsl2583_device_lux[11] = {
{  9830,  8520, 15729 },
{ 12452, 10807, 23344 },
{ 14746,  6383, 11705 },
@@ -121,25 +121,25 @@ static const struct gainadj gainadj[] = {
  * Provides initial operational parameter defaults.
  * These defaults may be changed through the device's sysfs files.
  */
-static void taos_defaults(struct tsl2583_chip *chip)
+static void tsl2583_defaults(struct tsl2583_chip *chip)
 {
/*
 * The integration time must be a multiple of 50ms and within the
 * range [50, 600] ms.
 */
-   chip->taos_settings.als_time = 100;
+   chip->als_settings.als_time = 100;
 
/*
 * This is an index into the gainadj table. Assume clear glass as the
 * default.
 */
-   chip->taos_settings.als_gain = 0;
+   chip->als_settings.als_gain = 0;
 
/* Default gain trim to account for aperture effects */
-   chip->taos_settings.als_gain_trim = 1000;
+   chip->als_settings.als_gain_trim = 1000;
 
/* Known external ALS reading used for 

[PATCH v4 14/26] staging: iio: tsl2583: updated code comment to match what the code does

2016-11-12 Thread Brian Masney
If channel 0 does not have any data, then the code sets the lux to zero.
The corresponding comment says that the last value is returned. This
updates the comment to correctly reflect what the code does. It also
clarifies the comment about why 0 is returned.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 52a39a6..dbb7f6a 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -221,7 +221,11 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
goto return_max;
 
if (!ch0) {
-   /* have no data, so return LAST VALUE */
+   /*
+* The sensor appears to be in total darkness so set the
+* calculated lux to 0 and return early to avoid a division by
+* zero below when calculating the ratio.
+*/
ret = 0;
chip->als_cur_info.lux = 0;
goto done;
-- 
2.7.4



[PATCH v4 17/26] staging: iio: tsl2583: remove unnecessary parentheses

2016-11-12 Thread Brian Masney
in_illuminance_lux_table_store() contains some unnecessary parentheses.
This patch removes them since they provide no value.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index fc58074..fe9d777 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -574,7 +574,7 @@ static ssize_t in_illuminance_lux_table_store(struct device 
*dev,
__func__, TSL2583_MAX_LUX_INTS);
goto done;
}
-   if ((value[(n - 2)] | value[(n - 1)] | value[n]) != 0) {
+   if ((value[n - 2] | value[n - 1] | value[n]) != 0) {
dev_err(dev, "%s: The last 3 entries in the lux table must be 
zeros.\n",
__func__);
goto done;
@@ -582,7 +582,7 @@ static ssize_t in_illuminance_lux_table_store(struct device 
*dev,
 
/* Zero out the table */
memset(tsl2583_device_lux, 0, sizeof(tsl2583_device_lux));
-   memcpy(tsl2583_device_lux, [1], (value[0] * 4));
+   memcpy(tsl2583_device_lux, [1], value[0] * 4);
 
ret = len;
 
-- 
2.7.4



[PATCH v4 10/26] staging: iio: tsl2583: fix comparison between signed and unsigned integers

2016-11-12 Thread Brian Masney
Fixed warning found by make W=2:

warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index d482a84..be3cbae 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -510,7 +510,7 @@ static ssize_t in_illuminance_lux_table_show(struct device 
*dev,
 struct device_attribute *attr,
 char *buf)
 {
-   int i;
+   unsigned int i;
int offset = 0;
 
for (i = 0; i < ARRAY_SIZE(tsl2583_device_lux); i++) {
@@ -541,7 +541,8 @@ static ssize_t in_illuminance_lux_table_store(struct device 
*dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
int value[ARRAY_SIZE(tsl2583_device_lux) * 3 + 1];
-   int n, ret = -EINVAL;
+   int ret = -EINVAL;
+   unsigned int n;
 
mutex_lock(>als_mutex);
 
@@ -719,7 +720,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_CALIBSCALE:
if (chan->type == IIO_LIGHT) {
-   int i;
+   unsigned int i;
 
for (i = 0; i < ARRAY_SIZE(gainadj); i++) {
if (gainadj[i].mean == val) {
-- 
2.7.4



[PATCH v4 11/26] staging: iio: tsl2583: change newlines to improve readability

2016-11-12 Thread Brian Masney
Add and remove newlines to improve code readability in preparation for
moving the driver out of staging.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index be3cbae..8303753 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -202,7 +202,6 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
ret = i2c_smbus_write_byte(chip->client,
   (TSL2583_CMD_REG | TSL2583_CMD_SPL_FN |
TSL2583_CMD_ALS_INT_CLR));
-
if (ret < 0) {
dev_err(>client->dev, "%s: failed to clear the interrupt 
bit\n",
__func__);
@@ -225,8 +224,10 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
chip->als_cur_info.lux = 0;
goto done;
}
+
/* calculate ratio */
ratio = (ch1 << 15) / ch0;
+
/* convert to unscaled lux using the pointer to the table */
for (p = (struct tsl2583_lux *)tsl2583_device_lux;
 p->ratio != 0 && p->ratio < ratio; p++)
@@ -273,6 +274,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
lux64 >>= 13;
lux = lux64;
lux = (lux + 500) / 1000;
+
if (lux > TSL2583_LUX_CALC_OVER_FLOW) { /* check for overflow */
 return_max:
lux = TSL2583_LUX_CALC_OVER_FLOW;
@@ -319,21 +321,23 @@ static int tsl2583_als_calibrate(struct iio_dev 
*indio_dev)
__func__);
return -ENODATA;
}
+
lux_val = tsl2583_get_lux(indio_dev);
if (lux_val < 0) {
dev_err(>client->dev, "%s: failed to get lux\n",
__func__);
return lux_val;
}
+
gain_trim_val = (unsigned int)(((chip->als_settings.als_cal_target)
* chip->als_settings.als_gain_trim) / lux_val);
-
if ((gain_trim_val < 250) || (gain_trim_val > 4000)) {
dev_err(>client->dev,
"%s: trim_val of %d is not within the range [250, 
4000]\n",
__func__, gain_trim_val);
return -ENODATA;
}
+
chip->als_settings.als_gain_trim = (int)gain_trim_val;
 
return (int)gain_trim_val;
@@ -529,6 +533,7 @@ static ssize_t in_illuminance_lux_table_show(struct device 
*dev,
}
 
offset += sprintf(buf + offset, "\n");
+
return offset;
 }
 
@@ -776,6 +781,7 @@ static int tsl2583_probe(struct i2c_client *clientp,
indio_dev = devm_iio_device_alloc(>dev, sizeof(*chip));
if (!indio_dev)
return -ENOMEM;
+
chip = iio_priv(indio_dev);
chip->client = clientp;
i2c_set_clientdata(clientp, indio_dev);
@@ -803,6 +809,7 @@ static int tsl2583_probe(struct i2c_client *clientp,
indio_dev->dev.parent = >dev;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->name = chip->client->name;
+
ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
if (ret) {
dev_err(>dev, "%s: iio registration failed\n",
@@ -819,6 +826,7 @@ static int tsl2583_probe(struct i2c_client *clientp,
return ret;
 
dev_info(>dev, "Light sensor found.\n");
+
return 0;
 }
 
@@ -834,6 +842,7 @@ static int __maybe_unused tsl2583_suspend(struct device 
*dev)
chip->suspended = true;
 
mutex_unlock(>als_mutex);
+
return ret;
 }
 
@@ -848,6 +857,7 @@ static int __maybe_unused tsl2583_resume(struct device *dev)
ret = tsl2583_chip_init_and_power_on(indio_dev);
 
mutex_unlock(>als_mutex);
+
return ret;
 }
 
-- 
2.7.4



[PATCH v4 12/26] staging: iio: tsl2583: combine sysfs documentation

2016-11-12 Thread Brian Masney
There are two separate files describing the tsl2583 sysfs attributes.
Combine the two files into one. Updated the name of the sysfs attributes
to match the current ABI.

Signed-off-by: Brian Masney 
Suggested-by: Peter Meerwald-Stadler 
---
 .../Documentation/light/sysfs-bus-iio-light-tsl2583  | 16 +++-
 .../iio/Documentation/sysfs-bus-iio-light-tsl2583| 20 
 2 files changed, 15 insertions(+), 21 deletions(-)
 delete mode 100644 
drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583

diff --git 
a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 
b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
index 470f7ad..a2e1996 100644
--- a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
+++ b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
@@ -1,6 +1,20 @@
-What:  /sys/bus/iio/devices/device[n]/in_illuminance0_calibrate
+What:  /sys/bus/iio/devices/device[n]/in_illuminance_calibrate
 KernelVersion: 2.6.37
 Contact:   linux-...@vger.kernel.org
 Description:
This property causes an internal calibration of the als gain 
trim
value which is later used in calculating illuminance in lux.
+
+What:  /sys/bus/iio/devices/device[n]/in_illuminance_lux_table
+KernelVersion: 2.6.37
+Contact:   linux-...@vger.kernel.org
+Description:
+   This property gets/sets the table of coefficients
+   used in calculating illuminance in lux.
+
+What:  /sys/bus/iio/devices/device[n]/in_illuminance_input_target
+KernelVersion: 2.6.37
+Contact:   linux-...@vger.kernel.org
+Description:
+   This property is the known externally illuminance (in lux).
+   It is used in the process of calibrating the device accuracy.
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 
b/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583
deleted file mode 100644
index 660781d..000
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583
+++ /dev/null
@@ -1,20 +0,0 @@
-What:  /sys/bus/iio/devices/device[n]/lux_table
-KernelVersion: 2.6.37
-Contact:   linux-...@vger.kernel.org
-Description:
-   This property gets/sets the table of coefficients
-   used in calculating illuminance in lux.
-
-What:  /sys/bus/iio/devices/device[n]/illuminance0_calibrate
-KernelVersion: 2.6.37
-Contact:   linux-...@vger.kernel.org
-Description:
-   This property causes an internal calibration of the als gain 
trim
-   value which is later used in calculating illuminance in lux.
-
-What:  /sys/bus/iio/devices/device[n]/illuminance0_input_target
-KernelVersion: 2.6.37
-Contact:   linux-...@vger.kernel.org
-Description:
-   This property is the known externally illuminance (in lux).
-   It is used in the process of calibrating the device accuracy.
-- 
2.7.4



[PATCH v4 04/26] staging: iio: tsl2583: change current chip state from a tristate to a bool

2016-11-12 Thread Brian Masney
The current chip state is represented as a tristate (working, suspended,
and unknown). The unknown state was not used. This patch changes the
chip state so that it is now represented as a single boolean value
(suspended).

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 40aa78e..5a32102 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -67,12 +67,6 @@
 #define TSL2583_CHIP_ID0x90
 #define TSL2583_CHIP_ID_MASK   0xf0
 
-enum {
-   TSL258X_CHIP_UNKNOWN = 0,
-   TSL258X_CHIP_WORKING = 1,
-   TSL258X_CHIP_SUSPENDED = 2
-};
-
 /* Per-device data */
 struct taos_als_info {
u16 als_ch0;
@@ -94,7 +88,7 @@ struct tsl2583_chip {
struct taos_settings taos_settings;
int als_time_scale;
int als_saturation;
-   int taos_chip_status;
+   bool suspended;
 };
 
 struct taos_lux {
@@ -441,7 +435,7 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev 
*indio_dev)
if (ret < 0)
return ret;
 
-   chip->taos_chip_status = TSL258X_CHIP_WORKING;
+   chip->suspended = false;
 
return ret;
 }
@@ -494,7 +488,7 @@ static ssize_t in_illuminance_calibrate_store(struct device 
*dev,
 
mutex_lock(>als_mutex);
 
-   if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+   if (chip->suspended) {
ret = -EBUSY;
goto done;
}
@@ -627,7 +621,7 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev,
 
mutex_lock(>als_mutex);
 
-   if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+   if (chip->suspended) {
ret = -EBUSY;
goto read_done;
}
@@ -704,7 +698,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
 
mutex_lock(>als_mutex);
 
-   if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+   if (chip->suspended) {
ret = -EBUSY;
goto write_done;
}
@@ -778,7 +772,7 @@ static int taos_probe(struct i2c_client *clientp,
i2c_set_clientdata(clientp, indio_dev);
 
mutex_init(>als_mutex);
-   chip->taos_chip_status = TSL258X_CHIP_UNKNOWN;
+   chip->suspended = true;
 
ret = i2c_smbus_read_byte_data(clientp,
   TSL258X_CMD_REG | TSL258X_CHIPID);
@@ -835,7 +829,7 @@ static int __maybe_unused taos_suspend(struct device *dev)
mutex_lock(>als_mutex);
 
ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
-   chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
+   chip->suspended = true;
 
mutex_unlock(>als_mutex);
return ret;
-- 
2.7.4



[PATCH v4 09/26] staging: iio: tsl2583: fix alignment of #define values

2016-11-12 Thread Brian Masney
Most of the values in the #defines have their values aligned on a single
column, but some do not. This changes the remaining defines to use
consistent alignment with the majority to improve code readability.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 5a82a26..d482a84 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -44,19 +44,19 @@
 /* tsl2583 cmd reg masks */
 #define TSL2583_CMD_REG0x80
 #define TSL2583_CMD_SPL_FN 0x60
-#define TSL2583_CMD_ALS_INT_CLR0X01
+#define TSL2583_CMD_ALS_INT_CLR0x01
 
 /* tsl2583 cntrl reg masks */
-#define TSL2583_CNTL_ADC_ENBL  0x02
+#define TSL2583_CNTL_ADC_ENBL  0x02
 #define TSL2583_CNTL_PWR_OFF   0x00
 #define TSL2583_CNTL_PWR_ON0x01
 
 /* tsl2583 status reg masks */
-#define TSL2583_STA_ADC_VALID  0x01
-#define TSL2583_STA_ADC_INTR   0x10
+#define TSL2583_STA_ADC_VALID  0x01
+#define TSL2583_STA_ADC_INTR   0x10
 
 /* Lux calculation constants */
-#defineTSL2583_LUX_CALC_OVER_FLOW  65535
+#defineTSL2583_LUX_CALC_OVER_FLOW  65535
 
 #define TSL2583_INTERRUPT_DISABLED 0x00
 
-- 
2.7.4



[PATCH v4 03/26] staging: iio: tsl2583: remove unnecessary chip status checks in suspend/resume

2016-11-12 Thread Brian Masney
The device probing and the suspend/resume code checks a flag internal to
the driver that determines whether or not the chip is in a working
state. These checks are not needed. This patch removes the unnecessary
checks. It will do no harm to the hardware if the chip is
reinitialized if it is already powered on.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index a550023..40aa78e 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -412,13 +412,6 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev 
*indio_dev)
struct tsl2583_chip *chip = iio_priv(indio_dev);
int ret;
 
-   /* and make sure we're not already on */
-   if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
-   /* if forcing a register update - turn off, then on */
-   dev_info(>client->dev, "device is already enabled\n");
-   return -EINVAL;
-   }
-
/* Power on the device; ADC off. */
ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_ON);
if (ret < 0)
@@ -841,10 +834,8 @@ static int __maybe_unused taos_suspend(struct device *dev)
 
mutex_lock(>als_mutex);
 
-   if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
-   ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
-   chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
-   }
+   ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
+   chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
 
mutex_unlock(>als_mutex);
return ret;
@@ -858,8 +849,7 @@ static int __maybe_unused taos_resume(struct device *dev)
 
mutex_lock(>als_mutex);
 
-   if (chip->taos_chip_status == TSL258X_CHIP_SUSPENDED)
-   ret = tsl2583_chip_init_and_power_on(indio_dev);
+   ret = tsl2583_chip_init_and_power_on(indio_dev);
 
mutex_unlock(>als_mutex);
return ret;
-- 
2.7.4



[PATCH v4 05/26] staging: iio: tsl2583: remove redundant write to the control register in taos_probe()

2016-11-12 Thread Brian Masney
taos_probe() calls i2c_smbus_write_byte() to select the control
register, however there are no subsequent calls to
i2c_smbus_read_byte(). The write call is unnecessary and is removed by
this patch.

Verified that the driver still functions correctly using a TSL2581
hooked up to a Raspberry Pi 2.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 5a32102..449506b 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -788,14 +788,6 @@ static int taos_probe(struct i2c_client *clientp,
return -EINVAL;
}
 
-   ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL));
-   if (ret < 0) {
-   dev_err(>dev,
-   "i2c_smbus_write_byte() to cmd reg failed in 
taos_probe(), err = %d\n",
-   ret);
-   return ret;
-   }
-
indio_dev->info = _info;
indio_dev->channels = tsl2583_channels;
indio_dev->num_channels = ARRAY_SIZE(tsl2583_channels);
-- 
2.7.4



[PATCH v4 06/26] staging: iio: tsl2583: remove the FSF's mailing address

2016-11-12 Thread Brian Masney
Address warning from checkpatch:

CHECK: Do not include the paragraph about writing to the Free Software
Foundation's mailing address from the sample GPL notice. The FSF has
changed addresses in the past, and may do so again. Linux already
includes a copy of the GPL.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 449506b..57279f7 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -13,10 +13,6 @@
  * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #include 
-- 
2.7.4



[PATCH v4 07/26] staging: iio: tsl2583: cleaned up logging

2016-11-12 Thread Brian Masney
There are several places in the code where the function name is
hardcoded in the log message. Use the __func__ constant string to build
the log message. This also clarifies some of the error messages to match
the code and ensures that the correct priority is used since the message
is already being changed.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2583.c | 73 ++---
 1 file changed, 43 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2583.c 
b/drivers/staging/iio/light/tsl2583.c
index 57279f7..5d74e0c1 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -170,13 +170,15 @@ static int taos_get_lux(struct iio_dev *indio_dev)
 
ret = i2c_smbus_read_byte_data(chip->client, TSL258X_CMD_REG);
if (ret < 0) {
-   dev_err(>client->dev, "taos_get_lux failed to read 
CMD_REG\n");
+   dev_err(>client->dev, "%s: failed to read CMD_REG 
register\n",
+   __func__);
goto done;
}
 
/* is data new & valid */
if (!(ret & TSL258X_STA_ADC_INTR)) {
-   dev_err(>client->dev, "taos_get_lux data not valid\n");
+   dev_err(>client->dev, "%s: data not valid; returning last 
value\n",
+   __func__);
ret = chip->als_cur_info.lux; /* return LAST VALUE */
goto done;
}
@@ -186,9 +188,8 @@ static int taos_get_lux(struct iio_dev *indio_dev)
 
ret = i2c_smbus_read_byte_data(chip->client, reg);
if (ret < 0) {
-   dev_err(>client->dev,
-   "taos_get_lux failed to read register %x\n",
-   reg);
+   dev_err(>client->dev, "%s: failed to read 
register %x\n",
+   __func__, reg);
goto done;
}
buf[i] = ret;
@@ -203,9 +204,8 @@ static int taos_get_lux(struct iio_dev *indio_dev)
TSL258X_CMD_ALS_INT_CLR));
 
if (ret < 0) {
-   dev_err(>client->dev,
-   "taos_i2c_write_command failed in taos_get_lux, err = 
%d\n",
-   ret);
+   dev_err(>client->dev, "%s: failed to clear the interrupt 
bit\n",
+   __func__);
goto done; /* have no data, so return failure */
}
 
@@ -246,7 +246,8 @@ static int taos_get_lux(struct iio_dev *indio_dev)
 
/* note: lux is 31 bit max at this point */
if (ch1lux > ch0lux) {
-   dev_dbg(>client->dev, "No Data - Return last value\n");
+   dev_dbg(>client->dev, "%s: No Data - Returning 0\n",
+   __func__);
ret = 0;
chip->als_cur_info.lux = 0;
goto done;
@@ -301,7 +302,7 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
   TSL258X_CMD_REG | TSL258X_CNTRL);
if (ret < 0) {
dev_err(>client->dev,
-   "%s failed to read from the CNTRL register\n",
+   "%s: failed to read from the CNTRL register\n",
__func__);
return ret;
}
@@ -309,16 +310,19 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
if ((ret & (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON))
!= (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) {
dev_err(>client->dev,
-   "taos_als_calibrate failed: device not powered on with 
ADC enabled\n");
+   "%s: Device is not powered on and/or ADC is not 
enabled\n",
+   __func__);
return -EINVAL;
} else if ((ret & TSL258X_STA_ADC_VALID) != TSL258X_STA_ADC_VALID) {
dev_err(>client->dev,
-   "taos_als_calibrate failed: STATUS - ADC not valid.\n");
+   "%s: The two ADC channels have not completed an 
integration cycle\n",
+   __func__);
return -ENODATA;
}
lux_val = taos_get_lux(indio_dev);
if (lux_val < 0) {
-   dev_err(>client->dev, "taos_als_calibrate failed to get 
lux\n");
+   dev_err(>client->dev, "%s: failed to get lux\n",
+   __func__);
return lux_val;
}
gain_trim_val = (unsigned int)(((chip->taos_settings.als_cal_target)
@@ -326,8 +330,8 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
 
if ((gain_trim_val < 250) || (gain_trim_val > 4000)) {
dev_err(>client->dev,
-   "taos_als_calibrate failed: trim_val of %d is out of 
range\n",
-   gain_trim_val);
+   "%s: trim_val of %d is not within the range [250, 

[PATCH v4 00/26] staging: iio: tsl2583: move out of staging

2016-11-12 Thread Brian Masney
This patch set continues my work to clean up the tsl2583 driver to move
it out of staging. Some highlights include:

- Eliminated some unnecessary i2c calls to the sensor.
- Fixed issue with changes to calibscale and int_time not being set on
  the chip.
- Moved from a global lux table to a per device lux table.
- Combined redundant sysfs ABI documentation.
- Made log messages clearer.
- Fixes for some return values that were not checked.
- Chip state is now represented as a boolean instead of a tristate.
- Removed unnecessary chip status checks.
- Use a unified prefix for all symbols (tsl2583_).
- Code style and formatting cleanups.
- Comment cleanups.
- Staging graduation.

I verified that the driver functions correctly using a TSL2581 hooked
up to a Raspberry Pi 2.

Changes from V3 to V4
- Fixed patch 03/28 so that it compiles properly. It was fixed later
  in the old series but this needs to be corrected so that people can
  use git bisect. I verified that every patch in this series compiles
  when incrementally applied.
- Clarified comment on patch 14 in this series.
- Use sizeof(value[1]) instead of sizeof(unsigned int) when updating
  the lux table on patch 18 of this series.

Changes from V2 to V3
- Fixed patch #09 to use "%s: ", __func__ consistently. Added
  missing terminating "\n" to one of the log messages. Issues reported
  by Joe Perches.
- Fixed issues found by Jonathan Cameron: comment cleanups, improved the
  wording of two log messages, removed an unnecessary memset call,
  removed unnecessary variable initialization, and multiple driver
  authors can be specified with multiple calls to MODULE_AUTHOR().
- Fixed warning found by make C=1 in the per device lux table:
  warning: Variable length array is used.

Changes from V1 to V2
- The first 7 patches in this series contains version 2 of the patches
  7-9 that I sent out on 2016-11-03. The only change is that the patches
  are split up further to make the code review easier.

Brian Masney (26):
  staging: iio: tsl2583: check if chip is in a working state in
in_illuminance_calibrate_store
  staging: iio: tsl2583: remove unnecessary chip status check in
taos_get_lux
  staging: iio: tsl2583: remove unnecessary chip status checks in
suspend/resume
  staging: iio: tsl2583: change current chip state from a tristate to a
bool
  staging: iio: tsl2583: remove redundant write to the control register
in taos_probe()
  staging: iio: tsl2583: remove the FSF's mailing address
  staging: iio: tsl2583: cleaned up logging
  staging: iio: tsl2583: unify function and variable prefix to tsl2583_
  staging: iio: tsl2583: fix alignment of #define values
  staging: iio: tsl2583: fix comparison between signed and unsigned
integers
  staging: iio: tsl2583: change newlines to improve readability
  staging: iio: tsl2583: combine sysfs documentation
  staging: iio: tsl2583: fix multiline comment syntax
  staging: iio: tsl2583: updated code comment to match what the code
does
  staging: iio: tsl2583: moved code block inside else statement
  staging: iio: tsl2583: change tsl2583_als_calibrate() to return 0 on
success
  staging: iio: tsl2583: remove unnecessary parentheses
  staging: iio: tsl2583: don't assume an unsigned int is 32 bits
  staging: iio: tsl2583: move from a global to a per device lux table
  staging: iio: tsl2583: add tsl2583 to list of supported devices in the
header
  staging: iio: tsl2583: clarified comment about clearing interrupts
  staging: iio: tsl2583: remove comment for tsl2583_probe()
  staging: iio: tsl2583: remove unnecessary memset call
  staging: iio: tsl2583: remove unnecessary variable initialization
  staging: iio: tsl2583: add copyright and MODULE_AUTHOR
  staging: iio: tsl2583: move out of staging

 .../ABI/testing/sysfs-bus-iio-light-tsl2583|  20 +
 drivers/iio/light/Kconfig  |   7 +
 drivers/iio/light/Makefile |   1 +
 drivers/iio/light/tsl2583.c| 913 +
 .../light/sysfs-bus-iio-light-tsl2583  |   6 -
 .../iio/Documentation/sysfs-bus-iio-light-tsl2583  |  20 -
 drivers/staging/iio/light/Kconfig  |   7 -
 drivers/staging/iio/light/Makefile |   1 -
 drivers/staging/iio/light/tsl2583.c| 896 
 9 files changed, 941 insertions(+), 930 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-light-tsl2583
 create mode 100644 drivers/iio/light/tsl2583.c
 delete mode 100644 
drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
 delete mode 100644 
drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583
 delete mode 100644 drivers/staging/iio/light/tsl2583.c

-- 
2.7.4



[PATCH] [STYLE 1/2]staging:speakup:varhandlers.c Moddified block comment

2016-11-12 Thread Walt Feasel
Modified block comment to multiline style

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/varhandlers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/varhandlers.c 
b/drivers/staging/speakup/varhandlers.c
index 21186e3..5ab7245 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -266,7 +266,8 @@ int spk_set_string_var(const char *page, struct 
st_var_header *var, int len)
return 0;
 }
 
-/* spk_set_mask_bits sets or clears the punc/delim/repeat bits,
+/*
+ * spk_set_mask_bits sets or clears the punc/delim/repeat bits,
  * if input is null uses the defaults.
  * values for how: 0 clears bits of chars supplied,
  * 1 clears allk, 2 sets bits for chars
-- 
2.1.4



[PATCH] isci: fix typo in deg_dbg message

2016-11-12 Thread Colin King
From: Colin Ian King 

Trivial fix to typo "repsonse" to "response" in dev_dbg message.

Signed-off-by: Colin Ian King 
---
 drivers/scsi/isci/request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index b709d2b..47f66e9 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -2473,7 +2473,7 @@ static void isci_request_process_response_iu(
"%s: resp_iu = %p "
"resp_iu->status = 0x%x,\nresp_iu->datapres = %d "
"resp_iu->response_data_len = %x, "
-   "resp_iu->sense_data_len = %x\nrepsonse data: ",
+   "resp_iu->sense_data_len = %x\nresponse data: ",
__func__,
resp_iu,
resp_iu->status,
-- 
2.10.2



[PATCH] [STYLE]staging:MAINTAINERS email revision speakup

2016-11-12 Thread Walt Feasel
Modified email address per the TODO file in
speakup's email listing, also verified email
address from speakup's website

Signed-off-by: Walt Feasel 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index ec1ee3e..40d272c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11540,7 +11540,7 @@ F:  drivers/staging/slicoss/
 STAGING - SPEAKUP CONSOLE SPEECH DRIVER
 M: William Hubbs 
 M: Chris Brannon 
-M: Kirk Reiser 
+M: Kirk Reiser 
 M: Samuel Thibault 
 L: spea...@linux-speakup.org
 W: http://www.linux-speakup.org/
-- 
2.1.4



Re: Source address fib invalidation on IPv6

2016-11-12 Thread Jason A. Donenfeld
Hi David,

On Sat, Nov 12, 2016 at 7:14 PM, David Ahern  wrote:
> I believe that is coming from __ip_route_output_key_hash(), line 2232 with 
> __ip_dev_find not finding a device with that address.

It's possible we simply are looking at different source trees, but I
have the -EINVAL return in 4.8 route.c sources happening due to the
assignment on line 2175 and the jump on line 2220.

> Not applicable for your use case, but __ip_dev_find does not have any checks 
> on which L3 domain the device belongs to so the check does not handle VRF for 
> example. I'll take a look at fixing this next week.

Interesting.

>
> Gotcha. I don't see any checks that the saddr is valid similar to what IPv4 
> does.
>
> I think the right place to add a check is in ip6_dst_lookup_tail():
> if (!ipv6_addr_any(>saddr)) {
> // saddr is valid for L3 domain
> }

Right. It should probably do the check here, and return
ERR_PTR(-EINVAL), the same as the v4 version, so that ret codes can be
checked consistently.

Thanks for looking into this. If you're backed up and would like me to
submit a patch, just let me know, and I'll give it my best shot.

Regards,
Jason


Re: [PATCH v2 1/2] arm64: dts: Add level for cpu dt node for exynos7

2016-11-12 Thread Krzysztof Kozlowski
On Sat, Nov 12, 2016 at 6:00 PM, Alim Akhtar  wrote:
> Hi Javier,
>
> On Sat, Nov 12, 2016 at 7:54 PM, Javier Martinez Canillas
>  wrote:
>> Hello Alim,
>>
>> On 11/12/2016 07:17 AM, Alim Akhtar wrote:
>>> This patch adds level for cpu dt node, so that these levels can be used
>>
>> Do you mean s/level/label here? I'm asking because you are using level
>> consistently in the subject line and commit message but I'm not sure
>> what it means in this context.
>>
>
> Ah!! my bad. Its __label__. If required, will respin.
> Thanks for review.

I think there is no need of respin because this should be squashed
with previous patch. This is quite small and there are no functional
changes here (labels are transparent, except of course conflict
cases). Without the 2/2,  this patch does not have much sense yet.

Best regards,
Krzysztof


Re: [PATCH] [STYLE]staging:MAINTAINERS email revision speakup

2016-11-12 Thread Chris Brannon
Walt Feasel  writes:

> Modified email address per the TODO file in
> speakup's email listing, also verified email
> address from speakup's website

NAK.  The website needs updating, because it has Kirk's old addresses.
k...@reisers.ca is correct.


[PATCH] Input: psmouse - disable automatic probing of BYD touchpads

2016-11-12 Thread Dmitry Torokhov
BYD automatic protocol detection is extremely unreliable and is often
triggers false positives on regular mice, Sentelic touchpads, and other
devices. BYD has several documents that have recommended detection
sequence, but they conflict with each other and, as far as I can see, still
would not produce unique enough output to reliably differentiate BYD from
other PS/2 devices.

OEMs sourcing BYD devices also do not do us any favors by not supplying any
reasonable DMI data and instead leaving turds like "To Be Filled By O.E.M."
in place of vendor data, or "System Serial Number" as serial number.

On top of that BYD is not truly modern multitouch controller, but rather a
single-touch transitional device that only reports absolute coordinates at
the beginning of finger contact and then reverts to reporting
displacements, and thus not very precise; the only benefit from using BYD
mode vs the legacy PS/2 mode is possibility of edge scrolling.

Given the above, and the fact that BYD devices are somewhat uncommon, let's
disable automatic detection of BYD devices. Users who know they have BYD
trackpads or want to experiment can attempt to activate BYD protocol via
sysfs:

echo -n "byd" > /sys/bus/serio/devices/serio1/drvctl

Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=151691
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=175421
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=120781
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=121281
Cc: sta...@vger.kernel.org
Signed-off-by: Dmitry Torokhov 
---
 drivers/input/mouse/psmouse-base.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c 
b/drivers/input/mouse/psmouse-base.c
index fb4b185..bee2674 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1115,10 +1115,6 @@ static int psmouse_extensions(struct psmouse *psmouse,
if (psmouse_try_protocol(psmouse, PSMOUSE_TOUCHKIT_PS2,
 _proto, set_properties, true))
return PSMOUSE_TOUCHKIT_PS2;
-
-   if (psmouse_try_protocol(psmouse, PSMOUSE_BYD,
-_proto, set_properties, true))
-   return PSMOUSE_BYD;
}
 
/*
-- 
2.8.0.rc3.226.g39d4020


-- 
Dmitry


Re: PM regression with LED changes in next-20161109

2016-11-12 Thread Jacek Anaszewski

Hi,

On 11/12/2016 11:33 AM, Hans de Goede wrote:

Hi,

On 12-11-16 11:24, Jacek Anaszewski wrote:

Hi,

On 11/11/2016 08:28 PM, Hans de Goede wrote:

Hi,

On 11-11-16 18:03, Jacek Anaszewski wrote:

On 11/11/2016 01:01 PM, Pavel Machek wrote:

On Thu 2016-11-10 22:34:07, Jacek Anaszewski wrote:

Hi,

On 11/10/2016 09:29 PM, Pavel Machek wrote:

On Thu 2016-11-10 10:55:37, Tony Lindgren wrote:

* Pavel Machek  [161110 09:29]:

Hi!


Looks like commit 883d32ce3385 ("leds: core: Add support for
poll()ing
the sysfs brightness attr for changes.") breaks runtime PM
for me.

On my omap dm3730 based test system, idle power consumption
is over 70
times higher now with this patch! It goes from about 6mW for
the core
system to over 440mW during idle meaning there's some busy
timer now
active.

Reverting this patch fixes the issue. Any ideas?


Are you using any LED that toggles with high frequency? Like
perhaps
LED that is lit when CPU is active?


Yeah one of them seems to have cpu0 as the default trigger.


Aha. Its quite obvious we don't want to notify sysfs each time that
one is toggled, right?

IMO brightness should display max brightness for the trigger, as
Hans
suggested, anything else is madness for trigger such as cpu
activity.


Are you suggesting that we should revert changes introduced
by below patch?

commit 29d76dfa29fe22583aefddccda0bc56aa81035dc
Author: Henrique de Moraes Holschuh 
Date:   Tue Mar 18 09:47:48 2008 +

leds: Add support to leds with readable status

Some led hardware allows drivers to query the led state, and
this patch
adds a hook to let the led class take advantage of that
information when
available.

Without this functionality, when access to the led hardware is
not
exclusive (i.e. firmware or hardware might change its state
behind the
kernel's back), reality goes out of sync with the led class'
idea of
what
the led is doing, which is annoying at best.


Hmm. So userland can read the LED state, and it can get _some_ value
back, but it can not know if it is current state or not.

I don't think that's a good interface. I see it is from 2008... is
someone using it? Maybe it is too late for revert.


I can imagine it being used in flash LED use case. E.g. one
could use oneshot trigger to trigger flash strobe, and then
he could periodically read brightness file to check, for whatever
reason, whether the flash is strobing.


But I'd certainly not extend it with poll.


We could add a dedicated file e.g. hw_brightness_change for that
(maybe someone will have a better candidate for the file name).


Why a dedicated file? Are we going to mirror brightness here
wrt r/w (show/store) behavior ? If not userspace now needs
2 open fds which is not really nice. If we are and we are
not going to use poll for something else on brightness itself
then why not just poll directly on brightness ?


My main concern is that reporting only hw brightness changes
wouldn't be consistent with general brightness file purpose.
One could expect that brightness changes made by triggers
should be also reported.


Ok, I agree that not notifying poll() while an actual
read() would result in a different value is not really good
semantics.

I don't like to call it hw_brightness_change though, as
mentioned before I believe that if we were to start with
a clean slate we would make the brightness file's read/write
behavior more a mirror of itself.

So I would like to propose creating a new read-write
user_brightness file.

The write behavior would be 100% identical to the brightness
file (in code terms it will call the same store function).

The the read behavior otoh will be different: it will shows
the last brightness as set by the user, this would show the
read behavior we really want of brightness: show the real
brightness when not blinking / triggers are active and show
the brightness used when on when blinking / triggers are active.

We could then add poll support on this new user_brightness
file, thus avoiding the problem with the extra cpu-load on
notifications on blinking / triggers.


I agree that user_brightness allows to solve the issues you raised
about inconsistent write and read brightness' semantics
(which is not that painful IMHO).

Reporting non-user brightness changes on user_brightness file
doesn't sound reasonable though. Also, how would we read the
brightness set by the firmware? We'd have to read brightness
file, so still two files would have to be opened which is
a second drawback of this approach.

Having no difference in this area between the two approaches
I'm still in favour of the read-only file for notifying
brightness changes procured by hardware.


I'd make it only readable, so it wouldn't mirror brightness
file behavior.


Then userspace which wants to be able to read + write + poll
the brightness again needs to open 2 fds, as suggested
above for the new user_brightness file it will be easy
to just make it mimic the brightness file write behavior
and 

Re: [srcu] Can we suppress sparse warning?

2016-11-12 Thread Paul E. McKenney
On Sat, Nov 12, 2016 at 11:26:15PM +0900, Tetsuo Handa wrote:
> Paul E. McKenney wrote:
> > Notwithstanding my confusion about what your self-referential
> > srcu_dereference() is intended to achieve, what happens if you change the
> > "void *ptr = srcu_dereference(ptr, );" to add __rcu?
> 
> Sorry, I wrote this code for only showing warning message.
> This self-referential has no intention.
> 
> Well, you can reproduce this warning with current linux.git by running
> make C=1 security/tomoyo/ with CONFIG_SECURITY_TOMOYO=y .
> 
> security/tomoyo/common.c:896:9: error: incompatible types in comparison 
> expression (different address spaces)
> security/tomoyo/common.c:896:9: error: incompatible types in comparison 
> expression (different address spaces)
> 
> -- security/tomoyo/common.c --
> 896:list_for_each_cookie(head->r.acl, _kernel_namespace.
> 897: policy_list[TOMOYO_ID_MANAGER]) {
> 
> -- security/tomoyo/common.h --
> 1320: /**
> 1321:  * list_for_each_cookie - iterate over a list with cookie.
> 1322:  * @pos:the  list_head to use as a loop cursor.
> 1323:  * @head:   the head for your list.
> 1324:  */
> 1325: #define list_for_each_cookie(pos, head) 
> \
> 1326: if (!pos)   
> \
> 1327: pos =  srcu_dereference((head)->next, _ss);  
> \
> 1328: for ( ; pos != (head); pos = srcu_dereference(pos->next, 
> _ss))

This definition will be fun if used in an "if" statement, but I will leave
that in your capable hands.

> 
> Both head->r.acl and 
> _kernel_namespace.policy_list[TOMOYO_ID_MANAGER]->next
> refer normal kernel address space. Thus, I think that this warning is a false 
> positive.
> 
> This warning goes away if I disable rcu_dereference_sparse() call in
> __rcu_dereference_check() from srcu_dereference_check() from 
> srcu_dereference().
> 
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -605,7 +605,7 @@ static inline void rcu_preempt_sleep_check(void)
> /* Dependency order vs. p above. */ \
> typeof(*p) *p1 = (typeof(*p) 
> *__force)lockless_dereference(p); \
> RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
> -   rcu_dereference_sparse(p, space); \
> +   /*rcu_dereference_sparse(p, space); */  \
> ((typeof(*p) __force __kernel *)(p1)); \
>  })
>  #define __rcu_dereference_protected(p, c, space) \

OK.

One approach would be for you to replace your:

pos =  srcu_dereference((head)->next, _ss);

with:

pos =  ecu_dereference_raw((head)->next);

This will suppress the sparse complaint, but would also suppress the
lockdep complaint about using list_for_each_cookie() unprotected by an
SRCU read-side critical section.  But this can be handled by placing an
appropriate RCU_LOCKDEP_WARN() in list_for_each_cookie().

Does that work for you?

Thanx, Paul



Re: [PATCH v7 4/9] drivers:input:tsc2007: add iio interface to read external ADC input and temperature

2016-11-12 Thread H. Nikolaus Schaller
> Am 12.11.2016 um 15:19 schrieb Jonathan Cameron :
> 
> On 12/11/16 14:04, Jonathan Cameron wrote:
>> On 11/11/16 19:02, H. Nikolaus Schaller wrote:
>>> The tsc2007 chip not only has a resistive touch screen controller but
>>> also an external AUX adc imput which can be used for an ambient
>>> light sensor, battery voltage monitoring or any general purpose.
>>> 
>>> Additionally it can measure the chip temperature.
>>> 
>>> This extension provides an iio interface for these adc channels.
>>> 
>>> Since it is not wasting much resources and is very straightforward,
>>> we simply provide all other adc channels as optional iio interfaces
>>> as weel. This can be used for debugging or special applications.
>>> 
>>> This patch also splits the tsc2007 driver in several source files:
>>> tsc2007.h -- constants, structs and stubs
>>> tsc2007_core.c -- functional parts of the original driver
>>> tsc2007_iio.c -- the optional iio stuff
>>> 
>>> Makefile magic allows to conditionally link the iio
>>> stuff if CONFIG_IIO=y in a way that it works with
>>> CONFIG_TOUCHSCREEN_TSC2007=m.
>>> 
>> 
>> I ran a quick build test and it blows up in a number of ways related to
>> the #ifdef CONFIG_IIO.
>> 
>> I'm not entirely sure why but
>> #if IS_ENABLED(CONFIG_IIO) works fine.
> Ah, I'm being sleepy today.  It's because I'm building IIO as a module
> and the symbol defined would therefore be CONFIG_IIO_MODULE.
> 
> The IS_ENABLED macro takes care of both cases.

Ah, yes. I wasn't aware that CONFIG_IIO is tristate at all.
We have it as "y" and therefore didn't notice.

I will collect this fix for V8.

>> 
>> Otherwise looks good to me
>>> Signed-off-by: H. Nikolaus Schaller 
>> Reviewed-by: Jonathan Cameron 

Will add this as well.

Thanks for the detailled review!

BR,
Nikolaus




[PATCH] [STYLE]staging:speakup:TODO Modify current email

2016-11-12 Thread Walt Feasel
Modified email address to reflect current address

Signed-off-by: Walt Feasel 
---
 drivers/staging/speakup/TODO | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/TODO b/drivers/staging/speakup/TODO
index 3094799..993410c 100644
--- a/drivers/staging/speakup/TODO
+++ b/drivers/staging/speakup/TODO
@@ -42,6 +42,6 @@ We prefer that you contact us on the mailing list; however, 
if you do
 not want to subscribe to a mailing list, send your email to all of the
 following:
 
-w.d.hu...@gmail.com, ch...@the-brannons.com, k...@braille.uwo.ca and
+w.d.hu...@gmail.com, ch...@the-brannons.com, k...@reisers.ca and
 samuel.thiba...@ens-lyon.org.
 
-- 
2.1.4



Re: [PATCH RFC] mm: Add debug_virt_to_phys()

2016-11-12 Thread Florian Fainelli
Le 11/11/2016 à 21:43, Will Deacon a écrit :
> On Fri, Nov 11, 2016 at 04:44:43PM -0800, Florian Fainelli wrote:
>> When CONFIG_DEBUG_VM is turned on, virt_to_phys() maps to
>> debug_virt_to_phys() which helps catch vmalloc space addresses being
>> passed. This is helpful in debugging bogus drivers that just assume
>> linear mappings all over the place.
>>
>> For ARM, ARM64, Unicore32 and Microblaze, the architectures define
>> __virt_to_phys() as being the functional implementation of the address
>> translation, so we special case the debug stub to call into
>> __virt_to_phys directly.
>>
>> Signed-off-by: Florian Fainelli 
>> ---
>>  arch/arm/include/asm/memory.h  |  4 
>>  arch/arm64/include/asm/memory.h|  4 
>>  include/asm-generic/memory_model.h |  4 
>>  mm/debug.c | 15 +++
>>  4 files changed, 27 insertions(+)
> 
> What's the interaction between this and the DEBUG_VIRTUAL patches from Laura?
> 
> http://lkml.kernel.org/r/20161102210054.16621-7-labb...@redhat.com
> 
> They seem to be tackling the exact same problem afaict.

Indeed thanks for pointing that out, I guess I could piggy back on this
patchset and try to cover ARM.

Thanks!
-- 
Florian


[PATCH] Revert "[STYLE]staging:MAINTAINERS email revision speakup"

2016-11-12 Thread Walt Feasel
This reverts commit 0970517be9d3d3e3a2fd5aa5a9938318b375f2d0.
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 40d272c..ec1ee3e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11540,7 +11540,7 @@ F:  drivers/staging/slicoss/
 STAGING - SPEAKUP CONSOLE SPEECH DRIVER
 M: William Hubbs 
 M: Chris Brannon 
-M: Kirk Reiser 
+M: Kirk Reiser 
 M: Samuel Thibault 
 L: spea...@linux-speakup.org
 W: http://www.linux-speakup.org/
-- 
2.1.4



Re: [PATCH] Input: psmouse - disable automatic probing of BYD touchpads

2016-11-12 Thread Pali Rohár
On Saturday 12 November 2016 20:15:45 Dmitry Torokhov wrote:
> BYD automatic protocol detection is extremely unreliable and is often
> triggers false positives on regular mice, Sentelic touchpads, and
> other devices. BYD has several documents that have recommended
> detection sequence, but they conflict with each other and, as far as
> I can see, still would not produce unique enough output to reliably
> differentiate BYD from other PS/2 devices.
> 
> OEMs sourcing BYD devices also do not do us any favors by not
> supplying any reasonable DMI data and instead leaving turds like "To
> Be Filled By O.E.M." in place of vendor data, or "System Serial
> Number" as serial number.
...
>   echo -n "byd" > /sys/bus/serio/devices/serio1/drvctl

I agree, if we cannot detect BYD devices correctly without breaking 
other non-BYD devices then detection must be done by user...

So you can add my Reviewed-by: Pali Rohár to this patch.

Anyway, BYD show Linux as supported OS for their devices. It is really 
rude from BYD that they show Linux as supported OS, but Linux driver is 
reverse-engineered by community and they do not want to cooperate and at 
least provide some useful documentation for detection...

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


[PATCH] [STYLE]staging:skein:threefish_block.c remove blank lines

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: Please don't use multiple blank lines

Signed-off-by: Walt Feasel 
---
 drivers/staging/skein/threefish_block.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/staging/skein/threefish_block.c 
b/drivers/staging/skein/threefish_block.c
index a95563f..5064065 100644
--- a/drivers/staging/skein/threefish_block.c
+++ b/drivers/staging/skein/threefish_block.c
@@ -64,7 +64,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, u64 
*input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k3 + t2;
b0 += b1 + k2;
b1 = rol64(b1, 14) ^ b0;
@@ -117,7 +116,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k0 + t1;
b0 += b1 + k4;
b1 = rol64(b1, 14) ^ b0;
@@ -170,7 +168,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k2 + t0;
b0 += b1 + k1;
b1 = rol64(b1, 14) ^ b0;
@@ -223,7 +220,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k4 + t2;
b0 += b1 + k3;
b1 = rol64(b1, 14) ^ b0;
@@ -276,7 +272,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k1 + t1;
b0 += b1 + k0;
b1 = rol64(b1, 14) ^ b0;
@@ -329,7 +324,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k3 + t0;
b0 += b1 + k2;
b1 = rol64(b1, 14) ^ b0;
@@ -382,7 +376,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k0 + t2;
b0 += b1 + k4;
b1 = rol64(b1, 14) ^ b0;
@@ -435,7 +428,6 @@ void threefish_encrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 += b1;
b1 = rol64(b1, 32) ^ b2;
 
-
b1 += k2 + t1;
b0 += b1 + k1;
b1 = rol64(b1, 14) ^ b0;
@@ -579,7 +571,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k3 + t2;
b3 -= k4 + 16;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
@@ -648,7 +639,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k1 + t0;
b3 -= k2 + 14;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
@@ -717,7 +707,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k4 + t1;
b3 -= k0 + 12;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
@@ -786,7 +775,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k2 + t2;
b3 -= k3 + 10;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
@@ -855,7 +843,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k0 + t0;
b3 -= k1 + 8;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
@@ -924,7 +911,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k3 + t1;
b3 -= k4 + 6;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
@@ -993,7 +979,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k1 + t2;
b3 -= k2 + 4;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
@@ -1062,7 +1047,6 @@ void threefish_decrypt_256(struct threefish_key *key_ctx, 
u64 *input,
b2 -= b3 + k4 + t0;
b3 -= k0 + 2;
 
-
tmp = b3 ^ b0;
b3 = ror64(tmp, 32);
b0 -= b3;
-- 
2.1.4



kvm: use-after-free/GPF in kvm_irq_delivery_to_apic_fast

2016-11-12 Thread Dmitry Vyukov
Hello,

The following program triggers use-after-free in kvm_irq_delivery_to_apic_fast:
https://gist.githubusercontent.com/dvyukov/68a25fb4f8f48807fb7cdf3ebbb84e58/raw/b7b85810a1070c93387ece6d2388da8dbe937452/gistfile1.txt

On commit 015ed9433be2b476ec7e2e6a9a411a56e3b5b035 (Nov 11).

==
BUG: KASAN: use-after-free in
kvm_irq_delivery_to_apic_fast+0x11fa/0x1210 at addr 88003da49610
Read of size 8 by task a.out/2749
CPU: 1 PID: 2749 Comm: a.out Not tainted 4.9.0-rc4+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 88003be37740 81c2e46b 88003e816d40 88003da495f8
 88003da49788  88003be37768 8165ab9c
 ed0007b492c2 ed0007b492c2 88003e816d40 88003be377e8
Call Trace:
 [< inline >] __dump_stack lib/dump_stack.c:15
 [] dump_stack+0xb3/0x118 lib/dump_stack.c:51
 [] kasan_object_err+0x1c/0x70 mm/kasan/report.c:156
 [< inline >] print_address_description mm/kasan/report.c:194
 [< inline >] kasan_report_error mm/kasan/report.c:283
 [] kasan_report+0x231/0x500 mm/kasan/report.c:303
 [] __asan_report_load8_noabort+0x14/0x20
mm/kasan/report.c:329
 [] kvm_irq_delivery_to_apic_fast+0x11fa/0x1210
arch/x86/kvm/lapic.c:824
 [] kvm_irq_delivery_to_apic+0x132/0x9a0
arch/x86/kvm/irq_comm.c:72
 [] kvm_set_msi+0x111/0x160 arch/x86/kvm/irq_comm.c:157
 [] kvm_send_userspace_msi+0x201/0x280
arch/x86/kvm/../../../virt/kvm/irqchip.c:74
 [] kvm_vm_ioctl+0xba5/0x1670
arch/x86/kvm/../../../virt/kvm/kvm_main.c:3015
 [< inline >] vfs_ioctl fs/ioctl.c:43
 [] do_vfs_ioctl+0x18c/0x1040 fs/ioctl.c:679
 [< inline >] SYSC_ioctl fs/ioctl.c:694
 [] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:685
 [] entry_SYSCALL_64_fastpath+0x1f/0xc2
arch/x86/entry/entry_64.S:209
Object at 88003da495f8, in cache anon_vma_chain size: 80
Allocated:
PID = 2683
 [  140.731021] [] save_stack_trace+0x16/0x20
 [  140.731021] [] save_stack+0x46/0xd0
 [  140.731021] [] kasan_kmalloc+0xad/0xe0
 [  140.731021] [] kasan_slab_alloc+0x12/0x20
 [  140.731021] [] kmem_cache_alloc+0xbc/0x260
 [  140.731021] [] anon_vma_prepare+0xb6/0x530
 [  140.731021] [] handle_mm_fault+0x17d4/0x1e70
 [  140.731021] [] __do_page_fault+0x4f8/0xae0
 [  140.731021] [] trace_do_page_fault+0x93/0x450
 [  140.731021] [] do_async_page_fault+0x14/0x70
 [  140.731021] [] async_page_fault+0x28/0x30
Freed:
PID = 2683
 [  140.731021] [] save_stack_trace+0x16/0x20
 [  140.731021] [] save_stack+0x46/0xd0
 [  140.731021] [] kasan_slab_free+0x71/0xb0
 [  140.731021] [] kmem_cache_free+0xb5/0x2d0
 [  140.731021] [] unlink_anon_vmas+0x12c/0x700
 [  140.731021] [] free_pgtables+0x1bd/0x3b0
 [  140.731021] [] exit_mmap+0x212/0x3d0
 [  140.731021] [] mmput+0x95/0x300
 [  140.731021] [] do_exit+0x71d/0x2bc0
 [  140.731021] [] do_group_exit+0x108/0x330
 [  140.731021] [] SyS_exit_group+0x1d/0x20
 [  140.731021] [] entry_SYSCALL_64_fastpath+0x1f/0xc2
Memory state around the buggy address:
 88003da49500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 88003da49580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fb
>88003da49600: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
 ^
 88003da49680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 88003da49700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==



Sometimes it also crashes with slab-out-of-bounds report:

BUG: KASAN: slab-out-of-bounds in
kvm_irq_delivery_to_apic_fast+0x11fa/0x1210 at addr 88003d9ca750
Read of size 8 by task syz-executor/22923
CPU: 0 PID: 22923 Comm: syz-executor Not tainted 4.9.0-rc4+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 880067d8f740 81c2e46b 88003e9fafc0 88003d9ca5d8
 88003d9ca7a8  880067d8f768 8165ab9c
 ed0007b394ea ed0007b394ea 88003e9fafc0 880067d8f7e8
Call Trace:
 [< inline >] __dump_stack lib/dump_stack.c:15
 [] dump_stack+0xb3/0x118 lib/dump_stack.c:51
 [] kasan_object_err+0x1c/0x70 mm/kasan/report.c:156
 [< inline >] print_address_description mm/kasan/report.c:194
 [< inline >] kasan_report_error mm/kasan/report.c:283
 [] kasan_report+0x231/0x500 mm/kasan/report.c:303
 [] __asan_report_load8_noabort+0x14/0x20
mm/kasan/report.c:329
 [] kvm_irq_delivery_to_apic_fast+0x11fa/0x1210
arch/x86/kvm/lapic.c:824
 [] kvm_irq_delivery_to_apic+0x132/0x9a0
arch/x86/kvm/irq_comm.c:72
 [] kvm_set_msi+0x111/0x160 arch/x86/kvm/irq_comm.c:157
 [] kvm_send_userspace_msi+0x201/0x280
arch/x86/kvm/../../../virt/kvm/irqchip.c:74
 [] kvm_vm_ioctl+0xba5/0x1670
arch/x86/kvm/../../../virt/kvm/kvm_main.c:3015
 [< inline >] vfs_ioctl fs/ioctl.c:43
 [] do_vfs_ioctl+0x18c/0x1040 fs/ioctl.c:679
 [< inline >] SYSC_ioctl fs/ioctl.c:694
 [] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:685
 [] entry_SYSCALL_64_fastpath+0x1f/0xc2

dm-crypt accepts '+' in the key

2016-11-12 Thread Mikulas Patocka
Hi

dm-crypt uses the function kstrtou8 to decode the encryption key. kstrtou8 
calls kstrtoull and kstrtoull skips the first character if it is '+'.

Consequently, it is possible to load keys with '+' in it. For example, 
this is possible:

dmsetup create cr --table "0 131072 crypt aes-cbc-essiv:sha256 
+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0 0 
/dev/debian/tmptest 0"

Should this be fixed in dm-crypt or in kstrtou8? A fix in kstrtou8 could 
be more appropriate, but we don't know how many other kernel parts depend 
on this "skip plus" behavior...

Mikulas


kvm: out-of-bounds write in __rtc_irq_eoi_tracking_restore_one

2016-11-12 Thread Dmitry Vyukov
Hello,

The following program triggers slab-ouf-of-bound write:
https://gist.githubusercontent.com/dvyukov/c4941c67e2eb5be314b902b17dc089df/raw/4f1844d19f6308135ca14c7f28e0898da1b363de/gistfile1.txt

On commit 015ed9433be2b476ec7e2e6a9a411a56e3b5b035 (Nov 11).

BUG: KASAN: slab-out-of-bounds in
__rtc_irq_eoi_tracking_restore_one+0x33b/0x350 at addr
88003bd82b7c
Write of size 1 by task syz-executor/5031
CPU: 3 PID: 5031 Comm: syz-executor Not tainted 4.9.0-rc4+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 88006d0df6b8 81c2e46b 88003e80cf40 88003bd82568
 88003bd82ea0 0001 88006d0df6e0 8165ab9c
 ed00077b056f ed00077b056f 88003e80cf40 88006d0df760
Call Trace:
 [] __asan_report_store1_noabort+0x17/0x20
mm/kasan/report.c:331
 [] __rtc_irq_eoi_tracking_restore_one+0x33b/0x350
arch/x86/kvm/ioapic.c:128
 [] kvm_rtc_eoi_tracking_restore_one+0x66/0x90
arch/x86/kvm/ioapic.c:142
 [] kvm_apic_set_state+0x9b5/0xde0 arch/x86/kvm/lapic.c:2091
 [< inline >] kvm_vcpu_ioctl_set_lapic arch/x86/kvm/x86.c:2834
 [] kvm_arch_vcpu_ioctl+0x155d/0x3100 arch/x86/kvm/x86.c:3337
 [] kvm_vcpu_ioctl+0x1e2/0xdd0
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2708
 [< inline >] vfs_ioctl fs/ioctl.c:43
 [] do_vfs_ioctl+0x18c/0x1040 fs/ioctl.c:679
 [< inline >] SYSC_ioctl fs/ioctl.c:694
 [] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:685
 [] entry_SYSCALL_64_fastpath+0x1f/0xc2
Object at 88003bd82568, in cache kmalloc-2048 size: 2048
Allocated:
PID = 5018
 [ 2761.628607] [] save_stack_trace+0x16/0x20
arch/x86/kernel/stacktrace.c:57
 [ 2761.628607] [] save_stack+0x46/0xd0 mm/kasan/kasan.c:495
 [ 2761.634614] [< inline >] set_track mm/kasan/kasan.c:507
 [ 2761.634614] [] kasan_kmalloc+0xad/0xe0
mm/kasan/kasan.c:598
 [ 2761.639003] [] kmem_cache_alloc_trace+0xf8/0x280
mm/slub.c:2735
 [ 2761.639003] [< inline >] kmalloc include/linux/slab.h:490
 [ 2761.639003] [< inline >] kzalloc include/linux/slab.h:636
 [ 2761.639003] [] kvm_ioapic_init+0x51/0x5d0
arch/x86/kvm/ioapic.c:611
 [ 2761.639003] [] kvm_arch_vm_ioctl+0xfb4/0x1c10
arch/x86/kvm/x86.c:3914
 [ 2761.639003] [] kvm_vm_ioctl+0x193/0x1670
arch/x86/kvm/../../../virt/kvm/kvm_main.c:3097
 [ 2761.639003] [< inline >] vfs_ioctl fs/ioctl.c:43
 [ 2761.639003] [] do_vfs_ioctl+0x18c/0x1040 fs/ioctl.c:679
 [ 2761.639003] [< inline >] SYSC_ioctl fs/ioctl.c:694
 [ 2761.639003] [] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:685
 [ 2761.639003] [] entry_SYSCALL_64_fastpath+0x1f/0xc2
Freed:
PID = 0
(stack is not available)
Memory state around the buggy address:
 88003bd82a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 88003bd82a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>88003bd82b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
 88003bd82b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 88003bd82c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==


kvm: BUG in pte_list_remove

2016-11-12 Thread Dmitry Vyukov
Hello,

The following program triggers BUG in pte_list_remove:
https://gist.githubusercontent.com/dvyukov/c763720296f6f4e51934c58ade173a71/raw/2f78e3e634dcd8c3d39d2fbbdcd2afb02bc736f5/gistfile1.txt

On commit 015ed9433be2b476ec7e2e6a9a411a56e3b5b035 (nov 11)

kernel BUG at arch/x86/kvm/mmu.c:1016!
invalid opcode:  [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 1923 Comm: syz-executor Not tainted 4.9.0-rc4+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: 88003744c480 task.stack: 88003bcc8000
RIP: 0010:[]  []
pte_list_remove+0x3a6/0x3f0 arch/x86/kvm/mmu.c:1015
RSP: 0018:88003bccf660  EFLAGS: 00010286
RAX: 0028 RBX: 88003c2f5d68 RCX: 
RDX: 0028 RSI: 0001 RDI: ed0007799ec0
RBP: 88003bccf6a0 R08: 0001 R09: 
R10: 84da2600 R11: 0001 R12: 88003763aa08
R13:  R14: 000f R15: 88003763aa30
FS:  7f5cac039700() GS:88003ec0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 006e CR3: 3ba9a000 CR4: 26f0
DR0: e3f1 DR1: 0006 DR2: 0006
DR3: 0458 DR6: 0ff0 DR7: 0400
Stack:
 88003c2f5d68 0001 88003dd43078 88003dd43078
 88003763aa08 88003d70c000 000f 88003763aa30
 88003bccf6e0 810d1eb6 88003744c480 37d8cc77
Call Trace:
 [< inline >] rmap_remove arch/x86/kvm/mmu.c:1092
 [] drop_spte+0x166/0x260 arch/x86/kvm/mmu.c:1174
 [] mmu_page_zap_pte+0x19d/0x1e0 arch/x86/kvm/mmu.c:2295
 [< inline >] kvm_mmu_page_unlink_children arch/x86/kvm/mmu.c:2317
 [] kvm_mmu_prepare_zap_page+0x126/0xd60
arch/x86/kvm/mmu.c:2361
 [< inline >] kvm_zap_obsolete_pages arch/x86/kvm/mmu.c:4904
 [] kvm_mmu_invalidate_zap_all_pages+0x2d4/0x490
arch/x86/kvm/mmu.c:4945
 [] kvm_arch_flush_shadow_all+0x15/0x20
arch/x86/kvm/x86.c:8152
 [] kvm_mmu_notifier_release+0x71/0xb0
arch/x86/kvm/../../../virt/kvm/kvm_main.c:467
 [] __mmu_notifier_release+0x101/0x3e0 mm/mmu_notifier.c:74
 [< inline >] mmu_notifier_release include/linux/mmu_notifier.h:235
 [] exit_mmap+0x32c/0x3d0 mm/mmap.c:2918
 [< inline >] __mmput kernel/fork.c:866
 [] mmput+0x95/0x300 kernel/fork.c:888
 [< inline >] exit_mm kernel/exit.c:512
 [] do_exit+0x71d/0x2bc0 kernel/exit.c:815
 [] do_group_exit+0x108/0x330 kernel/exit.c:931
 [] get_signal+0x617/0x1780 kernel/signal.c:2307
 [] do_signal+0x8d/0x19d0 arch/x86/kernel/signal.c:807
 [] exit_to_usermode_loop+0xf7/0x150
arch/x86/entry/common.c:156
 [< inline >] prepare_exit_to_usermode arch/x86/entry/common.c:190
 [] syscall_return_slowpath+0x1a0/0x1e0
arch/x86/entry/common.c:259
 [] entry_SYSCALL_64_fastpath+0xc0/0xc2
Code: 71 71 39 00 48 8b 75 d0 48 c7 c7 40 3e 22 83 e8 6a 07 48 00 0f
0b e8 5a 71 39 00 48 8b 75 d0 48 c7 c7 00 3e 22 83 e8 53 07 48 00 <0f>
0b e8 63 48 59 00 e9 c1 fe ff ff e8 f9 48 59 00 e9 4a ff ff
RIP  [] pte_list_remove+0x3a6/0x3f0 arch/x86/kvm/mmu.c:1015
 RSP 
---[ end trace 1cbf703067869156 ]---
Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: disabled
reboot: cpu_has_vmx: ecx=80a02021 1


kvm: recursive lock in kvm_clear_async_pf_completion_queue

2016-11-12 Thread Dmitry Vyukov
Hello,

I've got the following report while running syzkaller fuzzer.
On commit 015ed9433be2b476ec7e2e6a9a411a56e3b5b035 (Nov 11).


[ INFO: possible recursive locking detected ]
4.9.0-rc4+ #49 Not tainted
-
kworker/2:1/5658 is trying to acquire lock:
 ([ 1644.769018] (>work)
[< inline >] list_empty include/linux/compiler.h:243
[] flush_work+0x0/0x660 kernel/workqueue.c:1511

but task is already holding lock:
 ([ 1644.769018] (>work)
[] process_one_work+0x94b/0x1900 kernel/workqueue.c:2093

other info that might help us debug this:
 Possible unsafe locking scenario:

   CPU0
   
  lock([ 1644.828089] (>work)
);
  lock([ 1644.828089] (>work)
);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by kworker/2:1/5658:
 #0: [ 1644.832297]  (
 #1: [ 1644.850117]  (

stack backtrace:
CPU: 2 PID: 5658 Comm: kworker/2:1 Not tainted 4.9.0-rc4+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Workqueue: events async_pf_execute
 8800676ff630 81c2e46b 8485b930 88006b1fc480
  8485b930 8800676ff7e0 81339b27
 8800676ff7e8 0046 88006b1fcce8 88006b1fccf0
Call Trace:
 [< inline >] __dump_stack lib/dump_stack.c:15
 [] dump_stack+0xb3/0x118 lib/dump_stack.c:51
 [< inline >] print_deadlock_bug kernel/locking/lockdep.c:1728
 [< inline >] check_deadlock kernel/locking/lockdep.c:1772
 [< inline >] validate_chain kernel/locking/lockdep.c:2250
 [] __lock_acquire+0x1157/0x3630 kernel/locking/lockdep.c:3335
 [] lock_acquire+0x169/0x330 kernel/locking/lockdep.c:3746
 [] flush_work+0x93/0x660 kernel/workqueue.c:2846
 [] __cancel_work_timer+0x17a/0x410 kernel/workqueue.c:2916
 [] cancel_work_sync+0x17/0x20 kernel/workqueue.c:2951
 [] kvm_clear_async_pf_completion_queue+0xd7/0x400
arch/x86/kvm/../../../virt/kvm/async_pf.c:126
 [< inline >] kvm_free_vcpus arch/x86/kvm/x86.c:7841
 [] kvm_arch_destroy_vm+0x23d/0x620 arch/x86/kvm/x86.c:7946
 [< inline >] kvm_destroy_vm
arch/x86/kvm/../../../virt/kvm/kvm_main.c:731
 [] kvm_put_kvm+0x40e/0x790
arch/x86/kvm/../../../virt/kvm/kvm_main.c:752
 [] async_pf_execute+0x23d/0x4f0
arch/x86/kvm/../../../virt/kvm/async_pf.c:111
 [] process_one_work+0x9fc/0x1900 kernel/workqueue.c:2096
 [] worker_thread+0xef/0x1480 kernel/workqueue.c:2230
 [] kthread+0x244/0x2d0 kernel/kthread.c:209
 [] ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:433


[PATCH 1/2] x86/efi: Fix EFI memmap pointer size warning

2016-11-12 Thread Matt Fleming
From: Borislav Petkov 

Fix this when building on 32-bit:

  arch/x86/platform/efi/efi.c: In function ‘__efi_enter_virtual_mode’:
  arch/x86/platform/efi/efi.c:911:5: warning: cast to pointer from integer of 
different size [-Wint-to-pointer-cast]
   (efi_memory_desc_t *)pa);
   ^
  arch/x86/platform/efi/efi.c:918:5: warning: cast to pointer from integer of 
different size [-Wint-to-pointer-cast]
   (efi_memory_desc_t *)pa);
   ^

The @pa local variable is declared as phys_addr_t and that is a u64 when
CONFIG_PHYS_ADDR_T_64BIT=y. (The last is enabled on 32-bit on a PAE
build.)

However, its value comes from __pa() which is basically doing pointer
arithmetic and checking, and returns unsigned long as it is the native
pointer width.

So let's use an unsigned long too. It should be fine to do so because
the later users cast it to a pointer too.

Signed-off-by: Borislav Petkov 
Cc: Ard Biesheuvel 
Signed-off-by: Matt Fleming 
---
 arch/x86/platform/efi/efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index bf99aa7005eb..936a488d6cf6 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -861,7 +861,7 @@ static void __init __efi_enter_virtual_mode(void)
int count = 0, pg_shift = 0;
void *new_memmap = NULL;
efi_status_t status;
-   phys_addr_t pa;
+   unsigned long pa;
 
efi.systab = NULL;
 
-- 
2.10.0



[PATCH 2/2] x86/efi: Prevent mixed mode boot corruption with CONFIG_VMAP_STACK

2016-11-12 Thread Matt Fleming
Booting an EFI mixed mode kernel has been crashing since commit:

  e37e43a497d5 ("x86/mm/64: Enable vmapped stacks 
(CONFIG_HAVE_ARCH_VMAP_STACK=y)")

The user-visible effect in my test setup was the kernel being unable
to find the root file system ramdisk. This was likely caused by silent
memory or page table corruption.

Enabling CONFIG_DEBUG_VIRTUAL immediately flagged the thunking code as
abusing virt_to_phys() because it was passing addresses that were not
part of the kernel direct mapping.

Use the slow version instead, which correctly handles all memory
regions by performing a page table walk.

Suggested-by: Andy Lutomirski 
Cc: Ard Biesheuvel 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: "H. Peter Anvin" 
Signed-off-by: Matt Fleming 
---
 arch/x86/platform/efi/efi_64.c | 80 ++
 1 file changed, 57 insertions(+), 23 deletions(-)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 58b0f801f66f..319148bd4b05 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -211,6 +212,35 @@ void efi_sync_low_kernel_mappings(void)
memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
 }
 
+/*
+ * Wrapper for slow_virt_to_phys() that handles NULL addresses.
+ */
+static inline phys_addr_t
+virt_to_phys_or_null_size(void *va, unsigned long size)
+{
+   bool bad_size;
+
+   if (!va)
+   return 0;
+
+   if (virt_addr_valid(va))
+   return virt_to_phys(va);
+
+   /*
+* A fully aligned variable on the stack is guaranteed not to
+* cross a page bounary. Try to catch strings on the stack by
+* checking that 'size' is a power of two.
+*/
+   bad_size = size > PAGE_SIZE || !is_power_of_2(size);
+
+   WARN_ON(!IS_ALIGNED((unsigned long)va, size) || bad_size);
+
+   return slow_virt_to_phys(va);
+}
+
+#define virt_to_phys_or_null(addr) \
+   virt_to_phys_or_null_size((addr), sizeof(*(addr)))
+
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
unsigned long pfn, text;
@@ -494,8 +524,8 @@ static efi_status_t efi_thunk_get_time(efi_time_t *tm, 
efi_time_cap_t *tc)
 
spin_lock(_lock);
 
-   phys_tm = virt_to_phys(tm);
-   phys_tc = virt_to_phys(tc);
+   phys_tm = virt_to_phys_or_null(tm);
+   phys_tc = virt_to_phys_or_null(tc);
 
status = efi_thunk(get_time, phys_tm, phys_tc);
 
@@ -511,7 +541,7 @@ static efi_status_t efi_thunk_set_time(efi_time_t *tm)
 
spin_lock(_lock);
 
-   phys_tm = virt_to_phys(tm);
+   phys_tm = virt_to_phys_or_null(tm);
 
status = efi_thunk(set_time, phys_tm);
 
@@ -529,9 +559,9 @@ efi_thunk_get_wakeup_time(efi_bool_t *enabled, efi_bool_t 
*pending,
 
spin_lock(_lock);
 
-   phys_enabled = virt_to_phys(enabled);
-   phys_pending = virt_to_phys(pending);
-   phys_tm = virt_to_phys(tm);
+   phys_enabled = virt_to_phys_or_null(enabled);
+   phys_pending = virt_to_phys_or_null(pending);
+   phys_tm = virt_to_phys_or_null(tm);
 
status = efi_thunk(get_wakeup_time, phys_enabled,
 phys_pending, phys_tm);
@@ -549,7 +579,7 @@ efi_thunk_set_wakeup_time(efi_bool_t enabled, efi_time_t 
*tm)
 
spin_lock(_lock);
 
-   phys_tm = virt_to_phys(tm);
+   phys_tm = virt_to_phys_or_null(tm);
 
status = efi_thunk(set_wakeup_time, enabled, phys_tm);
 
@@ -558,6 +588,10 @@ efi_thunk_set_wakeup_time(efi_bool_t enabled, efi_time_t 
*tm)
return status;
 }
 
+static unsigned long efi_name_size(efi_char16_t *name)
+{
+   return ucs2_strsize(name, EFI_VAR_NAME_LEN) + 1;
+}
 
 static efi_status_t
 efi_thunk_get_variable(efi_char16_t *name, efi_guid_t *vendor,
@@ -567,11 +601,11 @@ efi_thunk_get_variable(efi_char16_t *name, efi_guid_t 
*vendor,
u32 phys_name, phys_vendor, phys_attr;
u32 phys_data_size, phys_data;
 
-   phys_data_size = virt_to_phys(data_size);
-   phys_vendor = virt_to_phys(vendor);
-   phys_name = virt_to_phys(name);
-   phys_attr = virt_to_phys(attr);
-   phys_data = virt_to_phys(data);
+   phys_data_size = virt_to_phys_or_null(data_size);
+   phys_vendor = virt_to_phys_or_null(vendor);
+   phys_name = virt_to_phys_or_null_size(name, efi_name_size(name));
+   phys_attr = virt_to_phys_or_null(attr);
+   phys_data = virt_to_phys_or_null_size(data, *data_size);
 
status = efi_thunk(get_variable, phys_name, phys_vendor,
   phys_attr, phys_data_size, phys_data);
@@ -586,9 +620,9 @@ efi_thunk_set_variable(efi_char16_t *name, efi_guid_t 
*vendor,
u32 phys_name, phys_vendor, phys_data;
efi_status_t status;
 
-   phys_name = virt_to_phys(name);
-   phys_vendor = virt_to_phys(vendor);
-   phys_data = 

[GIT PULL 0/2] EFI urgent fixes

2016-11-12 Thread Matt Fleming
Folks, please pull the following two EFI patches. The first fixes a
build warning for PAE that Boris hit. The second makes mixed-mode EFI
boot again after the vmap'd stack changes introduced during the merge
window.

The following changes since commit bc33b0ca11e3df46a4fa7639ba488c9d4911:

  Linux 4.9-rc4 (2016-11-05 16:23:36 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-urgent

for you to fetch changes up to 044ddf3d3e3cb62671f22fa837a2164d4786d867:

  x86/efi: Prevent mixed mode boot corruption with CONFIG_VMAP_STACK 
(2016-11-12 21:00:18 +)


 * Fix memory corruption when booting EFI mixed mode due to the recent
   vmap'd stack changes - Matt Fleming

 * Build warning fix in the EFI memmap code when CONFIG_X86_PAE and
   CONFIG_PHYS_ADDR_T_64BIT are enabled - Borislav Petkov


Borislav Petkov (1):
  x86/efi: Fix EFI memmap pointer size warning

Matt Fleming (1):
  x86/efi: Prevent mixed mode boot corruption with CONFIG_VMAP_STACK

 arch/x86/platform/efi/efi.c|  2 +-
 arch/x86/platform/efi/efi_64.c | 80 ++
 2 files changed, 58 insertions(+), 24 deletions(-)


[PATCH] [STYLE]staging:dgnc:dgnc_cls.h Spelling correction

2016-11-12 Thread Walt Feasel
Corrected a spelling mistake for control

Signed-off-by: Walt Feasel 
---
 drivers/staging/dgnc/dgnc_cls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.h b/drivers/staging/dgnc/dgnc_cls.h
index 2597e36..463ad30 100644
--- a/drivers/staging/dgnc/dgnc_cls.h
+++ b/drivers/staging/dgnc/dgnc_cls.h
@@ -69,7 +69,7 @@ struct cls_uart_struct {
 #define UART_EXAR654_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */
 #define UART_EXAR654_EFR_IXOFF0x8 /* Transmit Xon1/Xoff1 */
 #define UART_EXAR654_EFR_RTSDTR   0x40/* Auto RTS/DTR Flow Control Enable 
*/
-#define UART_EXAR654_EFR_CTSDSR   0x80/* Auto CTS/DSR Flow COntrol Enable 
*/
+#define UART_EXAR654_EFR_CTSDSR   0x80/* Auto CTS/DSR Flow Control Enable 
*/
 #define UART_EXAR654_IER_XOFF 0x20/* Xoff Interrupt Enable */
 #define UART_EXAR654_IER_RTSDTR   0x40/* Output Interrupt Enable */
 #define UART_EXAR654_IER_CTSDSR   0x80/* Input Interrupt Enable */
-- 
2.1.4



[PATCH v2] cpufreq: conservative: Decrease frequency faster when the update deferred

2016-11-12 Thread Stratos Karafotis
Conservative governor changes the CPU frequency in steps.
That means that if a CPU runs at max frequency, it will need several
sampling periods to return to min frequency when the workload
is finished.

If the update function that calculates the load and target frequency
is deferred, the governor might need even more time to decrease the
frequency.

This may have impact to power consumption and after all conservative
should decrease the frequency if there is no workload at every sampling
rate.

To resolve the above issue calculate the number of sampling periods
that the update is deferred. Considering that for each sampling period
conservative should drop the frequency by a freq_step because the
CPU was idle apply the proper subtraction to requested frequency.

Below, the kernel trace with and without this patch. First an
intensive workload is applied on a specific CPU. Then the workload
is removed and the CPU goes to idle.

WITHOUT

 -0 [007] dN..   620.329153: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    620.350857: cpu_frequency: state=170 cpu_id=7
kworker/7:2-556   [007]    620.370856: cpu_frequency: state=190 cpu_id=7
kworker/7:2-556   [007]    620.390854: cpu_frequency: state=210 cpu_id=7
kworker/7:2-556   [007]    620.411853: cpu_frequency: state=220 cpu_id=7
kworker/7:2-556   [007]    620.432854: cpu_frequency: state=240 cpu_id=7
kworker/7:2-556   [007]    620.453854: cpu_frequency: state=260 cpu_id=7
kworker/7:2-556   [007]    620.494856: cpu_frequency: state=290 cpu_id=7
kworker/7:2-556   [007]    620.515856: cpu_frequency: state=310 cpu_id=7
kworker/7:2-556   [007]    620.536858: cpu_frequency: state=330 cpu_id=7
kworker/7:2-556   [007]    620.557857: cpu_frequency: state=3401000 cpu_id=7
 -0 [007] d...   669.591363: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   669.591939: cpu_idle: state=4294967295 cpu_id=7
 -0 [007] d...   669.591980: cpu_idle: state=4 cpu_id=7
 -0 [007] dN..   669.591989: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   670.201224: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   670.221975: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    670.222016: cpu_frequency: state=330 cpu_id=7
 -0 [007] d...   670.222026: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   670.234964: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   670.801251: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   671.236046: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    671.236073: cpu_frequency: state=310 cpu_id=7
 -0 [007] d...   671.236112: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   671.393437: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   671.401277: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   671.404083: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    671.404111: cpu_frequency: state=290 cpu_id=7
 -0 [007] d...   671.404125: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   671.404974: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   671.501180: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   671.995414: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    671.995459: cpu_frequency: state=280 cpu_id=7
 -0 [007] d...   671.995469: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   671.996287: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   672.001305: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.078374: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    672.078410: cpu_frequency: state=260 cpu_id=7
 -0 [007] d...   672.078419: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.158020: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    672.158040: cpu_frequency: state=240 cpu_id=7
 -0 [007] d...   672.158044: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.160038: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   672.234557: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.237121: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    672.237174: cpu_frequency: state=210 cpu_id=7
 -0 [007] d...   672.237186: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.237778: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   672.267902: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.269860: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007]    672.269906: cpu_frequency: state=190 cpu_id=7
 -0 [007] d...   672.269914: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.271902: cpu_idle: state=4294967295 cpu_id=7
...
 -0 [007] d...   672.751342: cpu_idle: state=4 cpu_id=7
 -0 [007] d...   672.823056: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   

Re: PM regression with LED changes in next-20161109

2016-11-12 Thread Hans de Goede

Hi,

On 12-11-16 20:14, Jacek Anaszewski wrote:




Why a dedicated file? Are we going to mirror brightness here
wrt r/w (show/store) behavior ? If not userspace now needs
2 open fds which is not really nice. If we are and we are
not going to use poll for something else on brightness itself
then why not just poll directly on brightness ?


My main concern is that reporting only hw brightness changes
wouldn't be consistent with general brightness file purpose.
One could expect that brightness changes made by triggers
should be also reported.


Ok, I agree that not notifying poll() while an actual
read() would result in a different value is not really good
semantics.

I don't like to call it hw_brightness_change though, as
mentioned before I believe that if we were to start with
a clean slate we would make the brightness file's read/write
behavior more a mirror of itself.

So I would like to propose creating a new read-write
user_brightness file.

The write behavior would be 100% identical to the brightness
file (in code terms it will call the same store function).

The the read behavior otoh will be different: it will shows
the last brightness as set by the user, this would show the
read behavior we really want of brightness: show the real
brightness when not blinking / triggers are active and show
the brightness used when on when blinking / triggers are active.

We could then add poll support on this new user_brightness
file, thus avoiding the problem with the extra cpu-load on
notifications on blinking / triggers.


I agree that user_brightness allows to solve the issues you raised
about inconsistent write and read brightness' semantics
(which is not that painful IMHO).

Reporting non-user brightness changes on user_brightness file
doesn't sound reasonable though.


The changes I'm interested in are user brightness changes they
are just not done through sysfs, but through a hardwired hotkey,
they are however very much done by the user.


Also, how would we read the
brightness set by the firmware? We'd have to read brightness
file, so still two files would have to be opened which is
a second drawback of this approach.


No, look carefully at the definition of the read behavior
I plan to put in the ABI doc:

"Reading this file will return the actual led brightness
when not blinking and no triggers are active; reading this
file will return the brightness used when the led is on
when blinking or triggers are active."

So for e.g. the backlit keyboard case reading this single
file will return the actual brightness of the backlight,
since this does not involve blinking or triggers.

Basically the idea is that the user_brightness file
will have the semantics which IMHO the brightness file
itself should have had from the beginning, but which
we can't change now due to ABI reasons.


Having no difference in this area between the two approaches
I'm still in favour of the read-only file for notifying
brightness changes procured by hardware.


That brings back the needing 2 fds problem; and does
not solve userspace not being able to reliably read
the led on brightness when blinking or using triggers.

And this also has the issue that one is doing poll() on
one fd to detect changes on another fd, which is completely
unheard of in any kernel API, so I still vote NACK for the
entire idea of having a different file purely for notifying
changes. The way unix defines poll to work means that the
poll() and read() must be on the same fd, anything else
does not make sense.

Regards,

Hans


[PATCH] [STYLE]staging:dgnc:dgnc_driver.c Blankline before }

2016-11-12 Thread Walt Feasel
Made suggested modifications from checkpatch in reference
to CHECK: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Walt Feasel 
---
 drivers/staging/dgnc/dgnc_driver.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index d3243a3..e28ab04 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -150,7 +150,6 @@ static void cleanup(bool sysfiles)
dgnc_cleanup_tty(dgnc_board[i]);
dgnc_cleanup_board(dgnc_board[i]);
}
-
 }
 
 /*
-- 
2.1.4



[tip:perf/urgent] perf hists: Fix column length on --hierarchy

2016-11-12 Thread tip-bot for Namhyung Kim
Commit-ID:  c72ab446cac1d6c9551fd26c4cfef1b2fc5041fd
Gitweb: http://git.kernel.org/tip/c72ab446cac1d6c9551fd26c4cfef1b2fc5041fd
Author: Namhyung Kim 
AuthorDate: Tue, 8 Nov 2016 22:08:33 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Nov 2016 11:55:29 -0300

perf hists: Fix column length on --hierarchy

Markus reported that there's a weird behavior on perf top --hierarchy
regarding the column length.

Looking at the code, I found a dubious code which affects the symptoms.
When --hierarchy option is used, the last column length might be
inaccurate since it skips to update the length on leaf entries.

I cannot remember why it did and looks like a leftover from previous
version during the development.

Anyway, updating the column length often is not harmful.  So let's move
the code out.

Reported-and-Tested-by: Markus Trippelsdorf 
Signed-off-by: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Fixes: 1a3906a7e6b9 ("perf hists: Resort hist entries with hierarchy")
Link: http://lkml.kernel.org/r/20161108130833.9263-5-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/hist.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b02992e..a69f027 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1600,18 +1600,18 @@ static void hists__hierarchy_output_resort(struct hists 
*hists,
if (prog)
ui_progress__update(prog, 1);
 
+   hists->nr_entries++;
+   if (!he->filtered) {
+   hists->nr_non_filtered_entries++;
+   hists__calc_col_len(hists, he);
+   }
+
if (!he->leaf) {
hists__hierarchy_output_resort(hists, prog,
   >hroot_in,
   >hroot_out,
   min_callchain_hits,
   use_callchain);
-   hists->nr_entries++;
-   if (!he->filtered) {
-   hists->nr_non_filtered_entries++;
-   hists__calc_col_len(hists, he);
-   }
-
continue;
}
 


[tip:perf/urgent] perf/x86/intel/uncore: Add more Intel uncore IMC PCI IDs for SkyLake

2016-11-12 Thread tip-bot for Kan Liang
Commit-ID:  d786810b2f896854506e7b698a137f074942e410
Gitweb: http://git.kernel.org/tip/d786810b2f896854506e7b698a137f074942e410
Author: Kan Liang 
AuthorDate: Tue, 8 Nov 2016 13:54:41 -0500
Committer:  Ingo Molnar 
CommitDate: Fri, 11 Nov 2016 08:30:22 +0100

perf/x86/intel/uncore: Add more Intel uncore IMC PCI IDs for SkyLake

Several uncore IMC PCI IDs are missed for Intel SkyLake.

Add the PCI IDs for SkyLake Y, U, H and S platforms.
Rename the ID macros for 0x191f and 0x190c.

The corresponding bug:

  https://bugzilla.kernel.org/show_bug.cgi?id=187301

The related datasheets are also attached in the bug entry for permanent 
reference.

Reported-by: Ben Widawsky 
Tested-by: Ben Widawsky 
Signed-off-by: Kan Liang 
Reviewed-by: Ben Widawsky 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Link: 
http://lkml.kernel.org/r/1478631281-5061-1-git-send-email-kan.li...@intel.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/events/intel/uncore_snb.c | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/arch/x86/events/intel/uncore_snb.c 
b/arch/x86/events/intel/uncore_snb.c
index 5f845ee..81195cc 100644
--- a/arch/x86/events/intel/uncore_snb.c
+++ b/arch/x86/events/intel/uncore_snb.c
@@ -8,8 +8,12 @@
 #define PCI_DEVICE_ID_INTEL_HSW_IMC0x0c00
 #define PCI_DEVICE_ID_INTEL_HSW_U_IMC  0x0a04
 #define PCI_DEVICE_ID_INTEL_BDW_IMC0x1604
-#define PCI_DEVICE_ID_INTEL_SKL_IMC0x191f
-#define PCI_DEVICE_ID_INTEL_SKL_U_IMC  0x190c
+#define PCI_DEVICE_ID_INTEL_SKL_U_IMC  0x1904
+#define PCI_DEVICE_ID_INTEL_SKL_Y_IMC  0x190c
+#define PCI_DEVICE_ID_INTEL_SKL_HD_IMC 0x1900
+#define PCI_DEVICE_ID_INTEL_SKL_HQ_IMC 0x1910
+#define PCI_DEVICE_ID_INTEL_SKL_SD_IMC 0x190f
+#define PCI_DEVICE_ID_INTEL_SKL_SQ_IMC 0x191f
 
 /* SNB event control */
 #define SNB_UNC_CTL_EV_SEL_MASK0x00ff
@@ -616,13 +620,29 @@ static const struct pci_device_id bdw_uncore_pci_ids[] = {
 
 static const struct pci_device_id skl_uncore_pci_ids[] = {
{ /* IMC */
-   PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_IMC),
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_Y_IMC),
.driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
},
{ /* IMC */
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_U_IMC),
.driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
},
+   { /* IMC */
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_HD_IMC),
+   .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
+   },
+   { /* IMC */
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_HQ_IMC),
+   .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
+   },
+   { /* IMC */
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_SD_IMC),
+   .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
+   },
+   { /* IMC */
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_SQ_IMC),
+   .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
+   },
 
{ /* end: all zeroes */ },
 };
@@ -666,8 +686,12 @@ static const struct imc_uncore_pci_dev 
desktop_imc_pci_ids[] = {
IMC_DEV(HSW_IMC, _uncore_pci_driver),/* 4th Gen Core Processor 
*/
IMC_DEV(HSW_U_IMC, _uncore_pci_driver),  /* 4th Gen Core ULT Mobile 
Processor */
IMC_DEV(BDW_IMC, _uncore_pci_driver),/* 5th Gen Core U */
-   IMC_DEV(SKL_IMC, _uncore_pci_driver),/* 6th Gen Core */
+   IMC_DEV(SKL_Y_IMC, _uncore_pci_driver),  /* 6th Gen Core Y */
IMC_DEV(SKL_U_IMC, _uncore_pci_driver),  /* 6th Gen Core U */
+   IMC_DEV(SKL_HD_IMC, _uncore_pci_driver),  /* 6th Gen Core H Dual 
Core */
+   IMC_DEV(SKL_HQ_IMC, _uncore_pci_driver),  /* 6th Gen Core H Quad 
Core */
+   IMC_DEV(SKL_SD_IMC, _uncore_pci_driver),  /* 6th Gen Core S Dual 
Core */
+   IMC_DEV(SKL_SQ_IMC, _uncore_pci_driver),  /* 6th Gen Core S Quad 
Core */
{  /* end marker */ }
 };
 


[tip:sched/core] sched/deadline: Fix typo in a comment

2016-11-12 Thread tip-bot for Daniel Bristot de Oliveira
Commit-ID:  9846d50df3def5bff9d8a408a958722e79bcaa10
Gitweb: http://git.kernel.org/tip/9846d50df3def5bff9d8a408a958722e79bcaa10
Author: Daniel Bristot de Oliveira 
AuthorDate: Tue, 8 Nov 2016 11:15:23 +0100
Committer:  Ingo Molnar 
CommitDate: Fri, 11 Nov 2016 08:28:52 +0100

sched/deadline: Fix typo in a comment

In the comment:

/*
 * The task might have changed its scheduling policy to something
 * different than SCHED_DEADLINE (through switched_fromd_dl()).
 */

s/fromd/from/

Signed-off-by: Daniel Bristot de Oliveira 
Cc: Juri Lelli 
Cc: Linus Torvalds 
Cc: Luca Abeni 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/5408b3b3f9ee197a7b7f10fb834341100a4f2c88.1478599881.git.bris...@redhat.com
Signed-off-by: Ingo Molnar 
---
 kernel/sched/deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 37e2449..c61b461 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -586,7 +586,7 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer 
*timer)
 
/*
 * The task might have changed its scheduling policy to something
-* different than SCHED_DEADLINE (through switched_fromd_dl()).
+* different than SCHED_DEADLINE (through switched_from_dl()).
 */
if (!dl_task(p)) {
__dl_clear_params(p);


[tip:perf/urgent] perf hists browser: Fix indentation of folded sign on --hierarchy

2016-11-12 Thread tip-bot for Namhyung Kim
Commit-ID:  3d9f4683929a968dc9b9493f4e608b109ad292a2
Gitweb: http://git.kernel.org/tip/3d9f4683929a968dc9b9493f4e608b109ad292a2
Author: Namhyung Kim 
AuthorDate: Tue, 8 Nov 2016 22:08:30 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Nov 2016 11:20:56 -0300

perf hists browser: Fix indentation of folded sign on --hierarchy

It should indent 2 spaces for folded sign and a whitespace.

Signed-off-by: Namhyung Kim 
Tested-by: Markus Trippelsdorf 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20161108130833.9263-2-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 5adedc1..225ef2a 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1337,8 +1337,8 @@ static int hist_browser__show_hierarchy_entry(struct 
hist_browser *browser,
}
 
if (first) {
-   ui_browser__printf(>b, "%c", folded_sign);
-   width--;
+   ui_browser__printf(>b, "%c ", folded_sign);
+   width -= 2;
first = false;
} else {
ui_browser__printf(>b, "  ");
@@ -1555,7 +1555,7 @@ static int 
hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
int indent = hists->nr_hpp_node - 2;
bool first_node, first_col;
 
-   ret = scnprintf(buf, size, " ");
+   ret = scnprintf(buf, size, "  ");
if (advance_hpp_check(_hpp, ret))
return ret;
 


[tip:locking/core] locking/lockdep: Remove unused parameter from the add_lock_to_list() function

2016-11-12 Thread tip-bot for Tahsin Erdogan
Commit-ID:  83f06168ef15da5dc735c7ea14fae67609ed9538
Gitweb: http://git.kernel.org/tip/83f06168ef15da5dc735c7ea14fae67609ed9538
Author: Tahsin Erdogan 
AuthorDate: Tue, 8 Nov 2016 00:02:07 -0800
Committer:  Ingo Molnar 
CommitDate: Fri, 11 Nov 2016 08:25:20 +0100

locking/lockdep: Remove unused parameter from the add_lock_to_list() function

The 'class' parameter is not used, remove it.
n
Signed-off-by: Tahsin Erdogan 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1478592127-4376-1-git-send-email-tah...@google.com
Signed-off-by: Ingo Molnar 
---
 kernel/locking/lockdep.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 589d763..e74b438 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -840,9 +840,9 @@ static struct lock_list *alloc_list_entry(void)
 /*
  * Add a new dependency to the head of the list:
  */
-static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
-   struct list_head *head, unsigned long ip,
-   int distance, struct stack_trace *trace)
+static int add_lock_to_list(struct lock_class *this, struct list_head *head,
+   unsigned long ip, int distance,
+   struct stack_trace *trace)
 {
struct lock_list *entry;
/*
@@ -1869,14 +1869,14 @@ check_prev_add(struct task_struct *curr, struct 
held_lock *prev,
 * Ok, all validations passed, add the new lock
 * to the previous lock's dependency list:
 */
-   ret = add_lock_to_list(hlock_class(prev), hlock_class(next),
+   ret = add_lock_to_list(hlock_class(next),
   _class(prev)->locks_after,
   next->acquire_ip, distance, );
 
if (!ret)
return 0;
 
-   ret = add_lock_to_list(hlock_class(next), hlock_class(prev),
+   ret = add_lock_to_list(hlock_class(prev),
   _class(next)->locks_before,
   next->acquire_ip, distance, );
if (!ret)


[tip:ras/core] x86/MCE: Correct TSC timestamping of error records

2016-11-12 Thread tip-bot for Borislav Petkov
Commit-ID:  54467353a96577f840cd2348981417c559b21b4b
Gitweb: http://git.kernel.org/tip/54467353a96577f840cd2348981417c559b21b4b
Author: Borislav Petkov 
AuthorDate: Thu, 10 Nov 2016 14:10:53 +0100
Committer:  Ingo Molnar 
CommitDate: Fri, 11 Nov 2016 08:08:24 +0100

x86/MCE: Correct TSC timestamping of error records

We did have logic in the MCE code which would TSC-timestamp an error
record only when it is exact - i.e., when it wasn't detected by polling.
This isn't the case anymore. So let's fix that:

We have a valid TSC timestamp in the error record only when it has been
a precise detection, i.e., either in the #MC handler or in one of the
interrupt handlers (thresholding, deferred, ...).

All other error records still have mce.time which contains the wall
time in order to be able to place the error record in time at least
approximately.

Also, this fixes another bug where machine_check_poll() would clear
mce.tsc unconditionally even if we requested precise MCP_TIMESTAMP
logging.

The proper fix would be to generate timestamp only when it has been
requested and not always. But that would require a more thorough code
audit of all mce_gather_info/mce_setup() users. Add a FIXME for now.

Signed-off-by: Borislav Petkov 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Tony 
Cc: Tony Luck 
Cc: kernel test robot 
Cc: linux-edac 
Cc: l...@01.org
Link: http://lkml.kernel.org/r/20161110131053.kybsijfs5venp...@pd.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/mcheck/mce.c   | 16 ++--
 arch/x86/kernel/cpu/mcheck/mce_intel.c |  4 ++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 4ca0047..aab96f8 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -706,6 +706,15 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t 
*b)
 
mce_gather_info(, NULL);
 
+   /*
+* m.tsc was set in mce_setup(). Clear it if not requested.
+*
+* FIXME: Propagate @flags to mce_gather_info/mce_setup() to avoid
+*that dance.
+*/
+   if (!(flags & MCP_TIMESTAMP))
+   m.tsc = 0;
+
for (i = 0; i < mca_cfg.banks; i++) {
if (!mce_banks[i].ctl || !test_bit(i, *b))
continue;
@@ -713,14 +722,12 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t 
*b)
m.misc = 0;
m.addr = 0;
m.bank = i;
-   m.tsc = 0;
 
barrier();
m.status = mce_rdmsrl(msr_ops.status(i));
if (!(m.status & MCI_STATUS_VAL))
continue;
 
-
/*
 * Uncorrected or signalled events are handled by the exception
 * handler when it is enabled, so don't process those here.
@@ -735,9 +742,6 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t 
*b)
 
mce_read_aux(, i);
 
-   if (!(flags & MCP_TIMESTAMP))
-   m.tsc = 0;
-
severity = mce_severity(, mca_cfg.tolerant, NULL, false);
 
if (severity == MCE_DEFERRED_SEVERITY && memory_error())
@@ -1394,7 +1398,7 @@ static void mce_timer_fn(unsigned long data)
iv = __this_cpu_read(mce_next_interval);
 
if (mce_available(this_cpu_ptr(_info))) {
-   machine_check_poll(MCP_TIMESTAMP, 
this_cpu_ptr(_poll_banks));
+   machine_check_poll(0, this_cpu_ptr(_poll_banks));
 
if (mce_intel_cmci_poll()) {
iv = mce_adjust_timer(iv);
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c 
b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index 1defb8e..be0b2fa 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -130,7 +130,7 @@ bool mce_intel_cmci_poll(void)
 * Reset the counter if we've logged an error in the last poll
 * during the storm.
 */
-   if (machine_check_poll(MCP_TIMESTAMP, this_cpu_ptr(_banks_owned)))
+   if (machine_check_poll(0, this_cpu_ptr(_banks_owned)))
this_cpu_write(cmci_backoff_cnt, INITIAL_CHECK_INTERVAL);
else
this_cpu_dec(cmci_backoff_cnt);
@@ -342,7 +342,7 @@ void cmci_recheck(void)
return;
 
local_irq_save(flags);
-   machine_check_poll(MCP_TIMESTAMP, this_cpu_ptr(_banks_owned));
+   machine_check_poll(0, this_cpu_ptr(_banks_owned));
local_irq_restore(flags);
 }
 


[tip:x86/cpu] x86/cpu/AMD: Clean up cpu_llc_id assignment per topology feature

2016-11-12 Thread tip-bot for Yazen Ghannam
Commit-ID:  b6a50cddbcbda7105355898ead18f1a647c22520
Gitweb: http://git.kernel.org/tip/b6a50cddbcbda7105355898ead18f1a647c22520
Author: Yazen Ghannam 
AuthorDate: Tue, 8 Nov 2016 16:30:54 +0100
Committer:  Ingo Molnar 
CommitDate: Wed, 9 Nov 2016 17:07:43 +0100

x86/cpu/AMD: Clean up cpu_llc_id assignment per topology feature

These changes do not affect current hw - just a cleanup:

Currently, we assume that a system has a single Last Level Cache (LLC)
per node, and that the cpu_llc_id is thus equal to the node_id. This no
longer applies since Fam17h can have multiple last level caches within a
node.

So group the cpu_llc_id assignment by topology feature and family in
order to make the computation of cpu_llc_id on the different families
more clear.

Here is how the LLC ID is being computed on the different families:

The NODEID_MSR feature only applies to Fam10h in which case the LLC is
at the node level.

The TOPOEXT feature is used on families 15h, 16h and 17h. So far we only
see multiple last level caches if L3 caches are available. Otherwise,
the cpu_llc_id will default to be the phys_proc_id.

We have L3 caches only on families 15h and 17h:

 - on Fam15h, the LLC is at the node level.

 - on Fam17h, the LLC is at the core complex level and can be found by
   right shifting the APIC ID. Also, keep the family checks explicit so that
   new families will fall back to the default, which will be node_id for
   TOPOEXT systems.

Single node systems in families 10h and 15h will have a Node ID of 0
which will be the same as the phys_proc_id, so we don't need to check
for multiple nodes before using the node_id.

Tested-by: Borislav Petkov 
Signed-off-by: Yazen Ghannam 
[ Rewrote the commit message. ]
Signed-off-by: Borislav Petkov 
Acked-by: Thomas Gleixner 
Cc: Aravind Gopalakrishnan 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20161108153054.bs3sajbyevq6a...@pd.tnic
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/amd.c | 31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 1e81a37..4daad1e 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -314,11 +314,30 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
smp_num_siblings = ((ebx >> 8) & 3) + 1;
c->x86_max_cores /= smp_num_siblings;
c->cpu_core_id = ebx & 0xff;
+
+   /*
+* We may have multiple LLCs if L3 caches exist, so check if we
+* have an L3 cache by looking at the L3 cache CPUID leaf.
+*/
+   if (cpuid_edx(0x8006)) {
+   if (c->x86 == 0x17) {
+   /*
+* LLC is at the core complex level.
+* Core complex id is ApicId[3].
+*/
+   per_cpu(cpu_llc_id, cpu) = c->apicid >> 3;
+   } else {
+   /* LLC is at the node level. */
+   per_cpu(cpu_llc_id, cpu) = node_id;
+   }
+   }
} else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
u64 value;
 
rdmsrl(MSR_FAM10H_NODE_ID, value);
node_id = value & 7;
+
+   per_cpu(cpu_llc_id, cpu) = node_id;
} else
return;
 
@@ -329,9 +348,6 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
set_cpu_cap(c, X86_FEATURE_AMD_DCM);
cus_per_node = c->x86_max_cores / nodes_per_socket;
 
-   /* store NodeID, use llc_shared_map to store sibling info */
-   per_cpu(cpu_llc_id, cpu) = node_id;
-
/* core id has to be in the [0 .. cores_per_node - 1] range */
c->cpu_core_id %= cus_per_node;
}
@@ -356,15 +372,6 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
/* use socket ID also for last level cache */
per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
amd_get_topology(c);
-
-   /*
-* Fix percpu cpu_llc_id here as LLC topology is different
-* for Fam17h systems.
-*/
-if (c->x86 != 0x17 || !cpuid_edx(0x8006))
-   return;
-
-   per_cpu(cpu_llc_id, cpu) = c->apicid >> 3;
 #endif
 }
 


[tip:perf/urgent] perf hists browser: Show folded sign properly on --hierarchy

2016-11-12 Thread tip-bot for Namhyung Kim
Commit-ID:  131d51eb1d17aac3a604cf929fd99ff4dd34f495
Gitweb: http://git.kernel.org/tip/131d51eb1d17aac3a604cf929fd99ff4dd34f495
Author: Namhyung Kim 
AuthorDate: Tue, 8 Nov 2016 22:08:31 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Nov 2016 11:30:47 -0300

perf hists browser: Show folded sign properly on --hierarchy

When horizontal scrolling is used in hierarchy mode, the folded signed
disappears at the right most column.

Committer note:

To test it, run 'perf top --hierarchy, see the '+' symbol at the first
column, then press the right arrow key, the '+' symbol will disappear,
this patch fixes that.

Signed-off-by: Namhyung Kim 
Tested-by: Arnaldo Carvalho de Melo 
Tested-by: Markus Trippelsdorf 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20161108130833.9263-3-namhy...@kernel.org
[ Move 'width -= 2' invariant to right after the if/else ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 225ef2a..e767fbd 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1381,7 +1381,13 @@ static int hist_browser__show_hierarchy_entry(struct 
hist_browser *browser,
}
 
perf_hpp_list__for_each_format(entry->hpp_list, fmt) {
-   ui_browser__write_nstring(>b, "", 2);
+   if (first) {
+   ui_browser__printf(>b, "%c ", 
folded_sign);
+   first = false;
+   } else {
+   ui_browser__write_nstring(>b, "", 2);
+   }
+
width -= 2;
 
/*


[tip:perf/urgent] perf hist browser: Fix hierarchy column counts

2016-11-12 Thread tip-bot for Namhyung Kim
Commit-ID:  9cba9844547731d2f14d79485c43192ffaa37b76
Gitweb: http://git.kernel.org/tip/9cba9844547731d2f14d79485c43192ffaa37b76
Author: Namhyung Kim 
AuthorDate: Tue, 25 Oct 2016 01:21:10 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Nov 2016 11:19:28 -0300

perf hist browser: Fix hierarchy column counts

The perf report/top on TUI supports horizontal scrolling using LEFT and
RIGHT keys.

But it calculate the number of columns incorrectly when hierarchy mode
is enabled so that keep pressing RIGHT key can make the output
disappeared.

In the hierarchy mode, all sort keys are collapsed into a single column,
so it needs to be applied when calculating column numbers.

Reported-and-Tested-by: Markus Trippelsdorf 
Signed-off-by: Namhyung Kim 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20161024162110.17918-1-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 47b..5adedc1 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2076,8 +2076,21 @@ void hist_browser__init(struct hist_browser *browser,
browser->b.use_navkeypressed= true;
browser->show_headers   = symbol_conf.show_hist_headers;
 
-   hists__for_each_format(hists, fmt)
+   if (symbol_conf.report_hierarchy) {
+   struct perf_hpp_list_node *fmt_node;
+
+   /* count overhead columns (in the first node) */
+   fmt_node = list_first_entry(>hpp_formats,
+   struct perf_hpp_list_node, list);
+   perf_hpp_list__for_each_format(_node->hpp, fmt)
+   ++browser->b.columns;
+
+   /* add a single column for whole hierarchy sort keys*/
++browser->b.columns;
+   } else {
+   hists__for_each_format(hists, fmt)
+   ++browser->b.columns;
+   }
 
hists__reset_column_width(hists);
 }


[tip:perf/urgent] perf hists browser: Fix column indentation on --hierarchy

2016-11-12 Thread tip-bot for Namhyung Kim
Commit-ID:  b9bf911e990a189f89147ee6b0a153ed0125
Gitweb: http://git.kernel.org/tip/b9bf911e990a189f89147ee6b0a153ed0125
Author: Namhyung Kim 
AuthorDate: Tue, 8 Nov 2016 22:08:32 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 9 Nov 2016 11:45:58 -0300

perf hists browser: Fix column indentation on --hierarchy

When horizontall scrolling is used in hierarchy mode, the the right most
column has unnecessary indentation.  Actually it's needed only if some
of left (overhead) columns were shown.

Signed-off-by: Namhyung Kim 
Tested-by: Arnaldo Carvalho de Melo 
Tested-by: Markus Trippelsdorf 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20161108130833.9263-4-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e767fbd..a53fef0 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1361,8 +1361,10 @@ static int hist_browser__show_hierarchy_entry(struct 
hist_browser *browser,
width -= hpp.buf - s;
}
 
-   ui_browser__write_nstring(>b, "", hierarchy_indent);
-   width -= hierarchy_indent;
+   if (!first) {
+   ui_browser__write_nstring(>b, "", hierarchy_indent);
+   width -= hierarchy_indent;
+   }
 
if (column >= browser->b.horiz_scroll) {
char s[2048];
@@ -1565,6 +1567,7 @@ static int 
hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
if (advance_hpp_check(_hpp, ret))
return ret;
 
+   first_node = true;
/* the first hpp_list_node is for overhead columns */
fmt_node = list_first_entry(>hpp_formats,
struct perf_hpp_list_node, list);
@@ -1579,12 +1582,16 @@ static int 
hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "  ");
if (advance_hpp_check(_hpp, ret))
break;
+
+   first_node = false;
}
 
-   ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
-   indent * HIERARCHY_INDENT, "");
-   if (advance_hpp_check(_hpp, ret))
-   return ret;
+   if (!first_node) {
+   ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
+   indent * HIERARCHY_INDENT, "");
+   if (advance_hpp_check(_hpp, ret))
+   return ret;
+   }
 
first_node = true;
list_for_each_entry_continue(fmt_node, >hpp_formats, list) {


[PATCH] ppdev: check before attaching port

2016-11-12 Thread Sudip Mukherjee
After parport starts using the device model, all pardevice drivers
should decide in their match_port callback function if they want to
attach with that particulatr port. ppdev has been converted to use the
new parport device-model code but pp_attach() tried to attach with all
the ports.
Create a new array of pointer and use that to remember the ports we
have attached. And use that information to skip attaching ports which
we have already attached.

Tested-by: Joe Lawrence 
Signed-off-by: Sudip Mukherjee 
---
 drivers/char/ppdev.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 6af1ce0..b30d68c 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -86,6 +86,9 @@ struct pp_struct {
long default_inactivity;
 };
 
+/* should we use PARDEVICE_MAX here? */
+static struct device *devices[PARPORT_MAX];
+
 /* pp_struct.flags bitfields */
 #define PP_CLAIMED(1<<0)
 #define PP_EXCL   (1<<1)
@@ -789,13 +792,29 @@ static unsigned int pp_poll(struct file *file, poll_table 
*wait)
 
 static void pp_attach(struct parport *port)
 {
-   device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
- NULL, "parport%d", port->number);
+   struct device *ret;
+
+   if (devices[port->number])
+   return;
+
+   ret = device_create(ppdev_class, port->dev,
+   MKDEV(PP_MAJOR, port->number), NULL,
+   "parport%d", port->number);
+   if (IS_ERR(ret)) {
+   pr_err("Failed to create device parport%d\n",
+  port->number);
+   return;
+   }
+   devices[port->number] = ret;
 }
 
 static void pp_detach(struct parport *port)
 {
+   if (!devices[port->number])
+   return;
+
device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
+   devices[port->number] = NULL;
 }
 
 static int pp_probe(struct pardevice *par_dev)
-- 
1.9.1



[PATCH] [STYLE]staging:dgnc:dgnc_driver.h Spelling correction

2016-11-12 Thread Walt Feasel
Corrected spelling mistake for statements

Signed-off-by: Walt Feasel 
---
 drivers/staging/dgnc/dgnc_driver.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 8792026..5770a85 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -34,7 +34,7 @@
  *
  */
 
-/* Driver identification and error statments */
+/* Driver identification and error statements */
 #definePROCSTR "dgnc"  /* /proc entries
 */
 #defineDEVSTR  "/dev/dg/dgnc"  /* /dev entries 
 */
 #defineDRVSTR  "dgnc"  /* Driver name string   
 */
-- 
2.1.4



kvm: GPF in irqfd_shutdown/eventfd_ctx_remove_wait_queue

2016-11-12 Thread Dmitry Vyukov
Hello,

I've got the following crash while running syzkaller fuzzer.
On commit 015ed9433be2b476ec7e2e6a9a411a56e3b5b035 (Nov 11).
Unfortunately it is not reproducible.
May be related to:
https://groups.google.com/forum/#!topic/syzkaller/NKlClJzOOww
https://groups.google.com/forum/#!topic/syzkaller/Dz__GySpVr8

general protection fault:  [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 17194 Comm: kworker/0:2 Not tainted 4.9.0-rc4+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Workqueue: kvm-irqfd-cleanup irqfd_shutdown
task: 88003b2bdb40 task.stack: 88003bcd8000
RIP: 0010:[]  [< inline >] __list_del
include/linux/list.h:89
RIP: 0010:[]  [< inline >] list_del
include/linux/list.h:107
RIP: 0010:[]  [< inline >]
__remove_wait_queue include/linux/wait.h:196
RIP: 0010:[]  []
eventfd_ctx_remove_wait_queue+0x139/0x2d0 fs/eventfd.c:201
RSP: 0018:88003bcdfb50  EFLAGS: 00010002
RAX:  RBX: 88003cefbd40 RCX: dc00
RDX:  RSI: 0001 RDI: 0008
RBP: 88003bcdfb90 R08: 90a58b45 R09: 0001
R10: 84da2600 R11: 11000779bf36 R12: 88003b986b88
R13: 88003bcdfbc8 R14: 88003cefbd48 R15: 0081
FS:  () GS:88003ec0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 00813000 CR3: 65fd4000 CR4: 26f0
Stack:
 88003bcdfb60 88003cefbd90 0296 88003b986b80
 88003b986ca8 11000779bf75 88003b986c80 dc00
 88003bcdfc30 8106dd86  41b58ab3
Call Trace:
 [] irqfd_shutdown+0x96/0x1a0
arch/x86/kvm/../../../virt/kvm/eventfd.c:128
 [] process_one_work+0x9fc/0x1900 kernel/workqueue.c:2096
 [] worker_thread+0xef/0x1480 kernel/workqueue.c:2230
 [] kthread+0x244/0x2d0 kernel/kthread.c:209
 [] ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:433
Code: 48 89 f9 48 c1 e9 03 80 3c 01 00 0f 85 83 01 00 00 48 8d 7a 08
48 b9 00 00 00 00 00 fc ff df 49 8b 44 24 20 48 89 fe 48 c1 ee 03 <80>
3c 0e 00 0f 85 45 01 00 00 48 89 c6 48 b9 00 00 00 00 00 fc
RIP  [< inline >] __list_del include/linux/list.h:89
RIP  [< inline >] list_del include/linux/list.h:107
RIP  [< inline >] __remove_wait_queue include/linux/wait.h:196
RIP  [] eventfd_ctx_remove_wait_queue+0x139/0x2d0
fs/eventfd.c:201
 RSP 
---[ end trace 9772f974e210aab6 ]---
Kernel panic - not syncing: Fatal exception
Shutting down cpus with NMI
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: disabled
reboot: cpu_has_vmx: ecx=80a02021 1


kvm: WARNING in em_ret_far

2016-11-12 Thread Dmitry Vyukov
Hello,

The following program triggers WARNING in em_ret_far:
https://gist.githubusercontent.com/dvyukov/12bc06a5f638d91953f94bcbe49bcc89/raw/6d863470808a695c085620664b7134864b2eb2a9/gistfile1.txt

On commit 015ed9433be2b476ec7e2e6a9a411a56e3b5b035 (Nov 11).

WARNING: CPU: 2 PID: 3668 at arch/x86/kvm/emulate.c:2217 em_ret_far+0x428/0x480
Kernel panic - not syncing: panic_on_warn set ...

CPU: 2 PID: 3668 Comm: syz-executor Not tainted 4.9.0-rc4+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 88006b32f618 81c2e46b 83270ec0 88006b32f6f0
 83225600 8110a218 88006b32f6e0 81546463
 41b58ab3 837cda55 815462ac 815470e9
Call Trace:
 [< inline >] __dump_stack lib/dump_stack.c:15
 [] dump_stack+0xb3/0x118 lib/dump_stack.c:51
 [] panic+0x1b7/0x3a3 kernel/panic.c:179
 [] __warn+0x1c4/0x1e0 kernel/panic.c:542
 [] warn_slowpath_null+0x2c/0x40 kernel/panic.c:585
 [] em_ret_far+0x428/0x480 arch/x86/kvm/emulate.c:2217
 [] em_ret_far_imm+0x17/0x70 arch/x86/kvm/emulate.c:2227
 [] x86_emulate_insn+0x87a/0x3730 arch/x86/kvm/emulate.c:5294
 [] x86_emulate_instruction+0x520/0x1ba0
arch/x86/kvm/x86.c:5545
 [< inline >] emulate_instruction arch/x86/include/asm/kvm_host.h:1116
 [< inline >] complete_emulated_io arch/x86/kvm/x86.c:6870
 [] complete_emulated_mmio+0x4e9/0x710 arch/x86/kvm/x86.c:6934
 [] kvm_arch_vcpu_ioctl_run+0x3b7a/0x5a90
arch/x86/kvm/x86.c:6978
 [] kvm_vcpu_ioctl+0x61e/0xdd0
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2557
 [< inline >] vfs_ioctl fs/ioctl.c:43
 [] do_vfs_ioctl+0x18c/0x1040 fs/ioctl.c:679
 [< inline >] SYSC_ioctl fs/ioctl.c:694
 [] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:685
 [] entry_SYSCALL_64_fastpath+0x1f/0xc2
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: disabled
reboot: cpu_has_vmx: ecx=80a02021 1


<    1   2   3   4   5   6   7   >