Re: [PATCH 3/3] futex: make the encoded_op decoding readable

2017-03-04 Thread Jiri Slaby
On 03/03/2017, 01:27 PM, Jiri Slaby wrote:
> Decoding of encoded_op is a bit unreadable. It contains shifts to the
> left and to the right by some constants. Make it clearly visible what
> part of the bit mask is taken and shift the values only to the right
> appropriatelly.
> 
> Signed-off-by: Jiri Slaby 
> ---
>  kernel/futex.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/futex.c b/kernel/futex.c
> index c09424406560..5834df248f09 100644
> --- a/kernel/futex.c
> +++ b/kernel/futex.c
> @@ -1459,10 +1459,10 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int 
> nr_wake, u32 bitset)
>  
>  static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)
>  {
> - int op = (encoded_op >> 28) & 7;
> - int cmp = (encoded_op >> 24) & 15;
> - int oparg = (encoded_op << 8) >> 20;
> - int cmparg = (encoded_op << 20) >> 20;
> + int op = (encoded_op& 0x7000) >> 28;
> + int cmp = (encoded_op   & 0x0f00) >> 24;
> + int oparg = (encoded_op & 0x00fff000) >> 12;
> + int cmparg = encoded_op & 0x0fff;

And it turned out that this one is actually invalid as it doesn't
preserve signedness on oparg and cmdarg. So please avoid applying this one.

thanks,
-- 
js
suse labs


Re: [PATCH 3/3] futex: make the encoded_op decoding readable

2017-03-04 Thread Jiri Slaby
On 03/03/2017, 01:27 PM, Jiri Slaby wrote:
> Decoding of encoded_op is a bit unreadable. It contains shifts to the
> left and to the right by some constants. Make it clearly visible what
> part of the bit mask is taken and shift the values only to the right
> appropriatelly.
> 
> Signed-off-by: Jiri Slaby 
> ---
>  kernel/futex.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/futex.c b/kernel/futex.c
> index c09424406560..5834df248f09 100644
> --- a/kernel/futex.c
> +++ b/kernel/futex.c
> @@ -1459,10 +1459,10 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int 
> nr_wake, u32 bitset)
>  
>  static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)
>  {
> - int op = (encoded_op >> 28) & 7;
> - int cmp = (encoded_op >> 24) & 15;
> - int oparg = (encoded_op << 8) >> 20;
> - int cmparg = (encoded_op << 20) >> 20;
> + int op = (encoded_op& 0x7000) >> 28;
> + int cmp = (encoded_op   & 0x0f00) >> 24;
> + int oparg = (encoded_op & 0x00fff000) >> 12;
> + int cmparg = encoded_op & 0x0fff;

And it turned out that this one is actually invalid as it doesn't
preserve signedness on oparg and cmdarg. So please avoid applying this one.

thanks,
-- 
js
suse labs


Re: [PATCH] PCI: Add cavium acs pci quirk

2017-03-04 Thread Sunil Kovvuri
On Tue, Feb 14, 2017 at 10:14 AM, Alex Williamson
 wrote:
> On Sat, 30 Jan 2016 01:33:58 +0530
> Manish Jaggi  wrote:
>
>> Cavium devices matching this quirk do not perform
>> peer-to-peer with other functions, allowing masking out
>> these bits as if they were unimplemented in the ACS capability.
>>
>> Acked-by: Tirumalesh Chalamarla 
>> Signed-off-by: Manish Jaggi 
>> ---
>>  drivers/pci/quirks.c | 15 +++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
>> index 7e32730..a300fa6 100644
>> --- a/drivers/pci/quirks.c
>> +++ b/drivers/pci/quirks.c
>> @@ -3814,6 +3814,19 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, 
>> u16 acs_flags)
>>  #endif
>>  }
>>
>> +static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
>> +{
>> + /*
>> +  * Cavium devices matching this quirk do not perform
>> +  * peer-to-peer with other functions, allowing masking out
>> +  * these bits as if they were unimplemented in the ACS capability.
>> +  */
>> + acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR |
>> +PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT);
>> +
>> + return acs_flags ? 0 : 1;
>> +}
>> +
>>  /*
>>   * Many Intel PCH root ports do provide ACS-like features to disable peer
>>   * transactions and validate bus numbers in requests, but do not provide an
>> @@ -3966,6 +3979,8 @@ static const struct pci_dev_acs_enabled {
>>   { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs },
>>   { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */
>>   { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */
>> + /* Cavium ThunderX */
>> + { PCI_VENDOR_ID_CAVIUM, PCI_ANY_ID, pci_quirk_cavium_acs },
>>   { 0 }
>>  };
>>
>
> Apologies for not catching this, but what sort of crystal ball do you
> have that can predict not only current devices, but future devices will
> not support peer-to-peer features?  Is there an internal design
> guidelines reference specification for Cavium that we can realistically
> expect this to remain consistent, or is this just an attempt to never
> think about ACS again at the customer's peril?  What about the existing
> non-ThunderX products with Cavium vendor ID, does this really apply to
> those?  I would strongly suggest taking the device ID into account.
> See examples like the pci_quirk_intel_pch_acs quirk where the initial
> filter is PCI_ANY_ID, but specific device types and ranges of device
> IDs are identified by the function for evaluation.  This seems reckless
> to me and I'd advise that it be reverted.  Thanks,
>
> Alex

Just a thought, even if Cavium considers to support ACS for future devices,
wouldn't it be better to add exception list inside the quirk on a need basis
rather than adding big list of devices that don't. Especially when currently
almost all Cavium PCI devices don't support ACS.

Thanks,
Sunil.


Re: [PATCH] PCI: Add cavium acs pci quirk

2017-03-04 Thread Sunil Kovvuri
On Tue, Feb 14, 2017 at 10:14 AM, Alex Williamson
 wrote:
> On Sat, 30 Jan 2016 01:33:58 +0530
> Manish Jaggi  wrote:
>
>> Cavium devices matching this quirk do not perform
>> peer-to-peer with other functions, allowing masking out
>> these bits as if they were unimplemented in the ACS capability.
>>
>> Acked-by: Tirumalesh Chalamarla 
>> Signed-off-by: Manish Jaggi 
>> ---
>>  drivers/pci/quirks.c | 15 +++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
>> index 7e32730..a300fa6 100644
>> --- a/drivers/pci/quirks.c
>> +++ b/drivers/pci/quirks.c
>> @@ -3814,6 +3814,19 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, 
>> u16 acs_flags)
>>  #endif
>>  }
>>
>> +static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
>> +{
>> + /*
>> +  * Cavium devices matching this quirk do not perform
>> +  * peer-to-peer with other functions, allowing masking out
>> +  * these bits as if they were unimplemented in the ACS capability.
>> +  */
>> + acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR |
>> +PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT);
>> +
>> + return acs_flags ? 0 : 1;
>> +}
>> +
>>  /*
>>   * Many Intel PCH root ports do provide ACS-like features to disable peer
>>   * transactions and validate bus numbers in requests, but do not provide an
>> @@ -3966,6 +3979,8 @@ static const struct pci_dev_acs_enabled {
>>   { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs },
>>   { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */
>>   { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */
>> + /* Cavium ThunderX */
>> + { PCI_VENDOR_ID_CAVIUM, PCI_ANY_ID, pci_quirk_cavium_acs },
>>   { 0 }
>>  };
>>
>
> Apologies for not catching this, but what sort of crystal ball do you
> have that can predict not only current devices, but future devices will
> not support peer-to-peer features?  Is there an internal design
> guidelines reference specification for Cavium that we can realistically
> expect this to remain consistent, or is this just an attempt to never
> think about ACS again at the customer's peril?  What about the existing
> non-ThunderX products with Cavium vendor ID, does this really apply to
> those?  I would strongly suggest taking the device ID into account.
> See examples like the pci_quirk_intel_pch_acs quirk where the initial
> filter is PCI_ANY_ID, but specific device types and ranges of device
> IDs are identified by the function for evaluation.  This seems reckless
> to me and I'd advise that it be reverted.  Thanks,
>
> Alex

Just a thought, even if Cavium considers to support ACS for future devices,
wouldn't it be better to add exception list inside the quirk on a need basis
rather than adding big list of devices that don't. Especially when currently
almost all Cavium PCI devices don't support ACS.

Thanks,
Sunil.


[PATCH] Staging: iio: addac - fixed octal file permissions

2017-03-04 Thread Derek Robson
Changed file permission to octal style.
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/iio/addac/adt7316.c | 108 ++--
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/iio/addac/adt7316.c 
b/drivers/staging/iio/addac/adt7316.c
index 6054c7298fce..aa251c245981 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -267,7 +267,7 @@ static ssize_t adt7316_store_enabled(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(enabled, 0644,
adt7316_show_enabled,
adt7316_store_enabled,
0);
@@ -311,7 +311,7 @@ static ssize_t adt7316_store_select_ex_temp(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(select_ex_temp, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(select_ex_temp, 0644,
adt7316_show_select_ex_temp,
adt7316_store_select_ex_temp,
0);
@@ -352,7 +352,7 @@ static ssize_t adt7316_store_mode(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(mode, 0644,
adt7316_show_mode,
adt7316_store_mode,
0);
@@ -364,7 +364,7 @@ static ssize_t adt7316_show_all_modes(struct device *dev,
return sprintf(buf, "single_channel\nround_robin\n");
 }
 
-static IIO_DEVICE_ATTR(all_modes, S_IRUGO, adt7316_show_all_modes, NULL, 0);
+static IIO_DEVICE_ATTR(all_modes, 0444, adt7316_show_all_modes, NULL, 0);
 
 static ssize_t adt7316_show_ad_channel(struct device *dev,
struct device_attribute *attr,
@@ -446,7 +446,7 @@ static ssize_t adt7316_store_ad_channel(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(ad_channel, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(ad_channel, 0644,
adt7316_show_ad_channel,
adt7316_store_ad_channel,
0);
@@ -469,7 +469,7 @@ static ssize_t adt7316_show_all_ad_channels(struct device 
*dev,
"2 - External Temperature\n");
 }
 
-static IIO_DEVICE_ATTR(all_ad_channels, S_IRUGO,
+static IIO_DEVICE_ATTR(all_ad_channels, 0444,
adt7316_show_all_ad_channels, NULL, 0);
 
 static ssize_t adt7316_show_disable_averaging(struct device *dev,
@@ -506,7 +506,7 @@ static ssize_t adt7316_store_disable_averaging(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(disable_averaging, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(disable_averaging, 0644,
adt7316_show_disable_averaging,
adt7316_store_disable_averaging,
0);
@@ -545,7 +545,7 @@ static ssize_t adt7316_store_enable_smbus_timeout(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enable_smbus_timeout, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(enable_smbus_timeout, 0644,
adt7316_show_enable_smbus_timeout,
adt7316_store_enable_smbus_timeout,
0);
@@ -583,7 +583,7 @@ static ssize_t adt7316_store_powerdown(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(powerdown, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(powerdown, 0644,
adt7316_show_powerdown,
adt7316_store_powerdown,
0);
@@ -621,7 +621,7 @@ static ssize_t adt7316_store_fast_ad_clock(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(fast_ad_clock, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(fast_ad_clock, 0644,
adt7316_show_fast_ad_clock,
adt7316_store_fast_ad_clock,
0);
@@ -674,7 +674,7 @@ static ssize_t adt7316_store_da_high_resolution(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(da_high_resolution, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(da_high_resolution, 0644,
adt7316_show_da_high_resolution,
adt7316_store_da_high_resolution,
0);
@@ -720,7 +720,7 @@ static ssize_t adt7316_store_AIN_internal_Vref(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(AIN_internal_Vref, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(AIN_internal_Vref, 0644,
adt7316_show_AIN_internal_Vref,
adt7316_store_AIN_internal_Vref,
0);
@@ -760,7 +760,7 @@ static ssize_t adt7316_store_enable_prop_DACA(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enable_proportion_DACA, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(enable_proportion_DACA, 0644,
adt7316_show_enable_prop_DACA,
adt7316_store_enable_prop_DACA,
0);
@@ -799,7 +799,7 @@ static ssize_t adt7316_store_enable_prop_DACB(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enable_proportion_DACB, S_IRUGO | S_IWUSR,
+static 

[PATCH] Staging: iio: addac - fixed octal file permissions

2017-03-04 Thread Derek Robson
Changed file permission to octal style.
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/iio/addac/adt7316.c | 108 ++--
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/iio/addac/adt7316.c 
b/drivers/staging/iio/addac/adt7316.c
index 6054c7298fce..aa251c245981 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -267,7 +267,7 @@ static ssize_t adt7316_store_enabled(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(enabled, 0644,
adt7316_show_enabled,
adt7316_store_enabled,
0);
@@ -311,7 +311,7 @@ static ssize_t adt7316_store_select_ex_temp(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(select_ex_temp, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(select_ex_temp, 0644,
adt7316_show_select_ex_temp,
adt7316_store_select_ex_temp,
0);
@@ -352,7 +352,7 @@ static ssize_t adt7316_store_mode(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(mode, 0644,
adt7316_show_mode,
adt7316_store_mode,
0);
@@ -364,7 +364,7 @@ static ssize_t adt7316_show_all_modes(struct device *dev,
return sprintf(buf, "single_channel\nround_robin\n");
 }
 
-static IIO_DEVICE_ATTR(all_modes, S_IRUGO, adt7316_show_all_modes, NULL, 0);
+static IIO_DEVICE_ATTR(all_modes, 0444, adt7316_show_all_modes, NULL, 0);
 
 static ssize_t adt7316_show_ad_channel(struct device *dev,
struct device_attribute *attr,
@@ -446,7 +446,7 @@ static ssize_t adt7316_store_ad_channel(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(ad_channel, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(ad_channel, 0644,
adt7316_show_ad_channel,
adt7316_store_ad_channel,
0);
@@ -469,7 +469,7 @@ static ssize_t adt7316_show_all_ad_channels(struct device 
*dev,
"2 - External Temperature\n");
 }
 
-static IIO_DEVICE_ATTR(all_ad_channels, S_IRUGO,
+static IIO_DEVICE_ATTR(all_ad_channels, 0444,
adt7316_show_all_ad_channels, NULL, 0);
 
 static ssize_t adt7316_show_disable_averaging(struct device *dev,
@@ -506,7 +506,7 @@ static ssize_t adt7316_store_disable_averaging(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(disable_averaging, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(disable_averaging, 0644,
adt7316_show_disable_averaging,
adt7316_store_disable_averaging,
0);
@@ -545,7 +545,7 @@ static ssize_t adt7316_store_enable_smbus_timeout(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enable_smbus_timeout, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(enable_smbus_timeout, 0644,
adt7316_show_enable_smbus_timeout,
adt7316_store_enable_smbus_timeout,
0);
@@ -583,7 +583,7 @@ static ssize_t adt7316_store_powerdown(struct device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(powerdown, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(powerdown, 0644,
adt7316_show_powerdown,
adt7316_store_powerdown,
0);
@@ -621,7 +621,7 @@ static ssize_t adt7316_store_fast_ad_clock(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(fast_ad_clock, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(fast_ad_clock, 0644,
adt7316_show_fast_ad_clock,
adt7316_store_fast_ad_clock,
0);
@@ -674,7 +674,7 @@ static ssize_t adt7316_store_da_high_resolution(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(da_high_resolution, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(da_high_resolution, 0644,
adt7316_show_da_high_resolution,
adt7316_store_da_high_resolution,
0);
@@ -720,7 +720,7 @@ static ssize_t adt7316_store_AIN_internal_Vref(struct 
device *dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(AIN_internal_Vref, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(AIN_internal_Vref, 0644,
adt7316_show_AIN_internal_Vref,
adt7316_store_AIN_internal_Vref,
0);
@@ -760,7 +760,7 @@ static ssize_t adt7316_store_enable_prop_DACA(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enable_proportion_DACA, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(enable_proportion_DACA, 0644,
adt7316_show_enable_prop_DACA,
adt7316_store_enable_prop_DACA,
0);
@@ -799,7 +799,7 @@ static ssize_t adt7316_store_enable_prop_DACB(struct device 
*dev,
return len;
 }
 
-static IIO_DEVICE_ATTR(enable_proportion_DACB, S_IRUGO | S_IWUSR,
+static IIO_DEVICE_ATTR(enable_proportion_DACB, 0644,
  

[PATCH] staging: media: Remove unnecessary function and its call

2017-03-04 Thread simran singhal
The function atomisp_set_stop_timeout on being called, simply returns
back. The function hasn't been mentioned in the TODO and doesn't have
FIXME code around. Hence, atomisp_set_stop_timeout and its calls have been
removed.

Signed-off-by: simran singhal 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c  | 1 -
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h   | 1 -
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c | 5 -
 3 files changed, 7 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index e99f7b8..66299dd 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -1700,7 +1700,6 @@ void atomisp_wdt_work(struct work_struct *work)
}
}
 #endif
-   atomisp_set_stop_timeout(ATOMISP_CSS_STOP_TIMEOUT_US);
dev_err(isp->dev, "timeout recovery handling done\n");
atomic_set(>wdt_work_queued, 0);
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h
index 5a404e4..0b9ced5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h
@@ -660,7 +660,6 @@ int atomisp_css_set_acc_parameters(struct atomisp_acc_fw 
*acc_fw);
 int atomisp_css_isr_thread(struct atomisp_device *isp,
   bool *frame_done_found,
   bool *css_pipe_done);
-void atomisp_set_stop_timeout(unsigned int timeout);
 
 bool atomisp_css_valid_sof(struct atomisp_device *isp);
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index 6697d72..cfa0ad4 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -4699,11 +4699,6 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
return 0;
 }
 
-void atomisp_set_stop_timeout(unsigned int timeout)
-{
-   return;
-}
-
 bool atomisp_css_valid_sof(struct atomisp_device *isp)
 {
unsigned int i, j;
-- 
2.7.4



[PATCH] staging: media: Remove unnecessary function and its call

2017-03-04 Thread simran singhal
The function atomisp_set_stop_timeout on being called, simply returns
back. The function hasn't been mentioned in the TODO and doesn't have
FIXME code around. Hence, atomisp_set_stop_timeout and its calls have been
removed.

Signed-off-by: simran singhal 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c  | 1 -
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h   | 1 -
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c | 5 -
 3 files changed, 7 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index e99f7b8..66299dd 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -1700,7 +1700,6 @@ void atomisp_wdt_work(struct work_struct *work)
}
}
 #endif
-   atomisp_set_stop_timeout(ATOMISP_CSS_STOP_TIMEOUT_US);
dev_err(isp->dev, "timeout recovery handling done\n");
atomic_set(>wdt_work_queued, 0);
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h
index 5a404e4..0b9ced5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h
@@ -660,7 +660,6 @@ int atomisp_css_set_acc_parameters(struct atomisp_acc_fw 
*acc_fw);
 int atomisp_css_isr_thread(struct atomisp_device *isp,
   bool *frame_done_found,
   bool *css_pipe_done);
-void atomisp_set_stop_timeout(unsigned int timeout);
 
 bool atomisp_css_valid_sof(struct atomisp_device *isp);
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index 6697d72..cfa0ad4 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -4699,11 +4699,6 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
return 0;
 }
 
-void atomisp_set_stop_timeout(unsigned int timeout)
-{
-   return;
-}
-
 bool atomisp_css_valid_sof(struct atomisp_device *isp)
 {
unsigned int i, j;
-- 
2.7.4



Re: [PATCHv2 05/10] drm: omapdrm: crtc: detect manually updated displays

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> Signed-off-by: Sebastian Reichel 
> [t...@atomide.com: rebased on event_lock changes]

So for this feel free to add:

Tested-by: Tony Lindgren 
Signed-off-by: Tony Lindgren 


Re: [PATCHv2 05/10] drm: omapdrm: crtc: detect manually updated displays

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> Signed-off-by: Sebastian Reichel 
> [t...@atomide.com: rebased on event_lock changes]

So for this feel free to add:

Tested-by: Tony Lindgren 
Signed-off-by: Tony Lindgren 


Re: [PATCHv2 04/10] drm: omapdrm: crtc: save framedone callback from dss

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> Save the framedone callback supplied by dss for later
> usage.
> 
> Signed-off-by: Sebastian Reichel 

Tested-by: Tony Lindgren 


Re: [PATCHv2 04/10] drm: omapdrm: crtc: save framedone callback from dss

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> Save the framedone callback supplied by dss for later
> usage.
> 
> Signed-off-by: Sebastian Reichel 

Tested-by: Tony Lindgren 


Re: [PATCHv2 09/10] drm: omapdrm: crtc: get manual mode displays working

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> From: Tony Lindgren 
> 
> With manual mode displays we need to flush the panel manually.
> 
> Let's add flushing so we get Tomi's fbtest, kmstest, kmstest --flip,
> and X and wayland working.
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -97,6 +97,11 @@ bool omap_crtc_is_manual_updated(struct drm_crtc *crtc)
>   return omap_crtc->manually_updated;
>  }
>  
> +static void omap_crtc_manual_needs_flush(struct drm_crtc *crtc)
> +{
> + omap_crtc_flush(crtc, 0, 0, 0, 0);
> +}
...

> @@ -554,6 +561,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>   ret = drm_crtc_vblank_get(crtc);
>   WARN_ON(ret != 0);
>   }
> + omap_crtc_flush(_crtc->base, 0, 0, 0, 0);

Just noticed that this should also just use omap_crtc_manual_needs_flush()
here if you care to update it.

Regards,

Tony


Re: [PATCHv2 02/10] drm: omapdrm: panel-dsi-cm: add regulator support

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> The N950's display requires two regulators.

Also needed for droid 4:

Tested-by: Tony Lindgren 


Re: [PATCHv2 09/10] drm: omapdrm: crtc: get manual mode displays working

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> From: Tony Lindgren 
> 
> With manual mode displays we need to flush the panel manually.
> 
> Let's add flushing so we get Tomi's fbtest, kmstest, kmstest --flip,
> and X and wayland working.
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -97,6 +97,11 @@ bool omap_crtc_is_manual_updated(struct drm_crtc *crtc)
>   return omap_crtc->manually_updated;
>  }
>  
> +static void omap_crtc_manual_needs_flush(struct drm_crtc *crtc)
> +{
> + omap_crtc_flush(crtc, 0, 0, 0, 0);
> +}
...

> @@ -554,6 +561,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>   ret = drm_crtc_vblank_get(crtc);
>   WARN_ON(ret != 0);
>   }
> + omap_crtc_flush(_crtc->base, 0, 0, 0, 0);

Just noticed that this should also just use omap_crtc_manual_needs_flush()
here if you care to update it.

Regards,

Tony


Re: [PATCHv2 02/10] drm: omapdrm: panel-dsi-cm: add regulator support

2017-03-04 Thread Tony Lindgren
* Sebastian Reichel  [170304 16:45]:
> The N950's display requires two regulators.

Also needed for droid 4:

Tested-by: Tony Lindgren 


Re: [Outreachy kernel] [PATCH v3 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread Alison Schofield
On Sun, Mar 05, 2017 at 10:35:33AM +0530, simran singhal wrote:
> This patch fixes the following sparse warnings:
> 
> drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in assignment 
> (different base types)
> drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
> [unsigned] [long] [long long] [usertype] 
> drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 [usertype] 
> 
> 
> Signed-off-by: simran singhal 
> ---
>  
>  v3:
>-Change commit message
>-Drop the changes did in fbtft-bus.c

Hi Simran, 

Sorry, I didn't mean to drop the broken part of fbtft, but rather to fix it.

Let's tidy up a few things:
- we can't send out one patch labelled as part of a patchset without
  resending the entire set.  That's why I was suggesting just abandoning
  the patchset, and beginning to rework this anew with only the fbtft
  driver in a single patch.
- I suggest keeping the -bus and -io file changes together.
- Look to correct what is wrong with fbtft-bus.c before sending a new
  patch.
- Patch Subject would be something like: use __be64 types for endian
  correctness (if this is what you end up doing - hint)

So, next step,
1) read up on endianess and propose how to change -bus.c.
   OK to check that idea/code snippet here without re-rolling the patch.

   https://kernelnewbies.org/EndianIssues
   and Vaishali also gave a good link to lwn.net article
   and to see some example fixes (in iio subsystem) do this:
git log --pretty=oneline --abbrev-commit | grep iio | grep endian


2) build the patch.  At this point I say make it a first version and
   start totally fresh.  However, below the line --- where you usually
   put the version comments, you can add a comment stating that this
   was previously part of a patchset, but is now a single patch.
  
alisons


>   
>  drivers/staging/fbtft/fbtft-io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/fbtft/fbtft-io.c 
> b/drivers/staging/fbtft/fbtft-io.c
> index d868405..ffb9a3b 100644
> --- a/drivers/staging/fbtft/fbtft-io.c
> +++ b/drivers/staging/fbtft/fbtft-io.c
> @@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void 
> *buf, size_t len)
>   src++;
>   }
>   tmp |= ((*src & 0x0100) ? 1 : 0);
> - *(u64 *)dst = cpu_to_be64(tmp);
> + *(__be64 *)dst = cpu_to_be64(tmp);
>   dst += 8;
>   *dst++ = (u8)(*src++ & 0x00FF);
>   added++;
> -- 
> 2.7.4
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/20170305050533.GA10169%40singhal-Inspiron-5558.
> For more options, visit https://groups.google.com/d/optout.


Re: [Outreachy kernel] [PATCH v3 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread Alison Schofield
On Sun, Mar 05, 2017 at 10:35:33AM +0530, simran singhal wrote:
> This patch fixes the following sparse warnings:
> 
> drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in assignment 
> (different base types)
> drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
> [unsigned] [long] [long long] [usertype] 
> drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 [usertype] 
> 
> 
> Signed-off-by: simran singhal 
> ---
>  
>  v3:
>-Change commit message
>-Drop the changes did in fbtft-bus.c

Hi Simran, 

Sorry, I didn't mean to drop the broken part of fbtft, but rather to fix it.

Let's tidy up a few things:
- we can't send out one patch labelled as part of a patchset without
  resending the entire set.  That's why I was suggesting just abandoning
  the patchset, and beginning to rework this anew with only the fbtft
  driver in a single patch.
- I suggest keeping the -bus and -io file changes together.
- Look to correct what is wrong with fbtft-bus.c before sending a new
  patch.
- Patch Subject would be something like: use __be64 types for endian
  correctness (if this is what you end up doing - hint)

So, next step,
1) read up on endianess and propose how to change -bus.c.
   OK to check that idea/code snippet here without re-rolling the patch.

   https://kernelnewbies.org/EndianIssues
   and Vaishali also gave a good link to lwn.net article
   and to see some example fixes (in iio subsystem) do this:
git log --pretty=oneline --abbrev-commit | grep iio | grep endian


2) build the patch.  At this point I say make it a first version and
   start totally fresh.  However, below the line --- where you usually
   put the version comments, you can add a comment stating that this
   was previously part of a patchset, but is now a single patch.
  
alisons


>   
>  drivers/staging/fbtft/fbtft-io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/fbtft/fbtft-io.c 
> b/drivers/staging/fbtft/fbtft-io.c
> index d868405..ffb9a3b 100644
> --- a/drivers/staging/fbtft/fbtft-io.c
> +++ b/drivers/staging/fbtft/fbtft-io.c
> @@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void 
> *buf, size_t len)
>   src++;
>   }
>   tmp |= ((*src & 0x0100) ? 1 : 0);
> - *(u64 *)dst = cpu_to_be64(tmp);
> + *(__be64 *)dst = cpu_to_be64(tmp);
>   dst += 8;
>   *dst++ = (u8)(*src++ & 0x00FF);
>   added++;
> -- 
> 2.7.4
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/20170305050533.GA10169%40singhal-Inspiron-5558.
> For more options, visit https://groups.google.com/d/optout.


[PATCH v3 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread simran singhal
This patch fixes the following sparse warnings:

drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in assignment 
(different base types)
drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
[unsigned] [long] [long long] [usertype] 
drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 [usertype] 


Signed-off-by: simran singhal 
---
 
 v3:
   -Change commit message
   -Drop the changes did in fbtft-bus.c
  
 drivers/staging/fbtft/fbtft-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fbtft-io.c b/drivers/staging/fbtft/fbtft-io.c
index d868405..ffb9a3b 100644
--- a/drivers/staging/fbtft/fbtft-io.c
+++ b/drivers/staging/fbtft/fbtft-io.c
@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void 
*buf, size_t len)
src++;
}
tmp |= ((*src & 0x0100) ? 1 : 0);
-   *(u64 *)dst = cpu_to_be64(tmp);
+   *(__be64 *)dst = cpu_to_be64(tmp);
dst += 8;
*dst++ = (u8)(*src++ & 0x00FF);
added++;
-- 
2.7.4



[PATCH v3 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread simran singhal
This patch fixes the following sparse warnings:

drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in assignment 
(different base types)
drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
[unsigned] [long] [long long] [usertype] 
drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 [usertype] 


Signed-off-by: simran singhal 
---
 
 v3:
   -Change commit message
   -Drop the changes did in fbtft-bus.c
  
 drivers/staging/fbtft/fbtft-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fbtft-io.c b/drivers/staging/fbtft/fbtft-io.c
index d868405..ffb9a3b 100644
--- a/drivers/staging/fbtft/fbtft-io.c
+++ b/drivers/staging/fbtft/fbtft-io.c
@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void 
*buf, size_t len)
src++;
}
tmp |= ((*src & 0x0100) ? 1 : 0);
-   *(u64 *)dst = cpu_to_be64(tmp);
+   *(__be64 *)dst = cpu_to_be64(tmp);
dst += 8;
*dst++ = (u8)(*src++ & 0x00FF);
added++;
-- 
2.7.4



Re: Question Regarding ERMS memcpy

2017-03-04 Thread Logan Gunthorpe
Hey,

On 04/03/17 05:33 PM, Borislav Petkov wrote:
> On Sat, Mar 04, 2017 at 04:23:17PM -0800, h...@zytor.com wrote:
>> What are the compilation flags? It may be that gcc still does TRT
>> depending on this call site. I'd check what gcc6 or 7 generates,
>> though.
> Hmm, I wish we were able to say, "let gcc decide for small sizes and let
> us do the patching for larger ones."

So, I've found that my kernel config had the OPTIMIZE_FOR_SIZE selected
instead of OPTIMIZE_FOR_PERFORMANCE. I'm not sure why that is but
switching to the latter option fixes my problem. A memcpy call is used
instead of the poor inline solution. (I'm not really sure how the inline
solution even makes any sense as it almost certainly makes things larger
in the grand scheme of things.)

It still might make sense to apply your patch asking gcc to never use
the broken memcpy but I'll leave that in your capable hands to decide.

Anyway, thanks for the help with this.

Logan


Re: Question Regarding ERMS memcpy

2017-03-04 Thread Logan Gunthorpe
Hey,

On 04/03/17 05:33 PM, Borislav Petkov wrote:
> On Sat, Mar 04, 2017 at 04:23:17PM -0800, h...@zytor.com wrote:
>> What are the compilation flags? It may be that gcc still does TRT
>> depending on this call site. I'd check what gcc6 or 7 generates,
>> though.
> Hmm, I wish we were able to say, "let gcc decide for small sizes and let
> us do the patching for larger ones."

So, I've found that my kernel config had the OPTIMIZE_FOR_SIZE selected
instead of OPTIMIZE_FOR_PERFORMANCE. I'm not sure why that is but
switching to the latter option fixes my problem. A memcpy call is used
instead of the poor inline solution. (I'm not really sure how the inline
solution even makes any sense as it almost certainly makes things larger
in the grand scheme of things.)

It still might make sense to apply your patch asking gcc to never use
the broken memcpy but I'll leave that in your capable hands to decide.

Anyway, thanks for the help with this.

Logan


Re: [Outreachy kernel] Re: [PATCH v2 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread Vaishali Thakkar
On Sun, Mar 5, 2017 at 10:10 AM, SIMRAN SINGHAL
 wrote:
> On Sun, Mar 5, 2017 at 5:36 AM, Alison Schofield  wrote:
>> On Thu, Mar 02, 2017 at 02:26:37PM +0100, Noralf Trønnes wrote:
>>>
>>> Den 02.03.2017 14.04, skrev simran singhal:
>>> >This patch fixes the following sparse warnings:
>>> >
>>> >drivers/staging/fbtft/fbtft-bus.c:166:36: warning: incorrect type in 
>>> >assignment (different base types)
>>> >drivers/staging/fbtft/fbtft-bus.c:166:36:expected unsigned short 
>>> >[unsigned] [short] [usertype] 
>>> >drivers/staging/fbtft/fbtft-bus.c:166:36:got restricted __be16 
>>> >[usertype] 
>>> >
>>> >drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in 
>>> >assignment (different base types)
>>> >drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
>>> >[unsigned] [long] [long long] [usertype] 
>>> >drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 
>>> >[usertype] 
>>> >
>>> >Signed-off-by: simran singhal 
>>> >---
>>> >  v2:
>>> >-changed commit message
>>> >
>>> >  drivers/staging/fbtft/fbtft-bus.c | 2 +-
>>> >  drivers/staging/fbtft/fbtft-io.c  | 2 +-
>>> >  2 files changed, 2 insertions(+), 2 deletions(-)
>>> >
>>> >diff --git a/drivers/staging/fbtft/fbtft-bus.c 
>>> >b/drivers/staging/fbtft/fbtft-bus.c
>>> >index ec45043..df2223e 100644
>>> >--- a/drivers/staging/fbtft/fbtft-bus.c
>>> >+++ b/drivers/staging/fbtft/fbtft-bus.c
>>> >@@ -163,7 +163,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, 
>>> >size_t offset, size_t len)
>>> > to_copy, remain - to_copy);
>>> > for (i = 0; i < to_copy; i++)
>>> >-txbuf16[i] = cpu_to_be16(vmem16[i]);
>>> >+txbuf16[i] = vmem16[i];
>>>
>>> This change breaks functionality on little endian machines like
>>> the Raspberry Pi.
>>>
>>>
>>> Noralf.
>>>
>>
>> Hi Simran,
>>
>> It's probably good to get back to this one while we have Noralf's
>> attention.
>>
>> While the change above - in fbtft-bus.c is a problem, the change
>> below in fbtft-io.c looks ok.  So, compare what you did.  You can't
>> *not* do the endian conversion.
>>
>> This is a cleanup change, a cosmetic change.  There is no underlying
>> bug, so you just need to get the typing correct w/out affecting
>> behavior.
>> anyway.
>>
>> BTW: I think it's OK to pull this one out and send a v3 of this alone.
>> That would mean abandoning the patchset and doing them one at a time.
>> They are all in different drivers
>
> Hi alison,
>
> Thanks for the explaination.
>
> I will drop the changes I did in fbtft-bus.c and send a v3 of this alone.
>
> Can you please suggest me any source through which I can understand the
> concept of endianess. As right know I didn't understand it, I just
> tried to fix the
> warnings which I got through sparse and as you can see most of the fixes are
> wrong.
>
> Thanks!
> Simran
>

Hi Simran,

I would suggest to have a look at thie LWN article[1]. It is pretty old
article but explains very well on the concept of why these annotations
[__le16, __le32 etc] were introduced at first place and how Sparse
gives warnings based on these annotations.

In addition, you should look at the definitions of byte ordering macros.
For example, in this example we have 'cpu_to_be64' then you can go
and look at the definition of that macro see where they are used and
why they are used in the first place.

Thanks.

[1] https://lwn.net/Articles/205624/

>
>> alisons
>
>>
>>
>>
>>> > vmem16 = vmem16 + to_copy;
>>> > ret = par->fbtftops.write(par, par->txbuf.buf,
>>> >diff --git a/drivers/staging/fbtft/fbtft-io.c 
>>> >b/drivers/staging/fbtft/fbtft-io.c
>>> >index d868405..ffb9a3b 100644
>>> >--- a/drivers/staging/fbtft/fbtft-io.c
>>> >+++ b/drivers/staging/fbtft/fbtft-io.c
>>> >@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, 
>>> >void *buf, size_t len)
>>> > src++;
>>> > }
>>> > tmp |= ((*src & 0x0100) ? 1 : 0);
>>> >-*(u64 *)dst = cpu_to_be64(tmp);
>>> >+*(__be64 *)dst = cpu_to_be64(tmp);
>>> > dst += 8;
>>> > *dst++ = (u8)(*src++ & 0x00FF);
>>> > added++;
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "outreachy-kernel" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to outreachy-kernel+unsubscr...@googlegroups.com.
>>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/outreachy-kernel/fe8d6a85-3d4e-8019-937b-22389b942da3%40tronnes.org.
>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To 

Re: [Outreachy kernel] Re: [PATCH v2 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread Vaishali Thakkar
On Sun, Mar 5, 2017 at 10:10 AM, SIMRAN SINGHAL
 wrote:
> On Sun, Mar 5, 2017 at 5:36 AM, Alison Schofield  wrote:
>> On Thu, Mar 02, 2017 at 02:26:37PM +0100, Noralf Trønnes wrote:
>>>
>>> Den 02.03.2017 14.04, skrev simran singhal:
>>> >This patch fixes the following sparse warnings:
>>> >
>>> >drivers/staging/fbtft/fbtft-bus.c:166:36: warning: incorrect type in 
>>> >assignment (different base types)
>>> >drivers/staging/fbtft/fbtft-bus.c:166:36:expected unsigned short 
>>> >[unsigned] [short] [usertype] 
>>> >drivers/staging/fbtft/fbtft-bus.c:166:36:got restricted __be16 
>>> >[usertype] 
>>> >
>>> >drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in 
>>> >assignment (different base types)
>>> >drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
>>> >[unsigned] [long] [long long] [usertype] 
>>> >drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 
>>> >[usertype] 
>>> >
>>> >Signed-off-by: simran singhal 
>>> >---
>>> >  v2:
>>> >-changed commit message
>>> >
>>> >  drivers/staging/fbtft/fbtft-bus.c | 2 +-
>>> >  drivers/staging/fbtft/fbtft-io.c  | 2 +-
>>> >  2 files changed, 2 insertions(+), 2 deletions(-)
>>> >
>>> >diff --git a/drivers/staging/fbtft/fbtft-bus.c 
>>> >b/drivers/staging/fbtft/fbtft-bus.c
>>> >index ec45043..df2223e 100644
>>> >--- a/drivers/staging/fbtft/fbtft-bus.c
>>> >+++ b/drivers/staging/fbtft/fbtft-bus.c
>>> >@@ -163,7 +163,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, 
>>> >size_t offset, size_t len)
>>> > to_copy, remain - to_copy);
>>> > for (i = 0; i < to_copy; i++)
>>> >-txbuf16[i] = cpu_to_be16(vmem16[i]);
>>> >+txbuf16[i] = vmem16[i];
>>>
>>> This change breaks functionality on little endian machines like
>>> the Raspberry Pi.
>>>
>>>
>>> Noralf.
>>>
>>
>> Hi Simran,
>>
>> It's probably good to get back to this one while we have Noralf's
>> attention.
>>
>> While the change above - in fbtft-bus.c is a problem, the change
>> below in fbtft-io.c looks ok.  So, compare what you did.  You can't
>> *not* do the endian conversion.
>>
>> This is a cleanup change, a cosmetic change.  There is no underlying
>> bug, so you just need to get the typing correct w/out affecting
>> behavior.
>> anyway.
>>
>> BTW: I think it's OK to pull this one out and send a v3 of this alone.
>> That would mean abandoning the patchset and doing them one at a time.
>> They are all in different drivers
>
> Hi alison,
>
> Thanks for the explaination.
>
> I will drop the changes I did in fbtft-bus.c and send a v3 of this alone.
>
> Can you please suggest me any source through which I can understand the
> concept of endianess. As right know I didn't understand it, I just
> tried to fix the
> warnings which I got through sparse and as you can see most of the fixes are
> wrong.
>
> Thanks!
> Simran
>

Hi Simran,

I would suggest to have a look at thie LWN article[1]. It is pretty old
article but explains very well on the concept of why these annotations
[__le16, __le32 etc] were introduced at first place and how Sparse
gives warnings based on these annotations.

In addition, you should look at the definitions of byte ordering macros.
For example, in this example we have 'cpu_to_be64' then you can go
and look at the definition of that macro see where they are used and
why they are used in the first place.

Thanks.

[1] https://lwn.net/Articles/205624/

>
>> alisons
>
>>
>>
>>
>>> > vmem16 = vmem16 + to_copy;
>>> > ret = par->fbtftops.write(par, par->txbuf.buf,
>>> >diff --git a/drivers/staging/fbtft/fbtft-io.c 
>>> >b/drivers/staging/fbtft/fbtft-io.c
>>> >index d868405..ffb9a3b 100644
>>> >--- a/drivers/staging/fbtft/fbtft-io.c
>>> >+++ b/drivers/staging/fbtft/fbtft-io.c
>>> >@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, 
>>> >void *buf, size_t len)
>>> > src++;
>>> > }
>>> > tmp |= ((*src & 0x0100) ? 1 : 0);
>>> >-*(u64 *)dst = cpu_to_be64(tmp);
>>> >+*(__be64 *)dst = cpu_to_be64(tmp);
>>> > dst += 8;
>>> > *dst++ = (u8)(*src++ & 0x00FF);
>>> > added++;
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "outreachy-kernel" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to outreachy-kernel+unsubscr...@googlegroups.com.
>>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/outreachy-kernel/fe8d6a85-3d4e-8019-937b-22389b942da3%40tronnes.org.
>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to 

Re: [Outreachy kernel] Re: [PATCH v2 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread SIMRAN SINGHAL
On Sun, Mar 5, 2017 at 5:36 AM, Alison Schofield  wrote:
> On Thu, Mar 02, 2017 at 02:26:37PM +0100, Noralf Trønnes wrote:
>>
>> Den 02.03.2017 14.04, skrev simran singhal:
>> >This patch fixes the following sparse warnings:
>> >
>> >drivers/staging/fbtft/fbtft-bus.c:166:36: warning: incorrect type in 
>> >assignment (different base types)
>> >drivers/staging/fbtft/fbtft-bus.c:166:36:expected unsigned short 
>> >[unsigned] [short] [usertype] 
>> >drivers/staging/fbtft/fbtft-bus.c:166:36:got restricted __be16 
>> >[usertype] 
>> >
>> >drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in 
>> >assignment (different base types)
>> >drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
>> >[unsigned] [long] [long long] [usertype] 
>> >drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 [usertype] 
>> >
>> >
>> >Signed-off-by: simran singhal 
>> >---
>> >  v2:
>> >-changed commit message
>> >
>> >  drivers/staging/fbtft/fbtft-bus.c | 2 +-
>> >  drivers/staging/fbtft/fbtft-io.c  | 2 +-
>> >  2 files changed, 2 insertions(+), 2 deletions(-)
>> >
>> >diff --git a/drivers/staging/fbtft/fbtft-bus.c 
>> >b/drivers/staging/fbtft/fbtft-bus.c
>> >index ec45043..df2223e 100644
>> >--- a/drivers/staging/fbtft/fbtft-bus.c
>> >+++ b/drivers/staging/fbtft/fbtft-bus.c
>> >@@ -163,7 +163,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, 
>> >size_t offset, size_t len)
>> > to_copy, remain - to_copy);
>> > for (i = 0; i < to_copy; i++)
>> >-txbuf16[i] = cpu_to_be16(vmem16[i]);
>> >+txbuf16[i] = vmem16[i];
>>
>> This change breaks functionality on little endian machines like
>> the Raspberry Pi.
>>
>>
>> Noralf.
>>
>
> Hi Simran,
>
> It's probably good to get back to this one while we have Noralf's
> attention.
>
> While the change above - in fbtft-bus.c is a problem, the change
> below in fbtft-io.c looks ok.  So, compare what you did.  You can't
> *not* do the endian conversion.
>
> This is a cleanup change, a cosmetic change.  There is no underlying
> bug, so you just need to get the typing correct w/out affecting
> behavior.
> anyway.
>
> BTW: I think it's OK to pull this one out and send a v3 of this alone.
> That would mean abandoning the patchset and doing them one at a time.
> They are all in different drivers

Hi alison,

Thanks for the explaination.

I will drop the changes I did in fbtft-bus.c and send a v3 of this alone.

Can you please suggest me any source through which I can understand the
concept of endianess. As right know I didn't understand it, I just
tried to fix the
warnings which I got through sparse and as you can see most of the fixes are
wrong.

Thanks!
Simran



> alisons

>
>
>
>> > vmem16 = vmem16 + to_copy;
>> > ret = par->fbtftops.write(par, par->txbuf.buf,
>> >diff --git a/drivers/staging/fbtft/fbtft-io.c 
>> >b/drivers/staging/fbtft/fbtft-io.c
>> >index d868405..ffb9a3b 100644
>> >--- a/drivers/staging/fbtft/fbtft-io.c
>> >+++ b/drivers/staging/fbtft/fbtft-io.c
>> >@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void 
>> >*buf, size_t len)
>> > src++;
>> > }
>> > tmp |= ((*src & 0x0100) ? 1 : 0);
>> >-*(u64 *)dst = cpu_to_be64(tmp);
>> >+*(__be64 *)dst = cpu_to_be64(tmp);
>> > dst += 8;
>> > *dst++ = (u8)(*src++ & 0x00FF);
>> > added++;
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/fe8d6a85-3d4e-8019-937b-22389b942da3%40tronnes.org.
>> For more options, visit https://groups.google.com/d/optout.


Re: [Outreachy kernel] Re: [PATCH v2 4/6] staging: fbtft: Fix sparse warnings of incorrect type in assignment

2017-03-04 Thread SIMRAN SINGHAL
On Sun, Mar 5, 2017 at 5:36 AM, Alison Schofield  wrote:
> On Thu, Mar 02, 2017 at 02:26:37PM +0100, Noralf Trønnes wrote:
>>
>> Den 02.03.2017 14.04, skrev simran singhal:
>> >This patch fixes the following sparse warnings:
>> >
>> >drivers/staging/fbtft/fbtft-bus.c:166:36: warning: incorrect type in 
>> >assignment (different base types)
>> >drivers/staging/fbtft/fbtft-bus.c:166:36:expected unsigned short 
>> >[unsigned] [short] [usertype] 
>> >drivers/staging/fbtft/fbtft-bus.c:166:36:got restricted __be16 
>> >[usertype] 
>> >
>> >drivers/staging/fbtft/fbtft-io.c:74:29: warning: incorrect type in 
>> >assignment (different base types)
>> >drivers/staging/fbtft/fbtft-io.c:74:29:expected unsigned long long 
>> >[unsigned] [long] [long long] [usertype] 
>> >drivers/staging/fbtft/fbtft-io.c:74:29:got restricted __be64 [usertype] 
>> >
>> >
>> >Signed-off-by: simran singhal 
>> >---
>> >  v2:
>> >-changed commit message
>> >
>> >  drivers/staging/fbtft/fbtft-bus.c | 2 +-
>> >  drivers/staging/fbtft/fbtft-io.c  | 2 +-
>> >  2 files changed, 2 insertions(+), 2 deletions(-)
>> >
>> >diff --git a/drivers/staging/fbtft/fbtft-bus.c 
>> >b/drivers/staging/fbtft/fbtft-bus.c
>> >index ec45043..df2223e 100644
>> >--- a/drivers/staging/fbtft/fbtft-bus.c
>> >+++ b/drivers/staging/fbtft/fbtft-bus.c
>> >@@ -163,7 +163,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, 
>> >size_t offset, size_t len)
>> > to_copy, remain - to_copy);
>> > for (i = 0; i < to_copy; i++)
>> >-txbuf16[i] = cpu_to_be16(vmem16[i]);
>> >+txbuf16[i] = vmem16[i];
>>
>> This change breaks functionality on little endian machines like
>> the Raspberry Pi.
>>
>>
>> Noralf.
>>
>
> Hi Simran,
>
> It's probably good to get back to this one while we have Noralf's
> attention.
>
> While the change above - in fbtft-bus.c is a problem, the change
> below in fbtft-io.c looks ok.  So, compare what you did.  You can't
> *not* do the endian conversion.
>
> This is a cleanup change, a cosmetic change.  There is no underlying
> bug, so you just need to get the typing correct w/out affecting
> behavior.
> anyway.
>
> BTW: I think it's OK to pull this one out and send a v3 of this alone.
> That would mean abandoning the patchset and doing them one at a time.
> They are all in different drivers

Hi alison,

Thanks for the explaination.

I will drop the changes I did in fbtft-bus.c and send a v3 of this alone.

Can you please suggest me any source through which I can understand the
concept of endianess. As right know I didn't understand it, I just
tried to fix the
warnings which I got through sparse and as you can see most of the fixes are
wrong.

Thanks!
Simran



> alisons

>
>
>
>> > vmem16 = vmem16 + to_copy;
>> > ret = par->fbtftops.write(par, par->txbuf.buf,
>> >diff --git a/drivers/staging/fbtft/fbtft-io.c 
>> >b/drivers/staging/fbtft/fbtft-io.c
>> >index d868405..ffb9a3b 100644
>> >--- a/drivers/staging/fbtft/fbtft-io.c
>> >+++ b/drivers/staging/fbtft/fbtft-io.c
>> >@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void 
>> >*buf, size_t len)
>> > src++;
>> > }
>> > tmp |= ((*src & 0x0100) ? 1 : 0);
>> >-*(u64 *)dst = cpu_to_be64(tmp);
>> >+*(__be64 *)dst = cpu_to_be64(tmp);
>> > dst += 8;
>> > *dst++ = (u8)(*src++ & 0x00FF);
>> > added++;
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/fe8d6a85-3d4e-8019-937b-22389b942da3%40tronnes.org.
>> For more options, visit https://groups.google.com/d/optout.


Re: [PATCH v5 06/13] lockdep: Implement crossrelease feature

2017-03-04 Thread Byungchul Park
On Fri, Mar 03, 2017 at 10:13:38AM +0100, Peter Zijlstra wrote:
> On Fri, Mar 03, 2017 at 09:14:16AM +0100, Peter Zijlstra wrote:
> 
> Two boots + a make defconfig, the first didn't have the redundant bit
> in, the second did (full diff below still includes the reclaim rework,
> because that was still in that kernel and I forgot to reset the tree).
> 
> 
>  lock-classes: 1168   1169 [max: 8191]
>  direct dependencies:  7688   5812 [max: 32768]
>  indirect dependencies:   25492  25937
>  all direct dependencies:220113 217512
>  dependency chains:9005   9008 [max: 65536]
>  dependency chain hlocks: 34450  34366 [max: 327680]
>  in-hardirq chains:  55 51
>  in-softirq chains: 371378
>  in-process chains:8579   8579
>  stack-trace entries:108073  88474 [max: 524288]
>  combined max dependencies:   178738560  169094640
> 
>  max locking depth:  15 15
>  max bfs queue depth:   320329
> 
>  cyclic checks:9123   9190
> 
>  redundant checks:5046
>  redundant links: 1828
> 
>  find-mask forwards checks:2564   2599
>  find-mask backwards checks:  39521  39789
> 
> 
> So it saves nearly 2k links and a fair chunk of stack-trace entries, but

It's as we expect.

> as expected, makes no real difference on the indirect dependencies.

It looks that the indirect dependencies increased to me. This result is
also somewhat anticipated.

> At the same time, you see the max BFS depth increase, which is also

Yes. The depth should increase.

> expected, although it could easily be boot variance -- these numbers are
> not entirely stable between boots.
> 
> Could you run something similar? Or I'll take a look on your next spin
> of the patches.

I will check same thing you did and let you know the result at next spin.



Re: [PATCH v5 06/13] lockdep: Implement crossrelease feature

2017-03-04 Thread Byungchul Park
On Fri, Mar 03, 2017 at 10:13:38AM +0100, Peter Zijlstra wrote:
> On Fri, Mar 03, 2017 at 09:14:16AM +0100, Peter Zijlstra wrote:
> 
> Two boots + a make defconfig, the first didn't have the redundant bit
> in, the second did (full diff below still includes the reclaim rework,
> because that was still in that kernel and I forgot to reset the tree).
> 
> 
>  lock-classes: 1168   1169 [max: 8191]
>  direct dependencies:  7688   5812 [max: 32768]
>  indirect dependencies:   25492  25937
>  all direct dependencies:220113 217512
>  dependency chains:9005   9008 [max: 65536]
>  dependency chain hlocks: 34450  34366 [max: 327680]
>  in-hardirq chains:  55 51
>  in-softirq chains: 371378
>  in-process chains:8579   8579
>  stack-trace entries:108073  88474 [max: 524288]
>  combined max dependencies:   178738560  169094640
> 
>  max locking depth:  15 15
>  max bfs queue depth:   320329
> 
>  cyclic checks:9123   9190
> 
>  redundant checks:5046
>  redundant links: 1828
> 
>  find-mask forwards checks:2564   2599
>  find-mask backwards checks:  39521  39789
> 
> 
> So it saves nearly 2k links and a fair chunk of stack-trace entries, but

It's as we expect.

> as expected, makes no real difference on the indirect dependencies.

It looks that the indirect dependencies increased to me. This result is
also somewhat anticipated.

> At the same time, you see the max BFS depth increase, which is also

Yes. The depth should increase.

> expected, although it could easily be boot variance -- these numbers are
> not entirely stable between boots.
> 
> Could you run something similar? Or I'll take a look on your next spin
> of the patches.

I will check same thing you did and let you know the result at next spin.



[PATCH] MIPS: reset all task's asid to 0 after asid_cache(cpu) overflows

2017-03-04 Thread Jiwei Sun
If asid_cache(cpu) overflows, there may be two tasks with the same
asid. It is a risk that the two different tasks may have the same
address space.

A process will update its asid to newer version only when switch_mm()
is called and matches the following condition:
if ((cpu_context(cpu, next) ^ asid_cache(cpu))
& asid_version_mask(cpu))
get_new_mmu_context(next, cpu);
If asid_cache(cpu) overflows, cpu_context(cpu,next) and asid_cache(cpu)
will be reset to asid_first_version(cpu), and start a new cycle. It
can result in two tasks that have the same ASID in the process list.

For example, in CONFIG_CPU_MIPS32_R2, task named A's asid on CPU1 is
0x100, and has been sleeping and been not scheduled. After a long period
of time, another running task named B's asid on CPU1 is 0x, and
asid cached in the CPU1 is 0x too, next task named C is forked,
when schedule from B to C on CPU1, asid_cache(cpu) will overflow, so C's
asid on CPU1 will be 0x100 according to get_new_mmu_context(). A's asid
is the same as C, if now A is rescheduled on CPU1, A's asid is not able
to renew according to 'if' clause, and the local TLB entry can't be
flushed too, A's address space will be the same as C.

If asid_cache(cpu) overflows, all of user space task's asid on this CPU
are able to set a invalid value (such as 0), it will avoid the risk.

Signed-off-by: Jiwei Sun 
---
 arch/mips/include/asm/mmu_context.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/mmu_context.h 
b/arch/mips/include/asm/mmu_context.h
index ddd57ad..1f60efc 100644
--- a/arch/mips/include/asm/mmu_context.h
+++ b/arch/mips/include/asm/mmu_context.h
@@ -108,8 +108,15 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, 
struct task_struct *tsk)
 #else
local_flush_tlb_all();  /* start new asid cycle */
 #endif
-   if (!asid)  /* fix version if needed */
+   if (!asid) {/* fix version if needed */
+   struct task_struct *p;
+
+   for_each_process(p) {
+   if ((p->mm))
+   cpu_context(cpu, p->mm) = 0;
+   }
asid = asid_first_version(cpu);
+   }
}
 
cpu_context(cpu, mm) = asid_cache(cpu) = asid;
-- 
1.9.1



[PATCH] MIPS: reset all task's asid to 0 after asid_cache(cpu) overflows

2017-03-04 Thread Jiwei Sun
If asid_cache(cpu) overflows, there may be two tasks with the same
asid. It is a risk that the two different tasks may have the same
address space.

A process will update its asid to newer version only when switch_mm()
is called and matches the following condition:
if ((cpu_context(cpu, next) ^ asid_cache(cpu))
& asid_version_mask(cpu))
get_new_mmu_context(next, cpu);
If asid_cache(cpu) overflows, cpu_context(cpu,next) and asid_cache(cpu)
will be reset to asid_first_version(cpu), and start a new cycle. It
can result in two tasks that have the same ASID in the process list.

For example, in CONFIG_CPU_MIPS32_R2, task named A's asid on CPU1 is
0x100, and has been sleeping and been not scheduled. After a long period
of time, another running task named B's asid on CPU1 is 0x, and
asid cached in the CPU1 is 0x too, next task named C is forked,
when schedule from B to C on CPU1, asid_cache(cpu) will overflow, so C's
asid on CPU1 will be 0x100 according to get_new_mmu_context(). A's asid
is the same as C, if now A is rescheduled on CPU1, A's asid is not able
to renew according to 'if' clause, and the local TLB entry can't be
flushed too, A's address space will be the same as C.

If asid_cache(cpu) overflows, all of user space task's asid on this CPU
are able to set a invalid value (such as 0), it will avoid the risk.

Signed-off-by: Jiwei Sun 
---
 arch/mips/include/asm/mmu_context.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/mmu_context.h 
b/arch/mips/include/asm/mmu_context.h
index ddd57ad..1f60efc 100644
--- a/arch/mips/include/asm/mmu_context.h
+++ b/arch/mips/include/asm/mmu_context.h
@@ -108,8 +108,15 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, 
struct task_struct *tsk)
 #else
local_flush_tlb_all();  /* start new asid cycle */
 #endif
-   if (!asid)  /* fix version if needed */
+   if (!asid) {/* fix version if needed */
+   struct task_struct *p;
+
+   for_each_process(p) {
+   if ((p->mm))
+   cpu_context(cpu, p->mm) = 0;
+   }
asid = asid_first_version(cpu);
+   }
}
 
cpu_context(cpu, mm) = asid_cache(cpu) = asid;
-- 
1.9.1



Re: [PATCH v5 06/13] lockdep: Implement crossrelease feature

2017-03-04 Thread Byungchul Park
On Fri, Mar 03, 2017 at 09:14:16AM +0100, Peter Zijlstra wrote:
> On Fri, Mar 03, 2017 at 09:17:37AM +0900, Byungchul Park wrote:
> > On Thu, Mar 02, 2017 at 02:40:31PM +0100, Peter Zijlstra wrote:
> 
> > > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> > > index a95e5d1..7baea89 100644
> > > --- a/kernel/locking/lockdep.c
> > > +++ b/kernel/locking/lockdep.c
> > > @@ -1860,6 +1860,17 @@ check_prev_add(struct task_struct *curr, struct 
> > > held_lock *prev,
> > >   }
> > >   }
> > >  
> > > + /*
> > > +  * Is the  ->  redundant?
> > > +  */
> > > + this.class = hlock_class(prev);
> > > + this.parent = NULL;
> > > + ret = check_noncircular(, hlock_class(next), _entry);
> > > + if (!ret) /* exists, redundant */
> > > + return 2;
> > > + if (ret < 0)
> > > + return print_bfs_bug(ret);
> > > +
> > >   if (!*stack_saved) {
> > >   if (!save_trace())
> > >   return 0;
> > 
> > This whoud be very nice if you allow to add this code. However, prev_gen_id
> > thingy is still useful, the code above can achieve it though. Agree?
> 
> So my goal was to avoid prev_gen_id, and yes I think the above does
> that.
> 
> Now the problem with the above condition is that it makes reports
> harder to decipher, because by avoiding adding redundant links to our
> graph we loose a possible shorter path.

Let's see the following example:

   A -> B -> C

   where A, B and C are typical lock class.

Assume the graph above was built and operations happena in the
following order:

   CONTEXT XCONTEXT Y
   --
   acquire DX
acquire A
acquire B
acquire C

release and commit DX

   where A, B and C are typical lock class, DX is a crosslock class.

The graph will grow as following _without_ prev_gen_id.

-> A -> B -> C
   ///
   DX ---

   where A, B and C are typical lock class, DX is a crosslock class.

The graph will grow as following _with_ prev_gen_id.

   DX -> A -> B -> C

   where A, B and C are typical lock class, DX is a crosslock class.

You said the former is better because it has smaller cost in bfs. But it
has to use _much_ more memory to keep additional nodes in graph. Without
exaggeration, every crosslock would get linked with all locks in history
locks, on commit, unless redundant. It might be pretty more than we
expect - I will check and let you know how many it is. Is it still good?



Re: [PATCH v5 06/13] lockdep: Implement crossrelease feature

2017-03-04 Thread Byungchul Park
On Fri, Mar 03, 2017 at 09:14:16AM +0100, Peter Zijlstra wrote:
> On Fri, Mar 03, 2017 at 09:17:37AM +0900, Byungchul Park wrote:
> > On Thu, Mar 02, 2017 at 02:40:31PM +0100, Peter Zijlstra wrote:
> 
> > > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> > > index a95e5d1..7baea89 100644
> > > --- a/kernel/locking/lockdep.c
> > > +++ b/kernel/locking/lockdep.c
> > > @@ -1860,6 +1860,17 @@ check_prev_add(struct task_struct *curr, struct 
> > > held_lock *prev,
> > >   }
> > >   }
> > >  
> > > + /*
> > > +  * Is the  ->  redundant?
> > > +  */
> > > + this.class = hlock_class(prev);
> > > + this.parent = NULL;
> > > + ret = check_noncircular(, hlock_class(next), _entry);
> > > + if (!ret) /* exists, redundant */
> > > + return 2;
> > > + if (ret < 0)
> > > + return print_bfs_bug(ret);
> > > +
> > >   if (!*stack_saved) {
> > >   if (!save_trace())
> > >   return 0;
> > 
> > This whoud be very nice if you allow to add this code. However, prev_gen_id
> > thingy is still useful, the code above can achieve it though. Agree?
> 
> So my goal was to avoid prev_gen_id, and yes I think the above does
> that.
> 
> Now the problem with the above condition is that it makes reports
> harder to decipher, because by avoiding adding redundant links to our
> graph we loose a possible shorter path.

Let's see the following example:

   A -> B -> C

   where A, B and C are typical lock class.

Assume the graph above was built and operations happena in the
following order:

   CONTEXT XCONTEXT Y
   --
   acquire DX
acquire A
acquire B
acquire C

release and commit DX

   where A, B and C are typical lock class, DX is a crosslock class.

The graph will grow as following _without_ prev_gen_id.

-> A -> B -> C
   ///
   DX ---

   where A, B and C are typical lock class, DX is a crosslock class.

The graph will grow as following _with_ prev_gen_id.

   DX -> A -> B -> C

   where A, B and C are typical lock class, DX is a crosslock class.

You said the former is better because it has smaller cost in bfs. But it
has to use _much_ more memory to keep additional nodes in graph. Without
exaggeration, every crosslock would get linked with all locks in history
locks, on commit, unless redundant. It might be pretty more than we
expect - I will check and let you know how many it is. Is it still good?



Re: [PATCHv2 10/14] bpf: Use set_memory.h header

2017-03-04 Thread kbuild test robot
Hi Laura,

[auto build test ERROR on linus/master]
[also build test ERROR on next-20170303]
[cannot apply to tip/x86/core drm/drm-next v4.10]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Laura-Abbott/set_memory_-functions-header-refactor/20170305-062939
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   arch/arm/net/bpf_jit_32.c: In function 'bpf_jit_compile':
>> arch/arm/net/bpf_jit_32.c:1051:2: error: implicit declaration of function 
>> 'flush_icache_range' [-Werror=implicit-function-declaration]
 flush_icache_range((u32)header, (u32)(ctx.target + ctx.idx));
 ^~
   cc1: some warnings being treated as errors

vim +/flush_icache_range +1051 arch/arm/net/bpf_jit_32.c

ddecdfce Mircea Gherzan   2012-03-16  1035  goto out;
ddecdfce Mircea Gherzan   2012-03-16  1036  
55309dd3 Daniel Borkmann  2014-09-08  1037  ctx.target = (u32 *) target_ptr;
ddecdfce Mircea Gherzan   2012-03-16  1038  ctx.idx = 0;
55309dd3 Daniel Borkmann  2014-09-08  1039  
ddecdfce Mircea Gherzan   2012-03-16  1040  build_prologue();
0b59d880 Nicolas Schichan 2015-05-07  1041  if (build_body() < 0) {
0b59d880 Nicolas Schichan 2015-05-07  1042  #if __LINUX_ARM_ARCH__ < 7
0b59d880 Nicolas Schichan 2015-05-07  1043  if (ctx.imm_count)
0b59d880 Nicolas Schichan 2015-05-07  1044  kfree(ctx.imms);
0b59d880 Nicolas Schichan 2015-05-07  1045  #endif
0b59d880 Nicolas Schichan 2015-05-07  1046  
bpf_jit_binary_free(header);
0b59d880 Nicolas Schichan 2015-05-07  1047  goto out;
0b59d880 Nicolas Schichan 2015-05-07  1048  }
ddecdfce Mircea Gherzan   2012-03-16  1049  build_epilogue();
ddecdfce Mircea Gherzan   2012-03-16  1050  
ebaef649 Daniel Borkmann  2015-11-14 @1051  flush_icache_range((u32)header, 
(u32)(ctx.target + ctx.idx));
ddecdfce Mircea Gherzan   2012-03-16  1052  
ddecdfce Mircea Gherzan   2012-03-16  1053  #if __LINUX_ARM_ARCH__ < 7
ddecdfce Mircea Gherzan   2012-03-16  1054  if (ctx.imm_count)
ddecdfce Mircea Gherzan   2012-03-16  1055  kfree(ctx.imms);
ddecdfce Mircea Gherzan   2012-03-16  1056  #endif
ddecdfce Mircea Gherzan   2012-03-16  1057  
ddecdfce Mircea Gherzan   2012-03-16  1058  if (bpf_jit_enable > 1)
79617801 Daniel Borkmann  2013-03-21  1059  /* there are 2 passes 
here */

:: The code at line 1051 was first introduced by commit
:: ebaef649c26b44ff28114b452fd067a270ca7f02 bpf, arm: start flushing icache 
range from header

:: TO: Daniel Borkmann 
:: CC: David S. Miller 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCHv2 10/14] bpf: Use set_memory.h header

2017-03-04 Thread kbuild test robot
Hi Laura,

[auto build test ERROR on linus/master]
[also build test ERROR on next-20170303]
[cannot apply to tip/x86/core drm/drm-next v4.10]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Laura-Abbott/set_memory_-functions-header-refactor/20170305-062939
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   arch/arm/net/bpf_jit_32.c: In function 'bpf_jit_compile':
>> arch/arm/net/bpf_jit_32.c:1051:2: error: implicit declaration of function 
>> 'flush_icache_range' [-Werror=implicit-function-declaration]
 flush_icache_range((u32)header, (u32)(ctx.target + ctx.idx));
 ^~
   cc1: some warnings being treated as errors

vim +/flush_icache_range +1051 arch/arm/net/bpf_jit_32.c

ddecdfce Mircea Gherzan   2012-03-16  1035  goto out;
ddecdfce Mircea Gherzan   2012-03-16  1036  
55309dd3 Daniel Borkmann  2014-09-08  1037  ctx.target = (u32 *) target_ptr;
ddecdfce Mircea Gherzan   2012-03-16  1038  ctx.idx = 0;
55309dd3 Daniel Borkmann  2014-09-08  1039  
ddecdfce Mircea Gherzan   2012-03-16  1040  build_prologue();
0b59d880 Nicolas Schichan 2015-05-07  1041  if (build_body() < 0) {
0b59d880 Nicolas Schichan 2015-05-07  1042  #if __LINUX_ARM_ARCH__ < 7
0b59d880 Nicolas Schichan 2015-05-07  1043  if (ctx.imm_count)
0b59d880 Nicolas Schichan 2015-05-07  1044  kfree(ctx.imms);
0b59d880 Nicolas Schichan 2015-05-07  1045  #endif
0b59d880 Nicolas Schichan 2015-05-07  1046  
bpf_jit_binary_free(header);
0b59d880 Nicolas Schichan 2015-05-07  1047  goto out;
0b59d880 Nicolas Schichan 2015-05-07  1048  }
ddecdfce Mircea Gherzan   2012-03-16  1049  build_epilogue();
ddecdfce Mircea Gherzan   2012-03-16  1050  
ebaef649 Daniel Borkmann  2015-11-14 @1051  flush_icache_range((u32)header, 
(u32)(ctx.target + ctx.idx));
ddecdfce Mircea Gherzan   2012-03-16  1052  
ddecdfce Mircea Gherzan   2012-03-16  1053  #if __LINUX_ARM_ARCH__ < 7
ddecdfce Mircea Gherzan   2012-03-16  1054  if (ctx.imm_count)
ddecdfce Mircea Gherzan   2012-03-16  1055  kfree(ctx.imms);
ddecdfce Mircea Gherzan   2012-03-16  1056  #endif
ddecdfce Mircea Gherzan   2012-03-16  1057  
ddecdfce Mircea Gherzan   2012-03-16  1058  if (bpf_jit_enable > 1)
79617801 Daniel Borkmann  2013-03-21  1059  /* there are 2 passes 
here */

:: The code at line 1051 was first introduced by commit
:: ebaef649c26b44ff28114b452fd067a270ca7f02 bpf, arm: start flushing icache 
range from header

:: TO: Daniel Borkmann 
:: CC: David S. Miller 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[bdi_unregister] 165a5e22fa BUG kmalloc-512 (Not tainted): Poison overwritten

2017-03-04 Thread Fengguang Wu
Hi Jan,

Here is another bisect result.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

commit 165a5e22fafb127ecb5914e12e8c32a1f0d3f820
Author: Jan Kara <j...@suse.cz>
AuthorDate: Wed Feb 8 08:05:56 2017 +0100
Commit: Jens Axboe <ax...@fb.com>
CommitDate: Thu Mar 2 16:08:35 2017 -0700

 block: Move bdi_unregister() to del_gendisk()
 
 Commit 6cd18e711dd8 "block: destroy bdi before blockdev is
 unregistered." moved bdi unregistration (at that time through
 bdi_destroy()) from blk_release_queue() to blk_cleanup_queue() because
 it needs to happen before blk_unregister_region() call in del_gendisk()
 for MD. SCSI though will free up the device number from sd_remove()
 called through a maze of callbacks from device_del() in
 __scsi_remove_device() before blk_cleanup_queue() and thus similar races
 as described in 6cd18e711dd8 can happen for SCSI as well as reported by
 Omar [1].
 
 Moving bdi_unregister() to del_gendisk() works for MD and fixes the
 problem for SCSI since del_gendisk() gets called from sd_remove() before
 freeing the device number.
 
 This also makes device_add_disk() (calling bdi_register_owner()) more
 symmetric with del_gendisk().
 
 [1] http://marc.info/?l=linux-block=148554717109098=2
 
 Tested-by: Lekshmi Pillai <lekshmicpil...@in.ibm.com>
 Acked-by: Tejun Heo <t...@kernel.org>
 Signed-off-by: Jan Kara <j...@suse.cz>
 Tested-by: Omar Sandoval <osan...@fb.com>
 Signed-off-by: Jens Axboe <ax...@fb.com>

113285b473  blk-mq: ensure that bd->last is always set correctly
165a5e22fa  block: Move bdi_unregister() to del_gendisk()
+-+++
| | 113285b473 | 165a5e22fa |
+-+++
| boot_successes  | 434| 20 |
| boot_failures   | 0  | 116|
| BUG_kmalloc-#(Not_tainted):Poison_overwritten   | 0  | 116|
| INFO:#-#.First_byte#instead_of  | 0  | 116|
| INFO:Allocated_in_bdi_alloc_node_age=#cpu=#pid= | 0  | 89 |
| INFO:Freed_in_release_bdi_age=#cpu=#pid=| 0  | 89 |
| INFO:Slab#objects=#used=#fp=0x(null)flags=  | 0  | 116|
| INFO:Object#@offset=#fp=| 0  | 116|
| INFO:Allocated_in_load_elf_phdrs_age=#cpu=#pid= | 0  | 27 |
| INFO:Freed_in_load_elf_binary_age=#cpu=#pid=| 0  | 27 |
+-+++

[2.573289] Write protecting the kernel read-only data: 2676k
[2.574616] NX-protecting the kernel data: 5812k
[2.576021] rodata_test: all tests were successful
[2.583146] random: init: uninitialized urandom read (12 bytes read)
[2.596347] 
=
[2.596676] BUG kmalloc-512 (Not tainted): Poison overwritten
[2.596676] 
-
[2.596676] 
[2.596676] Disabling lock debugging due to kernel taint
[2.596676] INFO: 0xd6840cac-0xd6840caf. First byte 0x0 instead of 0x6b
[2.596676] INFO: Allocated in load_elf_phdrs+0x3e/0x73 age=3 cpu=1 pid=132
[2.596676]  ___slab_alloc+0x4c6/0x4d8
[2.596676]  __slab_alloc+0x40/0x6a
[2.596676]  __kmalloc+0x103/0x1cd
[2.596676]  load_elf_phdrs+0x3e/0x73
[2.596676]  load_elf_binary+0xa3/0x9f7

  # HH:MM RESULT GOOD 
BAD GOOD_BUT_DIRTY DIRTY_NOT_BAD
git bisect start a8abdd4d4ab9bb6c1d94c1f528e91e2abe823912 
c470abd4fde40ea6a0846a2beab642a578c0b8cd --
git bisect  bad f875f31a067fbad4a9f8cc8addcb83ee2890829a  # 07:14  B 13 
1   13  65  Merge 
'linux-review/Georgios-Emmanouil/Staging-wilc1000-linux_wlan-Modified-the-if-else-statement/20170304-041306'
 into devel-spot-201703041408
git bisect  bad 6740c9bb3604e0be1db08f0e81d02843cd057775  # 07:24  B 38 
3   37 100  Merge 
'linux-review/Arnd-Bergmann/scsi-qedi-fix-build-error-without-DEBUG_FS/20170304-083336'
 into devel-spot-201703041408
git bisect  bad 040c12521a4ab55b0cf5f12494d4d1974f492dbf  # 07:38  B 50 
1   50  89  Merge 'cifs/for-next' into devel-spot-201703041408
git bisect good feeeb3990cc4b5372c326a235deeb0921938854b  # 07:54  G128 
01   1  Merge 
'linux-review/Alban/mtd-Add-support-for-reading-MTD-devices-via-the-nvmem-API/20170304-124946'
 into devel-spot-201703041408
git bisect good 8fe21608956d7be06f0d97d352313f7bfd157ac7  # 08:10  G119 
00   0  Merge 
'linux-review/Wenyou-Yang/can-m_can-support-transmit-frame-in-CAN-FD-fo

[bdi_unregister] 165a5e22fa BUG kmalloc-512 (Not tainted): Poison overwritten

2017-03-04 Thread Fengguang Wu
Hi Jan,

Here is another bisect result.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

commit 165a5e22fafb127ecb5914e12e8c32a1f0d3f820
Author: Jan Kara 
AuthorDate: Wed Feb 8 08:05:56 2017 +0100
Commit: Jens Axboe 
CommitDate: Thu Mar 2 16:08:35 2017 -0700

 block: Move bdi_unregister() to del_gendisk()
 
 Commit 6cd18e711dd8 "block: destroy bdi before blockdev is
 unregistered." moved bdi unregistration (at that time through
 bdi_destroy()) from blk_release_queue() to blk_cleanup_queue() because
 it needs to happen before blk_unregister_region() call in del_gendisk()
 for MD. SCSI though will free up the device number from sd_remove()
 called through a maze of callbacks from device_del() in
 __scsi_remove_device() before blk_cleanup_queue() and thus similar races
 as described in 6cd18e711dd8 can happen for SCSI as well as reported by
 Omar [1].
 
 Moving bdi_unregister() to del_gendisk() works for MD and fixes the
 problem for SCSI since del_gendisk() gets called from sd_remove() before
 freeing the device number.
 
 This also makes device_add_disk() (calling bdi_register_owner()) more
 symmetric with del_gendisk().
 
 [1] http://marc.info/?l=linux-block=148554717109098=2
 
 Tested-by: Lekshmi Pillai 
 Acked-by: Tejun Heo 
 Signed-off-by: Jan Kara 
 Tested-by: Omar Sandoval 
 Signed-off-by: Jens Axboe 

113285b473  blk-mq: ensure that bd->last is always set correctly
165a5e22fa  block: Move bdi_unregister() to del_gendisk()
+-+++
| | 113285b473 | 165a5e22fa |
+-+++
| boot_successes  | 434| 20 |
| boot_failures   | 0  | 116|
| BUG_kmalloc-#(Not_tainted):Poison_overwritten   | 0  | 116|
| INFO:#-#.First_byte#instead_of  | 0  | 116|
| INFO:Allocated_in_bdi_alloc_node_age=#cpu=#pid= | 0  | 89 |
| INFO:Freed_in_release_bdi_age=#cpu=#pid=| 0  | 89 |
| INFO:Slab#objects=#used=#fp=0x(null)flags=  | 0  | 116|
| INFO:Object#@offset=#fp=| 0  | 116|
| INFO:Allocated_in_load_elf_phdrs_age=#cpu=#pid= | 0  | 27 |
| INFO:Freed_in_load_elf_binary_age=#cpu=#pid=| 0  | 27 |
+-+++

[2.573289] Write protecting the kernel read-only data: 2676k
[2.574616] NX-protecting the kernel data: 5812k
[2.576021] rodata_test: all tests were successful
[2.583146] random: init: uninitialized urandom read (12 bytes read)
[2.596347] 
=
[2.596676] BUG kmalloc-512 (Not tainted): Poison overwritten
[2.596676] 
-
[2.596676] 
[2.596676] Disabling lock debugging due to kernel taint
[2.596676] INFO: 0xd6840cac-0xd6840caf. First byte 0x0 instead of 0x6b
[2.596676] INFO: Allocated in load_elf_phdrs+0x3e/0x73 age=3 cpu=1 pid=132
[2.596676]  ___slab_alloc+0x4c6/0x4d8
[2.596676]  __slab_alloc+0x40/0x6a
[2.596676]  __kmalloc+0x103/0x1cd
[2.596676]  load_elf_phdrs+0x3e/0x73
[2.596676]  load_elf_binary+0xa3/0x9f7

  # HH:MM RESULT GOOD 
BAD GOOD_BUT_DIRTY DIRTY_NOT_BAD
git bisect start a8abdd4d4ab9bb6c1d94c1f528e91e2abe823912 
c470abd4fde40ea6a0846a2beab642a578c0b8cd --
git bisect  bad f875f31a067fbad4a9f8cc8addcb83ee2890829a  # 07:14  B 13 
1   13  65  Merge 
'linux-review/Georgios-Emmanouil/Staging-wilc1000-linux_wlan-Modified-the-if-else-statement/20170304-041306'
 into devel-spot-201703041408
git bisect  bad 6740c9bb3604e0be1db08f0e81d02843cd057775  # 07:24  B 38 
3   37 100  Merge 
'linux-review/Arnd-Bergmann/scsi-qedi-fix-build-error-without-DEBUG_FS/20170304-083336'
 into devel-spot-201703041408
git bisect  bad 040c12521a4ab55b0cf5f12494d4d1974f492dbf  # 07:38  B 50 
1   50  89  Merge 'cifs/for-next' into devel-spot-201703041408
git bisect good feeeb3990cc4b5372c326a235deeb0921938854b  # 07:54  G128 
01   1  Merge 
'linux-review/Alban/mtd-Add-support-for-reading-MTD-devices-via-the-nvmem-API/20170304-124946'
 into devel-spot-201703041408
git bisect good 8fe21608956d7be06f0d97d352313f7bfd157ac7  # 08:10  G119 
00   0  Merge 
'linux-review/Wenyou-Yang/can-m_can-support-transmit-frame-in-CAN-FD-format/20170304-123621'
 into devel-spot-201703041408
git bisect good 16e7a33d62c254187926a64d2c03351ca516677d  # 08:24  G128 
00   0  Merge 
'linux

Re: [PATCH] net/sched: act_skbmod: remove unneeded rcu_read_unlock in tcf_skbmod_dump

2017-03-04 Thread Jamal Hadi Salim

On 17-03-04 07:01 PM, Alexey Khoroshilov wrote:

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 


Acked-by: Jamal Hadi Salim 

cheers,
jamal



Re: [PATCH] net/sched: act_skbmod: remove unneeded rcu_read_unlock in tcf_skbmod_dump

2017-03-04 Thread Jamal Hadi Salim

On 17-03-04 07:01 PM, Alexey Khoroshilov wrote:

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 


Acked-by: Jamal Hadi Salim 

cheers,
jamal



[PATCH] Input: elan_i2c - add ASUS EeeBook X205TA special touchpad fw

2017-03-04 Thread Matjaz Hegedic
EeeBook X205TA is yet another ASUS device with a special touchpad
firmware that needs to be accounted for during initialization, or
else the touchpad will go into an invalid state upon suspend/resume.
Adding the appropriate ic_type and product_id check fixes the problem.

Signed-off-by: Matjaz Hegedic 
---
 drivers/input/mouse/elan_i2c_core.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 2c7d287..dde3ad7 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -218,17 +218,19 @@ static int elan_query_product(struct elan_tp_data *data)
 
 static int elan_check_ASUS_special_fw(struct elan_tp_data *data)
 {
-   if (data->ic_type != 0x0E)
-   return false;
-
-   switch (data->product_id) {
-   case 0x05 ... 0x07:
-   case 0x09:
-   case 0x13:
-   return true;
-   default:
-   return false;
+   if (data->ic_type == 0x0E) {
+   switch (data->product_id) {
+   case 0x05 ... 0x07:
+   case 0x09:
+   case 0x13:
+   return true;
+   }
}
+   /* ASUS EeeBook X205TA */
+   else if (data->ic_type == 0x8 && data->product_id == 0x26)
+   return true;
+
+   return false;
 }
 
 static int __elan_initialize(struct elan_tp_data *data)
-- 
2.7.4



[PATCH] Input: elan_i2c - add ASUS EeeBook X205TA special touchpad fw

2017-03-04 Thread Matjaz Hegedic
EeeBook X205TA is yet another ASUS device with a special touchpad
firmware that needs to be accounted for during initialization, or
else the touchpad will go into an invalid state upon suspend/resume.
Adding the appropriate ic_type and product_id check fixes the problem.

Signed-off-by: Matjaz Hegedic 
---
 drivers/input/mouse/elan_i2c_core.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c 
b/drivers/input/mouse/elan_i2c_core.c
index 2c7d287..dde3ad7 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -218,17 +218,19 @@ static int elan_query_product(struct elan_tp_data *data)
 
 static int elan_check_ASUS_special_fw(struct elan_tp_data *data)
 {
-   if (data->ic_type != 0x0E)
-   return false;
-
-   switch (data->product_id) {
-   case 0x05 ... 0x07:
-   case 0x09:
-   case 0x13:
-   return true;
-   default:
-   return false;
+   if (data->ic_type == 0x0E) {
+   switch (data->product_id) {
+   case 0x05 ... 0x07:
+   case 0x09:
+   case 0x13:
+   return true;
+   }
}
+   /* ASUS EeeBook X205TA */
+   else if (data->ic_type == 0x8 && data->product_id == 0x26)
+   return true;
+
+   return false;
 }
 
 static int __elan_initialize(struct elan_tp_data *data)
-- 
2.7.4



[PATCH 0/9] Drivers: hv: vmbus: Miscellaneous cleanup

2017-03-04 Thread kys
From: K. Y. Srinivasan 

Miscellaneous cleanup.

Stephen Hemminger (9):
  vmbus: only reschedule tasklet if time limit exceeded
  hyperv: fix warning about missing prototype
  vmbus: remove useless return's
  vmbus: remove unnecessary initialization
  vmbus: fix spelling errors
  hyperv: remove unnecessary return variable
  vmbus: make channel_message table constant
  vmbus: cleanup header file style
  vmbus: expose debug info for drivers

 arch/x86/hyperv/hv_init.c |2 +-
 drivers/hv/channel.c  |   10 +++---
 drivers/hv/channel_mgmt.c |   48 
 drivers/hv/connection.c   |   65 +++-
 drivers/hv/hv_balloon.c   |2 -
 drivers/hv/hv_fcopy.c |2 -
 drivers/hv/hv_kvp.c   |   12 +++-
 drivers/hv/hv_snapshot.c  |2 -
 drivers/hv/hyperv_vmbus.h |   29 ++--
 drivers/hv/ring_buffer.c  |   22 +-
 drivers/hv/vmbus_drv.c|4 +--
 include/linux/hyperv.h|   31 -
 12 files changed, 110 insertions(+), 119 deletions(-)



[PATCH 0/9] Drivers: hv: vmbus: Miscellaneous cleanup

2017-03-04 Thread kys
From: K. Y. Srinivasan 

Miscellaneous cleanup.

Stephen Hemminger (9):
  vmbus: only reschedule tasklet if time limit exceeded
  hyperv: fix warning about missing prototype
  vmbus: remove useless return's
  vmbus: remove unnecessary initialization
  vmbus: fix spelling errors
  hyperv: remove unnecessary return variable
  vmbus: make channel_message table constant
  vmbus: cleanup header file style
  vmbus: expose debug info for drivers

 arch/x86/hyperv/hv_init.c |2 +-
 drivers/hv/channel.c  |   10 +++---
 drivers/hv/channel_mgmt.c |   48 
 drivers/hv/connection.c   |   65 +++-
 drivers/hv/hv_balloon.c   |2 -
 drivers/hv/hv_fcopy.c |2 -
 drivers/hv/hv_kvp.c   |   12 +++-
 drivers/hv/hv_snapshot.c  |2 -
 drivers/hv/hyperv_vmbus.h |   29 ++--
 drivers/hv/ring_buffer.c  |   22 +-
 drivers/hv/vmbus_drv.c|4 +--
 include/linux/hyperv.h|   31 -
 12 files changed, 110 insertions(+), 119 deletions(-)



[PATCH 5/9] vmbus: fix spelling errors

2017-03-04 Thread kys
From: Stephen Hemminger 

Several spelling errors in comments

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c |   10 +-
 drivers/hv/hv_kvp.c  |   10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index a5f4c43..54075ac 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -333,7 +333,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,
 * Gpadl is u32 and we are using a pointer which could
 * be 64-bit
 * This is governed by the guest/host protocol and
-* so the hypervisor gurantees that this is ok.
+* so the hypervisor guarantees that this is ok.
 */
for (i = 0; i < pfncurr; i++)
gpadl_body->pfn[i] = slow_virt_to_phys(
@@ -380,7 +380,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,
 }
 
 /*
- * vmbus_establish_gpadl - Estabish a GPADL for the specified buffer
+ * vmbus_establish_gpadl - Establish a GPADL for the specified buffer
  *
  * @channel: a channel
  * @kbuffer: from kmalloc or vmalloc
@@ -728,7 +728,7 @@ int vmbus_sendpacket_pagebuffer_ctl(struct vmbus_channel 
*channel,
/* Setup the descriptor */
desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
desc.flags = flags;
-   desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+   desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */
desc.length8 = (u16)(packetlen_aligned >> 3);
desc.transactionid = requestid;
desc.rangecount = pagecount;
@@ -789,7 +789,7 @@ int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel,
/* Setup the descriptor */
desc->type = VM_PKT_DATA_USING_GPA_DIRECT;
desc->flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
-   desc->dataoffset8 = desc_size >> 3; /* in 8-bytes grandularity */
+   desc->dataoffset8 = desc_size >> 3; /* in 8-bytes granularity */
desc->length8 = (u16)(packetlen_aligned >> 3);
desc->transactionid = requestid;
desc->rangecount = 1;
@@ -839,7 +839,7 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel 
*channel,
/* Setup the descriptor */
desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
-   desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+   desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */
desc.length8 = (u16)(packetlen_aligned >> 3);
desc.transactionid = requestid;
desc.rangecount = 1;
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index d3979a6..e99ff2d 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -69,7 +69,7 @@
  *
  * While the request/response protocol is guaranteed by the host, we further
  * ensure this by serializing packet processing in this driver - we do not
- * read additional packets from the VMBUs until the current packet is fully
+ * read additional packets from the VMBUS until the current packet is fully
  * handled.
  */
 
@@ -397,7 +397,7 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
 * the max lengths specified. We will however, reserve room
 * for the string terminating character - in the utf16s_utf8s()
 * function we limit the size of the buffer where the converted
-* string is placed to HV_KVP_EXCHANGE_MAX_*_SIZE -1 to gaurantee
+* string is placed to HV_KVP_EXCHANGE_MAX_*_SIZE -1 to guarantee
 * that the strings can be properly terminated!
 */
 
@@ -531,7 +531,7 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
 */
if (error) {
/*
-* Something failed or we have timedout;
+* Something failed or we have timed out;
 * terminate the current host-side iteration.
 */
goto response_done;
@@ -605,8 +605,8 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
  * This callback is invoked when we get a KVP message from the host.
  * The host ensures that only one KVP transaction can be active at a time.
  * KVP implementation in Linux needs to forward the key to a user-mde
- * component to retrive the corresponding value. Consequently, we cannot
- * respond to the host in the conext of this callback. Since the host
+ * component to retrieve the corresponding value. Consequently, we cannot
+ * respond to the host in the context of this callback. Since the host
  * guarantees that at most only one transaction can be active at a time,
  * we stash away the transaction state in a set of global variables.
  */
-- 
1.7.1



[PATCH 5/9] vmbus: fix spelling errors

2017-03-04 Thread kys
From: Stephen Hemminger 

Several spelling errors in comments

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c |   10 +-
 drivers/hv/hv_kvp.c  |   10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index a5f4c43..54075ac 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -333,7 +333,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,
 * Gpadl is u32 and we are using a pointer which could
 * be 64-bit
 * This is governed by the guest/host protocol and
-* so the hypervisor gurantees that this is ok.
+* so the hypervisor guarantees that this is ok.
 */
for (i = 0; i < pfncurr; i++)
gpadl_body->pfn[i] = slow_virt_to_phys(
@@ -380,7 +380,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,
 }
 
 /*
- * vmbus_establish_gpadl - Estabish a GPADL for the specified buffer
+ * vmbus_establish_gpadl - Establish a GPADL for the specified buffer
  *
  * @channel: a channel
  * @kbuffer: from kmalloc or vmalloc
@@ -728,7 +728,7 @@ int vmbus_sendpacket_pagebuffer_ctl(struct vmbus_channel 
*channel,
/* Setup the descriptor */
desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
desc.flags = flags;
-   desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+   desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */
desc.length8 = (u16)(packetlen_aligned >> 3);
desc.transactionid = requestid;
desc.rangecount = pagecount;
@@ -789,7 +789,7 @@ int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel,
/* Setup the descriptor */
desc->type = VM_PKT_DATA_USING_GPA_DIRECT;
desc->flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
-   desc->dataoffset8 = desc_size >> 3; /* in 8-bytes grandularity */
+   desc->dataoffset8 = desc_size >> 3; /* in 8-bytes granularity */
desc->length8 = (u16)(packetlen_aligned >> 3);
desc->transactionid = requestid;
desc->rangecount = 1;
@@ -839,7 +839,7 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel 
*channel,
/* Setup the descriptor */
desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
-   desc.dataoffset8 = descsize >> 3; /* in 8-bytes grandularity */
+   desc.dataoffset8 = descsize >> 3; /* in 8-bytes granularity */
desc.length8 = (u16)(packetlen_aligned >> 3);
desc.transactionid = requestid;
desc.rangecount = 1;
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index d3979a6..e99ff2d 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -69,7 +69,7 @@
  *
  * While the request/response protocol is guaranteed by the host, we further
  * ensure this by serializing packet processing in this driver - we do not
- * read additional packets from the VMBUs until the current packet is fully
+ * read additional packets from the VMBUS until the current packet is fully
  * handled.
  */
 
@@ -397,7 +397,7 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
 * the max lengths specified. We will however, reserve room
 * for the string terminating character - in the utf16s_utf8s()
 * function we limit the size of the buffer where the converted
-* string is placed to HV_KVP_EXCHANGE_MAX_*_SIZE -1 to gaurantee
+* string is placed to HV_KVP_EXCHANGE_MAX_*_SIZE -1 to guarantee
 * that the strings can be properly terminated!
 */
 
@@ -531,7 +531,7 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
 */
if (error) {
/*
-* Something failed or we have timedout;
+* Something failed or we have timed out;
 * terminate the current host-side iteration.
 */
goto response_done;
@@ -605,8 +605,8 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
  * This callback is invoked when we get a KVP message from the host.
  * The host ensures that only one KVP transaction can be active at a time.
  * KVP implementation in Linux needs to forward the key to a user-mde
- * component to retrive the corresponding value. Consequently, we cannot
- * respond to the host in the conext of this callback. Since the host
+ * component to retrieve the corresponding value. Consequently, we cannot
+ * respond to the host in the context of this callback. Since the host
  * guarantees that at most only one transaction can be active at a time,
  * we stash away the transaction state in a set of global variables.
  */
-- 
1.7.1



[PATCH 2/9] hyperv: fix warning about missing prototype

2017-03-04 Thread kys
From: Stephen Hemminger 

Compiling with warnings enabled finds missing prototype for
hv_do_hypercall.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/hyperv/hv_init.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index db64baf..d4a5f82 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-
+#include 
 
 #ifdef CONFIG_X86_64
 
-- 
1.7.1



[PATCH 3/9] vmbus: remove useless return's

2017-03-04 Thread kys
From: Stephen Hemminger 

No need for empty return at end of void function

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_balloon.c  |2 --
 drivers/hv/hv_fcopy.c|2 --
 drivers/hv/hv_kvp.c  |2 --
 drivers/hv/hv_snapshot.c |2 --
 drivers/hv/ring_buffer.c |2 --
 drivers/hv/vmbus_drv.c   |2 --
 include/linux/hyperv.h   |2 --
 7 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 5fd03e5..f5728de 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -722,8 +722,6 @@ static void hv_mem_hot_add(unsigned long start, unsigned 
long size,
5*HZ);
post_status(_device);
}
-
-   return;
 }
 
 static void hv_online_page(struct page *pg)
diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
index a5596a6..daa75bd 100644
--- a/drivers/hv/hv_fcopy.c
+++ b/drivers/hv/hv_fcopy.c
@@ -186,8 +186,6 @@ static void fcopy_send_data(struct work_struct *dummy)
}
}
kfree(smsg_out);
-
-   return;
 }
 
 /*
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index a1adfe2..d3979a6 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -483,8 +483,6 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
}
 
kfree(message);
-
-   return;
 }
 
 /*
diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
index e659d1b..6831efd 100644
--- a/drivers/hv/hv_snapshot.c
+++ b/drivers/hv/hv_snapshot.c
@@ -212,8 +212,6 @@ static void vss_send_op(void)
}
 
kfree(vss_msg);
-
-   return;
 }
 
 static void vss_handle_request(struct work_struct *dummy)
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 87799e8..d0ff5b4 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -73,8 +73,6 @@ static void hv_signal_on_write(u32 old_write, struct 
vmbus_channel *channel)
 */
if (old_write == READ_ONCE(rbi->ring_buffer->read_index))
vmbus_setevent(channel);
-
-   return;
 }
 
 /* Get the next write location for the specified ring buffer. */
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 971ecb7..9ddbf4d 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -785,8 +785,6 @@ static void vmbus_shutdown(struct device *child_device)
 
if (drv->shutdown)
drv->shutdown(dev);
-
-   return;
 }
 
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 970771a..ee14f23 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1504,8 +1504,6 @@ static inline  void hv_signal_on_read(struct 
vmbus_channel *channel)
cached_write_sz = hv_get_cached_bytes_to_write(rbi);
if (cached_write_sz < pending_sz)
vmbus_setevent(channel);
-
-   return;
 }
 
 static inline void
-- 
1.7.1



[PATCH 2/9] hyperv: fix warning about missing prototype

2017-03-04 Thread kys
From: Stephen Hemminger 

Compiling with warnings enabled finds missing prototype for
hv_do_hypercall.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/hyperv/hv_init.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index db64baf..d4a5f82 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-
+#include 
 
 #ifdef CONFIG_X86_64
 
-- 
1.7.1



[PATCH 3/9] vmbus: remove useless return's

2017-03-04 Thread kys
From: Stephen Hemminger 

No need for empty return at end of void function

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_balloon.c  |2 --
 drivers/hv/hv_fcopy.c|2 --
 drivers/hv/hv_kvp.c  |2 --
 drivers/hv/hv_snapshot.c |2 --
 drivers/hv/ring_buffer.c |2 --
 drivers/hv/vmbus_drv.c   |2 --
 include/linux/hyperv.h   |2 --
 7 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 5fd03e5..f5728de 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -722,8 +722,6 @@ static void hv_mem_hot_add(unsigned long start, unsigned 
long size,
5*HZ);
post_status(_device);
}
-
-   return;
 }
 
 static void hv_online_page(struct page *pg)
diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
index a5596a6..daa75bd 100644
--- a/drivers/hv/hv_fcopy.c
+++ b/drivers/hv/hv_fcopy.c
@@ -186,8 +186,6 @@ static void fcopy_send_data(struct work_struct *dummy)
}
}
kfree(smsg_out);
-
-   return;
 }
 
 /*
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index a1adfe2..d3979a6 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -483,8 +483,6 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
}
 
kfree(message);
-
-   return;
 }
 
 /*
diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
index e659d1b..6831efd 100644
--- a/drivers/hv/hv_snapshot.c
+++ b/drivers/hv/hv_snapshot.c
@@ -212,8 +212,6 @@ static void vss_send_op(void)
}
 
kfree(vss_msg);
-
-   return;
 }
 
 static void vss_handle_request(struct work_struct *dummy)
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 87799e8..d0ff5b4 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -73,8 +73,6 @@ static void hv_signal_on_write(u32 old_write, struct 
vmbus_channel *channel)
 */
if (old_write == READ_ONCE(rbi->ring_buffer->read_index))
vmbus_setevent(channel);
-
-   return;
 }
 
 /* Get the next write location for the specified ring buffer. */
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 971ecb7..9ddbf4d 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -785,8 +785,6 @@ static void vmbus_shutdown(struct device *child_device)
 
if (drv->shutdown)
drv->shutdown(dev);
-
-   return;
 }
 
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 970771a..ee14f23 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1504,8 +1504,6 @@ static inline  void hv_signal_on_read(struct 
vmbus_channel *channel)
cached_write_sz = hv_get_cached_bytes_to_write(rbi);
if (cached_write_sz < pending_sz)
vmbus_setevent(channel);
-
-   return;
 }
 
 static inline void
-- 
1.7.1



[PATCH 9/9] vmbus: expose debug info for drivers

2017-03-04 Thread kys
From: Stephen Hemminger 

Allow driver to get debug information about state of the ring.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hyperv_vmbus.h |   11 ---
 drivers/hv/ring_buffer.c  |1 +
 include/linux/hyperv.h|   17 +
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index a69b52d..6113e91 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -248,14 +248,6 @@ struct hv_context {
 
 extern struct hv_context hv_context;
 
-struct hv_ring_buffer_debug_info {
-   u32 current_interrupt_mask;
-   u32 current_read_index;
-   u32 current_write_index;
-   u32 bytes_avail_toread;
-   u32 bytes_avail_towrite;
-};
-
 /* Hv Interface */
 
 extern int hv_init(void);
@@ -289,9 +281,6 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
   void *buffer, u32 buflen, u32 *buffer_actual_len,
   u64 *requestid, bool raw);
 
-void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
-struct hv_ring_buffer_debug_info *debug_info);
-
 /*
  * Maximum channels is determined by the size of the interrupt page
  * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 8a24974..cfacca5 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -206,6 +206,7 @@ void hv_ringbuffer_get_debuginfo(const struct 
hv_ring_buffer_info *ring_info,
ring_info->ring_buffer->interrupt_mask;
}
 }
+EXPORT_SYMBOL_GPL(hv_ringbuffer_get_debuginfo);
 
 /* Initialize the ring buffer. */
 int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 02f5d76..f681f7b 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -491,6 +491,12 @@ struct vmbus_channel_rescind_offer {
u32 child_relid;
 } __packed;
 
+static inline u32
+hv_ringbuffer_pending_size(const struct hv_ring_buffer_info *rbi)
+{
+   return rbi->ring_buffer->pending_send_sz;
+}
+
 /*
  * Request Offer -- no parameters, SynIC message contains the partition ID
  * Set Snoop -- no parameters, SynIC message contains the partition ID
@@ -1155,6 +1161,17 @@ static inline void hv_set_drvdata(struct hv_device *dev, 
void *data)
return dev_get_drvdata(>device);
 }
 
+struct hv_ring_buffer_debug_info {
+   u32 current_interrupt_mask;
+   u32 current_read_index;
+   u32 current_write_index;
+   u32 bytes_avail_toread;
+   u32 bytes_avail_towrite;
+};
+
+void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
+   struct hv_ring_buffer_debug_info *debug_info);
+
 /* Vmbus interface */
 #define vmbus_driver_register(driver)  \
__vmbus_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
-- 
1.7.1



[PATCH 1/9] vmbus: only reschedule tasklet if time limit exceeded

2017-03-04 Thread kys
From: Stephen Hemminger 

The change to reschedule tasklet if more data arrives in ring buffer
can cause performance regression if host timing is such that the
next response happens in small window.

Go back to a modified version of the original looping behavior.
If the race occurs in a small time, then loop. But if the tasklet
has been running for a long interval due to flood, then reschedule
the tasklet to allow migration to ksoftirqd.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/connection.c |   65 --
 1 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index a8366fe..fce27fb 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -296,44 +296,47 @@ struct vmbus_channel *relid2channel(u32 relid)
 
 /*
  * vmbus_on_event - Process a channel event notification
+ *
+ * For batched channels (default) optimize host to guest signaling
+ * by ensuring:
+ * 1. While reading the channel, we disable interrupts from host.
+ * 2. Ensure that we process all posted messages from the host
+ *before returning from this callback.
+ * 3. Once we return, enable signaling from the host. Once this
+ *state is set we check to see if additional packets are
+ *available to read. In this case we repeat the process.
+ *If this tasklet has been running for a long time
+ *then reschedule ourselves.
  */
 void vmbus_on_event(unsigned long data)
 {
struct vmbus_channel *channel = (void *) data;
-   void (*callback_fn)(void *);
+   unsigned long time_limit = jiffies + 2;
 
-   /*
-* A channel once created is persistent even when there
-* is no driver handling the device. An unloading driver
-* sets the onchannel_callback to NULL on the same CPU
-* as where this interrupt is handled (in an interrupt context).
-* Thus, checking and invoking the driver specific callback takes
-* care of orderly unloading of the driver.
-*/
-   callback_fn = READ_ONCE(channel->onchannel_callback);
-   if (unlikely(callback_fn == NULL))
-   return;
-
-   (*callback_fn)(channel->channel_callback_context);
-
-   if (channel->callback_mode == HV_CALL_BATCHED) {
-   /*
-* This callback reads the messages sent by the host.
-* We can optimize host to guest signaling by ensuring:
-* 1. While reading the channel, we disable interrupts from
-*host.
-* 2. Ensure that we process all posted messages from the host
-*before returning from this callback.
-* 3. Once we return, enable signaling from the host. Once this
-*state is set we check to see if additional packets are
-*available to read. In this case we repeat the process.
+   do {
+   void (*callback_fn)(void *);
+
+   /* A channel once created is persistent even when
+* there is no driver handling the device. An
+* unloading driver sets the onchannel_callback to NULL.
 */
-   if (hv_end_read(>inbound) != 0) {
-   hv_begin_read(>inbound);
+   callback_fn = READ_ONCE(channel->onchannel_callback);
+   if (unlikely(callback_fn == NULL))
+   return;
 
-   tasklet_schedule(>callback_event);
-   }
-   }
+   (*callback_fn)(channel->channel_callback_context);
+
+   if (channel->callback_mode != HV_CALL_BATCHED)
+   return;
+
+   if (likely(hv_end_read(>inbound) == 0))
+   return;
+
+   hv_begin_read(>inbound);
+   } while (likely(time_before(jiffies, time_limit)));
+
+   /* The time limit (2 jiffies) has been reached */
+   tasklet_schedule(>callback_event);
 }
 
 /*
-- 
1.7.1



[PATCH 1/9] vmbus: only reschedule tasklet if time limit exceeded

2017-03-04 Thread kys
From: Stephen Hemminger 

The change to reschedule tasklet if more data arrives in ring buffer
can cause performance regression if host timing is such that the
next response happens in small window.

Go back to a modified version of the original looping behavior.
If the race occurs in a small time, then loop. But if the tasklet
has been running for a long interval due to flood, then reschedule
the tasklet to allow migration to ksoftirqd.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/connection.c |   65 --
 1 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index a8366fe..fce27fb 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -296,44 +296,47 @@ struct vmbus_channel *relid2channel(u32 relid)
 
 /*
  * vmbus_on_event - Process a channel event notification
+ *
+ * For batched channels (default) optimize host to guest signaling
+ * by ensuring:
+ * 1. While reading the channel, we disable interrupts from host.
+ * 2. Ensure that we process all posted messages from the host
+ *before returning from this callback.
+ * 3. Once we return, enable signaling from the host. Once this
+ *state is set we check to see if additional packets are
+ *available to read. In this case we repeat the process.
+ *If this tasklet has been running for a long time
+ *then reschedule ourselves.
  */
 void vmbus_on_event(unsigned long data)
 {
struct vmbus_channel *channel = (void *) data;
-   void (*callback_fn)(void *);
+   unsigned long time_limit = jiffies + 2;
 
-   /*
-* A channel once created is persistent even when there
-* is no driver handling the device. An unloading driver
-* sets the onchannel_callback to NULL on the same CPU
-* as where this interrupt is handled (in an interrupt context).
-* Thus, checking and invoking the driver specific callback takes
-* care of orderly unloading of the driver.
-*/
-   callback_fn = READ_ONCE(channel->onchannel_callback);
-   if (unlikely(callback_fn == NULL))
-   return;
-
-   (*callback_fn)(channel->channel_callback_context);
-
-   if (channel->callback_mode == HV_CALL_BATCHED) {
-   /*
-* This callback reads the messages sent by the host.
-* We can optimize host to guest signaling by ensuring:
-* 1. While reading the channel, we disable interrupts from
-*host.
-* 2. Ensure that we process all posted messages from the host
-*before returning from this callback.
-* 3. Once we return, enable signaling from the host. Once this
-*state is set we check to see if additional packets are
-*available to read. In this case we repeat the process.
+   do {
+   void (*callback_fn)(void *);
+
+   /* A channel once created is persistent even when
+* there is no driver handling the device. An
+* unloading driver sets the onchannel_callback to NULL.
 */
-   if (hv_end_read(>inbound) != 0) {
-   hv_begin_read(>inbound);
+   callback_fn = READ_ONCE(channel->onchannel_callback);
+   if (unlikely(callback_fn == NULL))
+   return;
 
-   tasklet_schedule(>callback_event);
-   }
-   }
+   (*callback_fn)(channel->channel_callback_context);
+
+   if (channel->callback_mode != HV_CALL_BATCHED)
+   return;
+
+   if (likely(hv_end_read(>inbound) == 0))
+   return;
+
+   hv_begin_read(>inbound);
+   } while (likely(time_before(jiffies, time_limit)));
+
+   /* The time limit (2 jiffies) has been reached */
+   tasklet_schedule(>callback_event);
 }
 
 /*
-- 
1.7.1



[PATCH 9/9] vmbus: expose debug info for drivers

2017-03-04 Thread kys
From: Stephen Hemminger 

Allow driver to get debug information about state of the ring.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hyperv_vmbus.h |   11 ---
 drivers/hv/ring_buffer.c  |1 +
 include/linux/hyperv.h|   17 +
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index a69b52d..6113e91 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -248,14 +248,6 @@ struct hv_context {
 
 extern struct hv_context hv_context;
 
-struct hv_ring_buffer_debug_info {
-   u32 current_interrupt_mask;
-   u32 current_read_index;
-   u32 current_write_index;
-   u32 bytes_avail_toread;
-   u32 bytes_avail_towrite;
-};
-
 /* Hv Interface */
 
 extern int hv_init(void);
@@ -289,9 +281,6 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
   void *buffer, u32 buflen, u32 *buffer_actual_len,
   u64 *requestid, bool raw);
 
-void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
-struct hv_ring_buffer_debug_info *debug_info);
-
 /*
  * Maximum channels is determined by the size of the interrupt page
  * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 8a24974..cfacca5 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -206,6 +206,7 @@ void hv_ringbuffer_get_debuginfo(const struct 
hv_ring_buffer_info *ring_info,
ring_info->ring_buffer->interrupt_mask;
}
 }
+EXPORT_SYMBOL_GPL(hv_ringbuffer_get_debuginfo);
 
 /* Initialize the ring buffer. */
 int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 02f5d76..f681f7b 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -491,6 +491,12 @@ struct vmbus_channel_rescind_offer {
u32 child_relid;
 } __packed;
 
+static inline u32
+hv_ringbuffer_pending_size(const struct hv_ring_buffer_info *rbi)
+{
+   return rbi->ring_buffer->pending_send_sz;
+}
+
 /*
  * Request Offer -- no parameters, SynIC message contains the partition ID
  * Set Snoop -- no parameters, SynIC message contains the partition ID
@@ -1155,6 +1161,17 @@ static inline void hv_set_drvdata(struct hv_device *dev, 
void *data)
return dev_get_drvdata(>device);
 }
 
+struct hv_ring_buffer_debug_info {
+   u32 current_interrupt_mask;
+   u32 current_read_index;
+   u32 current_write_index;
+   u32 bytes_avail_toread;
+   u32 bytes_avail_towrite;
+};
+
+void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
+   struct hv_ring_buffer_debug_info *debug_info);
+
 /* Vmbus interface */
 #define vmbus_driver_register(driver)  \
__vmbus_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
-- 
1.7.1



[PATCH 8/9] vmbus: cleanup header file style

2017-03-04 Thread kys
From: Stephen Hemminger 

Minor changes to align hyper-v vmbus include files with current
linux kernel style.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hyperv_vmbus.h |   16 
 include/linux/hyperv.h|   12 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index b552c3a..a69b52d 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -218,8 +218,8 @@ struct hv_per_cpu_context {
 
 struct hv_context {
/* We only support running on top of Hyper-V
-   * So at this point this really can only contain the Hyper-V ID
-   */
+* So at this point this really can only contain the Hyper-V ID
+*/
u64 guestid;
 
void *tsc_page;
@@ -403,17 +403,17 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
 void vmbus_on_event(unsigned long data);
 void vmbus_on_msg_dpc(unsigned long data);
 
-int hv_kvp_init(struct hv_util_service *);
+int hv_kvp_init(struct hv_util_service *srv);
 void hv_kvp_deinit(void);
-void hv_kvp_onchannelcallback(void *);
+void hv_kvp_onchannelcallback(void *context);
 
-int hv_vss_init(struct hv_util_service *);
+int hv_vss_init(struct hv_util_service *srv);
 void hv_vss_deinit(void);
-void hv_vss_onchannelcallback(void *);
+void hv_vss_onchannelcallback(void *context);
 
-int hv_fcopy_init(struct hv_util_service *);
+int hv_fcopy_init(struct hv_util_service *srv);
 void hv_fcopy_deinit(void);
-void hv_fcopy_onchannelcallback(void *);
+void hv_fcopy_onchannelcallback(void *context);
 void vmbus_initiate_unload(bool crash);
 
 static inline void hv_poll_channel(struct vmbus_channel *channel,
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index ee14f23..02f5d76 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -524,10 +524,10 @@ struct vmbus_channel_open_channel {
u32 target_vp;
 
/*
-   * The upstream ring buffer begins at offset zero in the memory
-   * described by RingBufferGpadlHandle. The downstream ring buffer
-   * follows it at this offset (in pages).
-   */
+* The upstream ring buffer begins at offset zero in the memory
+* described by RingBufferGpadlHandle. The downstream ring buffer
+* follows it at this offset (in pages).
+*/
u32 downstream_ringbuffer_pageoffset;
 
/* User-specific data to be passed along to the server endpoint. */
@@ -1013,7 +1013,7 @@ extern int vmbus_open(struct vmbus_channel *channel,
u32 recv_ringbuffersize,
void *userdata,
u32 userdatalen,
-   void(*onchannel_callback)(void *context),
+   void (*onchannel_callback)(void *context),
void *context);
 
 extern void vmbus_close(struct vmbus_channel *channel);
@@ -1428,7 +1428,7 @@ struct hyperv_service_callback {
char *log_msg;
uuid_le data;
struct vmbus_channel *channel;
-   void (*callback) (void *context);
+   void (*callback)(void *context);
 };
 
 #define MAX_SRV_VER0x7ff
-- 
1.7.1



[PATCH 7/9] vmbus: make channel_message table constant

2017-03-04 Thread kys
From: Stephen Hemminger 

This table is immutable and should be const.
Cleanup indentation and whitespace for this as well.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |   48 ++--
 drivers/hv/hyperv_vmbus.h |2 +-
 drivers/hv/vmbus_drv.c|2 +-
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index bf846d0..fe376af 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1079,30 +1079,30 @@ static void vmbus_onversion_response(
 }
 
 /* Channel message dispatch table */
-struct vmbus_channel_message_table_entry
-   channel_message_table[CHANNELMSG_COUNT] = {
-   {CHANNELMSG_INVALID,0, NULL},
-   {CHANNELMSG_OFFERCHANNEL,   0, vmbus_onoffer},
-   {CHANNELMSG_RESCIND_CHANNELOFFER,   0, vmbus_onoffer_rescind},
-   {CHANNELMSG_REQUESTOFFERS,  0, NULL},
-   {CHANNELMSG_ALLOFFERS_DELIVERED,1, vmbus_onoffers_delivered},
-   {CHANNELMSG_OPENCHANNEL,0, NULL},
-   {CHANNELMSG_OPENCHANNEL_RESULT, 1, vmbus_onopen_result},
-   {CHANNELMSG_CLOSECHANNEL,   0, NULL},
-   {CHANNELMSG_GPADL_HEADER,   0, NULL},
-   {CHANNELMSG_GPADL_BODY, 0, NULL},
-   {CHANNELMSG_GPADL_CREATED,  1, vmbus_ongpadl_created},
-   {CHANNELMSG_GPADL_TEARDOWN, 0, NULL},
-   {CHANNELMSG_GPADL_TORNDOWN, 1, vmbus_ongpadl_torndown},
-   {CHANNELMSG_RELID_RELEASED, 0, NULL},
-   {CHANNELMSG_INITIATE_CONTACT,   0, NULL},
-   {CHANNELMSG_VERSION_RESPONSE,   1, vmbus_onversion_response},
-   {CHANNELMSG_UNLOAD, 0, NULL},
-   {CHANNELMSG_UNLOAD_RESPONSE,1, vmbus_unload_response},
-   {CHANNELMSG_18, 0, NULL},
-   {CHANNELMSG_19, 0, NULL},
-   {CHANNELMSG_20, 0, NULL},
-   {CHANNELMSG_TL_CONNECT_REQUEST, 0, NULL},
+const struct vmbus_channel_message_table_entry
+channel_message_table[CHANNELMSG_COUNT] = {
+   { CHANNELMSG_INVALID,   0, NULL },
+   { CHANNELMSG_OFFERCHANNEL,  0, vmbus_onoffer },
+   { CHANNELMSG_RESCIND_CHANNELOFFER,  0, vmbus_onoffer_rescind },
+   { CHANNELMSG_REQUESTOFFERS, 0, NULL },
+   { CHANNELMSG_ALLOFFERS_DELIVERED,   1, vmbus_onoffers_delivered },
+   { CHANNELMSG_OPENCHANNEL,   0, NULL },
+   { CHANNELMSG_OPENCHANNEL_RESULT,1, vmbus_onopen_result },
+   { CHANNELMSG_CLOSECHANNEL,  0, NULL },
+   { CHANNELMSG_GPADL_HEADER,  0, NULL },
+   { CHANNELMSG_GPADL_BODY,0, NULL },
+   { CHANNELMSG_GPADL_CREATED, 1, vmbus_ongpadl_created },
+   { CHANNELMSG_GPADL_TEARDOWN,0, NULL },
+   { CHANNELMSG_GPADL_TORNDOWN,1, vmbus_ongpadl_torndown },
+   { CHANNELMSG_RELID_RELEASED,0, NULL },
+   { CHANNELMSG_INITIATE_CONTACT,  0, NULL },
+   { CHANNELMSG_VERSION_RESPONSE,  1, vmbus_onversion_response },
+   { CHANNELMSG_UNLOAD,0, NULL },
+   { CHANNELMSG_UNLOAD_RESPONSE,   1, vmbus_unload_response },
+   { CHANNELMSG_18,0, NULL },
+   { CHANNELMSG_19,0, NULL },
+   { CHANNELMSG_20,0, NULL },
+   { CHANNELMSG_TL_CONNECT_REQUEST,0, NULL },
 };
 
 /*
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 884f83b..b552c3a 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -376,7 +376,7 @@ struct vmbus_channel_message_table_entry {
void (*message_handler)(struct vmbus_channel_message_header *msg);
 };
 
-extern struct vmbus_channel_message_table_entry
+extern const struct vmbus_channel_message_table_entry
channel_message_table[CHANNELMSG_COUNT];
 
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 9ddbf4d..7fe8ef3 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -851,7 +851,7 @@ void vmbus_on_msg_dpc(unsigned long data)
struct hv_message *msg = (struct hv_message *)page_addr +
  VMBUS_MESSAGE_SINT;
struct vmbus_channel_message_header *hdr;
-   struct vmbus_channel_message_table_entry *entry;
+   const struct vmbus_channel_message_table_entry *entry;
struct onmessage_work_context *ctx;
u32 message_type = msg->header.message_type;
 
-- 
1.7.1



[PATCH 8/9] vmbus: cleanup header file style

2017-03-04 Thread kys
From: Stephen Hemminger 

Minor changes to align hyper-v vmbus include files with current
linux kernel style.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hyperv_vmbus.h |   16 
 include/linux/hyperv.h|   12 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index b552c3a..a69b52d 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -218,8 +218,8 @@ struct hv_per_cpu_context {
 
 struct hv_context {
/* We only support running on top of Hyper-V
-   * So at this point this really can only contain the Hyper-V ID
-   */
+* So at this point this really can only contain the Hyper-V ID
+*/
u64 guestid;
 
void *tsc_page;
@@ -403,17 +403,17 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
 void vmbus_on_event(unsigned long data);
 void vmbus_on_msg_dpc(unsigned long data);
 
-int hv_kvp_init(struct hv_util_service *);
+int hv_kvp_init(struct hv_util_service *srv);
 void hv_kvp_deinit(void);
-void hv_kvp_onchannelcallback(void *);
+void hv_kvp_onchannelcallback(void *context);
 
-int hv_vss_init(struct hv_util_service *);
+int hv_vss_init(struct hv_util_service *srv);
 void hv_vss_deinit(void);
-void hv_vss_onchannelcallback(void *);
+void hv_vss_onchannelcallback(void *context);
 
-int hv_fcopy_init(struct hv_util_service *);
+int hv_fcopy_init(struct hv_util_service *srv);
 void hv_fcopy_deinit(void);
-void hv_fcopy_onchannelcallback(void *);
+void hv_fcopy_onchannelcallback(void *context);
 void vmbus_initiate_unload(bool crash);
 
 static inline void hv_poll_channel(struct vmbus_channel *channel,
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index ee14f23..02f5d76 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -524,10 +524,10 @@ struct vmbus_channel_open_channel {
u32 target_vp;
 
/*
-   * The upstream ring buffer begins at offset zero in the memory
-   * described by RingBufferGpadlHandle. The downstream ring buffer
-   * follows it at this offset (in pages).
-   */
+* The upstream ring buffer begins at offset zero in the memory
+* described by RingBufferGpadlHandle. The downstream ring buffer
+* follows it at this offset (in pages).
+*/
u32 downstream_ringbuffer_pageoffset;
 
/* User-specific data to be passed along to the server endpoint. */
@@ -1013,7 +1013,7 @@ extern int vmbus_open(struct vmbus_channel *channel,
u32 recv_ringbuffersize,
void *userdata,
u32 userdatalen,
-   void(*onchannel_callback)(void *context),
+   void (*onchannel_callback)(void *context),
void *context);
 
 extern void vmbus_close(struct vmbus_channel *channel);
@@ -1428,7 +1428,7 @@ struct hyperv_service_callback {
char *log_msg;
uuid_le data;
struct vmbus_channel *channel;
-   void (*callback) (void *context);
+   void (*callback)(void *context);
 };
 
 #define MAX_SRV_VER0x7ff
-- 
1.7.1



[PATCH 7/9] vmbus: make channel_message table constant

2017-03-04 Thread kys
From: Stephen Hemminger 

This table is immutable and should be const.
Cleanup indentation and whitespace for this as well.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |   48 ++--
 drivers/hv/hyperv_vmbus.h |2 +-
 drivers/hv/vmbus_drv.c|2 +-
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index bf846d0..fe376af 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1079,30 +1079,30 @@ static void vmbus_onversion_response(
 }
 
 /* Channel message dispatch table */
-struct vmbus_channel_message_table_entry
-   channel_message_table[CHANNELMSG_COUNT] = {
-   {CHANNELMSG_INVALID,0, NULL},
-   {CHANNELMSG_OFFERCHANNEL,   0, vmbus_onoffer},
-   {CHANNELMSG_RESCIND_CHANNELOFFER,   0, vmbus_onoffer_rescind},
-   {CHANNELMSG_REQUESTOFFERS,  0, NULL},
-   {CHANNELMSG_ALLOFFERS_DELIVERED,1, vmbus_onoffers_delivered},
-   {CHANNELMSG_OPENCHANNEL,0, NULL},
-   {CHANNELMSG_OPENCHANNEL_RESULT, 1, vmbus_onopen_result},
-   {CHANNELMSG_CLOSECHANNEL,   0, NULL},
-   {CHANNELMSG_GPADL_HEADER,   0, NULL},
-   {CHANNELMSG_GPADL_BODY, 0, NULL},
-   {CHANNELMSG_GPADL_CREATED,  1, vmbus_ongpadl_created},
-   {CHANNELMSG_GPADL_TEARDOWN, 0, NULL},
-   {CHANNELMSG_GPADL_TORNDOWN, 1, vmbus_ongpadl_torndown},
-   {CHANNELMSG_RELID_RELEASED, 0, NULL},
-   {CHANNELMSG_INITIATE_CONTACT,   0, NULL},
-   {CHANNELMSG_VERSION_RESPONSE,   1, vmbus_onversion_response},
-   {CHANNELMSG_UNLOAD, 0, NULL},
-   {CHANNELMSG_UNLOAD_RESPONSE,1, vmbus_unload_response},
-   {CHANNELMSG_18, 0, NULL},
-   {CHANNELMSG_19, 0, NULL},
-   {CHANNELMSG_20, 0, NULL},
-   {CHANNELMSG_TL_CONNECT_REQUEST, 0, NULL},
+const struct vmbus_channel_message_table_entry
+channel_message_table[CHANNELMSG_COUNT] = {
+   { CHANNELMSG_INVALID,   0, NULL },
+   { CHANNELMSG_OFFERCHANNEL,  0, vmbus_onoffer },
+   { CHANNELMSG_RESCIND_CHANNELOFFER,  0, vmbus_onoffer_rescind },
+   { CHANNELMSG_REQUESTOFFERS, 0, NULL },
+   { CHANNELMSG_ALLOFFERS_DELIVERED,   1, vmbus_onoffers_delivered },
+   { CHANNELMSG_OPENCHANNEL,   0, NULL },
+   { CHANNELMSG_OPENCHANNEL_RESULT,1, vmbus_onopen_result },
+   { CHANNELMSG_CLOSECHANNEL,  0, NULL },
+   { CHANNELMSG_GPADL_HEADER,  0, NULL },
+   { CHANNELMSG_GPADL_BODY,0, NULL },
+   { CHANNELMSG_GPADL_CREATED, 1, vmbus_ongpadl_created },
+   { CHANNELMSG_GPADL_TEARDOWN,0, NULL },
+   { CHANNELMSG_GPADL_TORNDOWN,1, vmbus_ongpadl_torndown },
+   { CHANNELMSG_RELID_RELEASED,0, NULL },
+   { CHANNELMSG_INITIATE_CONTACT,  0, NULL },
+   { CHANNELMSG_VERSION_RESPONSE,  1, vmbus_onversion_response },
+   { CHANNELMSG_UNLOAD,0, NULL },
+   { CHANNELMSG_UNLOAD_RESPONSE,   1, vmbus_unload_response },
+   { CHANNELMSG_18,0, NULL },
+   { CHANNELMSG_19,0, NULL },
+   { CHANNELMSG_20,0, NULL },
+   { CHANNELMSG_TL_CONNECT_REQUEST,0, NULL },
 };
 
 /*
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 884f83b..b552c3a 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -376,7 +376,7 @@ struct vmbus_channel_message_table_entry {
void (*message_handler)(struct vmbus_channel_message_header *msg);
 };
 
-extern struct vmbus_channel_message_table_entry
+extern const struct vmbus_channel_message_table_entry
channel_message_table[CHANNELMSG_COUNT];
 
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 9ddbf4d..7fe8ef3 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -851,7 +851,7 @@ void vmbus_on_msg_dpc(unsigned long data)
struct hv_message *msg = (struct hv_message *)page_addr +
  VMBUS_MESSAGE_SINT;
struct vmbus_channel_message_header *hdr;
-   struct vmbus_channel_message_table_entry *entry;
+   const struct vmbus_channel_message_table_entry *entry;
struct onmessage_work_context *ctx;
u32 message_type = msg->header.message_type;
 
-- 
1.7.1



[PATCH 4/9] vmbus: remove unnecessary initialization

2017-03-04 Thread kys
From: Stephen Hemminger 

Don't initialize variables that are then set a few lines later.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index d0ff5b4..52d0556 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -265,14 +265,13 @@ void hv_ringbuffer_cleanup(struct hv_ring_buffer_info 
*ring_info)
 int hv_ringbuffer_write(struct vmbus_channel *channel,
const struct kvec *kv_list, u32 kv_count)
 {
-   int i = 0;
+   int i;
u32 bytes_avail_towrite;
-   u32 totalbytes_towrite = 0;
-
+   u32 totalbytes_towrite = sizeof(u64);
u32 next_write_location;
u32 old_write;
-   u64 prev_indices = 0;
-   unsigned long flags = 0;
+   u64 prev_indices;
+   unsigned long flags;
struct hv_ring_buffer_info *outring_info = >outbound;
 
if (channel->rescind)
@@ -281,8 +280,6 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
for (i = 0; i < kv_count; i++)
totalbytes_towrite += kv_list[i].iov_len;
 
-   totalbytes_towrite += sizeof(u64);
-
spin_lock_irqsave(_info->ring_lock, flags);
 
bytes_avail_towrite = hv_get_bytes_to_write(outring_info);
@@ -339,7 +336,7 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
   u64 *requestid, bool raw)
 {
u32 bytes_avail_toread;
-   u32 next_read_location = 0;
+   u32 next_read_location;
u64 prev_indices = 0;
struct vmpacket_descriptor desc;
u32 offset;
-- 
1.7.1



Re: [PATCH v5 2/5] staging: lustre: Remove unnecessary cast on void pointer

2017-03-04 Thread James Simmons

> The following Coccinelle script was used to detect this:
> @r@
> expression x;
> void* e;
> type T;
> identifier f;
> @@
> (
>   *((T *)e)
> |
>   ((T *)x)[...]
> |
>   ((T*)x)->f
> |
> - (T*)
>   e
> )
> 
> Signed-off-by: simran singhal 

Reviewed-by: James Simmons 

> ---
>  drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
> b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index 271e189..09b46924 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -640,7 +640,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, 
> void *karg,
>   int remote_gf_size = 0;
>   int rc;
>  
> - gf = (struct getinfo_fid2path *)karg;
> + gf = karg;
>   tgt = lmv_find_target(lmv, >gf_fid);
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> @@ -657,7 +657,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, 
> void *karg,
>   struct getinfo_fid2path *ori_gf;
>   char *ptr;
>  
> - ori_gf = (struct getinfo_fid2path *)karg;
> + ori_gf = karg;
>   if (strlen(ori_gf->gf_path) +
>   strlen(gf->gf_path) > ori_gf->gf_pathlen) {
>   rc = -EOVERFLOW;
> -- 
> 2.7.4
> 
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 


[PATCH 4/9] vmbus: remove unnecessary initialization

2017-03-04 Thread kys
From: Stephen Hemminger 

Don't initialize variables that are then set a few lines later.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index d0ff5b4..52d0556 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -265,14 +265,13 @@ void hv_ringbuffer_cleanup(struct hv_ring_buffer_info 
*ring_info)
 int hv_ringbuffer_write(struct vmbus_channel *channel,
const struct kvec *kv_list, u32 kv_count)
 {
-   int i = 0;
+   int i;
u32 bytes_avail_towrite;
-   u32 totalbytes_towrite = 0;
-
+   u32 totalbytes_towrite = sizeof(u64);
u32 next_write_location;
u32 old_write;
-   u64 prev_indices = 0;
-   unsigned long flags = 0;
+   u64 prev_indices;
+   unsigned long flags;
struct hv_ring_buffer_info *outring_info = >outbound;
 
if (channel->rescind)
@@ -281,8 +280,6 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
for (i = 0; i < kv_count; i++)
totalbytes_towrite += kv_list[i].iov_len;
 
-   totalbytes_towrite += sizeof(u64);
-
spin_lock_irqsave(_info->ring_lock, flags);
 
bytes_avail_towrite = hv_get_bytes_to_write(outring_info);
@@ -339,7 +336,7 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
   u64 *requestid, bool raw)
 {
u32 bytes_avail_toread;
-   u32 next_read_location = 0;
+   u32 next_read_location;
u64 prev_indices = 0;
struct vmpacket_descriptor desc;
u32 offset;
-- 
1.7.1



Re: [PATCH v5 2/5] staging: lustre: Remove unnecessary cast on void pointer

2017-03-04 Thread James Simmons

> The following Coccinelle script was used to detect this:
> @r@
> expression x;
> void* e;
> type T;
> identifier f;
> @@
> (
>   *((T *)e)
> |
>   ((T *)x)[...]
> |
>   ((T*)x)->f
> |
> - (T*)
>   e
> )
> 
> Signed-off-by: simran singhal 

Reviewed-by: James Simmons 

> ---
>  drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
> b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index 271e189..09b46924 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -640,7 +640,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, 
> void *karg,
>   int remote_gf_size = 0;
>   int rc;
>  
> - gf = (struct getinfo_fid2path *)karg;
> + gf = karg;
>   tgt = lmv_find_target(lmv, >gf_fid);
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> @@ -657,7 +657,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, 
> void *karg,
>   struct getinfo_fid2path *ori_gf;
>   char *ptr;
>  
> - ori_gf = (struct getinfo_fid2path *)karg;
> + ori_gf = karg;
>   if (strlen(ori_gf->gf_path) +
>   strlen(gf->gf_path) > ori_gf->gf_pathlen) {
>   rc = -EOVERFLOW;
> -- 
> 2.7.4
> 
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 


[PATCH 6/9] hyperv: remove unnecessary return variable

2017-03-04 Thread kys
From: Stephen Hemminger 

hv_ringbuffer_read cleanup.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 52d0556..8a24974 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -341,13 +341,11 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
struct vmpacket_descriptor desc;
u32 offset;
u32 packetlen;
-   int ret = 0;
struct hv_ring_buffer_info *inring_info = >inbound;
 
if (buflen <= 0)
return -EINVAL;
 
-
*buffer_actual_len = 0;
*requestid = 0;
 
@@ -358,7 +356,7 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
 * No error is set when there is even no header, drivers are
 * supposed to analyze buffer_actual_len.
 */
-   return ret;
+   return 0;
}
 
init_cached_read_index(channel);
@@ -403,5 +401,5 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
 
hv_signal_on_read(channel);
 
-   return ret;
+   return 0;
 }
-- 
1.7.1



[PATCH 6/9] hyperv: remove unnecessary return variable

2017-03-04 Thread kys
From: Stephen Hemminger 

hv_ringbuffer_read cleanup.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 52d0556..8a24974 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -341,13 +341,11 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
struct vmpacket_descriptor desc;
u32 offset;
u32 packetlen;
-   int ret = 0;
struct hv_ring_buffer_info *inring_info = >inbound;
 
if (buflen <= 0)
return -EINVAL;
 
-
*buffer_actual_len = 0;
*requestid = 0;
 
@@ -358,7 +356,7 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
 * No error is set when there is even no header, drivers are
 * supposed to analyze buffer_actual_len.
 */
-   return ret;
+   return 0;
}
 
init_cached_read_index(channel);
@@ -403,5 +401,5 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
 
hv_signal_on_read(channel);
 
-   return ret;
+   return 0;
 }
-- 
1.7.1



Re: [PATCHv2 07/14] drm: Use set_memory.h header

2017-03-04 Thread kbuild test robot
Hi Laura,

[auto build test ERROR on linus/master]
[also build test ERROR on next-20170303]
[cannot apply to tip/x86/core drm/drm-next v4.10]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Laura-Abbott/set_memory_-functions-header-refactor/20170305-062939
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

>> drivers/char/agp/generic.c:42:28: fatal error: asm/set_memory.h: No such 
>> file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/radeon/radeon_gart.c:30:28: fatal error: asm/set_memory.h: 
>> No such file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/ttm/ttm_tt.c:47:28: fatal error: asm/set_memory.h: No such 
>> file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/ttm/ttm_page_alloc.c:54:28: fatal error: asm/set_memory.h: 
>> No such file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/ttm/ttm_page_alloc_dma.c:56:28: fatal error: 
>> asm/set_memory.h: No such file or directory
#include 
   ^
   compilation terminated.

vim +30 drivers/gpu/drm/radeon/radeon_gart.c

24   * Authors: Dave Airlie
25   *  Alex Deucher
26   *  Jerome Glisse
27   */
28  #include 
29  #include 
  > 30  #include 
31  #include "radeon.h"
32  
33  /*

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCHv2 07/14] drm: Use set_memory.h header

2017-03-04 Thread kbuild test robot
Hi Laura,

[auto build test ERROR on linus/master]
[also build test ERROR on next-20170303]
[cannot apply to tip/x86/core drm/drm-next v4.10]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Laura-Abbott/set_memory_-functions-header-refactor/20170305-062939
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

>> drivers/char/agp/generic.c:42:28: fatal error: asm/set_memory.h: No such 
>> file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/radeon/radeon_gart.c:30:28: fatal error: asm/set_memory.h: 
>> No such file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/ttm/ttm_tt.c:47:28: fatal error: asm/set_memory.h: No such 
>> file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/ttm/ttm_page_alloc.c:54:28: fatal error: asm/set_memory.h: 
>> No such file or directory
#include 
   ^
   compilation terminated.
--
>> drivers/gpu/drm/ttm/ttm_page_alloc_dma.c:56:28: fatal error: 
>> asm/set_memory.h: No such file or directory
#include 
   ^
   compilation terminated.

vim +30 drivers/gpu/drm/radeon/radeon_gart.c

24   * Authors: Dave Airlie
25   *  Alex Deucher
26   *  Jerome Glisse
27   */
28  #include 
29  #include 
  > 30  #include 
31  #include "radeon.h"
32  
33  /*

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH 2/4] vmbus: remove hv_event_tasklet_disable/enable

2017-03-04 Thread kys
From: Dexuan Cui 

With the recent introduction of per-channel tasklet, we need to update
the way we handle the 3 concurrency issues:

1. hv_process_channel_removal -> percpu_channel_deq vs.
   vmbus_chan_sched -> list_for_each_entry(..., percpu_list);

2. vmbus_process_offer -> percpu_channel_enq/deq vs. vmbus_chan_sched.

3. vmbus_close_internal vs. the per-channel tasklet vmbus_on_event;

The first 2 issues can be handled by Stephen's recent patch
"vmbus: use rcu for per-cpu channel list", and the third issue
can be handled by calling tasklet_disable in vmbus_close_internal here.

We don't need the original hv_event_tasklet_disable/enable since we
now use per-channel tasklet instead of the previous per-CPU tasklet,
and actually we must remove them due to the side effect now:
vmbus_process_offer -> hv_event_tasklet_enable -> tasklet_schedule will
start the per-channel callback prematurely, cauing NULL dereferencing
(the channel may haven't been properly configured to run the callback yet).

Fixes: 631e63a9f346 ("vmbus: change to per channel tasklet")

Signed-off-by: Dexuan Cui 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Tested-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |   12 
 drivers/hv/channel_mgmt.c |   19 ---
 include/linux/hyperv.h|3 ---
 3 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 81a80c8..a5f4c43 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -530,15 +530,13 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
int ret;
 
/*
-* vmbus_on_event(), running in the tasklet, can race
+* vmbus_on_event(), running in the per-channel tasklet, can race
 * with vmbus_close_internal() in the case of SMP guest, e.g., when
 * the former is accessing channel->inbound.ring_buffer, the latter
-* could be freeing the ring_buffer pages.
-*
-* To resolve the race, we can serialize them by disabling the
-* tasklet when the latter is running here.
+* could be freeing the ring_buffer pages, so here we must stop it
+* first.
 */
-   hv_event_tasklet_disable(channel);
+   tasklet_disable(>callback_event);
 
/*
 * In case a device driver's probe() fails (e.g.,
@@ -605,8 +603,6 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
 
 out:
-   hv_event_tasklet_enable(channel);
-
return ret;
 }
 
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index d2cfa3e..bf846d0 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -382,19 +382,6 @@ static void vmbus_release_relid(u32 relid)
   true);
 }
 
-void hv_event_tasklet_disable(struct vmbus_channel *channel)
-{
-   tasklet_disable(>callback_event);
-}
-
-void hv_event_tasklet_enable(struct vmbus_channel *channel)
-{
-   tasklet_enable(>callback_event);
-
-   /* In case there is any pending event */
-   tasklet_schedule(>callback_event);
-}
-
 void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
 {
unsigned long flags;
@@ -403,7 +390,6 @@ void hv_process_channel_removal(struct vmbus_channel 
*channel, u32 relid)
BUG_ON(!channel->rescind);
BUG_ON(!mutex_is_locked(_connection.channel_mutex));
 
-   hv_event_tasklet_disable(channel);
if (channel->target_cpu != get_cpu()) {
put_cpu();
smp_call_function_single(channel->target_cpu,
@@ -412,7 +398,6 @@ void hv_process_channel_removal(struct vmbus_channel 
*channel, u32 relid)
percpu_channel_deq(channel);
put_cpu();
}
-   hv_event_tasklet_enable(channel);
 
if (channel->primary_channel == NULL) {
list_del(>listentry);
@@ -506,7 +491,6 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
 
init_vp_index(newchannel, dev_type);
 
-   hv_event_tasklet_disable(newchannel);
if (newchannel->target_cpu != get_cpu()) {
put_cpu();
smp_call_function_single(newchannel->target_cpu,
@@ -516,7 +500,6 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
percpu_channel_enq(newchannel);
put_cpu();
}
-   hv_event_tasklet_enable(newchannel);
 
/*
 * This state is used to indicate a successful open
@@ -566,7 +549,6 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
list_del(>listentry);
mutex_unlock(_connection.channel_mutex);
 
-   hv_event_tasklet_disable(newchannel);
if 

[PATCH 4/4] Drivers: hv: util: don't forget to init host_ts.lock

2017-03-04 Thread kys
From: Dexuan Cui 

Without the patch, I always get a "BUG: spinlock bad magic" warning.

Fixes: 3716a49a81ba ("hv_utils: implement Hyper-V PTP source")

Signed-off-by: Dexuan Cui 
Cc: Vitaly Kuznetsov 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_util.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index 3042eaa..186b100 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -590,6 +590,8 @@ static int hv_timesync_init(struct hv_util_service *srv)
if (!hyperv_cs)
return -ENODEV;
 
+   spin_lock_init(_ts.lock);
+
INIT_WORK(, hv_set_host_time);
 
/*
-- 
1.7.1



[PATCH 2/4] vmbus: remove hv_event_tasklet_disable/enable

2017-03-04 Thread kys
From: Dexuan Cui 

With the recent introduction of per-channel tasklet, we need to update
the way we handle the 3 concurrency issues:

1. hv_process_channel_removal -> percpu_channel_deq vs.
   vmbus_chan_sched -> list_for_each_entry(..., percpu_list);

2. vmbus_process_offer -> percpu_channel_enq/deq vs. vmbus_chan_sched.

3. vmbus_close_internal vs. the per-channel tasklet vmbus_on_event;

The first 2 issues can be handled by Stephen's recent patch
"vmbus: use rcu for per-cpu channel list", and the third issue
can be handled by calling tasklet_disable in vmbus_close_internal here.

We don't need the original hv_event_tasklet_disable/enable since we
now use per-channel tasklet instead of the previous per-CPU tasklet,
and actually we must remove them due to the side effect now:
vmbus_process_offer -> hv_event_tasklet_enable -> tasklet_schedule will
start the per-channel callback prematurely, cauing NULL dereferencing
(the channel may haven't been properly configured to run the callback yet).

Fixes: 631e63a9f346 ("vmbus: change to per channel tasklet")

Signed-off-by: Dexuan Cui 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Tested-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel.c  |   12 
 drivers/hv/channel_mgmt.c |   19 ---
 include/linux/hyperv.h|3 ---
 3 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 81a80c8..a5f4c43 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -530,15 +530,13 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
int ret;
 
/*
-* vmbus_on_event(), running in the tasklet, can race
+* vmbus_on_event(), running in the per-channel tasklet, can race
 * with vmbus_close_internal() in the case of SMP guest, e.g., when
 * the former is accessing channel->inbound.ring_buffer, the latter
-* could be freeing the ring_buffer pages.
-*
-* To resolve the race, we can serialize them by disabling the
-* tasklet when the latter is running here.
+* could be freeing the ring_buffer pages, so here we must stop it
+* first.
 */
-   hv_event_tasklet_disable(channel);
+   tasklet_disable(>callback_event);
 
/*
 * In case a device driver's probe() fails (e.g.,
@@ -605,8 +603,6 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
 
 out:
-   hv_event_tasklet_enable(channel);
-
return ret;
 }
 
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index d2cfa3e..bf846d0 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -382,19 +382,6 @@ static void vmbus_release_relid(u32 relid)
   true);
 }
 
-void hv_event_tasklet_disable(struct vmbus_channel *channel)
-{
-   tasklet_disable(>callback_event);
-}
-
-void hv_event_tasklet_enable(struct vmbus_channel *channel)
-{
-   tasklet_enable(>callback_event);
-
-   /* In case there is any pending event */
-   tasklet_schedule(>callback_event);
-}
-
 void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
 {
unsigned long flags;
@@ -403,7 +390,6 @@ void hv_process_channel_removal(struct vmbus_channel 
*channel, u32 relid)
BUG_ON(!channel->rescind);
BUG_ON(!mutex_is_locked(_connection.channel_mutex));
 
-   hv_event_tasklet_disable(channel);
if (channel->target_cpu != get_cpu()) {
put_cpu();
smp_call_function_single(channel->target_cpu,
@@ -412,7 +398,6 @@ void hv_process_channel_removal(struct vmbus_channel 
*channel, u32 relid)
percpu_channel_deq(channel);
put_cpu();
}
-   hv_event_tasklet_enable(channel);
 
if (channel->primary_channel == NULL) {
list_del(>listentry);
@@ -506,7 +491,6 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
 
init_vp_index(newchannel, dev_type);
 
-   hv_event_tasklet_disable(newchannel);
if (newchannel->target_cpu != get_cpu()) {
put_cpu();
smp_call_function_single(newchannel->target_cpu,
@@ -516,7 +500,6 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
percpu_channel_enq(newchannel);
put_cpu();
}
-   hv_event_tasklet_enable(newchannel);
 
/*
 * This state is used to indicate a successful open
@@ -566,7 +549,6 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
list_del(>listentry);
mutex_unlock(_connection.channel_mutex);
 
-   hv_event_tasklet_disable(newchannel);
if (newchannel->target_cpu != get_cpu()) {
put_cpu();
smp_call_function_single(newchannel->target_cpu,
@@ -575,7 +557,6 @@ 

[PATCH 4/4] Drivers: hv: util: don't forget to init host_ts.lock

2017-03-04 Thread kys
From: Dexuan Cui 

Without the patch, I always get a "BUG: spinlock bad magic" warning.

Fixes: 3716a49a81ba ("hv_utils: implement Hyper-V PTP source")

Signed-off-by: Dexuan Cui 
Cc: Vitaly Kuznetsov 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_util.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index 3042eaa..186b100 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -590,6 +590,8 @@ static int hv_timesync_init(struct hv_util_service *srv)
if (!hyperv_cs)
return -ENODEV;
 
+   spin_lock_init(_ts.lock);
+
INIT_WORK(, hv_set_host_time);
 
/*
-- 
1.7.1



[PATCH 1/4] vmbus: use rcu for per-cpu channel list

2017-03-04 Thread kys
From: Stephen Hemminger 

The per-cpu channel list is now referred to in the interrupt
routine. This is mostly safe since the host will not normally generate
an interrupt when channel is being deleted but if it did then there
would be a use after free problem.

To solve, this use RCU protection on ther per-cpu list.

Fixes: 631e63a9f346 ("vmbus: change to per channel tasklet")

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |7 ---
 drivers/hv/vmbus_drv.c|6 +-
 include/linux/hyperv.h|7 +++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index f33465d..d2cfa3e 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -350,7 +350,8 @@ bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp,
 static void free_channel(struct vmbus_channel *channel)
 {
tasklet_kill(>callback_event);
-   kfree(channel);
+
+   kfree_rcu(channel, rcu);
 }
 
 static void percpu_channel_enq(void *arg)
@@ -359,14 +360,14 @@ static void percpu_channel_enq(void *arg)
struct hv_per_cpu_context *hv_cpu
= this_cpu_ptr(hv_context.cpu_context);
 
-   list_add_tail(>percpu_list, _cpu->chan_list);
+   list_add_tail_rcu(>percpu_list, _cpu->chan_list);
 }
 
 static void percpu_channel_deq(void *arg)
 {
struct vmbus_channel *channel = arg;
 
-   list_del(>percpu_list);
+   list_del_rcu(>percpu_list);
 }
 
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index f7f6b91..971ecb7 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -937,8 +937,10 @@ static void vmbus_chan_sched(struct hv_per_cpu_context 
*hv_cpu)
if (relid == 0)
continue;
 
+   rcu_read_lock();
+
/* Find channel based on relid */
-   list_for_each_entry(channel, _cpu->chan_list, percpu_list) {
+   list_for_each_entry_rcu(channel, _cpu->chan_list, 
percpu_list) {
if (channel->offermsg.child_relid != relid)
continue;
 
@@ -954,6 +956,8 @@ static void vmbus_chan_sched(struct hv_per_cpu_context 
*hv_cpu)
tasklet_schedule(>callback_event);
}
}
+
+   rcu_read_unlock();
}
 }
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 62bbf3c..c4c7ae9 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -845,6 +845,13 @@ struct vmbus_channel {
 * link up channels based on their CPU affinity.
 */
struct list_head percpu_list;
+
+   /*
+* Defer freeing channel until after all cpu's have
+* gone through grace period.
+*/
+   struct rcu_head rcu;
+
/*
 * For performance critical channels (storage, networking
 * etc,), Hyper-V has a mechanism to enhance the throughput
-- 
1.7.1



[PATCH 1/4] vmbus: use rcu for per-cpu channel list

2017-03-04 Thread kys
From: Stephen Hemminger 

The per-cpu channel list is now referred to in the interrupt
routine. This is mostly safe since the host will not normally generate
an interrupt when channel is being deleted but if it did then there
would be a use after free problem.

To solve, this use RCU protection on ther per-cpu list.

Fixes: 631e63a9f346 ("vmbus: change to per channel tasklet")

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |7 ---
 drivers/hv/vmbus_drv.c|6 +-
 include/linux/hyperv.h|7 +++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index f33465d..d2cfa3e 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -350,7 +350,8 @@ bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp,
 static void free_channel(struct vmbus_channel *channel)
 {
tasklet_kill(>callback_event);
-   kfree(channel);
+
+   kfree_rcu(channel, rcu);
 }
 
 static void percpu_channel_enq(void *arg)
@@ -359,14 +360,14 @@ static void percpu_channel_enq(void *arg)
struct hv_per_cpu_context *hv_cpu
= this_cpu_ptr(hv_context.cpu_context);
 
-   list_add_tail(>percpu_list, _cpu->chan_list);
+   list_add_tail_rcu(>percpu_list, _cpu->chan_list);
 }
 
 static void percpu_channel_deq(void *arg)
 {
struct vmbus_channel *channel = arg;
 
-   list_del(>percpu_list);
+   list_del_rcu(>percpu_list);
 }
 
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index f7f6b91..971ecb7 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -937,8 +937,10 @@ static void vmbus_chan_sched(struct hv_per_cpu_context 
*hv_cpu)
if (relid == 0)
continue;
 
+   rcu_read_lock();
+
/* Find channel based on relid */
-   list_for_each_entry(channel, _cpu->chan_list, percpu_list) {
+   list_for_each_entry_rcu(channel, _cpu->chan_list, 
percpu_list) {
if (channel->offermsg.child_relid != relid)
continue;
 
@@ -954,6 +956,8 @@ static void vmbus_chan_sched(struct hv_per_cpu_context 
*hv_cpu)
tasklet_schedule(>callback_event);
}
}
+
+   rcu_read_unlock();
}
 }
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 62bbf3c..c4c7ae9 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -845,6 +845,13 @@ struct vmbus_channel {
 * link up channels based on their CPU affinity.
 */
struct list_head percpu_list;
+
+   /*
+* Defer freeing channel until after all cpu's have
+* gone through grace period.
+*/
+   struct rcu_head rcu;
+
/*
 * For performance critical channels (storage, networking
 * etc,), Hyper-V has a mechanism to enhance the throughput
-- 
1.7.1



[PATCH 3/4] Drivers: hv: util: move waiting for release to hv_utils_transport itself

2017-03-04 Thread kys
From: Vitaly Kuznetsov 

Waiting for release_event in all three drivers introduced issues on release
as on_reset() hook is not always called. E.g. if the device was never
opened we will never get the completion.

Move the waiting code to hvutil_transport_destroy() and make sure it is
only called when the device is open. hvt->lock serialization should
guarantee the absence of races.

Fixes: 5a66fecbf6aa ("Drivers: hv: util: kvp: Fix a rescind processing issue")
Fixes: 20951c7535b5 ("Drivers: hv: util: Fcopy: Fix a rescind processing issue")
Fixes: d77044d142e9 ("Drivers: hv: util: Backup: Fix a rescind processing 
issue")

Reported-by: Dexuan Cui 
Tested-by: Dexuan Cui 
Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_fcopy.c   |4 
 drivers/hv/hv_kvp.c |4 
 drivers/hv/hv_snapshot.c|4 
 drivers/hv/hv_utils_transport.c |   12 
 drivers/hv/hv_utils_transport.h |1 +
 5 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
index 9aee601..a5596a6 100644
--- a/drivers/hv/hv_fcopy.c
+++ b/drivers/hv/hv_fcopy.c
@@ -71,7 +71,6 @@
 static const char fcopy_devname[] = "vmbus/hv_fcopy";
 static u8 *recv_buffer;
 static struct hvutil_transport *hvt;
-static struct completion release_event;
 /*
  * This state maintains the version number registered by the daemon.
  */
@@ -331,7 +330,6 @@ static void fcopy_on_reset(void)
 
if (cancel_delayed_work_sync(_timeout_work))
fcopy_respond_to_host(HV_E_FAIL);
-   complete(_event);
 }
 
 int hv_fcopy_init(struct hv_util_service *srv)
@@ -339,7 +337,6 @@ int hv_fcopy_init(struct hv_util_service *srv)
recv_buffer = srv->recv_buffer;
fcopy_transaction.recv_channel = srv->channel;
 
-   init_completion(_event);
/*
 * When this driver loads, the user level daemon that
 * processes the host requests may not yet be running.
@@ -361,5 +358,4 @@ void hv_fcopy_deinit(void)
fcopy_transaction.state = HVUTIL_DEVICE_DYING;
cancel_delayed_work_sync(_timeout_work);
hvutil_transport_destroy(hvt);
-   wait_for_completion(_event);
 }
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index de26371..a1adfe2 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -101,7 +101,6 @@
 static const char kvp_devname[] = "vmbus/hv_kvp";
 static u8 *recv_buffer;
 static struct hvutil_transport *hvt;
-static struct completion release_event;
 /*
  * Register the kernel component with the user-level daemon.
  * As part of this registration, pass the LIC version number.
@@ -714,7 +713,6 @@ static void kvp_on_reset(void)
if (cancel_delayed_work_sync(_timeout_work))
kvp_respond_to_host(NULL, HV_E_FAIL);
kvp_transaction.state = HVUTIL_DEVICE_INIT;
-   complete(_event);
 }
 
 int
@@ -723,7 +721,6 @@ static void kvp_on_reset(void)
recv_buffer = srv->recv_buffer;
kvp_transaction.recv_channel = srv->channel;
 
-   init_completion(_event);
/*
 * When this driver loads, the user level daemon that
 * processes the host requests may not yet be running.
@@ -747,5 +744,4 @@ void hv_kvp_deinit(void)
cancel_delayed_work_sync(_timeout_work);
cancel_work_sync(_sendkey_work);
hvutil_transport_destroy(hvt);
-   wait_for_completion(_event);
 }
diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
index bcc03f0..e659d1b 100644
--- a/drivers/hv/hv_snapshot.c
+++ b/drivers/hv/hv_snapshot.c
@@ -79,7 +79,6 @@
 static const char vss_devname[] = "vmbus/hv_vss";
 static __u8 *recv_buffer;
 static struct hvutil_transport *hvt;
-static struct completion release_event;
 
 static void vss_timeout_func(struct work_struct *dummy);
 static void vss_handle_request(struct work_struct *dummy);
@@ -361,13 +360,11 @@ static void vss_on_reset(void)
if (cancel_delayed_work_sync(_timeout_work))
vss_respond_to_host(HV_E_FAIL);
vss_transaction.state = HVUTIL_DEVICE_INIT;
-   complete(_event);
 }
 
 int
 hv_vss_init(struct hv_util_service *srv)
 {
-   init_completion(_event);
if (vmbus_proto_version < VERSION_WIN8_1) {
pr_warn("Integration service 'Backup (volume snapshot)'"
" not supported on this host version.\n");
@@ -400,5 +397,4 @@ void hv_vss_deinit(void)
cancel_delayed_work_sync(_timeout_work);
cancel_work_sync(_handle_request_work);
hvutil_transport_destroy(hvt);
-   wait_for_completion(_event);
 }
diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index c235a95..4402a71 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -182,10 +182,11 @@ static int hvt_op_release(struct inode *inode, struct 

[PATCH 3/4] Drivers: hv: util: move waiting for release to hv_utils_transport itself

2017-03-04 Thread kys
From: Vitaly Kuznetsov 

Waiting for release_event in all three drivers introduced issues on release
as on_reset() hook is not always called. E.g. if the device was never
opened we will never get the completion.

Move the waiting code to hvutil_transport_destroy() and make sure it is
only called when the device is open. hvt->lock serialization should
guarantee the absence of races.

Fixes: 5a66fecbf6aa ("Drivers: hv: util: kvp: Fix a rescind processing issue")
Fixes: 20951c7535b5 ("Drivers: hv: util: Fcopy: Fix a rescind processing issue")
Fixes: d77044d142e9 ("Drivers: hv: util: Backup: Fix a rescind processing 
issue")

Reported-by: Dexuan Cui 
Tested-by: Dexuan Cui 
Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/hv_fcopy.c   |4 
 drivers/hv/hv_kvp.c |4 
 drivers/hv/hv_snapshot.c|4 
 drivers/hv/hv_utils_transport.c |   12 
 drivers/hv/hv_utils_transport.h |1 +
 5 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c
index 9aee601..a5596a6 100644
--- a/drivers/hv/hv_fcopy.c
+++ b/drivers/hv/hv_fcopy.c
@@ -71,7 +71,6 @@
 static const char fcopy_devname[] = "vmbus/hv_fcopy";
 static u8 *recv_buffer;
 static struct hvutil_transport *hvt;
-static struct completion release_event;
 /*
  * This state maintains the version number registered by the daemon.
  */
@@ -331,7 +330,6 @@ static void fcopy_on_reset(void)
 
if (cancel_delayed_work_sync(_timeout_work))
fcopy_respond_to_host(HV_E_FAIL);
-   complete(_event);
 }
 
 int hv_fcopy_init(struct hv_util_service *srv)
@@ -339,7 +337,6 @@ int hv_fcopy_init(struct hv_util_service *srv)
recv_buffer = srv->recv_buffer;
fcopy_transaction.recv_channel = srv->channel;
 
-   init_completion(_event);
/*
 * When this driver loads, the user level daemon that
 * processes the host requests may not yet be running.
@@ -361,5 +358,4 @@ void hv_fcopy_deinit(void)
fcopy_transaction.state = HVUTIL_DEVICE_DYING;
cancel_delayed_work_sync(_timeout_work);
hvutil_transport_destroy(hvt);
-   wait_for_completion(_event);
 }
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index de26371..a1adfe2 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -101,7 +101,6 @@
 static const char kvp_devname[] = "vmbus/hv_kvp";
 static u8 *recv_buffer;
 static struct hvutil_transport *hvt;
-static struct completion release_event;
 /*
  * Register the kernel component with the user-level daemon.
  * As part of this registration, pass the LIC version number.
@@ -714,7 +713,6 @@ static void kvp_on_reset(void)
if (cancel_delayed_work_sync(_timeout_work))
kvp_respond_to_host(NULL, HV_E_FAIL);
kvp_transaction.state = HVUTIL_DEVICE_INIT;
-   complete(_event);
 }
 
 int
@@ -723,7 +721,6 @@ static void kvp_on_reset(void)
recv_buffer = srv->recv_buffer;
kvp_transaction.recv_channel = srv->channel;
 
-   init_completion(_event);
/*
 * When this driver loads, the user level daemon that
 * processes the host requests may not yet be running.
@@ -747,5 +744,4 @@ void hv_kvp_deinit(void)
cancel_delayed_work_sync(_timeout_work);
cancel_work_sync(_sendkey_work);
hvutil_transport_destroy(hvt);
-   wait_for_completion(_event);
 }
diff --git a/drivers/hv/hv_snapshot.c b/drivers/hv/hv_snapshot.c
index bcc03f0..e659d1b 100644
--- a/drivers/hv/hv_snapshot.c
+++ b/drivers/hv/hv_snapshot.c
@@ -79,7 +79,6 @@
 static const char vss_devname[] = "vmbus/hv_vss";
 static __u8 *recv_buffer;
 static struct hvutil_transport *hvt;
-static struct completion release_event;
 
 static void vss_timeout_func(struct work_struct *dummy);
 static void vss_handle_request(struct work_struct *dummy);
@@ -361,13 +360,11 @@ static void vss_on_reset(void)
if (cancel_delayed_work_sync(_timeout_work))
vss_respond_to_host(HV_E_FAIL);
vss_transaction.state = HVUTIL_DEVICE_INIT;
-   complete(_event);
 }
 
 int
 hv_vss_init(struct hv_util_service *srv)
 {
-   init_completion(_event);
if (vmbus_proto_version < VERSION_WIN8_1) {
pr_warn("Integration service 'Backup (volume snapshot)'"
" not supported on this host version.\n");
@@ -400,5 +397,4 @@ void hv_vss_deinit(void)
cancel_delayed_work_sync(_timeout_work);
cancel_work_sync(_handle_request_work);
hvutil_transport_destroy(hvt);
-   wait_for_completion(_event);
 }
diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index c235a95..4402a71 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -182,10 +182,11 @@ static int hvt_op_release(struct inode *inode, struct 
file *file)
 * connects back.
 */
hvt_reset(hvt);
-   mutex_unlock(>lock);
 

[PATCH 0/4] Drivers: hv: vmbus: Miscellaneous Fixes

2017-03-04 Thread kys
From: K. Y. Srinivasan 

These patches fix several issues introduced in 4.11. Greg,
Please pick these patches for 4.11.

Dexuan Cui (2):
  vmbus: remove hv_event_tasklet_disable/enable
  Drivers: hv: util: don't forget to init host_ts.lock

Stephen Hemminger (1):
  vmbus: use rcu for per-cpu channel list

Vitaly Kuznetsov (1):
  Drivers: hv: util: move waiting for release to hv_utils_transport
itself

 drivers/hv/channel.c|   12 
 drivers/hv/channel_mgmt.c   |   26 --
 drivers/hv/hv_fcopy.c   |4 
 drivers/hv/hv_kvp.c |4 
 drivers/hv/hv_snapshot.c|4 
 drivers/hv/hv_util.c|2 ++
 drivers/hv/hv_utils_transport.c |   12 
 drivers/hv/hv_utils_transport.h |1 +
 drivers/hv/vmbus_drv.c  |6 +-
 include/linux/hyperv.h  |   10 +++---
 10 files changed, 31 insertions(+), 50 deletions(-)



[PATCH 0/4] Drivers: hv: vmbus: Miscellaneous Fixes

2017-03-04 Thread kys
From: K. Y. Srinivasan 

These patches fix several issues introduced in 4.11. Greg,
Please pick these patches for 4.11.

Dexuan Cui (2):
  vmbus: remove hv_event_tasklet_disable/enable
  Drivers: hv: util: don't forget to init host_ts.lock

Stephen Hemminger (1):
  vmbus: use rcu for per-cpu channel list

Vitaly Kuznetsov (1):
  Drivers: hv: util: move waiting for release to hv_utils_transport
itself

 drivers/hv/channel.c|   12 
 drivers/hv/channel_mgmt.c   |   26 --
 drivers/hv/hv_fcopy.c   |4 
 drivers/hv/hv_kvp.c |4 
 drivers/hv/hv_snapshot.c|4 
 drivers/hv/hv_util.c|2 ++
 drivers/hv/hv_utils_transport.c |   12 
 drivers/hv/hv_utils_transport.h |1 +
 drivers/hv/vmbus_drv.c  |6 +-
 include/linux/hyperv.h  |   10 +++---
 10 files changed, 31 insertions(+), 50 deletions(-)



Re: rcu: WARNING in rcu_seq_end

2017-03-04 Thread Paul E. McKenney
On Sat, Mar 04, 2017 at 05:01:19PM +0100, Dmitry Vyukov wrote:
> Hello,
> 
> Paul, you wanted bugs in rcu.

Well, whether I want them or not, I must deal with them.  ;-)

> I've got this WARNING while running syzkaller fuzzer on
> 86292b33d4b79ee03e2f43ea0381ef85f077c760:
> 
> [ cut here ]
> WARNING: CPU: 0 PID: 4832 at kernel/rcu/tree.c:3533
> rcu_seq_end+0x110/0x140 kernel/rcu/tree.c:3533
> Kernel panic - not syncing: panic_on_warn set ...
> CPU: 0 PID: 4832 Comm: kworker/0:3 Not tainted 4.10.0+ #276
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> Workqueue: events wait_rcu_exp_gp
> Call Trace:
>  __dump_stack lib/dump_stack.c:15 [inline]
>  dump_stack+0x2ee/0x3ef lib/dump_stack.c:51
>  panic+0x1fb/0x412 kernel/panic.c:179
>  __warn+0x1c4/0x1e0 kernel/panic.c:540
>  warn_slowpath_null+0x2c/0x40 kernel/panic.c:583
>  rcu_seq_end+0x110/0x140 kernel/rcu/tree.c:3533
>  rcu_exp_gp_seq_end kernel/rcu/tree_exp.h:36 [inline]
>  rcu_exp_wait_wake+0x8a9/0x1330 kernel/rcu/tree_exp.h:517
>  rcu_exp_sel_wait_wake kernel/rcu/tree_exp.h:559 [inline]
>  wait_rcu_exp_gp+0x83/0xc0 kernel/rcu/tree_exp.h:570
>  process_one_work+0xc06/0x1c20 kernel/workqueue.c:2096
>  worker_thread+0x223/0x19c0 kernel/workqueue.c:2230
>  kthread+0x326/0x3f0 kernel/kthread.c:227
>  ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
> Dumping ftrace buffer:
>(ftrace buffer empty)
> Kernel Offset: disabled
> Rebooting in 86400 seconds..
> 
> 
> Not reproducible. But looking at the code, shouldn't it be:
> 
>  static void rcu_seq_end(unsigned long *sp)
>  {
> smp_mb(); /* Ensure update-side operation before counter increment. */
> +   WARN_ON_ONCE(!(*sp & 0x1));
> WRITE_ONCE(*sp, *sp + 1);
> -   WARN_ON_ONCE(*sp & 0x1);
>  }
> 
> ?
> 
> Otherwise wait_event in _synchronize_rcu_expedited can return as soon
> as WRITE_ONCE(*sp, *sp + 1) finishes. As far as I understand this
> consequently can allow start of next grace periods. Which in turn can
> make the warning fire. Am I missing something?
> 
> I don't see any other bad consequences of this. The rest of
> rcu_exp_wait_wake can proceed when _synchronize_rcu_expedited has
> returned and destroyed work on stack and next period has started and
> ended, but it seems OK.

I believe that this is a heygood change, but I don't see how it will
help in this case.  BTW, may I have your Signed-off-by?

The reason I don't believe that it will help is that the
rcu_exp_gp_seq_end() function is called from a workqueue handler that
is invoked holding ->exp_mutex, and this mutex is not released until
after the handler invokes rcu_seq_end() and then wakes up the task that
scheduled the workqueue handler.  So the ordering above should not matter
(but I agree that your ordering is cleaner.

That said, it looks like I am missing some memory barriers, please
see the following patch.

But what architecture did you see this on?

Thanx, Paul



commit 1038d97908afb04750d0775748e2165a6e92d851
Author: Paul E. McKenney 
Date:   Sat Mar 4 12:33:53 2017 -0800

rcu: Expedited wakeups need to be fully ordered

Expedited grace periods use workqueue handlers that wake up the requesters,
but there is no lock mediating this wakeup.  Therefore, memory barriers
are required to ensure that the handler's memory references are seen by
all to occur before synchronize_*_expedited() returns to its caller.
Possibly detected by syzkaller.

Reported-by: Dmitry Vyukov 
Signed-off-by: Paul E. McKenney 

diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index 51ca287828a2..027e123d93c7 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -533,6 +533,7 @@ static void rcu_exp_wait_wake(struct rcu_state *rsp, 
unsigned long s)
rnp->exp_seq_rq = s;
spin_unlock(>exp_lock);
}
+   smp_mb(); /* All above changes before wakeup. */
wake_up_all(>exp_wq[(rsp->expedited_sequence >> 1) & 0x3]);
}
trace_rcu_exp_grace_period(rsp->name, s, TPS("endwake"));
@@ -614,6 +615,7 @@ static void _synchronize_rcu_expedited(struct rcu_state 
*rsp,
wait_event(rnp->exp_wq[(s >> 1) & 0x3],
   sync_exp_work_done(rsp,
  >exp_workdone0, s));
+   smp_mb(); /* Workqueue actions happen before return. */
 
/* Let the next expedited grace period start. */
mutex_unlock(>exp_mutex);



Re: rcu: WARNING in rcu_seq_end

2017-03-04 Thread Paul E. McKenney
On Sat, Mar 04, 2017 at 05:01:19PM +0100, Dmitry Vyukov wrote:
> Hello,
> 
> Paul, you wanted bugs in rcu.

Well, whether I want them or not, I must deal with them.  ;-)

> I've got this WARNING while running syzkaller fuzzer on
> 86292b33d4b79ee03e2f43ea0381ef85f077c760:
> 
> [ cut here ]
> WARNING: CPU: 0 PID: 4832 at kernel/rcu/tree.c:3533
> rcu_seq_end+0x110/0x140 kernel/rcu/tree.c:3533
> Kernel panic - not syncing: panic_on_warn set ...
> CPU: 0 PID: 4832 Comm: kworker/0:3 Not tainted 4.10.0+ #276
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> Workqueue: events wait_rcu_exp_gp
> Call Trace:
>  __dump_stack lib/dump_stack.c:15 [inline]
>  dump_stack+0x2ee/0x3ef lib/dump_stack.c:51
>  panic+0x1fb/0x412 kernel/panic.c:179
>  __warn+0x1c4/0x1e0 kernel/panic.c:540
>  warn_slowpath_null+0x2c/0x40 kernel/panic.c:583
>  rcu_seq_end+0x110/0x140 kernel/rcu/tree.c:3533
>  rcu_exp_gp_seq_end kernel/rcu/tree_exp.h:36 [inline]
>  rcu_exp_wait_wake+0x8a9/0x1330 kernel/rcu/tree_exp.h:517
>  rcu_exp_sel_wait_wake kernel/rcu/tree_exp.h:559 [inline]
>  wait_rcu_exp_gp+0x83/0xc0 kernel/rcu/tree_exp.h:570
>  process_one_work+0xc06/0x1c20 kernel/workqueue.c:2096
>  worker_thread+0x223/0x19c0 kernel/workqueue.c:2230
>  kthread+0x326/0x3f0 kernel/kthread.c:227
>  ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
> Dumping ftrace buffer:
>(ftrace buffer empty)
> Kernel Offset: disabled
> Rebooting in 86400 seconds..
> 
> 
> Not reproducible. But looking at the code, shouldn't it be:
> 
>  static void rcu_seq_end(unsigned long *sp)
>  {
> smp_mb(); /* Ensure update-side operation before counter increment. */
> +   WARN_ON_ONCE(!(*sp & 0x1));
> WRITE_ONCE(*sp, *sp + 1);
> -   WARN_ON_ONCE(*sp & 0x1);
>  }
> 
> ?
> 
> Otherwise wait_event in _synchronize_rcu_expedited can return as soon
> as WRITE_ONCE(*sp, *sp + 1) finishes. As far as I understand this
> consequently can allow start of next grace periods. Which in turn can
> make the warning fire. Am I missing something?
> 
> I don't see any other bad consequences of this. The rest of
> rcu_exp_wait_wake can proceed when _synchronize_rcu_expedited has
> returned and destroyed work on stack and next period has started and
> ended, but it seems OK.

I believe that this is a heygood change, but I don't see how it will
help in this case.  BTW, may I have your Signed-off-by?

The reason I don't believe that it will help is that the
rcu_exp_gp_seq_end() function is called from a workqueue handler that
is invoked holding ->exp_mutex, and this mutex is not released until
after the handler invokes rcu_seq_end() and then wakes up the task that
scheduled the workqueue handler.  So the ordering above should not matter
(but I agree that your ordering is cleaner.

That said, it looks like I am missing some memory barriers, please
see the following patch.

But what architecture did you see this on?

Thanx, Paul



commit 1038d97908afb04750d0775748e2165a6e92d851
Author: Paul E. McKenney 
Date:   Sat Mar 4 12:33:53 2017 -0800

rcu: Expedited wakeups need to be fully ordered

Expedited grace periods use workqueue handlers that wake up the requesters,
but there is no lock mediating this wakeup.  Therefore, memory barriers
are required to ensure that the handler's memory references are seen by
all to occur before synchronize_*_expedited() returns to its caller.
Possibly detected by syzkaller.

Reported-by: Dmitry Vyukov 
Signed-off-by: Paul E. McKenney 

diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index 51ca287828a2..027e123d93c7 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -533,6 +533,7 @@ static void rcu_exp_wait_wake(struct rcu_state *rsp, 
unsigned long s)
rnp->exp_seq_rq = s;
spin_unlock(>exp_lock);
}
+   smp_mb(); /* All above changes before wakeup. */
wake_up_all(>exp_wq[(rsp->expedited_sequence >> 1) & 0x3]);
}
trace_rcu_exp_grace_period(rsp->name, s, TPS("endwake"));
@@ -614,6 +615,7 @@ static void _synchronize_rcu_expedited(struct rcu_state 
*rsp,
wait_event(rnp->exp_wq[(s >> 1) & 0x3],
   sync_exp_work_done(rsp,
  >exp_workdone0, s));
+   smp_mb(); /* Workqueue actions happen before return. */
 
/* Let the next expedited grace period start. */
mutex_unlock(>exp_mutex);



[PATCH] x86/reboot/quirks: add ASUS EeeBook X205TA reboot quirk

2017-03-04 Thread Matjaz Hegedic
Without the parameter reboot=a, ASUS EeeBook X205TA will hang
when it should reboot. This adds the appropriate quirk, thus
fixing the problem.

Signed-off-by: Matjaz Hegedic 
---
 arch/x86/kernel/reboot.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index e244c19..01c9cda 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -223,6 +223,14 @@ static struct dmi_system_id __initdata reboot_dmi_table[] 
= {
DMI_MATCH(DMI_BOARD_NAME, "P4S800"),
},
},
+   {   /* Handle problems with rebooting on ASUS EeeBook X205TA */
+   .callback = set_acpi_reboot,
+   .ident = "ASUS EeeBook X205TA",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+   DMI_MATCH(DMI_PRODUCT_NAME, "X205TAW"),
+   },
+   },
 
/* Certec */
{   /* Handle problems with rebooting on Certec BPC600 */
-- 
2.7.4



[PATCH] x86/reboot/quirks: add ASUS EeeBook X205TA reboot quirk

2017-03-04 Thread Matjaz Hegedic
Without the parameter reboot=a, ASUS EeeBook X205TA will hang
when it should reboot. This adds the appropriate quirk, thus
fixing the problem.

Signed-off-by: Matjaz Hegedic 
---
 arch/x86/kernel/reboot.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index e244c19..01c9cda 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -223,6 +223,14 @@ static struct dmi_system_id __initdata reboot_dmi_table[] 
= {
DMI_MATCH(DMI_BOARD_NAME, "P4S800"),
},
},
+   {   /* Handle problems with rebooting on ASUS EeeBook X205TA */
+   .callback = set_acpi_reboot,
+   .ident = "ASUS EeeBook X205TA",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+   DMI_MATCH(DMI_PRODUCT_NAME, "X205TAW"),
+   },
+   },
 
/* Certec */
{   /* Handle problems with rebooting on Certec BPC600 */
-- 
2.7.4



Re: Question Regarding ERMS memcpy

2017-03-04 Thread hpa
On March 4, 2017 4:33:49 PM PST, Borislav Petkov  wrote:
>On Sat, Mar 04, 2017 at 04:23:17PM -0800, h...@zytor.com wrote:
>> What are the compilation flags? It may be that gcc still does TRT
>> depending on this call site. I'd check what gcc6 or 7 generates,
>> though.
>
>Well, I don't think that matters: if you're building a kernel on one
>machine to boot on another machine, the compiler can't know at build
>time what the best MOVS* variant would be for the target machine.
>That's
>why we're doing the alternatives patching at *boot* time.
>
>However, if the size is small enough, the CALL/patch overhead would be
>definitely too much.
>
>Hmm, I wish we were able to say, "let gcc decide for small sizes and
>let
>us do the patching for larger ones."

That's what the -march= and -mtune= option do!
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Re: Question Regarding ERMS memcpy

2017-03-04 Thread hpa
On March 4, 2017 4:33:49 PM PST, Borislav Petkov  wrote:
>On Sat, Mar 04, 2017 at 04:23:17PM -0800, h...@zytor.com wrote:
>> What are the compilation flags? It may be that gcc still does TRT
>> depending on this call site. I'd check what gcc6 or 7 generates,
>> though.
>
>Well, I don't think that matters: if you're building a kernel on one
>machine to boot on another machine, the compiler can't know at build
>time what the best MOVS* variant would be for the target machine.
>That's
>why we're doing the alternatives patching at *boot* time.
>
>However, if the size is small enough, the CALL/patch overhead would be
>definitely too much.
>
>Hmm, I wish we were able to say, "let gcc decide for small sizes and
>let
>us do the patching for larger ones."

That's what the -march= and -mtune= option do!
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Re: [PATCH v5 3/5] staging: lustre: lustre: Remove unnecessary cast on void pointer

2017-03-04 Thread James Simmons

> The following Coccinelle script was used to detect this:
> @r@
> expression x;
> void* e;
> type T;
> identifier f;
> @@
> (
>   *((T *)e)
> |
>   ((T *)x)[...]
> |
>   ((T*)x)->f
> |
> - (T*)
>   e
> )
> 
> Signed-off-by: simran singhal 

Reviewed-by: James Simmons 

> ---
> 
>  v5:
>-Fixed compilation warnings.
> 
>  drivers/staging/lustre/lustre/llite/range_lock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/llite/range_lock.c 
> b/drivers/staging/lustre/lustre/llite/range_lock.c
> index 14148a0..161391b 100644
> --- a/drivers/staging/lustre/lustre/llite/range_lock.c
> +++ b/drivers/staging/lustre/lustre/llite/range_lock.c
> @@ -174,7 +174,7 @@ void range_unlock(struct range_lock_tree *tree, struct 
> range_lock *lock)
>   */
>  static enum interval_iter range_lock_cb(struct interval_node *node, void 
> *arg)
>  {
> - struct range_lock *lock = (struct range_lock *)arg;
> + struct range_lock *lock = arg;
>   struct range_lock *overlap = node2rangelock(node);
>  
>   lock->rl_blocking_ranges += overlap->rl_lock_count + 1;
> -- 
> 2.7.4
> 
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 


Re: [PATCH v5 3/5] staging: lustre: lustre: Remove unnecessary cast on void pointer

2017-03-04 Thread James Simmons

> The following Coccinelle script was used to detect this:
> @r@
> expression x;
> void* e;
> type T;
> identifier f;
> @@
> (
>   *((T *)e)
> |
>   ((T *)x)[...]
> |
>   ((T*)x)->f
> |
> - (T*)
>   e
> )
> 
> Signed-off-by: simran singhal 

Reviewed-by: James Simmons 

> ---
> 
>  v5:
>-Fixed compilation warnings.
> 
>  drivers/staging/lustre/lustre/llite/range_lock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/llite/range_lock.c 
> b/drivers/staging/lustre/lustre/llite/range_lock.c
> index 14148a0..161391b 100644
> --- a/drivers/staging/lustre/lustre/llite/range_lock.c
> +++ b/drivers/staging/lustre/lustre/llite/range_lock.c
> @@ -174,7 +174,7 @@ void range_unlock(struct range_lock_tree *tree, struct 
> range_lock *lock)
>   */
>  static enum interval_iter range_lock_cb(struct interval_node *node, void 
> *arg)
>  {
> - struct range_lock *lock = (struct range_lock *)arg;
> + struct range_lock *lock = arg;
>   struct range_lock *overlap = node2rangelock(node);
>  
>   lock->rl_blocking_ranges += overlap->rl_lock_count + 1;
> -- 
> 2.7.4
> 
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 


[GIT] Networking

2017-03-04 Thread David Miller

1) Fix double-free in batman-adv, from Sven Eckelmann.

2) Fix packet stats for fast-RX path, from Joannes Berg.

3) Netfilter's ip_route_me_harder() doesn't handle request sockets
   properly, fix from Florian Westphal.

4) Fix sendmsg deadlock in rxrpc, from David Howells.

5) Add missing RCU locking to transport hashtable scan, from
   Xin Long.

6) Fix potential packet loss in mlxsw driver, from Ido Schimmel.

7) Fix race in NAPI handling between poll handlers and busy polling,
   from Eric Dumazet.

8) TX path in vxlan and geneve need proper RCU locking, from Jakub
   Kicinski.

9) SYN processing in DCCP and TCP need to disable BH, from Eric
   Dumazet.

10) Properly handle net_enable_timestamp() being invoked from IRQ
context, also from Eric Dumazet.

11) Fix crash on device-tree systems in xgene driver, from Alban
Bedel.

12) Do not call sk_free() on a locked socket, from Arnaldo Carvalho de
Melo.

13) Fix use-after-free in netvsc driver, from Dexuan Cui.

14) Fix max MTU setting in bonding driver, from WANG Cong.

15) xen-netback hash table can be allocated from softirq
context, so use GFP_ATOMIC.  From Anoob Soman.

16) Fix MAC address change bug in bgmac driver, from Hari Vyas.

17) strparser needs to destroy strp_wq on module exit, from WANG Cong.

Please pull, thanks a lot!

The following changes since commit 2d6be4abf514fc26c83d239c7f31da1f95e4a31d:

  Merge tag 'for-linus-4.11' of git://git.code.sf.net/p/openipmi/linux-ipmi 
(2017-02-28 21:06:30 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 

for you to fetch changes up to f78ef7cd9a0686b979679d0de061c6dbfd8d649e:

  strparser: destroy workqueue on module exit (2017-03-03 20:43:26 -0800)


Alban Bedel (1):
  drivers: net: xgene: Fix crash on DT systems

Alexander Duyck (1):
  ixgbe: Limit use of 2K buffers on architectures with 256B or larger cache 
lines

Alexander Potapenko (1):
  net: don't call strlen() on the user buffer in packet_bind_spkt()

Anoob Soman (1):
  xen-netback: Use GFP_ATOMIC to allocate hash

Arnaldo Carvalho de Melo (2):
  dccp: Unlock sock before calling sk_free()
  net: Introduce sk_clone_lock() error path routine

Baruch Siach (1):
  MAINTAINERS: Orphan usb/net/hso driver

Christophe Leroy (1):
  netfilter: nf_conntrack_sip: fix wrong memory initialisation

Colin Ian King (1):
  net: usb: asix_devices: fix missing return code check on call to 
asix_write_medium_mode

Dan Carpenter (1):
  net/mlx4: && vs & typo

David Howells (2):
  rxrpc: Fix deadlock between call creation and sendmsg/recvmsg
  rxrpc: Fix potential NULL-pointer exception

David S. Miller (13):
  Merge branch 'vxlan-geneve-rcu-fixes'
  Merge tag 'mac80211-for-davem-2017-02-28' of 
git://git.kernel.org/.../jberg/mac80211
  Merge branch 'amd-xgbe-fixes'
  Merge tag 'batadv-net-for-davem-20170301' of 
git://git.open-mesh.org/linux-merge
  Merge tag 'wireless-drivers-for-davem-2017-03-02' of 
git://git.kernel.org/.../kvalo/wireless-drivers
  Merge tag 'mac80211-for-davem-2017-03-02' of 
git://git.kernel.org/.../jberg/mac80211
  Merge branch '10GbE' of git://git.kernel.org/.../jkirsher/net-queue
  Merge branch 'xen-netback-fixes'
  Merge branch 'bgmac-fixes'
  Merge branch 'nfp-fixes'
  Merge tag 'linux-can-fixes-for-4.11-20170303' of 
git://git.kernel.org/.../mkl/linux-can
  Merge branch 'sfx-fixes'
  Merge git://git.kernel.org/.../pablo/nf

Dexuan Cui (1):
  netvsc: fix use-after-free in netvsc_change_mtu()

Dmitry Torokhov (1):
  drivers: net: ethernet: remove incorrect __exit markups

Edward Cree (2):
  sfc: avoid max() in array size
  sfc: fix IPID endianness in TSOv2

Emmanuel Grumbach (1):
  mac80211: fix power saving clients handling in iwlwifi

Eric Dumazet (4):
  net: solve a NAPI race
  tcp/dccp: block BH for SYN processing
  net: net_enable_timestamp() can be called from irq contexts
  ipv6: orphan skbs in reassembly unit

Ethan Zonca (2):
  can: gs_usb: Don't use stack memory for USB transfers
  can: gs_usb: fix coding style

Felix Fietkau (1):
  mac80211: don't handle filtered frames within a BA session

Felix Jia (1):
  net/ipv6: avoid possible dead locking on addr_gen_mode sysctl

Florian Westphal (1):
  netfilter: use skb_to_full_sk in ip_route_me_harder

Ganesh Goudar (1):
  cxgb4: update latest firmware version supported

Gary Lin (1):
  bpf: update the comment about the length of analysis

Hari Vyas (1):
  net: ethernet: bgmac: mac address change bug

Ido Schimmel (1):
  mlxsw: spectrum_router: Avoid potential packets loss

Jakub Kicinski (4):
  vxlan: lock RCU on TX path
  geneve: lock RCU on TX path
  nfp: don't tell FW about the reserved buffer space
  nfp: correct DMA direction in XDP DMA sync

Johannes 

[GIT] Networking

2017-03-04 Thread David Miller

1) Fix double-free in batman-adv, from Sven Eckelmann.

2) Fix packet stats for fast-RX path, from Joannes Berg.

3) Netfilter's ip_route_me_harder() doesn't handle request sockets
   properly, fix from Florian Westphal.

4) Fix sendmsg deadlock in rxrpc, from David Howells.

5) Add missing RCU locking to transport hashtable scan, from
   Xin Long.

6) Fix potential packet loss in mlxsw driver, from Ido Schimmel.

7) Fix race in NAPI handling between poll handlers and busy polling,
   from Eric Dumazet.

8) TX path in vxlan and geneve need proper RCU locking, from Jakub
   Kicinski.

9) SYN processing in DCCP and TCP need to disable BH, from Eric
   Dumazet.

10) Properly handle net_enable_timestamp() being invoked from IRQ
context, also from Eric Dumazet.

11) Fix crash on device-tree systems in xgene driver, from Alban
Bedel.

12) Do not call sk_free() on a locked socket, from Arnaldo Carvalho de
Melo.

13) Fix use-after-free in netvsc driver, from Dexuan Cui.

14) Fix max MTU setting in bonding driver, from WANG Cong.

15) xen-netback hash table can be allocated from softirq
context, so use GFP_ATOMIC.  From Anoob Soman.

16) Fix MAC address change bug in bgmac driver, from Hari Vyas.

17) strparser needs to destroy strp_wq on module exit, from WANG Cong.

Please pull, thanks a lot!

The following changes since commit 2d6be4abf514fc26c83d239c7f31da1f95e4a31d:

  Merge tag 'for-linus-4.11' of git://git.code.sf.net/p/openipmi/linux-ipmi 
(2017-02-28 21:06:30 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 

for you to fetch changes up to f78ef7cd9a0686b979679d0de061c6dbfd8d649e:

  strparser: destroy workqueue on module exit (2017-03-03 20:43:26 -0800)


Alban Bedel (1):
  drivers: net: xgene: Fix crash on DT systems

Alexander Duyck (1):
  ixgbe: Limit use of 2K buffers on architectures with 256B or larger cache 
lines

Alexander Potapenko (1):
  net: don't call strlen() on the user buffer in packet_bind_spkt()

Anoob Soman (1):
  xen-netback: Use GFP_ATOMIC to allocate hash

Arnaldo Carvalho de Melo (2):
  dccp: Unlock sock before calling sk_free()
  net: Introduce sk_clone_lock() error path routine

Baruch Siach (1):
  MAINTAINERS: Orphan usb/net/hso driver

Christophe Leroy (1):
  netfilter: nf_conntrack_sip: fix wrong memory initialisation

Colin Ian King (1):
  net: usb: asix_devices: fix missing return code check on call to 
asix_write_medium_mode

Dan Carpenter (1):
  net/mlx4: && vs & typo

David Howells (2):
  rxrpc: Fix deadlock between call creation and sendmsg/recvmsg
  rxrpc: Fix potential NULL-pointer exception

David S. Miller (13):
  Merge branch 'vxlan-geneve-rcu-fixes'
  Merge tag 'mac80211-for-davem-2017-02-28' of 
git://git.kernel.org/.../jberg/mac80211
  Merge branch 'amd-xgbe-fixes'
  Merge tag 'batadv-net-for-davem-20170301' of 
git://git.open-mesh.org/linux-merge
  Merge tag 'wireless-drivers-for-davem-2017-03-02' of 
git://git.kernel.org/.../kvalo/wireless-drivers
  Merge tag 'mac80211-for-davem-2017-03-02' of 
git://git.kernel.org/.../jberg/mac80211
  Merge branch '10GbE' of git://git.kernel.org/.../jkirsher/net-queue
  Merge branch 'xen-netback-fixes'
  Merge branch 'bgmac-fixes'
  Merge branch 'nfp-fixes'
  Merge tag 'linux-can-fixes-for-4.11-20170303' of 
git://git.kernel.org/.../mkl/linux-can
  Merge branch 'sfx-fixes'
  Merge git://git.kernel.org/.../pablo/nf

Dexuan Cui (1):
  netvsc: fix use-after-free in netvsc_change_mtu()

Dmitry Torokhov (1):
  drivers: net: ethernet: remove incorrect __exit markups

Edward Cree (2):
  sfc: avoid max() in array size
  sfc: fix IPID endianness in TSOv2

Emmanuel Grumbach (1):
  mac80211: fix power saving clients handling in iwlwifi

Eric Dumazet (4):
  net: solve a NAPI race
  tcp/dccp: block BH for SYN processing
  net: net_enable_timestamp() can be called from irq contexts
  ipv6: orphan skbs in reassembly unit

Ethan Zonca (2):
  can: gs_usb: Don't use stack memory for USB transfers
  can: gs_usb: fix coding style

Felix Fietkau (1):
  mac80211: don't handle filtered frames within a BA session

Felix Jia (1):
  net/ipv6: avoid possible dead locking on addr_gen_mode sysctl

Florian Westphal (1):
  netfilter: use skb_to_full_sk in ip_route_me_harder

Ganesh Goudar (1):
  cxgb4: update latest firmware version supported

Gary Lin (1):
  bpf: update the comment about the length of analysis

Hari Vyas (1):
  net: ethernet: bgmac: mac address change bug

Ido Schimmel (1):
  mlxsw: spectrum_router: Avoid potential packets loss

Jakub Kicinski (4):
  vxlan: lock RCU on TX path
  geneve: lock RCU on TX path
  nfp: don't tell FW about the reserved buffer space
  nfp: correct DMA direction in XDP DMA sync

Johannes 

Re: [PATCH] serial: 8250_dw: Fix breakage when HAVE_CLK=n

2017-03-04 Thread Heiko Stuebner
Am Samstag, 4. März 2017, 13:09:58 CET schrieb James Hogan:
> Commit 6a171b299379 ("serial: 8250_dw: Allow hardware flow control to be
> used") recently broke the 8250_dw driver on platforms which don't select
> HAVE_CLK, as dw8250_set_termios() gets confused by the behaviour of the
> fallback HAVE_CLK=n clock API in linux/clk.h which pretends everything
> is fine but returns (valid) NULL clocks and 0 HZ clock rates.
> 
> That 0 rate is written into the uartclk resulting in a crash at boot,
> e.g. on Cavium Octeon III based UTM-8 we get something like this:
> 
> 118000800.serial: ttyS0 at MMIO 0x118000800 (irq = 41, base_baud =
> 2500) is a OCTEON [ cut here ]
> WARNING: CPU: 2 PID: 1 at drivers/tty/serial/serial_core.c:441
> uart_get_baud_rate+0xfc/0x1f0 ...
> Call Trace:
> ...
> [] uart_get_baud_rate+0xfc/0x1f0
> [] serial8250_do_set_termios+0xb0/0x440
> [] uart_set_options+0xe8/0x190
> [] serial8250_console_setup+0x84/0x158
> [] univ8250_console_setup+0x54/0x70
> [] register_console+0x1c8/0x418
> [] uart_add_one_port+0x434/0x4b0
> [] serial8250_register_8250_port+0x2d8/0x440
> [] dw8250_probe+0x388/0x5e8
> ...
> 
> The clock API is defined such that NULL is a valid clock handle so it
> wouldn't be right to check explicitly for NULL. Instead treat a
> clk_round_rate() return value of 0 as an error which prevents uartclk
> being overwritten.
> 
> Fixes: 6a171b299379 ("serial: 8250_dw: Allow hardware flow control to be
> used") Signed-off-by: James Hogan 
> Cc: Greg Kroah-Hartman 
> Cc: Andy Shevchenko 
> Cc: Jason Uy 
> Cc: Kefeng Wang 
> Cc: Heiko Stuebner 
> Cc: David Daney 
> Cc: Russell King 
> Cc: linux-ser...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: linux-m...@linux-mips.org
> Cc: bcm-kernel-feedback-l...@broadcom.com
> ---
>  drivers/tty/serial/8250/8250_dw.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c
> b/drivers/tty/serial/8250/8250_dw.c index 223ac234ddb2..e65808c482f1 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -267,6 +267,8 @@ static void dw8250_set_termios(struct uart_port *p,
> struct ktermios *termios, rate = clk_round_rate(d->clk, baud * 16);
>   if (rate < 0)
>   ret = rate;
> + else if (rate == 0)
> + ret = -ENOENT;
>   else
>   ret = clk_set_rate(d->clk, rate);
>   clk_prepare_enable(d->clk);

Looks good
Reviewed-by: Heiko Stuebner 



Re: [PATCH] serial: 8250_dw: Fix breakage when HAVE_CLK=n

2017-03-04 Thread Heiko Stuebner
Am Samstag, 4. März 2017, 13:09:58 CET schrieb James Hogan:
> Commit 6a171b299379 ("serial: 8250_dw: Allow hardware flow control to be
> used") recently broke the 8250_dw driver on platforms which don't select
> HAVE_CLK, as dw8250_set_termios() gets confused by the behaviour of the
> fallback HAVE_CLK=n clock API in linux/clk.h which pretends everything
> is fine but returns (valid) NULL clocks and 0 HZ clock rates.
> 
> That 0 rate is written into the uartclk resulting in a crash at boot,
> e.g. on Cavium Octeon III based UTM-8 we get something like this:
> 
> 118000800.serial: ttyS0 at MMIO 0x118000800 (irq = 41, base_baud =
> 2500) is a OCTEON [ cut here ]
> WARNING: CPU: 2 PID: 1 at drivers/tty/serial/serial_core.c:441
> uart_get_baud_rate+0xfc/0x1f0 ...
> Call Trace:
> ...
> [] uart_get_baud_rate+0xfc/0x1f0
> [] serial8250_do_set_termios+0xb0/0x440
> [] uart_set_options+0xe8/0x190
> [] serial8250_console_setup+0x84/0x158
> [] univ8250_console_setup+0x54/0x70
> [] register_console+0x1c8/0x418
> [] uart_add_one_port+0x434/0x4b0
> [] serial8250_register_8250_port+0x2d8/0x440
> [] dw8250_probe+0x388/0x5e8
> ...
> 
> The clock API is defined such that NULL is a valid clock handle so it
> wouldn't be right to check explicitly for NULL. Instead treat a
> clk_round_rate() return value of 0 as an error which prevents uartclk
> being overwritten.
> 
> Fixes: 6a171b299379 ("serial: 8250_dw: Allow hardware flow control to be
> used") Signed-off-by: James Hogan 
> Cc: Greg Kroah-Hartman 
> Cc: Andy Shevchenko 
> Cc: Jason Uy 
> Cc: Kefeng Wang 
> Cc: Heiko Stuebner 
> Cc: David Daney 
> Cc: Russell King 
> Cc: linux-ser...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: linux-m...@linux-mips.org
> Cc: bcm-kernel-feedback-l...@broadcom.com
> ---
>  drivers/tty/serial/8250/8250_dw.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c
> b/drivers/tty/serial/8250/8250_dw.c index 223ac234ddb2..e65808c482f1 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -267,6 +267,8 @@ static void dw8250_set_termios(struct uart_port *p,
> struct ktermios *termios, rate = clk_round_rate(d->clk, baud * 16);
>   if (rate < 0)
>   ret = rate;
> + else if (rate == 0)
> + ret = -ENOENT;
>   else
>   ret = clk_set_rate(d->clk, rate);
>   clk_prepare_enable(d->clk);

Looks good
Reviewed-by: Heiko Stuebner 



[PATCHv2 06/10] drm: omapdrm: crtc: add support for manual updated displays

2017-03-04 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
[t...@atomide.com: rebased and fixed up to work with droid 4]
Signed-off-by: Tony Lindgren 
---
 drivers/gpu/drm/omapdrm/omap_connector.c | 12 --
 drivers/gpu/drm/omapdrm/omap_crtc.c  | 65 
 drivers/gpu/drm/omapdrm/omap_drv.h   |  2 +-
 drivers/gpu/drm/omapdrm/omap_fb.c|  2 +-
 4 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
b/drivers/gpu/drm/omapdrm/omap_connector.c
index b09d8989b789..5ab672cac0b2 100644
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ b/drivers/gpu/drm/omapdrm/omap_connector.c
@@ -212,18 +212,6 @@ static const struct drm_connector_helper_funcs 
omap_connector_helper_funcs = {
.mode_valid = omap_connector_mode_valid,
 };
 
-/* flush an area of the framebuffer (in case of manual update display that
- * is not automatically flushed)
- */
-void omap_connector_flush(struct drm_connector *connector,
-   int x, int y, int w, int h)
-{
-   struct omap_connector *omap_connector = to_omap_connector(connector);
-
-   /* TODO: enable when supported in dss */
-   VERB("%s: %d,%d, %dx%d", omap_connector->dssdev->name, x, y, w, h);
-}
-
 /* initialize connector */
 struct drm_connector *omap_connector_init(struct drm_device *dev,
int connector_type, struct omap_dss_device *dssdev,
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 03351ca2ee41..432ad6023f27 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -43,6 +43,7 @@ struct omap_crtc {
bool pending;
wait_queue_head_t pending_wait;
struct drm_pending_vblank_event *event;
+   struct delayed_work update_work;
 
void (*framedone_handler)(void *);
void *framedone_handler_data;
@@ -138,6 +139,7 @@ static void omap_crtc_dss_disconnect(enum omap_channel 
channel,
 
 static void omap_crtc_dss_start_update(enum omap_channel channel)
 {
+   dispc_mgr_enable(channel, true);
 }
 
 /* Called only from the encoder enable/disable and suspend/resume handlers. */
@@ -347,6 +349,60 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
DBG("%s: apply done", omap_crtc->name);
 }
 
+void omap_crtc_flush(struct drm_crtc *crtc,
+   int x, int y, int w, int h)
+{
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+
+   if (!omap_crtc->manually_updated)
+   return;
+
+   if (!delayed_work_pending(_crtc->update_work))
+   schedule_delayed_work(_crtc->update_work, 0);
+}
+
+static void omap_crtc_manual_display_update(struct work_struct *data)
+{
+   struct omap_crtc *omap_crtc = container_of(data, struct omap_crtc,
+   update_work.work);
+   struct drm_crtc *crtc = _crtc->base;
+   struct omap_dss_device *dssdev = omap_crtc_output[omap_crtc->channel];
+   struct omap_dss_driver *dssdrv;
+   int ret;
+
+   if (!dssdev || !dssdev->dst) {
+   dev_err_once(omap_crtc->base.dev->dev, "missing dssdev!\n");
+   return;
+   }
+
+   dssdev = dssdev->dst;
+   dssdrv = dssdev->driver;
+
+   if (!dssdrv)
+   return;
+
+   if (!dssdrv || !dssdrv->update)
+   return;
+
+   /*
+* REVISIT: Testing and setting omap_crtc->pending here will cause all
+* kind of warnings at least on droid 4. Maybe we should be testing
+* something else here instead of omap_crtc->pending?
+*/
+
+   if (dssdrv->sync)
+   dssdrv->sync(dssdev);
+
+   ret = dssdrv->update(dssdev, 0, 0,
+dssdev->panel.vm.vactive, 
dssdev->panel.vm.hactive);
+   if (ret < 0) {
+   spin_lock_irq(>dev->event_lock);
+   omap_crtc->pending = false;
+   spin_unlock_irq(>dev->event_lock);
+   wake_up(_crtc->pending_wait);
+   }
+}
+
 /* 
-
  * CRTC Functions
  */
@@ -395,9 +451,15 @@ static void omap_crtc_enable(struct drm_crtc *crtc)
 static void omap_crtc_disable(struct drm_crtc *crtc)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
 
DBG("%s", omap_crtc->name);
 
+   cancel_delayed_work(_crtc->update_work);
+
+   if (!omap_crtc_wait_pending(crtc))
+   dev_warn(dev->dev, "manual display update did not finish!");
+
drm_crtc_vblank_off(crtc);
 }
 
@@ -469,6 +531,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
}
 
spin_lock_irq(>dev->event_lock);
+   dispc_mgr_enable(omap_crtc->channel, true);
dispc_mgr_go(omap_crtc->channel);
 
WARN_ON(omap_crtc->pending);
@@ -597,6 +660,8 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,

[PATCHv2 07/10] drm: omapdrm: plane: update fifo size on atomic update

2017-03-04 Thread Sebastian Reichel
This is a workaround for a hardware bug occuring on OMAP3
with manually updated panels. Details about the HW bug are
unknown to me, but without this fix the panel refresh does
not work at all on Nokia N950.

Signed-off-By: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   |  2 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 
 drivers/gpu/drm/omapdrm/omap_drv.h|  1 +
 drivers/gpu/drm/omapdrm/omap_plane.c  | 23 +++
 4 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index d956e6266368..97240e59b248 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -1321,6 +1321,7 @@ void dispc_ovl_set_fifo_threshold(enum omap_plane plane, 
u32 low, u32 high)
plane != OMAP_DSS_WB)
dispc_write_reg(DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
 }
+EXPORT_SYMBOL(dispc_ovl_set_fifo_threshold);
 
 void dispc_enable_fifomerge(bool enable)
 {
@@ -1379,6 +1380,7 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane 
plane,
*fifo_high = total_fifo_size - buf_unit;
}
 }
+EXPORT_SYMBOL(dispc_ovl_compute_fifo_thresholds);
 
 static void dispc_ovl_set_mflag(enum omap_plane plane, bool enable)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 5666ecbe4b80..65c3530a3b53 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -878,6 +878,10 @@ void dispc_ovl_set_channel_out(enum omap_plane plane,
enum omap_channel channel);
 int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
bool replication, const struct videomode *vm, bool mem_to_mem);
+void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane,
+   u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
+   bool manual_update);
+void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high);
 
 enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel 
channel);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index ee8901dc0381..71b5c5e25ee4 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -146,6 +146,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
u32 possible_crtcs);
 void omap_plane_install_properties(struct drm_plane *plane,
struct drm_mode_object *obj);
+void omap_plane_update_fifo(struct drm_plane *plane);
 
 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
struct omap_dss_device *dssdev);
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c 
b/drivers/gpu/drm/omapdrm/omap_plane.c
index 386d90af70f7..8d290cfe8925 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -73,6 +73,28 @@ static void omap_plane_cleanup_fb(struct drm_plane *plane,
omap_framebuffer_unpin(old_state->fb);
 }
 
+void omap_plane_update_fifo(struct drm_plane *plane)
+{
+   struct omap_plane *omap_plane = to_omap_plane(plane);
+   struct drm_plane_state *state = plane->state;
+   struct drm_device *dev = plane->dev;
+   bool use_fifo_merge = false;
+   u32 fifo_low, fifo_high;
+   bool use_manual_update;
+
+   if (!dispc_ovl_enabled(omap_plane->id))
+   return;
+
+   use_manual_update = omap_crtc_is_manual_updated(state->crtc);
+
+   dispc_ovl_compute_fifo_thresholds(omap_plane->id, _low, _high,
+   use_fifo_merge, use_manual_update);
+
+   dev_dbg(dev->dev, "update fifo: %d %d", fifo_low, fifo_high);
+
+   dispc_ovl_set_fifo_threshold(omap_plane->id, fifo_low, fifo_high);
+}
+
 static void omap_plane_atomic_update(struct drm_plane *plane,
 struct drm_plane_state *old_state)
 {
@@ -137,6 +159,7 @@ static void omap_plane_atomic_update(struct drm_plane 
*plane,
}
 
dispc_ovl_enable(omap_plane->id, true);
+   omap_plane_update_fifo(plane);
 }
 
 static void omap_plane_atomic_disable(struct drm_plane *plane,
-- 
2.11.0



[PATCHv2 06/10] drm: omapdrm: crtc: add support for manual updated displays

2017-03-04 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
[t...@atomide.com: rebased and fixed up to work with droid 4]
Signed-off-by: Tony Lindgren 
---
 drivers/gpu/drm/omapdrm/omap_connector.c | 12 --
 drivers/gpu/drm/omapdrm/omap_crtc.c  | 65 
 drivers/gpu/drm/omapdrm/omap_drv.h   |  2 +-
 drivers/gpu/drm/omapdrm/omap_fb.c|  2 +-
 4 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
b/drivers/gpu/drm/omapdrm/omap_connector.c
index b09d8989b789..5ab672cac0b2 100644
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ b/drivers/gpu/drm/omapdrm/omap_connector.c
@@ -212,18 +212,6 @@ static const struct drm_connector_helper_funcs 
omap_connector_helper_funcs = {
.mode_valid = omap_connector_mode_valid,
 };
 
-/* flush an area of the framebuffer (in case of manual update display that
- * is not automatically flushed)
- */
-void omap_connector_flush(struct drm_connector *connector,
-   int x, int y, int w, int h)
-{
-   struct omap_connector *omap_connector = to_omap_connector(connector);
-
-   /* TODO: enable when supported in dss */
-   VERB("%s: %d,%d, %dx%d", omap_connector->dssdev->name, x, y, w, h);
-}
-
 /* initialize connector */
 struct drm_connector *omap_connector_init(struct drm_device *dev,
int connector_type, struct omap_dss_device *dssdev,
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 03351ca2ee41..432ad6023f27 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -43,6 +43,7 @@ struct omap_crtc {
bool pending;
wait_queue_head_t pending_wait;
struct drm_pending_vblank_event *event;
+   struct delayed_work update_work;
 
void (*framedone_handler)(void *);
void *framedone_handler_data;
@@ -138,6 +139,7 @@ static void omap_crtc_dss_disconnect(enum omap_channel 
channel,
 
 static void omap_crtc_dss_start_update(enum omap_channel channel)
 {
+   dispc_mgr_enable(channel, true);
 }
 
 /* Called only from the encoder enable/disable and suspend/resume handlers. */
@@ -347,6 +349,60 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
DBG("%s: apply done", omap_crtc->name);
 }
 
+void omap_crtc_flush(struct drm_crtc *crtc,
+   int x, int y, int w, int h)
+{
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+
+   if (!omap_crtc->manually_updated)
+   return;
+
+   if (!delayed_work_pending(_crtc->update_work))
+   schedule_delayed_work(_crtc->update_work, 0);
+}
+
+static void omap_crtc_manual_display_update(struct work_struct *data)
+{
+   struct omap_crtc *omap_crtc = container_of(data, struct omap_crtc,
+   update_work.work);
+   struct drm_crtc *crtc = _crtc->base;
+   struct omap_dss_device *dssdev = omap_crtc_output[omap_crtc->channel];
+   struct omap_dss_driver *dssdrv;
+   int ret;
+
+   if (!dssdev || !dssdev->dst) {
+   dev_err_once(omap_crtc->base.dev->dev, "missing dssdev!\n");
+   return;
+   }
+
+   dssdev = dssdev->dst;
+   dssdrv = dssdev->driver;
+
+   if (!dssdrv)
+   return;
+
+   if (!dssdrv || !dssdrv->update)
+   return;
+
+   /*
+* REVISIT: Testing and setting omap_crtc->pending here will cause all
+* kind of warnings at least on droid 4. Maybe we should be testing
+* something else here instead of omap_crtc->pending?
+*/
+
+   if (dssdrv->sync)
+   dssdrv->sync(dssdev);
+
+   ret = dssdrv->update(dssdev, 0, 0,
+dssdev->panel.vm.vactive, 
dssdev->panel.vm.hactive);
+   if (ret < 0) {
+   spin_lock_irq(>dev->event_lock);
+   omap_crtc->pending = false;
+   spin_unlock_irq(>dev->event_lock);
+   wake_up(_crtc->pending_wait);
+   }
+}
+
 /* 
-
  * CRTC Functions
  */
@@ -395,9 +451,15 @@ static void omap_crtc_enable(struct drm_crtc *crtc)
 static void omap_crtc_disable(struct drm_crtc *crtc)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
 
DBG("%s", omap_crtc->name);
 
+   cancel_delayed_work(_crtc->update_work);
+
+   if (!omap_crtc_wait_pending(crtc))
+   dev_warn(dev->dev, "manual display update did not finish!");
+
drm_crtc_vblank_off(crtc);
 }
 
@@ -469,6 +531,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
}
 
spin_lock_irq(>dev->event_lock);
+   dispc_mgr_enable(omap_crtc->channel, true);
dispc_mgr_go(omap_crtc->channel);
 
WARN_ON(omap_crtc->pending);
@@ -597,6 +660,8 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
omap_crtc->channel = channel;

[PATCHv2 07/10] drm: omapdrm: plane: update fifo size on atomic update

2017-03-04 Thread Sebastian Reichel
This is a workaround for a hardware bug occuring on OMAP3
with manually updated panels. Details about the HW bug are
unknown to me, but without this fix the panel refresh does
not work at all on Nokia N950.

Signed-off-By: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   |  2 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 
 drivers/gpu/drm/omapdrm/omap_drv.h|  1 +
 drivers/gpu/drm/omapdrm/omap_plane.c  | 23 +++
 4 files changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index d956e6266368..97240e59b248 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -1321,6 +1321,7 @@ void dispc_ovl_set_fifo_threshold(enum omap_plane plane, 
u32 low, u32 high)
plane != OMAP_DSS_WB)
dispc_write_reg(DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
 }
+EXPORT_SYMBOL(dispc_ovl_set_fifo_threshold);
 
 void dispc_enable_fifomerge(bool enable)
 {
@@ -1379,6 +1380,7 @@ void dispc_ovl_compute_fifo_thresholds(enum omap_plane 
plane,
*fifo_high = total_fifo_size - buf_unit;
}
 }
+EXPORT_SYMBOL(dispc_ovl_compute_fifo_thresholds);
 
 static void dispc_ovl_set_mflag(enum omap_plane plane, bool enable)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 5666ecbe4b80..65c3530a3b53 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -878,6 +878,10 @@ void dispc_ovl_set_channel_out(enum omap_plane plane,
enum omap_channel channel);
 int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
bool replication, const struct videomode *vm, bool mem_to_mem);
+void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane,
+   u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
+   bool manual_update);
+void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high);
 
 enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel 
channel);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index ee8901dc0381..71b5c5e25ee4 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -146,6 +146,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
u32 possible_crtcs);
 void omap_plane_install_properties(struct drm_plane *plane,
struct drm_mode_object *obj);
+void omap_plane_update_fifo(struct drm_plane *plane);
 
 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
struct omap_dss_device *dssdev);
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c 
b/drivers/gpu/drm/omapdrm/omap_plane.c
index 386d90af70f7..8d290cfe8925 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -73,6 +73,28 @@ static void omap_plane_cleanup_fb(struct drm_plane *plane,
omap_framebuffer_unpin(old_state->fb);
 }
 
+void omap_plane_update_fifo(struct drm_plane *plane)
+{
+   struct omap_plane *omap_plane = to_omap_plane(plane);
+   struct drm_plane_state *state = plane->state;
+   struct drm_device *dev = plane->dev;
+   bool use_fifo_merge = false;
+   u32 fifo_low, fifo_high;
+   bool use_manual_update;
+
+   if (!dispc_ovl_enabled(omap_plane->id))
+   return;
+
+   use_manual_update = omap_crtc_is_manual_updated(state->crtc);
+
+   dispc_ovl_compute_fifo_thresholds(omap_plane->id, _low, _high,
+   use_fifo_merge, use_manual_update);
+
+   dev_dbg(dev->dev, "update fifo: %d %d", fifo_low, fifo_high);
+
+   dispc_ovl_set_fifo_threshold(omap_plane->id, fifo_low, fifo_high);
+}
+
 static void omap_plane_atomic_update(struct drm_plane *plane,
 struct drm_plane_state *old_state)
 {
@@ -137,6 +159,7 @@ static void omap_plane_atomic_update(struct drm_plane 
*plane,
}
 
dispc_ovl_enable(omap_plane->id, true);
+   omap_plane_update_fifo(plane);
 }
 
 static void omap_plane_atomic_disable(struct drm_plane *plane,
-- 
2.11.0



[PATCHv2 09/10] drm: omapdrm: crtc: get manual mode displays working

2017-03-04 Thread Sebastian Reichel
From: Tony Lindgren 

With manual mode displays we need to flush the panel manually.

Let's add flushing so we get Tomi's fbtest, kmstest, kmstest --flip,
and X and wayland working.

Signed-off-by: Tony Lindgren 
[On Nokia N950]
Tested-By: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 4601533215d6..e07b0a0be4bf 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -97,6 +97,11 @@ bool omap_crtc_is_manual_updated(struct drm_crtc *crtc)
return omap_crtc->manually_updated;
 }
 
+static void omap_crtc_manual_needs_flush(struct drm_crtc *crtc)
+{
+   omap_crtc_flush(crtc, 0, 0, 0, 0);
+}
+
 /* 
-
  * DSS Manager Functions
  */
@@ -139,7 +144,11 @@ static void omap_crtc_dss_disconnect(enum omap_channel 
channel,
 
 static void omap_crtc_dss_start_update(enum omap_channel channel)
 {
+   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_crtc *crtc = _crtc->base;
+
dispc_mgr_enable(channel, true);
+   omap_crtc_manual_needs_flush(crtc);
 }
 
 /* Called only from the encoder enable/disable and suspend/resume handlers. */
@@ -155,11 +164,12 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, 
bool enable)
if (WARN_ON(omap_crtc->enabled == enable))
return;
 
-   if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
-   dispc_mgr_enable(channel, enable);
-   omap_crtc->enabled = enable;
+   dispc_mgr_enable(channel, enable);
+   omap_crtc->enabled = enable;
+   omap_crtc_manual_needs_flush(crtc);
+
+   if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI)
return;
-   }
 
if (omap_crtc->channel == OMAP_DSS_CHANNEL_DIGIT) {
/*
@@ -190,9 +200,6 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, 
bool enable)
wait = omap_irq_wait_init(dev, vsync_irq, 2);
}
 
-   dispc_mgr_enable(channel, enable);
-   omap_crtc->enabled = enable;
-
ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100));
if (ret) {
dev_err(dev->dev, "%s: timeout waiting for %s\n",
@@ -554,6 +561,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
ret = drm_crtc_vblank_get(crtc);
WARN_ON(ret != 0);
}
+   omap_crtc_flush(_crtc->base, 0, 0, 0, 0);
 
spin_lock_irq(>dev->event_lock);
dispc_mgr_enable(omap_crtc->channel, true);
-- 
2.11.0



[PATCHv2 10/10] ARM: dts: n950: add display support

2017-03-04 Thread Sebastian Reichel
Add basic panel support for the Nokia N950. It must be tweaked a
little bit later, since the panel was built into the device
upside-down. Also the first 5 and the last 5 pixels are covered
by plastic.

Signed-off-By: Sebastian Reichel 
---
 arch/arm/boot/dts/omap3-n950.dts | 89 
 1 file changed, 89 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
index 646601a3ebd8..1aa4251b39d7 100644
--- a/arch/arm/boot/dts/omap3-n950.dts
+++ b/arch/arm/boot/dts/omap3-n950.dts
@@ -51,6 +51,26 @@
};
 };
 
+_pmx_core {
+   dsi_pins: pinmux_dsi_pins {
+   pinctrl-single,pins = <
+   OMAP3_CORE1_IOPAD(0x20dc, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dx0 - data0+ */
+   OMAP3_CORE1_IOPAD(0x20de, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dy0 - data0- */
+   OMAP3_CORE1_IOPAD(0x20e0, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dx1 - clk+   */
+   OMAP3_CORE1_IOPAD(0x20e2, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dy1 - clk-   */
+   OMAP3_CORE1_IOPAD(0x20e4, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dx2 - data1+ */
+   OMAP3_CORE1_IOPAD(0x20e6, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dy2 - data1- */
+   >;
+   };
+
+   display_pins: pinmux_display_pins {
+   pinctrl-single,pins = <
+   OMAP3_CORE1_IOPAD(0x20ca, PIN_INPUT | MUX_MODE4) /* 
gpio 62 - display te */
+   OMAP3_CORE1_IOPAD(0x20fe, PIN_OUTPUT | MUX_MODE4) /* 
gpio 87 - display reset */
+   >;
+   };
+};
+
  {
smia_1: camera@10 {
compatible = "nokia,smia";
@@ -185,3 +205,72 @@
st,max-limit-y = <32>;
st,max-limit-z = <32>;
 };
+
+ {
+   status = "ok";
+
+   vdda_video-supply = <>;
+};
+
+ {
+   status = "ok";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   vdd-supply = <>;
+
+   port {
+   dsi_out_ep: endpoint {
+   remote-endpoint = <_in>;
+   lanes = <2 3 0 1 4 5>;
+   };
+   };
+
+   lcd0: display {
+   compatible = "nokia,himalaya", "panel-dsi-cm";
+   label = "lcd0";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   vpnl-supply = <>;
+   vddi-supply = <>;
+
+   reset-gpios = < 23 GPIO_ACTIVE_HIGH>; /* 87 */
+   te-gpios = < 30 GPIO_ACTIVE_HIGH>;/* 62 */
+
+   has-dsi-backlight;
+
+   /* panel is upside-down, 480x464 pixels */
+   /* top and bottom 5 lines are not visible */
+   /* physical dimensions: 48960µm x 88128µm */
+   panel-timing {
+   clock-frequency = <0>;  /* Calculated by dsi */
+
+   hback-porch = <2>;
+   hactive = <480>;
+   hfront-porch = <0>;
+   hsync-len = <2>;
+
+   vback-porch = <1>;
+   vactive = <864>;
+   vfront-porch = <0>;
+   vsync-len = <1>;
+
+   hsync-active = <0>;
+   vsync-active = <0>;
+   de-active = <1>;
+   pixelclk-active = <1>;
+
+   /* TODO: rotate panel by 180° */
+   /* TODO: add 5 pixel y-offset and limit vactive to 854 
*/
+   };
+
+   port {
+   lcd0_in: endpoint {
+   remote-endpoint = <_out_ep>;
+   };
+   };
+   };
+};
-- 
2.11.0



[PATCHv2 10/10] ARM: dts: n950: add display support

2017-03-04 Thread Sebastian Reichel
Add basic panel support for the Nokia N950. It must be tweaked a
little bit later, since the panel was built into the device
upside-down. Also the first 5 and the last 5 pixels are covered
by plastic.

Signed-off-By: Sebastian Reichel 
---
 arch/arm/boot/dts/omap3-n950.dts | 89 
 1 file changed, 89 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
index 646601a3ebd8..1aa4251b39d7 100644
--- a/arch/arm/boot/dts/omap3-n950.dts
+++ b/arch/arm/boot/dts/omap3-n950.dts
@@ -51,6 +51,26 @@
};
 };
 
+_pmx_core {
+   dsi_pins: pinmux_dsi_pins {
+   pinctrl-single,pins = <
+   OMAP3_CORE1_IOPAD(0x20dc, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dx0 - data0+ */
+   OMAP3_CORE1_IOPAD(0x20de, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dy0 - data0- */
+   OMAP3_CORE1_IOPAD(0x20e0, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dx1 - clk+   */
+   OMAP3_CORE1_IOPAD(0x20e2, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dy1 - clk-   */
+   OMAP3_CORE1_IOPAD(0x20e4, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dx2 - data1+ */
+   OMAP3_CORE1_IOPAD(0x20e6, PIN_OUTPUT | MUX_MODE1) /* 
dsi_dy2 - data1- */
+   >;
+   };
+
+   display_pins: pinmux_display_pins {
+   pinctrl-single,pins = <
+   OMAP3_CORE1_IOPAD(0x20ca, PIN_INPUT | MUX_MODE4) /* 
gpio 62 - display te */
+   OMAP3_CORE1_IOPAD(0x20fe, PIN_OUTPUT | MUX_MODE4) /* 
gpio 87 - display reset */
+   >;
+   };
+};
+
  {
smia_1: camera@10 {
compatible = "nokia,smia";
@@ -185,3 +205,72 @@
st,max-limit-y = <32>;
st,max-limit-z = <32>;
 };
+
+ {
+   status = "ok";
+
+   vdda_video-supply = <>;
+};
+
+ {
+   status = "ok";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   vdd-supply = <>;
+
+   port {
+   dsi_out_ep: endpoint {
+   remote-endpoint = <_in>;
+   lanes = <2 3 0 1 4 5>;
+   };
+   };
+
+   lcd0: display {
+   compatible = "nokia,himalaya", "panel-dsi-cm";
+   label = "lcd0";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   vpnl-supply = <>;
+   vddi-supply = <>;
+
+   reset-gpios = < 23 GPIO_ACTIVE_HIGH>; /* 87 */
+   te-gpios = < 30 GPIO_ACTIVE_HIGH>;/* 62 */
+
+   has-dsi-backlight;
+
+   /* panel is upside-down, 480x464 pixels */
+   /* top and bottom 5 lines are not visible */
+   /* physical dimensions: 48960µm x 88128µm */
+   panel-timing {
+   clock-frequency = <0>;  /* Calculated by dsi */
+
+   hback-porch = <2>;
+   hactive = <480>;
+   hfront-porch = <0>;
+   hsync-len = <2>;
+
+   vback-porch = <1>;
+   vactive = <864>;
+   vfront-porch = <0>;
+   vsync-len = <1>;
+
+   hsync-active = <0>;
+   vsync-active = <0>;
+   de-active = <1>;
+   pixelclk-active = <1>;
+
+   /* TODO: rotate panel by 180° */
+   /* TODO: add 5 pixel y-offset and limit vactive to 854 
*/
+   };
+
+   port {
+   lcd0_in: endpoint {
+   remote-endpoint = <_out_ep>;
+   };
+   };
+   };
+};
-- 
2.11.0



[PATCHv2 09/10] drm: omapdrm: crtc: get manual mode displays working

2017-03-04 Thread Sebastian Reichel
From: Tony Lindgren 

With manual mode displays we need to flush the panel manually.

Let's add flushing so we get Tomi's fbtest, kmstest, kmstest --flip,
and X and wayland working.

Signed-off-by: Tony Lindgren 
[On Nokia N950]
Tested-By: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 4601533215d6..e07b0a0be4bf 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -97,6 +97,11 @@ bool omap_crtc_is_manual_updated(struct drm_crtc *crtc)
return omap_crtc->manually_updated;
 }
 
+static void omap_crtc_manual_needs_flush(struct drm_crtc *crtc)
+{
+   omap_crtc_flush(crtc, 0, 0, 0, 0);
+}
+
 /* 
-
  * DSS Manager Functions
  */
@@ -139,7 +144,11 @@ static void omap_crtc_dss_disconnect(enum omap_channel 
channel,
 
 static void omap_crtc_dss_start_update(enum omap_channel channel)
 {
+   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_crtc *crtc = _crtc->base;
+
dispc_mgr_enable(channel, true);
+   omap_crtc_manual_needs_flush(crtc);
 }
 
 /* Called only from the encoder enable/disable and suspend/resume handlers. */
@@ -155,11 +164,12 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, 
bool enable)
if (WARN_ON(omap_crtc->enabled == enable))
return;
 
-   if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
-   dispc_mgr_enable(channel, enable);
-   omap_crtc->enabled = enable;
+   dispc_mgr_enable(channel, enable);
+   omap_crtc->enabled = enable;
+   omap_crtc_manual_needs_flush(crtc);
+
+   if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI)
return;
-   }
 
if (omap_crtc->channel == OMAP_DSS_CHANNEL_DIGIT) {
/*
@@ -190,9 +200,6 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, 
bool enable)
wait = omap_irq_wait_init(dev, vsync_irq, 2);
}
 
-   dispc_mgr_enable(channel, enable);
-   omap_crtc->enabled = enable;
-
ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100));
if (ret) {
dev_err(dev->dev, "%s: timeout waiting for %s\n",
@@ -554,6 +561,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
ret = drm_crtc_vblank_get(crtc);
WARN_ON(ret != 0);
}
+   omap_crtc_flush(_crtc->base, 0, 0, 0, 0);
 
spin_lock_irq(>dev->event_lock);
dispc_mgr_enable(omap_crtc->channel, true);
-- 
2.11.0



[PATCHv2 08/10] drm: omapdrm: crtc: handle framedone directly

2017-03-04 Thread Sebastian Reichel
From: Tony Lindgren 

We can handle framedone interrupt directly simlar to commit
e0519af75d6e ("drm: omapdrm: Handle CRTC error IRQs directly").

By default we just print a warning on framedone and do nothing.
Any manually refreshed displays can register a callback.

Signed-off-by: Tony Lindgren 
[Drop REVISIT comment for omap3, patch works on N950]
Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 25 +
 drivers/gpu/drm/omapdrm/omap_drv.h  |  1 +
 drivers/gpu/drm/omapdrm/omap_irq.c  |  7 ++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 432ad6023f27..4601533215d6 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -349,6 +349,31 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
DBG("%s: apply done", omap_crtc->name);
 }
 
+void omap_crtc_framedone_irq(struct drm_crtc *crtc, uint32_t irqstatus)
+{
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+
+   if (!omap_crtc->framedone_handler) {
+   dev_warn(omap_crtc->base.dev->dev, "no framedone handler?\n");
+
+   return;
+   }
+
+   omap_crtc->framedone_handler(omap_crtc->framedone_handler_data);
+
+   spin_lock(>dev->event_lock);
+   /* Send the vblank event if one has been requested. */
+   if (omap_crtc->event) {
+   drm_crtc_send_vblank_event(crtc, omap_crtc->event);
+   omap_crtc->event = NULL;
+   }
+   omap_crtc->pending = false;
+   spin_unlock(>dev->event_lock);
+
+   /* Wake up omap_atomic_complete. */
+   wake_up(_crtc->pending_wait);
+}
+
 void omap_crtc_flush(struct drm_crtc *crtc,
int x, int y, int w, int h)
 {
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index 71b5c5e25ee4..9586551960e9 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -138,6 +138,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
struct drm_plane *plane, enum omap_channel channel, int id);
 int omap_crtc_wait_pending(struct drm_crtc *crtc);
 void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
+void omap_crtc_framedone_irq(struct drm_crtc *crtc, uint32_t irqstatus);
 void omap_crtc_vblank_irq(struct drm_crtc *crtc);
 bool omap_crtc_is_manual_updated(struct drm_crtc *crtc);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c 
b/drivers/gpu/drm/omapdrm/omap_irq.c
index 9adfa7c99695..fb39601721f6 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -215,6 +215,9 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
 
if (irqstatus & dispc_mgr_get_sync_lost_irq(channel))
omap_crtc_error_irq(crtc, irqstatus);
+
+   if (irqstatus & dispc_mgr_get_framedone_irq(channel))
+   omap_crtc_framedone_irq(crtc, irqstatus);
}
 
omap_irq_ocp_error_handler(irqstatus);
@@ -264,8 +267,10 @@ int omap_drm_irq_install(struct drm_device *dev)
priv->irq_mask |= omap_underflow_irqs[i];
}
 
-   for (i = 0; i < num_mgrs; ++i)
+   for (i = 0; i < num_mgrs; ++i) {
priv->irq_mask |= dispc_mgr_get_sync_lost_irq(i);
+   priv->irq_mask |= dispc_mgr_get_framedone_irq(i);
+   }
 
dispc_runtime_get();
dispc_clear_irqstatus(0x);
-- 
2.11.0



[PATCHv2 08/10] drm: omapdrm: crtc: handle framedone directly

2017-03-04 Thread Sebastian Reichel
From: Tony Lindgren 

We can handle framedone interrupt directly simlar to commit
e0519af75d6e ("drm: omapdrm: Handle CRTC error IRQs directly").

By default we just print a warning on framedone and do nothing.
Any manually refreshed displays can register a callback.

Signed-off-by: Tony Lindgren 
[Drop REVISIT comment for omap3, patch works on N950]
Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 25 +
 drivers/gpu/drm/omapdrm/omap_drv.h  |  1 +
 drivers/gpu/drm/omapdrm/omap_irq.c  |  7 ++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 432ad6023f27..4601533215d6 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -349,6 +349,31 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
DBG("%s: apply done", omap_crtc->name);
 }
 
+void omap_crtc_framedone_irq(struct drm_crtc *crtc, uint32_t irqstatus)
+{
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+
+   if (!omap_crtc->framedone_handler) {
+   dev_warn(omap_crtc->base.dev->dev, "no framedone handler?\n");
+
+   return;
+   }
+
+   omap_crtc->framedone_handler(omap_crtc->framedone_handler_data);
+
+   spin_lock(>dev->event_lock);
+   /* Send the vblank event if one has been requested. */
+   if (omap_crtc->event) {
+   drm_crtc_send_vblank_event(crtc, omap_crtc->event);
+   omap_crtc->event = NULL;
+   }
+   omap_crtc->pending = false;
+   spin_unlock(>dev->event_lock);
+
+   /* Wake up omap_atomic_complete. */
+   wake_up(_crtc->pending_wait);
+}
+
 void omap_crtc_flush(struct drm_crtc *crtc,
int x, int y, int w, int h)
 {
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index 71b5c5e25ee4..9586551960e9 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -138,6 +138,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
struct drm_plane *plane, enum omap_channel channel, int id);
 int omap_crtc_wait_pending(struct drm_crtc *crtc);
 void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
+void omap_crtc_framedone_irq(struct drm_crtc *crtc, uint32_t irqstatus);
 void omap_crtc_vblank_irq(struct drm_crtc *crtc);
 bool omap_crtc_is_manual_updated(struct drm_crtc *crtc);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c 
b/drivers/gpu/drm/omapdrm/omap_irq.c
index 9adfa7c99695..fb39601721f6 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -215,6 +215,9 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
 
if (irqstatus & dispc_mgr_get_sync_lost_irq(channel))
omap_crtc_error_irq(crtc, irqstatus);
+
+   if (irqstatus & dispc_mgr_get_framedone_irq(channel))
+   omap_crtc_framedone_irq(crtc, irqstatus);
}
 
omap_irq_ocp_error_handler(irqstatus);
@@ -264,8 +267,10 @@ int omap_drm_irq_install(struct drm_device *dev)
priv->irq_mask |= omap_underflow_irqs[i];
}
 
-   for (i = 0; i < num_mgrs; ++i)
+   for (i = 0; i < num_mgrs; ++i) {
priv->irq_mask |= dispc_mgr_get_sync_lost_irq(i);
+   priv->irq_mask |= dispc_mgr_get_framedone_irq(i);
+   }
 
dispc_runtime_get();
dispc_clear_irqstatus(0x);
-- 
2.11.0



[PATCHv2 05/10] drm: omapdrm: crtc: detect manually updated displays

2017-03-04 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
[t...@atomide.com: rebased on event_lock changes]
---
 drivers/gpu/drm/omapdrm/dss/omapdss.h|  1 +
 drivers/gpu/drm/omapdrm/dss/output.c |  6 ++
 drivers/gpu/drm/omapdrm/omap_connector.c |  7 +++
 drivers/gpu/drm/omapdrm/omap_crtc.c  | 29 +++--
 drivers/gpu/drm/omapdrm/omap_drv.h   |  2 ++
 5 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 5b3b961127bd..5666ecbe4b80 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -918,5 +918,6 @@ int dss_mgr_register_framedone_handler(enum omap_channel 
channel,
void (*handler)(void *), void *data);
 void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
void (*handler)(void *), void *data);
+bool dss_lcd_mgr_config_get_stallmode(const struct dss_lcd_mgr_config *config);
 
 #endif /* __OMAP_DRM_DSS_H */
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index a901af5a9bc3..08c730d1dada 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -214,6 +214,12 @@ void dss_mgr_set_lcd_config(enum omap_channel channel,
 }
 EXPORT_SYMBOL(dss_mgr_set_lcd_config);
 
+bool dss_lcd_mgr_config_get_stallmode(const struct dss_lcd_mgr_config *config)
+{
+   return config->stallmode;
+}
+EXPORT_SYMBOL(dss_lcd_mgr_config_get_stallmode);
+
 int dss_mgr_enable(enum omap_channel channel)
 {
return dss_mgr_ops->enable(channel);
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
b/drivers/gpu/drm/omapdrm/omap_connector.c
index 7b2a9f680dce..b09d8989b789 100644
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ b/drivers/gpu/drm/omapdrm/omap_connector.c
@@ -35,6 +35,13 @@ struct omap_connector {
bool hdmi_mode;
 };
 
+bool omap_connector_get_manually_updated(struct drm_connector *connector)
+{
+   struct omap_connector *omap_connector = to_omap_connector(connector);
+
+   return !!(omap_connector->dssdev->caps & 
OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE);
+}
+
 bool omap_connector_get_hdmi_mode(struct drm_connector *connector)
 {
struct omap_connector *omap_connector = to_omap_connector(connector);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 76a411fe957a..03351ca2ee41 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -35,6 +35,7 @@ struct omap_crtc {
enum omap_channel channel;
 
struct videomode vm;
+   bool manually_updated;
 
bool ignore_digit_sync_lost;
 
@@ -89,6 +90,12 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
  msecs_to_jiffies(250));
 }
 
+bool omap_crtc_is_manual_updated(struct drm_crtc *crtc)
+{
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+   return omap_crtc->manually_updated;
+}
+
 /* 
-
  * DSS Manager Functions
  */
@@ -237,6 +244,9 @@ static void omap_crtc_dss_set_lcd_config(enum omap_channel 
channel,
 {
struct omap_crtc *omap_crtc = omap_crtcs[channel];
DBG("%s", omap_crtc->name);
+
+   omap_crtc->manually_updated = dss_lcd_mgr_config_get_stallmode(config);
+
dispc_mgr_set_lcd_config(omap_crtc->channel, config);
 }
 
@@ -355,10 +365,23 @@ static void omap_crtc_destroy(struct drm_crtc *crtc)
 static void omap_crtc_enable(struct drm_crtc *crtc)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
+   struct drm_connector *connector;
int ret;
 
DBG("%s", omap_crtc->name);
 
+   /* manual updated display will not trigger vsync irq */
+   /* omap_crtc->manually_updated is not yet set */
+   drm_for_each_connector(connector, crtc->dev) {
+   if (connector->state->crtc != crtc)
+   continue;
+   if (!omap_connector_get_manually_updated(connector))
+   continue;
+   dev_dbg(dev->dev, "manually updated display detected!");
+   return;
+   }
+
spin_lock_irq(>dev->event_lock);
drm_crtc_vblank_on(crtc);
ret = drm_crtc_vblank_get(crtc);
@@ -440,8 +463,10 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 
DBG("%s: GO", omap_crtc->name);
 
-   ret = drm_crtc_vblank_get(crtc);
-   WARN_ON(ret != 0);
+   if (!omap_crtc->manually_updated) {
+   ret = drm_crtc_vblank_get(crtc);
+   WARN_ON(ret != 0);
+   }
 
spin_lock_irq(>dev->event_lock);
dispc_mgr_go(omap_crtc->channel);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index 5b1061586401..5a0106239be2 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ 

[PATCHv2 04/10] drm: omapdrm: crtc: save framedone callback from dss

2017-03-04 Thread Sebastian Reichel
Save the framedone callback supplied by dss for later
usage.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index b68c70eb395f..76a411fe957a 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -42,6 +42,9 @@ struct omap_crtc {
bool pending;
wait_queue_head_t pending_wait;
struct drm_pending_vblank_event *event;
+
+   void (*framedone_handler)(void *);
+   void *framedone_handler_data;
 };
 
 /* 
-
@@ -241,6 +244,17 @@ static int omap_crtc_dss_register_framedone(
enum omap_channel channel,
void (*handler)(void *), void *data)
 {
+   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_device *dev = omap_crtc->base.dev;
+
+   if (omap_crtc->framedone_handler)
+   return -EBUSY;
+
+   dev_dbg(dev->dev, "register framedone %s", omap_crtc->name);
+
+   omap_crtc->framedone_handler = handler;
+   omap_crtc->framedone_handler_data = data;
+
return 0;
 }
 
@@ -248,6 +262,16 @@ static void omap_crtc_dss_unregister_framedone(
enum omap_channel channel,
void (*handler)(void *), void *data)
 {
+   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_device *dev = omap_crtc->base.dev;
+
+   dev_dbg(dev->dev, "unregister framedone %s", omap_crtc->name);
+
+   WARN_ON(omap_crtc->framedone_handler != handler);
+   WARN_ON(omap_crtc->framedone_handler_data != data);
+
+   omap_crtc->framedone_handler = NULL;
+   omap_crtc->framedone_handler_data = NULL;
 }
 
 static const struct dss_mgr_ops mgr_ops = {
-- 
2.11.0



[PATCHv2 05/10] drm: omapdrm: crtc: detect manually updated displays

2017-03-04 Thread Sebastian Reichel
Signed-off-by: Sebastian Reichel 
[t...@atomide.com: rebased on event_lock changes]
---
 drivers/gpu/drm/omapdrm/dss/omapdss.h|  1 +
 drivers/gpu/drm/omapdrm/dss/output.c |  6 ++
 drivers/gpu/drm/omapdrm/omap_connector.c |  7 +++
 drivers/gpu/drm/omapdrm/omap_crtc.c  | 29 +++--
 drivers/gpu/drm/omapdrm/omap_drv.h   |  2 ++
 5 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 5b3b961127bd..5666ecbe4b80 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -918,5 +918,6 @@ int dss_mgr_register_framedone_handler(enum omap_channel 
channel,
void (*handler)(void *), void *data);
 void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
void (*handler)(void *), void *data);
+bool dss_lcd_mgr_config_get_stallmode(const struct dss_lcd_mgr_config *config);
 
 #endif /* __OMAP_DRM_DSS_H */
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index a901af5a9bc3..08c730d1dada 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -214,6 +214,12 @@ void dss_mgr_set_lcd_config(enum omap_channel channel,
 }
 EXPORT_SYMBOL(dss_mgr_set_lcd_config);
 
+bool dss_lcd_mgr_config_get_stallmode(const struct dss_lcd_mgr_config *config)
+{
+   return config->stallmode;
+}
+EXPORT_SYMBOL(dss_lcd_mgr_config_get_stallmode);
+
 int dss_mgr_enable(enum omap_channel channel)
 {
return dss_mgr_ops->enable(channel);
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
b/drivers/gpu/drm/omapdrm/omap_connector.c
index 7b2a9f680dce..b09d8989b789 100644
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ b/drivers/gpu/drm/omapdrm/omap_connector.c
@@ -35,6 +35,13 @@ struct omap_connector {
bool hdmi_mode;
 };
 
+bool omap_connector_get_manually_updated(struct drm_connector *connector)
+{
+   struct omap_connector *omap_connector = to_omap_connector(connector);
+
+   return !!(omap_connector->dssdev->caps & 
OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE);
+}
+
 bool omap_connector_get_hdmi_mode(struct drm_connector *connector)
 {
struct omap_connector *omap_connector = to_omap_connector(connector);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 76a411fe957a..03351ca2ee41 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -35,6 +35,7 @@ struct omap_crtc {
enum omap_channel channel;
 
struct videomode vm;
+   bool manually_updated;
 
bool ignore_digit_sync_lost;
 
@@ -89,6 +90,12 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
  msecs_to_jiffies(250));
 }
 
+bool omap_crtc_is_manual_updated(struct drm_crtc *crtc)
+{
+   struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+   return omap_crtc->manually_updated;
+}
+
 /* 
-
  * DSS Manager Functions
  */
@@ -237,6 +244,9 @@ static void omap_crtc_dss_set_lcd_config(enum omap_channel 
channel,
 {
struct omap_crtc *omap_crtc = omap_crtcs[channel];
DBG("%s", omap_crtc->name);
+
+   omap_crtc->manually_updated = dss_lcd_mgr_config_get_stallmode(config);
+
dispc_mgr_set_lcd_config(omap_crtc->channel, config);
 }
 
@@ -355,10 +365,23 @@ static void omap_crtc_destroy(struct drm_crtc *crtc)
 static void omap_crtc_enable(struct drm_crtc *crtc)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
+   struct drm_connector *connector;
int ret;
 
DBG("%s", omap_crtc->name);
 
+   /* manual updated display will not trigger vsync irq */
+   /* omap_crtc->manually_updated is not yet set */
+   drm_for_each_connector(connector, crtc->dev) {
+   if (connector->state->crtc != crtc)
+   continue;
+   if (!omap_connector_get_manually_updated(connector))
+   continue;
+   dev_dbg(dev->dev, "manually updated display detected!");
+   return;
+   }
+
spin_lock_irq(>dev->event_lock);
drm_crtc_vblank_on(crtc);
ret = drm_crtc_vblank_get(crtc);
@@ -440,8 +463,10 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 
DBG("%s: GO", omap_crtc->name);
 
-   ret = drm_crtc_vblank_get(crtc);
-   WARN_ON(ret != 0);
+   if (!omap_crtc->manually_updated) {
+   ret = drm_crtc_vblank_get(crtc);
+   WARN_ON(ret != 0);
+   }
 
spin_lock_irq(>dev->event_lock);
dispc_mgr_go(omap_crtc->channel);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index 5b1061586401..5a0106239be2 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ 

[PATCHv2 04/10] drm: omapdrm: crtc: save framedone callback from dss

2017-03-04 Thread Sebastian Reichel
Save the framedone callback supplied by dss for later
usage.

Signed-off-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index b68c70eb395f..76a411fe957a 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -42,6 +42,9 @@ struct omap_crtc {
bool pending;
wait_queue_head_t pending_wait;
struct drm_pending_vblank_event *event;
+
+   void (*framedone_handler)(void *);
+   void *framedone_handler_data;
 };
 
 /* 
-
@@ -241,6 +244,17 @@ static int omap_crtc_dss_register_framedone(
enum omap_channel channel,
void (*handler)(void *), void *data)
 {
+   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_device *dev = omap_crtc->base.dev;
+
+   if (omap_crtc->framedone_handler)
+   return -EBUSY;
+
+   dev_dbg(dev->dev, "register framedone %s", omap_crtc->name);
+
+   omap_crtc->framedone_handler = handler;
+   omap_crtc->framedone_handler_data = data;
+
return 0;
 }
 
@@ -248,6 +262,16 @@ static void omap_crtc_dss_unregister_framedone(
enum omap_channel channel,
void (*handler)(void *), void *data)
 {
+   struct omap_crtc *omap_crtc = omap_crtcs[channel];
+   struct drm_device *dev = omap_crtc->base.dev;
+
+   dev_dbg(dev->dev, "unregister framedone %s", omap_crtc->name);
+
+   WARN_ON(omap_crtc->framedone_handler != handler);
+   WARN_ON(omap_crtc->framedone_handler_data != data);
+
+   omap_crtc->framedone_handler = NULL;
+   omap_crtc->framedone_handler_data = NULL;
 }
 
 static const struct dss_mgr_ops mgr_ops = {
-- 
2.11.0



  1   2   3   4   5   6   >