[PATCHv2] tools: hv: hv_set_ifconfig.sh double check before setting ip

2017-12-08 Thread Eduardo Otubo
This patch fixes the behavior of the hv_set_ifconfig script when setting
the interface ip. Sometimes the interface has already been configured by
network daemon, in this case hv_set_ifconfig causes "RTNETLINK: file
exists error"; in order to avoid this error this patch makes sure double
checks the interface before trying anything.

Signed-off-by: Eduardo Otubo 
---
v2: wrap the interface configuration inside a safe wAY to avoid
interaction with network script.
 tools/hv/hv_set_ifconfig.sh | 45 +++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/tools/hv/hv_set_ifconfig.sh b/tools/hv/hv_set_ifconfig.sh
index 7ed9f85ef908..b6429703cc98 100755
--- a/tools/hv/hv_set_ifconfig.sh
+++ b/tools/hv/hv_set_ifconfig.sh
@@ -61,5 +61,46 @@ cp $1 /etc/sysconfig/network-scripts/
 
 interface=$(echo $1 | awk -F - '{ print $2 }')
 
-/sbin/ifdown $interface 2>/dev/null
-/sbin/ifup $interface 2>/dev/null
+current_ip=$(ip addr show $interface|sed -En 's/.*inet 
(addr:)?(([0-9*\.){3}[0-9]*).*/\2/p');
+config_file_ip=$(grep IPADDR 
/etc/sysconfig/network-scripts/ifcfg-$interface|cut -d"=" -f2);
+
+current_ipv6=$(ip addr show $interface|sed -E 's/^*.inet6\ (.*)\ scope\ 
global/\1/');
+config_file_ipv6=$(grep IPV6ADDR 
/etc/sysconfig/network-scripts/ifcfg-eth-$interface|cut -d"=" -f2);
+config_file_ipv6_netmask=$(grep IPV6NETMASK 
/etc/sysconfig/network-scripts/ifcfg-eth-$interface|cut -d"=" -f2);
+config_file_ipv6=${config_file_ipv6}/${config_file_ipv6_netmask};
+
+configure_interface(){
+# only set the IP if the network service has not done yet
+if [[ ${current_ip} != *${config_file_ip}* || ${current_ipv6} != 
${config_file_ipv6} ]]; then
+/sbin/ifdown $interface 2>/dev/null
+/sbin/ifup $interface 2>/dev/null
+fi
+}
+
+error_exit(){
+message=$1
+logger "KVP daemon: $message"
+exit 1;
+}
+
+if [ -e /var/run/subsys/network ]; then
+# network script is already up
+# it is safe to configure the interface
+configure_interface;
+else
+i=0;
+while [ ! -e /var/run/subsys/network ]; do
+# network script might be still starting.
+# let's wait for 3 minutes
+sleep 1m;
+((i++));
+
+# if network service doens't come up in 3 minutes
+# perhaps there's no network service at all
+[[ $i == 3 ]] && break;
+done
+
+# at this point it doesn't matter if network service is up or down
+# we're safe either way
+configure_interface;
+fi
-- 
2.13.6

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


Re: [PATCH net 1/3] hv_netvsc: Correct the max receive buffer size

2017-12-08 Thread Dan Carpenter
On Thu, Dec 07, 2017 at 04:10:53PM -0800, Stephen Hemminger wrote:
> From: Haiyang Zhang 
> 
> It should be 31 MB on recent host versions.
> 
> Signed-off-by: Haiyang Zhang 
> Signed-off-by: Stephen Hemminger 

This is very vague.  What does "recent" mean in this context?  There are
also some unrelated white space changes here which make the patch harder
to read.

This patch kind of makes the bug fixed by patch 2 even worse because
before the receive buffer was capped at around 16MB and now we can set
the receive buffer to 31MB.  It might make sense to fold the two
patches together.

Is patch 2 a memory corruption bug?  The changelog doesn't really say
what the user visible effects of the bug are.  Basically if you make the
buffer too small then it's a performance issue but if you make it too
large what happens?  It's not clear to me.

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


[PATCHv4] staging: pi433: pi433_if.c remove SET_CHECKED macro

2017-12-08 Thread Nguyen Phan Quang Minh
The macro calls its argument -a function- twice, makes the calling
function return prematurely -skipping resource cleanup code- and hurts
understandability.

Signed-off-by: Nguyen Phan Quang Minh 
---
v4: rebase the patch on lastest tree

 drivers/staging/pi433/pi433_if.c | 193 ---
 1 file changed, 139 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 55ed45f45998..32db3b320cbd 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -119,12 +119,6 @@ struct pi433_instance {
struct pi433_tx_cfg tx_cfg;
 };
 
-/*-*/
-
-/* macro for checked access of registers of radio module */
-#define SET_CHECKED(retval) \
-   if (retval < 0) \
-   return retval;
 
 /*-*/
 
@@ -183,15 +177,33 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
int payload_length;
 
/* receiver config */
-   SET_CHECKED(rf69_set_frequency  (dev->spi, rx_cfg->frequency));
-   SET_CHECKED(rf69_set_bit_rate   (dev->spi, rx_cfg->bit_rate));
-   SET_CHECKED(rf69_set_modulation (dev->spi, rx_cfg->modulation));
-   SET_CHECKED(rf69_set_antenna_impedance   (dev->spi, 
rx_cfg->antenna_impedance));
-   SET_CHECKED(rf69_set_rssi_threshold  (dev->spi, 
rx_cfg->rssi_threshold));
-   SET_CHECKED(rf69_set_ook_threshold_dec   (dev->spi, 
rx_cfg->threshold_decrement));
-   SET_CHECKED(rf69_set_bandwidth   (dev->spi, 
rx_cfg->bw_mantisse, rx_cfg->bw_exponent));
-   SET_CHECKED(rf69_set_bandwidth_during_afc(dev->spi, 
rx_cfg->bw_mantisse, rx_cfg->bw_exponent));
-   SET_CHECKED(rf69_set_dagc(dev->spi, rx_cfg->dagc));
+   ret = rf69_set_frequency(dev->spi, rx_cfg->frequency);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_bit_rate(dev->spi, rx_cfg->bit_rate);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_modulation(dev->spi, rx_cfg->modulation);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_antenna_impedance(dev->spi, rx_cfg->antenna_impedance);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_rssi_threshold(dev->spi, rx_cfg->rssi_threshold);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_ook_threshold_dec(dev->spi, rx_cfg->threshold_decrement);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_bandwidth(dev->spi, rx_cfg->bw_mantisse, 
rx_cfg->bw_exponent);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_bandwidth_during_afc(dev->spi, rx_cfg->bw_mantisse, 
rx_cfg->bw_exponent);
+   if (ret < 0)
+   return ret;
+   ret = rf69_set_dagc(dev->spi, rx_cfg->dagc);
+   if (ret < 0)
+   return ret;
 
dev->rx_bytes_to_drop = rx_cfg->bytes_to_drop;
 
@@ -203,7 +215,9 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
if (ret < 0)
return ret;
 
-   SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, 
afterSyncInterrupt));
+   ret = rf69_set_fifo_fill_condition(dev->spi, 
afterSyncInterrupt);
+   if (ret < 0)
+   return ret;
}
else
{
@@ -211,7 +225,9 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
if (ret < 0)
return ret;
 
-   SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, always));
+   ret = rf69_set_fifo_fill_condition(dev->spi, always);
+   if (ret < 0)
+   return ret;
}
if (rx_cfg->enable_length_byte == OPTION_ON) {
ret = rf69_set_packet_format(dev->spi, packetLengthVar);
@@ -222,7 +238,9 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
if (ret < 0)
return ret;
}
-   SET_CHECKED(rf69_set_adressFiltering(dev->spi, 
rx_cfg->enable_address_filtering));
+   ret = rf69_set_adressFiltering(dev->spi, 
rx_cfg->enable_address_filtering);
+   if (ret < 0)
+   return ret;
 
if (rx_cfg->enable_crc == OPTION_ON) {
ret = rf69_enable_crc(dev->spi);
@@ -235,32 +253,46 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
}
 
/* lengths */
-   SET_CHECKED(rf69_set_sync_size(dev->spi, rx_cfg->sync_length));
+   ret = rf69_set_sync_size(dev->spi, rx_cfg->sync_length);
+   if (ret < 0)
+   return ret;
if (rx_cfg->enable_length_byte == OPTION_ON)
{
-   SET_CHECKED(rf69_set_payload_length(dev->spi, 0xff));
+   ret = rf69_set_payload_length(dev->spi, 0xff);

Re: [PATCH net 3/3] hv_netvsc: Fix the default receive buffer size

2017-12-08 Thread Dan Carpenter
On Thu, Dec 07, 2017 at 04:10:55PM -0800, Stephen Hemminger wrote:
> From: Haiyang Zhang 
> 
> The intended size is 16 MB, and the default slot size is 1728.
> So, NETVSC_DEFAULT_RX should be 16*1024*1024 / 1728 = 9709.
> 
> Fixes: 5023a6db73196 ("netvsc: increase default receive buffer size")
> Signed-off-by: Haiyang Zhang 
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/net/hyperv/netvsc_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index dc70de674ca9..edfcde5d3621 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -50,7 +50,7 @@
>  #define NETVSC_MIN_TX_SECTIONS   10
>  #define NETVSC_DEFAULT_TX192 /* ~1M */
>  #define NETVSC_MIN_RX_SECTIONS   10  /* ~64K */
> -#define NETVSC_DEFAULT_RX10485   /* Max ~16M */
> +#define NETVSC_DEFAULT_RX9709/* ~16M */

How does this bug look like to the user?  Memory corruption?

It's weird to me reviewing this code that the default sizes are
stored in netvsc_drv.c and the max sizes are stored in hyperv_net.h.
Could we move these to hyperv_net.h?  We could write it like:
#define NETVSC_DEFAULT_RX ((16 * 1024 * 1024) / NETVSC_RECV_SECTION_SIZE)

16MB is sort of a weird default because it's larger than the 15MB
allowed for legacy versions, but it's smaller than the 32MB you'd want
for the current versions.

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


Re: [PATCHv4] staging: pi433: pi433_if.c remove SET_CHECKED macro

2017-12-08 Thread Dan Carpenter
On Fri, Dec 08, 2017 at 11:43:19AM +0100, Nguyen Phan Quang Minh wrote:
> The macro calls its argument -a function- twice, makes the calling
> function return prematurely -skipping resource cleanup code- and hurts
> understandability.
> 
> Signed-off-by: Nguyen Phan Quang Minh 

Looks good.  Thanks!

Reviewed-by: Dan Carpenter 

regards,
dan carpenter

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


[PATCH 5/6] x86/kvm: pass stable clocksource to guests when running nested on Hyper-V

2017-12-08 Thread Vitaly Kuznetsov
Currently, KVM is able to work in 'masterclock' mode passing
PVCLOCK_TSC_STABLE_BIT to guests when the clocksource we use on the host
is TSC. When running nested on Hyper-V we normally use a different one:
TSC page which is resistant to TSC frequency changes on event like L1
migration. Add support for it in KVM.

The only non-trivial change in the patch is in vgettsc(): when updating
our gtod copy we now need to get both the clockread and tsc value.

Signed-off-by: Vitaly Kuznetsov 
---
RFC -> v1:
- 'gtod_cs_mode_good' -> 'gtod_is_based_on_tsc' [Radim Krčmář]
- rewrite vgettsc() to handle -1 from hv_read_tsc_page_tsc() [Radim Krčmář]
- cycle_now -> tsc_timestamp [Radim Krčmář]
---
 arch/x86/kvm/x86.c | 93 +++---
 1 file changed, 68 insertions(+), 25 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index eee8e7faf1af..96e04a0cb921 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include "trace.h"
@@ -1377,6 +1378,11 @@ static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 
kernel_ns)
return tsc;
 }
 
+static inline int gtod_is_based_on_tsc(int mode)
+{
+   return mode == VCLOCK_TSC || mode == VCLOCK_HVCLOCK;
+}
+
 static void kvm_track_tsc_matching(struct kvm_vcpu *vcpu)
 {
 #ifdef CONFIG_X86_64
@@ -1396,7 +1402,7 @@ static void kvm_track_tsc_matching(struct kvm_vcpu *vcpu)
 * perform request to enable masterclock.
 */
if (ka->use_master_clock ||
-   (gtod->clock.vclock_mode == VCLOCK_TSC && vcpus_matched))
+   (gtod_is_based_on_tsc(gtod->clock.vclock_mode) && vcpus_matched))
kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu);
 
trace_kvm_track_tsc(vcpu->vcpu_id, ka->nr_vcpus_matched_tsc,
@@ -1459,6 +1465,19 @@ static void kvm_vcpu_write_tsc_offset(struct kvm_vcpu 
*vcpu, u64 offset)
vcpu->arch.tsc_offset = offset;
 }
 
+static inline bool kvm_check_tsc_unstable(void)
+{
+#ifdef CONFIG_X86_64
+   /*
+* TSC is marked unstable when we're running on Hyper-V,
+* 'TSC page' clocksource is good.
+*/
+   if (pvclock_gtod_data.clock.vclock_mode == VCLOCK_HVCLOCK)
+   return false;
+#endif
+   return check_tsc_unstable();
+}
+
 void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)
 {
struct kvm *kvm = vcpu->kvm;
@@ -1504,7 +1523,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data 
*msr)
  */
if (synchronizing &&
vcpu->arch.virtual_tsc_khz == kvm->arch.last_tsc_khz) {
-   if (!check_tsc_unstable()) {
+   if (!kvm_check_tsc_unstable()) {
offset = kvm->arch.cur_tsc_offset;
pr_debug("kvm: matched tsc offset for %llu\n", data);
} else {
@@ -1604,18 +1623,43 @@ static u64 read_tsc(void)
return last;
 }
 
-static inline u64 vgettsc(u64 *cycle_now)
+static inline u64 vgettsc(u64 *tsc_timestamp, int *mode)
 {
long v;
struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
+   u64 tsc_pg_val;
+
+   switch (gtod->clock.vclock_mode) {
+   case VCLOCK_HVCLOCK:
+   tsc_pg_val = hv_read_tsc_page_tsc(hv_get_tsc_page(),
+ tsc_timestamp);
+   if (tsc_pg_val != U64_MAX) {
+   /* TSC page valid */
+   *mode = VCLOCK_HVCLOCK;
+   v = (tsc_pg_val - gtod->clock.cycle_last) &
+   gtod->clock.mask;
+   } else {
+   /* TSC page invalid */
+   *mode = VCLOCK_NONE;
+   }
+   break;
+   case VCLOCK_TSC:
+   *mode = VCLOCK_TSC;
+   *tsc_timestamp = read_tsc();
+   v = (*tsc_timestamp - gtod->clock.cycle_last) &
+   gtod->clock.mask;
+   break;
+   default:
+   *mode = VCLOCK_NONE;
+   }
 
-   *cycle_now = read_tsc();
+   if (*mode == VCLOCK_NONE)
+   *tsc_timestamp = v = 0;
 
-   v = (*cycle_now - gtod->clock.cycle_last) & gtod->clock.mask;
return v * gtod->clock.mult;
 }
 
-static int do_monotonic_boot(s64 *t, u64 *cycle_now)
+static int do_monotonic_boot(s64 *t, u64 *tsc_timestamp)
 {
struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
unsigned long seq;
@@ -1624,9 +1668,8 @@ static int do_monotonic_boot(s64 *t, u64 *cycle_now)
 
do {
seq = read_seqcount_begin(>od->seq);
-   mode = gtod->clock.vclock_mode;
ns = gtod->nsec_base;
-   ns += vgettsc(cycle_now);
+   ns += vgettsc(tsc_timestamp, &mode);
ns >>= gtod->clock.shift;
ns += gtod->boot_ns;
} while (unlikely(read_seqcount_retry(>od->se

[PATCH 1/6] x86/hyper-v: check for required priviliges in hyperv_init()

2017-12-08 Thread Vitaly Kuznetsov
In hyperv_init() we presume we always have access to VP index and hypercall
MSRs while according to the specification we should check if we're allowed
to access the corresponding MSRs before accessing them.

Signed-off-by: Vitaly Kuznetsov 
---
RFC -> v1:
- 'requied_msrs' -> 'required_msrs' [Andrew Jones]
---
 arch/x86/hyperv/hv_init.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 189a398290db..21f9d53d9f00 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -110,12 +110,19 @@ static int hv_cpu_init(unsigned int cpu)
  */
 void hyperv_init(void)
 {
-   u64 guest_id;
+   u64 guest_id, required_msrs;
union hv_x64_msr_hypercall_contents hypercall_msr;
 
if (x86_hyper_type != X86_HYPER_MS_HYPERV)
return;
 
+   /* Absolutely required MSRs */
+   required_msrs = HV_X64_MSR_HYPERCALL_AVAILABLE |
+   HV_X64_MSR_VP_INDEX_AVAILABLE;
+
+   if ((ms_hyperv.features & required_msrs) != required_msrs)
+   return;
+
/* Allocate percpu VP index */
hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index),
GFP_KERNEL);
-- 
2.14.3

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


[PATCH 3/6] x86/hyper-v: reenlightenment notifications support

2017-12-08 Thread Vitaly Kuznetsov
Hyper-V supports Live Migration notification. This is supposed to be used
in conjunction with TSC emulation: when we are migrated to a host with
different TSC frequency for some short period host emulates our accesses
to TSC and sends us an interrupt to notify about the event. When we're
done updating everything we can disable TSC emulation and everything will
start working fast again.

We didn't need these notifications before as Hyper-V guests are not
supposed to use TSC as a clocksource: in Linux we even mark it as unstable
on boot. Guests normally use 'tsc page' clocksouce and host updates its
values on migrations automatically.

Things change when we want to run nested virtualization: even when we pass
through PV clocksources (kvm-clock or tsc page) to our guests we need to
know TSC frequency and when it changes.

Hyper-V Top Level Functional Specification (as of v5.0b) wrongly specifies
EAX:BIT(12) of CPUID:0x4009 as the feature identification bit. The
right one to check is EAX:BIT(13) of CPUID:0x4003. I was assured that
the fix in on the way.

Signed-off-by: Vitaly Kuznetsov 
---
RFC -> v1:
- #include  [kbuild test robot]
- use div64_u64() [kbuild test robot]
- DECLARE_WORK -> DECLARE_DELAYED_WORK as testing showed there's some bug
  in Hyper-V hypervisor and disabling emulation after receiving interrupt
  may screw TSC counters.
---
 arch/x86/entry/entry_64.S  |  4 +++
 arch/x86/hyperv/hv_init.c  | 71 ++
 arch/x86/include/asm/entry_arch.h  |  4 +++
 arch/x86/include/asm/hw_irq.h  |  1 +
 arch/x86/include/asm/irq_vectors.h |  7 +++-
 arch/x86/include/asm/mshyperv.h|  8 +
 arch/x86/include/uapi/asm/hyperv.h | 27 +++
 arch/x86/kernel/idt.c  |  3 ++
 8 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index f81d50d7ceac..a32730b260bc 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -826,6 +826,10 @@ apicinterrupt SPURIOUS_APIC_VECTOR 
spurious_interrupt  smp_spurious_interrupt
 apicinterrupt IRQ_WORK_VECTOR  irq_work_interrupt  
smp_irq_work_interrupt
 #endif
 
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPERV_REENLIGHTENMENT_VECTORhyperv_reenlightenment_intr 
smp_hyperv_reenlightenment_intr
+#endif
+
 /*
  * Exception entry points.
  */
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 1a6c63f721bc..bb62839ede81 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -102,6 +103,76 @@ static int hv_cpu_init(unsigned int cpu)
return 0;
 }
 
+static void (*hv_reenlightenment_cb)(void);
+
+static void hv_reenlightenment_notify(struct work_struct *dummy)
+{
+   if (hv_reenlightenment_cb)
+   hv_reenlightenment_cb();
+}
+static DECLARE_DELAYED_WORK(hv_reenlightenment_work, 
hv_reenlightenment_notify);
+
+void hyperv_stop_tsc_emulation(void)
+{
+   u64 freq;
+   struct hv_tsc_emulation_status emu_status;
+
+   rdmsrl(HV_X64_MSR_TSC_EMULATION_STATUS, *(u64 *)&emu_status);
+   emu_status.inprogress = 0;
+   wrmsrl(HV_X64_MSR_TSC_EMULATION_STATUS, *(u64 *)&emu_status);
+
+   rdmsrl(HV_X64_MSR_TSC_FREQUENCY, freq);
+   tsc_khz = div64_u64(freq, 1000);
+}
+EXPORT_SYMBOL_GPL(hyperv_stop_tsc_emulation);
+
+void register_hv_tsc_update(void (*cb)(void))
+{
+   struct hv_reenlightenment_control re_ctrl = {
+   .vector = HYPERV_REENLIGHTENMENT_VECTOR,
+   .enabled = 1,
+   .target_vp = hv_vp_index[smp_processor_id()]
+   };
+   struct hv_tsc_emulation_control emu_ctrl = {.enabled = 1};
+
+   if (!(ms_hyperv.features & HV_X64_ACCESS_REENLIGHTENMENT))
+   return;
+
+   hv_reenlightenment_cb = cb;
+
+   /* Make sure callback is registered before we write to MSRs */
+   wmb();
+
+   wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
+   wrmsrl(HV_X64_MSR_TSC_EMULATION_CONTROL, *((u64 *)&emu_ctrl));
+}
+EXPORT_SYMBOL_GPL(register_hv_tsc_update);
+
+void unregister_hv_tsc_update(void)
+{
+   struct hv_reenlightenment_control re_ctrl;
+
+   if (!(ms_hyperv.features & HV_X64_ACCESS_REENLIGHTENMENT))
+   return;
+
+   rdmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *(u64 *)&re_ctrl);
+   re_ctrl.enabled = 0;
+   wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *(u64 *)&re_ctrl);
+
+   hv_reenlightenment_cb = NULL;
+}
+EXPORT_SYMBOL_GPL(unregister_hv_tsc_update);
+
+asmlinkage __visible void
+__irq_entry smp_hyperv_reenlightenment_intr(struct pt_regs *regs)
+{
+   entering_ack_irq();
+
+   schedule_delayed_work(&hv_reenlightenment_work, HZ/10);
+
+   exiting_irq();
+}
+
 /*
  * This function is to be invoked early in the boot sequence after the
  * hypervisor has been detected.
diff --

[PATCH 2/6] x86/hyper-v: add a function to read both TSC and TSC page value simulateneously

2017-12-08 Thread Vitaly Kuznetsov
This is going to be used from KVM code where we need to get both
TSC and TSC page value.

When Hyper-V code is compiled out just return rdtsc(), this will allow us
to avoid ugly ifdefs in non-Hyper-V code.

Signed-off-by: Vitaly Kuznetsov 
---
RFC -> v1:
- EXPORT_SYMBOL_GPL(hv_get_tsc_page) [kbuild test robot]
- BUG() in !CONFIG_HYPERV_TSCPAGE case [Stephen Hemminger, Paolo Bonzini]
- 'were' -> 'where' [Andrew Jones]
---
 arch/x86/hyperv/hv_init.c   |  1 +
 arch/x86/include/asm/mshyperv.h | 23 +++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 21f9d53d9f00..1a6c63f721bc 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -37,6 +37,7 @@ struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
 {
return tsc_pg;
 }
+EXPORT_SYMBOL_GPL(hv_get_tsc_page);
 
 static u64 read_hv_clock_tsc(struct clocksource *arg)
 {
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 5400add2885b..a0b34994f453 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -323,9 +323,10 @@ static inline void hyperv_setup_mmu_ops(void) {}
 
 #ifdef CONFIG_HYPERV_TSCPAGE
 struct ms_hyperv_tsc_page *hv_get_tsc_page(void);
-static inline u64 hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg)
+static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg,
+  u64 *cur_tsc)
 {
-   u64 scale, offset, cur_tsc;
+   u64 scale, offset;
u32 sequence;
 
/*
@@ -356,7 +357,7 @@ static inline u64 hv_read_tsc_page(const struct 
ms_hyperv_tsc_page *tsc_pg)
 
scale = READ_ONCE(tsc_pg->tsc_scale);
offset = READ_ONCE(tsc_pg->tsc_offset);
-   cur_tsc = rdtsc_ordered();
+   *cur_tsc = rdtsc_ordered();
 
/*
 * Make sure we read sequence after we read all other values
@@ -366,7 +367,14 @@ static inline u64 hv_read_tsc_page(const struct 
ms_hyperv_tsc_page *tsc_pg)
 
} while (READ_ONCE(tsc_pg->tsc_sequence) != sequence);
 
-   return mul_u64_u64_shr(cur_tsc, scale, 64) + offset;
+   return mul_u64_u64_shr(*cur_tsc, scale, 64) + offset;
+}
+
+static inline u64 hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg)
+{
+   u64 cur_tsc;
+
+   return hv_read_tsc_page_tsc(tsc_pg, &cur_tsc);
 }
 
 #else
@@ -374,5 +382,12 @@ static inline struct ms_hyperv_tsc_page 
*hv_get_tsc_page(void)
 {
return NULL;
 }
+
+static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page *tsc_pg,
+  u64 *cur_tsc)
+{
+   BUG();
+   return U64_MAX;
+}
 #endif
 #endif
-- 
2.14.3

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


[PATCH 6/6] x86/kvm: support Hyper-V reenlightenment

2017-12-08 Thread Vitaly Kuznetsov
When we run nested KVM on Hyper-V guests we need to update masterclocks for
all guests when L1 migrates to a host with different TSC frequency.
Implement the procedure in the following way:
- Pause all guests.
- Tell our host (Hyper-V) to stop emulating TSC accesses.
- Update our gtod copy, recompute clocks.
- Unpause all guests.

This is somewhat similar to cpufreq but we have two important differences:
we can only disable TSC emulation globally (on all CPUs) and we don't know
the new TSC frequency until we turn the emulation off so we can't
'prepare' ourselves to the event.

Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/kvm/x86.c | 45 +
 1 file changed, 45 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 96e04a0cb921..04d90712ffd2 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -68,6 +68,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include "trace.h"
@@ -5946,6 +5947,43 @@ static void tsc_khz_changed(void *data)
__this_cpu_write(cpu_tsc_khz, khz);
 }
 
+void kvm_hyperv_tsc_notifier(void)
+{
+#ifdef CONFIG_X86_64
+   struct kvm *kvm;
+   struct kvm_vcpu *vcpu;
+   int cpu;
+
+   spin_lock(&kvm_lock);
+   list_for_each_entry(kvm, &vm_list, vm_list)
+   kvm_make_mclock_inprogress_request(kvm);
+
+   hyperv_stop_tsc_emulation();
+
+   /* TSC frequency always matches when on Hyper-V */
+   for_each_present_cpu(cpu)
+   per_cpu(cpu_tsc_khz, cpu) = tsc_khz;
+   kvm_max_guest_tsc_khz = tsc_khz;
+
+   list_for_each_entry(kvm, &vm_list, vm_list) {
+   struct kvm_arch *ka = &kvm->arch;
+
+   spin_lock(&ka->pvclock_gtod_sync_lock);
+
+   pvclock_update_vm_gtod_copy(kvm);
+
+   kvm_for_each_vcpu(cpu, vcpu, kvm)
+   kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
+
+   kvm_for_each_vcpu(cpu, vcpu, kvm)
+   kvm_clear_request(KVM_REQ_MCLOCK_INPROGRESS, vcpu);
+
+   spin_unlock(&ka->pvclock_gtod_sync_lock);
+   }
+   spin_unlock(&kvm_lock);
+#endif
+}
+
 static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long 
val,
 void *data)
 {
@@ -6231,6 +6269,9 @@ int kvm_arch_init(void *opaque)
kvm_lapic_init();
 #ifdef CONFIG_X86_64
pvclock_gtod_register_notifier(&pvclock_gtod_notifier);
+
+   if (x86_hyper_type == X86_HYPER_MS_HYPERV)
+   register_hv_tsc_update(kvm_hyperv_tsc_notifier);
 #endif
 
return 0;
@@ -6243,6 +6284,10 @@ int kvm_arch_init(void *opaque)
 
 void kvm_arch_exit(void)
 {
+#ifdef CONFIG_X86_64
+   if (x86_hyper_type == X86_HYPER_MS_HYPERV)
+   unregister_hv_tsc_update();
+#endif
kvm_lapic_exit();
perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
 
-- 
2.14.3

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


[PATCH 4/6] x86/hyper-v: redirect reenlightment notifications on CPU offlining

2017-12-08 Thread Vitaly Kuznetsov
It is very unlikely for CPUs to get offlined when we run on Hyper-V as
we have a protection in vmbus module which prevents it when we have any
VMBus devices assigned. This, however,  may change in future if an option
to reassign an already active channel will be added. It is also possible
to run without any Hyper-V devices of have a CPU with no assigned channels.

Reassign reenlightenment notifications to some other active CPU when
the CPU which is assigned to get them goes offline.

Signed-off-by: Vitaly Kuznetsov 
---
RFC -> v1:
- protect hv_cpu_die() from reentrance (when multiple CPUs go offline
  in parallel. I don't think it happens nowdays though but things tend
  to change).
---
 arch/x86/hyperv/hv_init.c | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index bb62839ede81..fbf8e372e261 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -173,6 +173,36 @@ __irq_entry smp_hyperv_reenlightenment_intr(struct pt_regs 
*regs)
exiting_irq();
 }
 
+static int hv_cpu_die(unsigned int cpu)
+{
+   struct hv_reenlightenment_control re_ctrl;
+   int i;
+   static DEFINE_SPINLOCK(lock);
+
+   if (hv_reenlightenment_cb == NULL)
+   return 0;
+
+   /* Make sure the CPU we migrate to is not going away too */
+   spin_lock(&lock);
+   rdmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
+   if (re_ctrl.target_vp == hv_vp_index[cpu]) {
+   /* Find some other online CPU */
+   for_each_online_cpu(i) {
+   if (i == cpu)
+   continue;
+
+   re_ctrl.target_vp = hv_vp_index[i];
+   wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL,
+  *((u64 *)&re_ctrl));
+
+   break;
+   }
+   }
+   spin_unlock(&lock);
+
+   return 0;
+}
+
 /*
  * This function is to be invoked early in the boot sequence after the
  * hypervisor has been detected.
@@ -202,7 +232,7 @@ void hyperv_init(void)
return;
 
if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv_init:online",
- hv_cpu_init, NULL) < 0)
+ hv_cpu_init, hv_cpu_die) < 0)
goto free_vp_index;
 
/*
-- 
2.14.3

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


[PATCH 0/6] x86/kvm/hyperv: stable clocksorce for L2 guests when running nested KVM on Hyper-V

2017-12-08 Thread Vitaly Kuznetsov
Changes since RFC:
- Handle disabled TSC page case [Radim Krčmář]
- Function/parameter renames [Radim Krčmář]
- Protect against simultaneous CPU shutdown (future-proof) [Radim Krčmář]
- BUG() in !CONFIG_HYPERV_TSCPAGE case [Stephen Hemminger, Paolo Bonzini]
- Fix build issues (hopefully) [kbuild test robot]
- Fix typos [Andrew Jones]
- Switch to delayed work to workaround a host issue (reported to Microsoft)
Changes are described in the individual patches too.

Original description:

Currently, KVM passes PVCLOCK_TSC_STABLE_BIT to its guests when running in
so called 'masterclock' mode and this is only possible when the clocksource
on the host is TSC. When running nested on Hyper-V we're using a different
clocksource in L1 (Hyper-V TSC Page) which can actually be used for
masterclock. This series brings the required support.

Making KVM work with TSC page clocksource is relatively easy, it is done in
PATCH 5 of the series. All the rest is required to support L1 migration
when TSC frequency changes, we use a special feature from Hyper-V to do
the job.

Vitaly Kuznetsov (6):
  x86/hyper-v: check for required priviliges in hyperv_init()
  x86/hyper-v: add a function to read both TSC and TSC page value
simulateneously
  x86/hyper-v: reenlightenment notifications support
  x86/hyper-v: redirect reenlightment notifications on CPU offlining
  x86/kvm: pass stable clocksource to guests when running nested on
Hyper-V
  x86/kvm: support Hyper-V reenlightenment

 arch/x86/entry/entry_64.S  |   4 ++
 arch/x86/hyperv/hv_init.c  | 113 +-
 arch/x86/include/asm/entry_arch.h  |   4 ++
 arch/x86/include/asm/hw_irq.h  |   1 +
 arch/x86/include/asm/irq_vectors.h |   7 +-
 arch/x86/include/asm/mshyperv.h|  31 +++--
 arch/x86/include/uapi/asm/hyperv.h |  27 
 arch/x86/kernel/idt.c  |   3 +
 arch/x86/kvm/x86.c | 138 ++---
 9 files changed, 296 insertions(+), 32 deletions(-)

-- 
2.14.3

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


Re: [PATCH] android: binder: Check for errors in binder_alloc_shrinker_init().

2017-12-08 Thread Dan Carpenter
On Wed, Dec 06, 2017 at 02:05:58PM -0500, Sherry Yang wrote:
> Hi Tetsuo,
> 
> It looks like this patch was not submitted to LKML. Perhaps you want
> to send it to the mailing list and add the correct set of recipients
> using scripts/get_maintainer.pl as suggested here
> https://www.kernel.org/doc/html/v4.12/process/submitting-patches.html.
> 
> -Sherry
> 

I've always viewed the de...@driverdev.osuosl.org as sufficient.  You're
not really going to get more reviewers by CC'ing LKML...

regards,
dan carpenter

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


Re: [PATCHv2] tools: hv: hv_set_ifconfig.sh double check before setting ip

2017-12-08 Thread Olaf Hering
On Fri, Dec 08, Eduardo Otubo wrote:

>  tools/hv/hv_set_ifconfig.sh | 45 
> +++--
>  1 file changed, 43 insertions(+), 2 deletions(-)

> +# let's wait for 3 minutes

Was this codepath runtime tested?

Last time this came up, the conclusion was that Windows terminates the
"KVP connection" after 60 seconds. After that, the VM must be rebooted
because the kernel does not deal with the long-running script. It is
also not clear what the kernel is supposed to do: either silently report
success and hope the scripts reports success one day, or report error
independent from what the script actually returns. New KVP requests
would need to be queued either way.


Olaf


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


[PATCH] staging: ccree: cleanup a small white space issue

2017-12-08 Thread Dan Carpenter
The call to set_flow_mode() was supposed to be on the next line.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 5548c7b24fc9..24e56d69039e 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -747,8 +747,8 @@ static void cc_set_assoc_desc(struct aead_request *areq, 
unsigned int flow_mode,
dev_dbg(dev, "ASSOC buffer type DLLI\n");
hw_desc_init(&desc[idx]);
set_din_type(&desc[idx], DMA_DLLI, sg_dma_address(areq->src),
-areq->assoclen, NS_BIT); set_flow_mode(&desc[idx],
-flow_mode);
+areq->assoclen, NS_BIT);
+   set_flow_mode(&desc[idx], flow_mode);
if (ctx->auth_mode == DRV_HASH_XCBC_MAC &&
areq_ctx->cryptlen > 0)
set_din_not_last_indication(&desc[idx]);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wlan-ng: Fixing coding style warning

2017-12-08 Thread Rodrigo Zaiden
Removes following warnings found by checkpatch.pl script:
WARNING: line over 80 characters

Signed-off-by: Rodrigo Zaiden 
---
 drivers/staging/wlan-ng/p80211netdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/p80211netdev.c 
b/drivers/staging/wlan-ng/p80211netdev.c
index 0b5aecd..ec9cc00 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -641,7 +641,8 @@ static int p80211knetdev_set_mac_address(struct net_device 
*dev, void *addr)
dot11req.msgcode = DIDmsg_dot11req_mibset;
dot11req.msglen = sizeof(dot11req);
memcpy(dot11req.devname,
-  ((struct wlandevice *)dev->ml_priv)->name, WLAN_DEVNAMELEN_MAX - 
1);
+  ((struct wlandevice *)dev->ml_priv)->name,
+  WLAN_DEVNAMELEN_MAX - 1);
 
/* Set up the mibattribute argument */
mibattr->did = DIDmsg_dot11req_mibset_mibattribute;
-- 
1.9.1

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


[PATCH 0/6] staging: fsl-dpaa2/eth: Frame buffer optimizations

2017-12-08 Thread Ioana Radulescu
This patchset continues the work related to frame buffer layout.

The first two patches fix an issue and simplify some rather convoluted
formulas introduced by a previous commit.

The third adds a new counter for TX skb reallocations due to
insufficient headroom. This helped us notice that most of the frames
originated on the core had skbs with too little headroom, leading to
additional alloc/free operations and a performance penalty for
egress termination traffic.

A closer look at hardware requirements vs recommandations showed
that we don't in fact need to be so strict with our TX buffer layout.
The last three patches in this set remove all restrictions that are
not mandatory from a functional standpoint, lowering the required
TX headroom from 192B to 64B.

This helps avoid realloc's for most TCP frames. On a LS2088A board
with one core @2GHz, running a netperf TCP_SENDFILE test (as client),
we see an increase in throughput from 3.79Gbps to 5.11Gbps. For UDP
traffic no improvement is observed, since the stack usually creates
skbs with minimal headroom (2B) for UDP frames.

Ioana Radulescu (6):
  staging: fsl-dpaa2/eth: Fix access to FAS field
  staging: fsl-dpaa2/eth: Don't set netdev->needed_headroom
  staging: fsl-dpaa2/eth: Add counter for skb reallocs
  staging: fsl-dpaa2/eth: Don't enable FAS on Tx
  staging: fsl-dpaa2/eth: Compute needed headroom per frame
  staging: fsl-dpaa2/eth: Make Tx buffer alignment optional

 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 111 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  31 +++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c |   1 +
 3 files changed, 46 insertions(+), 97 deletions(-)

-- 
2.7.4

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


[PATCH 3/6] staging: fsl-dpaa2/eth: Add counter for skb reallocs

2017-12-08 Thread Ioana Radulescu
Add a counter for the number of egress frames that need to be
realloc'ed due to insufficient headroom space.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 1 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 1 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 04db65c..6de6cdd 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -578,6 +578,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct 
net_device *net_dev)
percpu_stats->tx_dropped++;
goto err_alloc_headroom;
}
+   percpu_extras->tx_reallocs++;
dev_kfree_skb(skb);
skb = ns;
}
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 63b09d1..6940a98 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -231,6 +231,7 @@ struct dpaa2_eth_drv_stats {
__u64   tx_conf_bytes;
__u64   tx_sg_frames;
__u64   tx_sg_bytes;
+   __u64   tx_reallocs;
__u64   rx_sg_frames;
__u64   rx_sg_bytes;
/* Enqueues retried due to portal busy */
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index ebe8fd6..070a3f2 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -62,6 +62,7 @@ static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
"[drv] tx conf bytes",
"[drv] tx sg frames",
"[drv] tx sg bytes",
+   "[drv] tx realloc frames",
"[drv] rx sg frames",
"[drv] rx sg bytes",
"[drv] enqueue portal busy",
-- 
2.7.4

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


[PATCH 2/6] staging: fsl-dpaa2/eth: Don't set netdev->needed_headroom

2017-12-08 Thread Ioana Radulescu
Commit 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX
buffers") tried to avoid the performance penalty of doing skb
reallocations in the network stack for IP forwarded frames between
two DPAA2 Ethernet interfaces. This led to a (too) complicated
formula that relies on the stack's internal implementation.

Instead, it's safer and easier to just not request any guarantee
from the stack. We already double check in the driver the required
headroom size of egress frames and realloc the skb if needed, so
we don't need to add any extra code.

On forwarding between two of our own interfaces, there is no
functional change; for traffic forwarded from a different device or
generated on the core, skb realloc operations are moved from the stack
to our driver, with no visible impact on performance.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 24 ++--
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  2 +-
 2 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index c8a8e3a..04db65c 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -449,8 +449,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
struct sk_buff **skbh;
dma_addr_t addr;
 
-   buffer_start = PTR_ALIGN(skb->data - priv->tx_data_offset -
-DPAA2_ETH_TX_BUF_ALIGN,
+   buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
 DPAA2_ETH_TX_BUF_ALIGN);
 
/* PTA from egress side is passed as is to the confirmation side so
@@ -571,7 +570,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct 
net_device *net_dev)
percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras);
 
-   if (unlikely(skb_headroom(skb) < dpaa2_eth_needed_headroom(priv))) {
+   if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) {
struct sk_buff *ns;
 
ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
@@ -2273,7 +2272,6 @@ static int netdev_init(struct net_device *net_dev)
 {
struct device *dev = net_dev->dev.parent;
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
-   u16 rx_headroom, req_headroom;
u8 bcast_addr[ETH_ALEN];
u8 num_queues;
int err;
@@ -2292,24 +2290,6 @@ static int netdev_init(struct net_device *net_dev)
return err;
}
 
-   /* Reserve enough space to align buffer as per hardware requirement;
-* NOTE: priv->tx_data_offset MUST be initialized at this point.
-*/
-   net_dev->needed_headroom = dpaa2_eth_needed_headroom(priv);
-
-   /* If headroom guaranteed by hardware in the Rx frame buffer is
-* smaller than the Tx headroom required by the stack, issue a
-* one time warning. This will most likely mean skbs forwarded to
-* another DPAA2 network interface will get reallocated, with a
-* significant performance impact.
-*/
-   req_headroom = LL_RESERVED_SPACE(net_dev) - ETH_HLEN;
-   rx_headroom = ALIGN(DPAA2_ETH_RX_HWA_SIZE +
-   dpaa2_eth_rx_head_room(priv), priv->rx_buf_align);
-   if (req_headroom > rx_headroom)
-   dev_info_once(dev, "Required headroom (%d) greater than 
available (%d)\n",
- req_headroom, rx_headroom);
-
/* Set MTU limits */
net_dev->min_mtu = 68;
net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 3a4e939..63b09d1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -371,7 +371,7 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct 
dpaa2_eth_priv *priv)
 static inline
 unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
 {
-   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN - HH_DATA_MOD;
+   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN;
 }
 
 /* Extra headroom space requested to hardware, in order to make sure there's
-- 
2.7.4

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


[PATCH 1/6] staging: fsl-dpaa2/eth: Fix access to FAS field

2017-12-08 Thread Ioana Radulescu
Commit 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX
buffers") removes the software annotation (SWA) area from the RX
buffer layout, as it's not used by anyone, but fails to update the
macros for accessing hardware annotation (HWA) fields, which is
right after the SWA in the buffer headroom.

This may lead to some frame annotation status fields (e.g. indication
if L3/L4 checksum is valid) to be read incorrectly.

Turn the accessor macros into inline functions and add a bool param
to specify if SWA is present or not.

Fixes: 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX buffers")

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |  8 
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 13 +
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 0d8ed00..c8a8e3a 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -249,7 +249,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
vaddr = dpaa2_iova_to_virt(priv->iommu_domain, addr);
dma_unmap_single(dev, addr, DPAA2_ETH_RX_BUF_SIZE, DMA_FROM_DEVICE);
 
-   fas = dpaa2_get_fas(vaddr);
+   fas = dpaa2_get_fas(vaddr, false);
prefetch(fas);
buf_data = vaddr + dpaa2_fd_get_offset(fd);
prefetch(buf_data);
@@ -385,7 +385,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 * on TX confirmation. We are clearing FAS (Frame Annotation Status)
 * field from the hardware annotation area
 */
-   fas = dpaa2_get_fas(sgt_buf);
+   fas = dpaa2_get_fas(sgt_buf, true);
memset(fas, 0, DPAA2_FAS_SIZE);
 
sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset);
@@ -458,7 +458,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
 * on TX confirmation. We are clearing FAS (Frame Annotation Status)
 * field from the hardware annotation area
 */
-   fas = dpaa2_get_fas(buffer_start);
+   fas = dpaa2_get_fas(buffer_start, true);
memset(fas, 0, DPAA2_FAS_SIZE);
 
/* Store a backpointer to the skb at the beginning of the buffer
@@ -510,7 +510,7 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
 
fd_addr = dpaa2_fd_get_addr(fd);
skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr);
-   fas = dpaa2_get_fas(skbh);
+   fas = dpaa2_get_fas(skbh, true);
 
if (fd_format == dpaa2_fd_single) {
skb = *skbh;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 5b3ab9f..3a4e939 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -153,10 +153,15 @@ struct dpaa2_fas {
 #define DPAA2_FAS_SIZE (sizeof(struct dpaa2_fas))
 
 /* Accessors for the hardware annotation fields that we use */
-#define dpaa2_get_hwa(buf_addr) \
-   ((void *)(buf_addr) + DPAA2_ETH_SWA_SIZE)
-#define dpaa2_get_fas(buf_addr) \
-   (struct dpaa2_fas *)(dpaa2_get_hwa(buf_addr) + DPAA2_FAS_OFFSET)
+static inline void *dpaa2_get_hwa(void *buf_addr, bool swa)
+{
+   return buf_addr + (swa ? DPAA2_ETH_SWA_SIZE : 0);
+}
+
+static inline struct dpaa2_fas *dpaa2_get_fas(void *buf_addr, bool swa)
+{
+   return dpaa2_get_hwa(buf_addr, swa) + DPAA2_FAS_OFFSET;
+}
 
 /* Error and status bits in the frame annotation status word */
 /* Debug frame, otherwise supposed to be discarded */
-- 
2.7.4

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


[PATCH 5/6] staging: fsl-dpaa2/eth: Compute needed headroom per frame

2017-12-08 Thread Ioana Radulescu
For non-linear skbs we build scatter-gather frames and allocate
a new buffer for the S/G table in which we reserve the required
headroom, so the actual skb headroom size doesn't matter.

Rather than use a one-size-fits-all approach, decide when to
enforce headroom requirements on a frame by frame basis.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |  9 ++---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 11 ---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 2c12859..8edb7c1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -437,7 +437,8 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
struct sk_buff **skbh;
dma_addr_t addr;
 
-   buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
+   buffer_start = PTR_ALIGN(skb->data -
+dpaa2_eth_needed_headroom(priv, skb),
 DPAA2_ETH_TX_BUF_ALIGN);
 
/* Store a backpointer to the skb at the beginning of the buffer
@@ -532,15 +533,17 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, 
struct net_device *net_dev)
struct dpaa2_eth_drv_stats *percpu_extras;
struct dpaa2_eth_fq *fq;
u16 queue_mapping;
+   unsigned int needed_headroom;
int err, i;
 
percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras);
 
-   if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) {
+   needed_headroom = dpaa2_eth_needed_headroom(priv, skb);
+   if (skb_headroom(skb) < needed_headroom) {
struct sk_buff *ns;
 
-   ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
+   ns = skb_realloc_headroom(skb, needed_headroom);
if (unlikely(!ns)) {
percpu_stats->tx_dropped++;
goto err_alloc_headroom;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 546a862..4ea41d8 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -364,9 +364,13 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct 
dpaa2_eth_priv *priv)
 }
 
 static inline
-unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
+unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv,
+  struct sk_buff *skb)
 {
-   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN;
+   if (skb_is_nonlinear(skb))
+   return 0;
+
+   return DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
 }
 
 /* Extra headroom space requested to hardware, in order to make sure there's
@@ -374,7 +378,8 @@ unsigned int dpaa2_eth_needed_headroom(struct 
dpaa2_eth_priv *priv)
  */
 static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv)
 {
-   return dpaa2_eth_needed_headroom(priv) - DPAA2_ETH_RX_HWA_SIZE;
+   return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN -
+  DPAA2_ETH_RX_HWA_SIZE;
 }
 
 static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv)
-- 
2.7.4

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


[PATCH 6/6] staging: fsl-dpaa2/eth: Make Tx buffer alignment optional

2017-12-08 Thread Ioana Radulescu
Aligning the Tx buffers at 64B is a performance optimization
recommendation, not a hard requirement.

Make optional the alignment of Tx FD buffers, without enforcing
a reallocation in case there is not enough headroom for it.

On Rx, we keep allocating buffers with enough headroom to allow
Tx alignment of forwarded frames.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 14 ++
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 8edb7c1..7f3e4fa 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -433,13 +433,19 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
   struct dpaa2_fd *fd)
 {
struct device *dev = priv->net_dev->dev.parent;
-   u8 *buffer_start;
+   u8 *buffer_start, *aligned_start;
struct sk_buff **skbh;
dma_addr_t addr;
 
-   buffer_start = PTR_ALIGN(skb->data -
-dpaa2_eth_needed_headroom(priv, skb),
-DPAA2_ETH_TX_BUF_ALIGN);
+   buffer_start = skb->data - dpaa2_eth_needed_headroom(priv, skb);
+
+   /* If there's enough room to align the FD address, do it.
+* It will help hardware optimize accesses.
+*/
+   aligned_start = PTR_ALIGN(buffer_start - DPAA2_ETH_TX_BUF_ALIGN,
+ DPAA2_ETH_TX_BUF_ALIGN);
+   if (aligned_start >= skb->head)
+   buffer_start = aligned_start;
 
/* Store a backpointer to the skb at the beginning of the buffer
 * (in the private data area) such that we can release it
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 4ea41d8..d68ac38 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -370,7 +370,7 @@ unsigned int dpaa2_eth_needed_headroom(struct 
dpaa2_eth_priv *priv,
if (skb_is_nonlinear(skb))
return 0;
 
-   return DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
+   return DPAA2_ETH_SWA_SIZE;
 }
 
 /* Extra headroom space requested to hardware, in order to make sure there's
-- 
2.7.4

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


[PATCH 4/6] staging: fsl-dpaa2/eth: Don't enable FAS on Tx

2017-12-08 Thread Ioana Radulescu
For Tx confirmed frames that have an error indication in the frame
descriptor, we look at the Frame Annotation Status field (in the
buffer headroom) for details on the root cause and then print
a debug message with that information.

While useful in initial development stages, it doesn't bring
enough added value to justify reserving 64B of headroom for all
Tx frames (FAS is only 8B long, but we must reserve chunks of 64B
from the hardware annotation area).

If we remove the need for FAS field from egress frames, we can
renounce hardware annotation completely, since FAS is the only
HWA field we currently use.

Signed-off-by: Ioana Radulescu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 73 +-
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |  6 ---
 2 files changed, 13 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 6de6cdd..2c12859 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -348,7 +348,6 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
int num_sg;
int num_dma_bufs;
struct dpaa2_eth_swa *swa;
-   struct dpaa2_fas *fas;
 
/* Create and map scatterlist.
 * We don't advertise NETIF_F_FRAGLIST, so skb_to_sgvec() will not have
@@ -379,15 +378,6 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
goto sgt_buf_alloc_failed;
}
sgt_buf = PTR_ALIGN(sgt_buf, DPAA2_ETH_TX_BUF_ALIGN);
-
-   /* PTA from egress side is passed as is to the confirmation side so
-* we need to clear some fields here in order to find consistent values
-* on TX confirmation. We are clearing FAS (Frame Annotation Status)
-* field from the hardware annotation area
-*/
-   fas = dpaa2_get_fas(sgt_buf, true);
-   memset(fas, 0, DPAA2_FAS_SIZE);
-
sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset);
 
/* Fill in the HW SGT structure.
@@ -424,8 +414,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_format(fd, dpaa2_fd_sg);
dpaa2_fd_set_addr(fd, addr);
dpaa2_fd_set_len(fd, skb->len);
-   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_ASAL | DPAA2_FD_CTRL_PTA |
- DPAA2_FD_CTRL_PTV1);
+   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
 
return 0;
 
@@ -445,21 +434,12 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
 {
struct device *dev = priv->net_dev->dev.parent;
u8 *buffer_start;
-   struct dpaa2_fas *fas;
struct sk_buff **skbh;
dma_addr_t addr;
 
buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
 DPAA2_ETH_TX_BUF_ALIGN);
 
-   /* PTA from egress side is passed as is to the confirmation side so
-* we need to clear some fields here in order to find consistent values
-* on TX confirmation. We are clearing FAS (Frame Annotation Status)
-* field from the hardware annotation area
-*/
-   fas = dpaa2_get_fas(buffer_start, true);
-   memset(fas, 0, DPAA2_FAS_SIZE);
-
/* Store a backpointer to the skb at the beginning of the buffer
 * (in the private data area) such that we can release it
 * on Tx confirm
@@ -477,8 +457,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_offset(fd, (u16)(skb->data - buffer_start));
dpaa2_fd_set_len(fd, skb->len);
dpaa2_fd_set_format(fd, dpaa2_fd_single);
-   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_ASAL | DPAA2_FD_CTRL_PTA |
- DPAA2_FD_CTRL_PTV1);
+   dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
 
return 0;
 }
@@ -493,8 +472,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
  * to be checked if we're on the confirmation path.
  */
 static void free_tx_fd(const struct dpaa2_eth_priv *priv,
-  const struct dpaa2_fd *fd,
-  u32 *status)
+  const struct dpaa2_fd *fd)
 {
struct device *dev = priv->net_dev->dev.parent;
dma_addr_t fd_addr;
@@ -505,11 +483,9 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
int num_sg, num_dma_bufs;
struct dpaa2_eth_swa *swa;
u8 fd_format = dpaa2_fd_get_format(fd);
-   struct dpaa2_fas *fas;
 
fd_addr = dpaa2_fd_get_addr(fd);
skbh = dpaa2_iova_to_virt(priv->iommu_domain, fd_addr);
-   fas = dpaa2_get_fas(skbh, true);
 
if (fd_format == dpaa2_fd_single) {
skb = *skbh;
@@ -536,19 +512,10 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
   sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs);
dma_unmap_single(dev, fd_addr, unmap_size, DMA_BIDIRECTIONAL);
} else {
-

Re: [PATCHv2] tools: hv: hv_set_ifconfig.sh double check before setting ip

2017-12-08 Thread Eduardo Otubo
On Fri, Dec 08, 2017 at 12:33:38PM +0100, Olaf Hering wrote:
> On Fri, Dec 08, Eduardo Otubo wrote:
> 
> >  tools/hv/hv_set_ifconfig.sh | 45 
> > +++--
> >  1 file changed, 43 insertions(+), 2 deletions(-)
> 
> > +# let's wait for 3 minutes
> 
> Was this codepath runtime tested?
> 
> Last time this came up, the conclusion was that Windows terminates the
> "KVP connection" after 60 seconds. After that, the VM must be rebooted
> because the kernel does not deal with the long-running script. It is
> also not clear what the kernel is supposed to do: either silently report
> success and hope the scripts reports success one day, or report error
> independent from what the script actually returns. New KVP requests
> would need to be queued either way.
> 
Now that you mentioned, I guess my tests never touched this part. But I guess
we're going to fix this downstream-only setting a rule on systemd to start
hypervkvpd only after NetworkManager started. Please drop the reviews on this.

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


[PATCH 1/2] staging: pi433: Fix missing 'undefined' value in enum modulation

2017-12-08 Thread Marcin Ciupak
It is possible that rf69_get_modulation() function will return
'undefined' value and this value is missing in enum modulation. Fix this
by adding appropriate entry in enum modulation.

Signed-off-by: Marcin Ciupak 
---
 drivers/staging/pi433/rf69.c  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 7140fa2ea592..3b73a3a02879 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -118,7 +118,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO 
improvement: change 3 to define
case DATAMODUL_MODULATION_TYPE_OOK: return OOK;
case DATAMODUL_MODULATION_TYPE_FSK: return FSK;
-   default:return undefined;
+   default:return UNDEF;
}
 }
 
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 4e64e38ae4ff..ec91f329d871 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -28,7 +28,8 @@ enum mode {
 
 enum modulation {
OOK,
-   FSK
+   FSK,
+   UNDEF
 };
 
 enum mod_shaping {
-- 
2.15.0

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


[PATCH 0/2] Fix usage and validation of undefined value in enum modulation

2017-12-08 Thread Marcin Ciupak
This patches fixes usage and validation of undefined enum modulation
value.

First one adds missing enum which is returned from rf69_get_modulation
function, second one fixes validation issue in
rf69_set_modulation_shaping function.

The issue is that return value is checked against FSK enum value only
and all other values are in else branch what leads to possibility of
setting modulation shaping for undefined modulation.

Marcin Ciupak (2):
  staging: pi433: Fix missing 'undefined' value in enum modulation
  staging: pi433: Fix validation of rf69_get_modulation value

 drivers/staging/pi433/rf69.c  | 10 +++---
 drivers/staging/pi433/rf69_enum.h |  3 ++-
 2 files changed, 9 insertions(+), 4 deletions(-)

-- 
2.15.0

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


[PATCH 2/2] staging: pi433: Fix validation of rf69_get_modulation value

2017-12-08 Thread Marcin Ciupak
Checking of modulation in rf69_set_modulation_shaping is done by
if-else and since else part covers OOK and UNDEF values it possible to
set modulation shaping for undefined modulation type.
To fix this validation should be done by switch clause and in case of
undefined modulation error returned.

Signed-off-by: Marcin Ciupak 
---
 drivers/staging/pi433/rf69.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 3b73a3a02879..a66db795d7df 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -129,7 +129,8 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
dev_dbg(&spi->dev, "set: mod shaping");
#endif
 
-   if (rf69_get_modulation(spi) == FSK) {
+   switch (rf69_get_modulation(spi)) {
+   case FSK:
switch (mod_shaping) {
case SHAPING_OFF: return rf69_read_mod_write(spi, 
REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, 
DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_1_0: return rf69_read_mod_write(spi, 
REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_1_0);
@@ -139,7 +140,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
}
-   } else {
+   case OOK:
switch (mod_shaping) {
case SHAPING_OFF: return rf69_read_mod_write(spi, 
REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, 
DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_BR:  return rf69_read_mod_write(spi, 
REG_DATAMODUL, MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_BR);
@@ -148,6 +149,9 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
dev_dbg(&spi->dev, "set: illegal input param");
return -EINVAL;
}
+   default:
+   dev_dbg(&spi->dev, "set: modulation undefined");
+   return -EINVAL;
}
 }
 
-- 
2.15.0

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


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

2017-12-08 Thread Greg KH
On Thu, Dec 07, 2017 at 12:11:07PM -0500, David Kershner wrote:
> Move the visorbus driver out of staging (drivers/staging/unisys/visorbus)
> and to drivers/visorbus. Modify the configuration and makefiles so they
> now reference the new location. The s-Par header file visorbus.h that is
> referenced by all s-Par drivers, is being moved into include/linux.
> 
> Signed-off-by: David Kershner 
> Reviewed-by: Tim Sell 

Nice work, now applied to my testing tree!

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


Re: [PATCH net 1/3] hv_netvsc: Correct the max receive buffer size

2017-12-08 Thread David Miller
From: Dan Carpenter 
Date: Fri, 8 Dec 2017 13:33:25 +0300

> On Thu, Dec 07, 2017 at 04:10:53PM -0800, Stephen Hemminger wrote:
>> From: Haiyang Zhang 
>> 
>> It should be 31 MB on recent host versions.
>> 
>> Signed-off-by: Haiyang Zhang 
>> Signed-off-by: Stephen Hemminger 
> 
> This is very vague.  What does "recent" mean in this context?  There are
> also some unrelated white space changes here which make the patch harder
> to read.
> 
> This patch kind of makes the bug fixed by patch 2 even worse because
> before the receive buffer was capped at around 16MB and now we can set
> the receive buffer to 31MB.  It might make sense to fold the two
> patches together.
> 
> Is patch 2 a memory corruption bug?  The changelog doesn't really say
> what the user visible effects of the bug are.  Basically if you make the
> buffer too small then it's a performance issue but if you make it too
> large what happens?  It's not clear to me.

Agreed with Dan, we definitely need more verbose and detailed commit
log messages for this series.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH net 1/3] hv_netvsc: Correct the max receive buffer size

2017-12-08 Thread Haiyang Zhang


> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Friday, December 8, 2017 5:33 AM
> To: Stephen Hemminger 
> Cc: KY Srinivasan ; Haiyang Zhang
> ; Stephen Hemminger
> ; de...@linuxdriverproject.org;
> net...@vger.kernel.org
> Subject: Re: [PATCH net 1/3] hv_netvsc: Correct the max receive buffer size
> 
> On Thu, Dec 07, 2017 at 04:10:53PM -0800, Stephen Hemminger wrote:
> > From: Haiyang Zhang 
> >
> > It should be 31 MB on recent host versions.
> >
> > Signed-off-by: Haiyang Zhang 
> > Signed-off-by: Stephen Hemminger 
> 
> This is very vague.  What does "recent" mean in this context?  There are also
> some unrelated white space changes here which make the patch harder to
> read.
> 
> This patch kind of makes the bug fixed by patch 2 even worse because
> before the receive buffer was capped at around 16MB and now we can set
> the receive buffer to 31MB.  It might make sense to fold the two patches
> together.
> 
> Is patch 2 a memory corruption bug?  The changelog doesn't really say what
> the user visible effects of the bug are.  Basically if you make the buffer too
> small then it's a performance issue but if you make it too large what happens?
> It's not clear to me.

For NVSP v2, and earlier host, the limit is 15MB. Later hosts, the limit is 
31MB.
Setting beyond it will be denied by the host, resulting the vNIC doesn't come 
up.

I will merge this one together with the patch 2.

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


RE: [PATCH net 3/3] hv_netvsc: Fix the default receive buffer size

2017-12-08 Thread Haiyang Zhang


> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Friday, December 8, 2017 5:45 AM
> To: Stephen Hemminger 
> Cc: KY Srinivasan ; Haiyang Zhang
> ; Stephen Hemminger
> ; de...@linuxdriverproject.org;
> net...@vger.kernel.org
> Subject: Re: [PATCH net 3/3] hv_netvsc: Fix the default receive buffer size
> 
> On Thu, Dec 07, 2017 at 04:10:55PM -0800, Stephen Hemminger wrote:
> > From: Haiyang Zhang 
> >
> > The intended size is 16 MB, and the default slot size is 1728.
> > So, NETVSC_DEFAULT_RX should be 16*1024*1024 / 1728 = 9709.
> >
> > Fixes: 5023a6db73196 ("netvsc: increase default receive buffer size")
> > Signed-off-by: Haiyang Zhang 
> > Signed-off-by: Stephen Hemminger 
> > ---
> >  drivers/net/hyperv/netvsc_drv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/hyperv/netvsc_drv.c
> > b/drivers/net/hyperv/netvsc_drv.c index dc70de674ca9..edfcde5d3621
> > 100644
> > --- a/drivers/net/hyperv/netvsc_drv.c
> > +++ b/drivers/net/hyperv/netvsc_drv.c
> > @@ -50,7 +50,7 @@
> >  #define NETVSC_MIN_TX_SECTIONS 10
> >  #define NETVSC_DEFAULT_TX  192 /* ~1M */
> >  #define NETVSC_MIN_RX_SECTIONS 10  /* ~64K */
> > -#define NETVSC_DEFAULT_RX  10485   /* Max ~16M */
> > +#define NETVSC_DEFAULT_RX  9709/* ~16M */
> 
> How does this bug look like to the user?  Memory corruption?
> 
> It's weird to me reviewing this code that the default sizes are stored in
> netvsc_drv.c and the max sizes are stored in hyperv_net.h.
> Could we move these to hyperv_net.h?  We could write it like:
> #define NETVSC_DEFAULT_RX ((16 * 1024 * 1024) /
> NETVSC_RECV_SECTION_SIZE)
> 
> 16MB is sort of a weird default because it's larger than the 15MB allowed for
> legacy versions, but it's smaller than the 32MB you'd want for the current
> versions.

As a tradeoff between traffic burst and latency, we set the default to be 16MB.
And this default is reduced automatically for legacy hosts based on the NVSP
version in patch 2. 

I will move the change to hyperv_net.h

Thanks,
- Haiyang

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


[PATCH 10/10] staging: pi433: space prohibited in IS_ERR

2017-12-08 Thread Oliver Graute
This patch fixes this codestyle issue:

ERROR: space prohibited after that open parenthesis '('
+   if ( IS_ERR(device->gpiod[i]) )

ERROR: space prohibited before that close parenthesis ')'
+   if ( IS_ERR(device->gpiod[i]) )

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index c85a0fa..88e8c74 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -998,7 +998,7 @@ static void free_GPIOs(struct pi433_device *device)
 
for (i = 0; i < NUM_DIO; i++) {
/* check if gpiod is valid */
-   if ( IS_ERR(device->gpiod[i]) )
+   if (IS_ERR(device->gpiod[i]))
continue;
 
free_irq(device->irq_num[i], device);
-- 
1.9.1

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


[PATCH 05/10] staging: pi433: codestyle brace should be on previous line

2017-12-08 Thread Oliver Graute
This patch fixed codestyle issues of kind:

ERROR: that open brace { should be on the previous line
 +   if (device->rx_active) +   {

ERROR: that open brace { should be on the previous line
+   else
+   {

ERROR: else should follow close brace '}'
+   }
+   else

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 70d2c39..3e79ebf 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -712,13 +712,10 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
 
/* just one read request at a time */
mutex_lock(&device->rx_lock);
-   if (device->rx_active)
-   {
+   if (device->rx_active) {
mutex_unlock(&device->rx_lock);
return -EAGAIN;
-   }
-   else
-   {
+   } else {
device->rx_active = true;
mutex_unlock(&device->rx_lock);
}
-- 
1.9.1

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


[PATCH 04/10] staging: pi433: pi433_if.c codestyle brace on previous line

2017-12-08 Thread Oliver Graute
ERROR: that open brace { should be on the previous line
 +   if (rx_interrupted) +   {

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 51da5b3..70d2c39 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -683,8 +683,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
/* everything sent? */
if (kfifo_is_empty(&device->tx_fifo)) {
 abort:
-   if (rx_interrupted)
-   {
+   if (rx_interrupted) {
rx_interrupted = false;
pi433_start_rx(device);
}
-- 
1.9.1

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


[PATCH 03/10] staging: pi433: space prohibted before that close parentesis

2017-12-08 Thread Oliver Graute
ERROR: space prohibited before that close parenthesis
 ')' +kthread_should_stop() );

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 58b69b4..51da5b3 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -672,7 +672,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
dev_dbg(device->dev, "thread: wait for packet to get sent/fifo 
to be empty");
wait_event_interruptible(device->fifo_wait_queue,
 device->free_in_fifo == FIFO_SIZE ||
-kthread_should_stop() );
+kthread_should_stop());
if ( kthread_should_stop() )printk("ABORT\n");
 
 
-- 
1.9.1

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


[PATCH 06/10] staging: pi433: space prohibited

2017-12-08 Thread Oliver Graute
This patch fixes this codestyle issues:

ERROR: space prohibited after that open parenthesis '('
+   if ( retval != sizeof(instance->tx_cfg) )

ERROR: space prohibited before that close parenthesis ')'
+   if ( retval != sizeof(instance->tx_cfg) )

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 3e79ebf..ae49212 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -768,7 +768,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
goto abort;
 
retval = kfifo_in (&device->tx_fifo, &count, sizeof(size_t));
-   if ( retval != sizeof(size_t) )
+   if (retval != sizeof(size_t))
goto abort;
 
retval = kfifo_from_user(&device->tx_fifo, buf, count, &copied);
-- 
1.9.1

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


[PATCH 01/10] staging: pi433: codestyle space required

2017-12-08 Thread Oliver Graute
ERROR: spaces required around that '+=' (ctx:WxV) +
   position +=temp;
   ^

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 55ed45f..726b710 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -651,7 +651,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
rf69_write_fifo(spi,
&buffer[position],
temp);
-   position +=temp;
+   position += temp;
}
else
{   /* msg fits into fifo - take all */
-- 
1.9.1

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


[PATCH 02/10] staging: pi433: space prohibited before closing parenthesis

2017-12-08 Thread Oliver Graute
ERROR: space prohibited before that close parenthesis
 ')' + (size - position) );

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 726b710..58b69b4 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -659,7 +659,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
repetitions--;
rf69_write_fifo(spi,
&buffer[position],
-   (size - position) );
+   (size - position));
position = 0; /* reset for next repetition */
}
 
-- 
1.9.1

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


[PATCH 08/10] staging: pi433: forbidden space and open brace

2017-12-08 Thread Oliver Graute
This patch fixes this codestyle issues:
 
ERROR: that open brace { should be on the previous line
+   if ( IS_ERR(device->gpiod[i]) ) +   {

ERROR: space prohibited after that open parenthesis '('
+   if ( IS_ERR(device->gpiod[i]) )

ERROR: space prohibited before that close parenthesis ')'
+   if ( IS_ERR(device->gpiod[i]) )

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 70f320c..1b9aef0 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -954,8 +954,7 @@ static int setup_GPIOs(struct pi433_device *device)
if (device->gpiod[i] == ERR_PTR(-EBUSY))
dev_dbg(&device->spi->dev, "%s is busy.", name);
 
-   if ( IS_ERR(device->gpiod[i]) )
-   {
+   if (IS_ERR(device->gpiod[i])) {
retval = PTR_ERR(device->gpiod[i]);
/* release already allocated gpios */
for (i--; i >= 0; i--) {
-- 
1.9.1

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


[PATCH 07/10] staging: pi433: pi433_if.c space required in for loop

2017-12-08 Thread Oliver Graute
This patch fixes this codesstyle issues:

ERROR: that open brace { should be on the previous line
+   for (i=0; i
---
 drivers/staging/pi433/pi433_if.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index ae49212..70f320c 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -941,8 +941,7 @@ static int setup_GPIOs(struct pi433_device *device)
DIO1_irq_handler
};
 
-   for (i=0; igpiod[i] = gpiod_get(&device->spi->dev, name, 0 
/*GPIOD_IN*/);
-- 
1.9.1

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


[PATCH 09/10] staging: pi433: open brace on previous line

2017-12-08 Thread Oliver Graute
This patch fixes this codestyle issue:

ERROR: that open brace { should be on the previous line
+   for (i = 0; i < NUM_DIO; i++) +   {

Signed-off-by: Oliver Graute 
---
 drivers/staging/pi433/pi433_if.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 1b9aef0..c85a0fa 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -996,8 +996,7 @@ static void free_GPIOs(struct pi433_device *device)
 {
int i;
 
-   for (i = 0; i < NUM_DIO; i++)
-   {
+   for (i = 0; i < NUM_DIO; i++) {
/* check if gpiod is valid */
if ( IS_ERR(device->gpiod[i]) )
continue;
-- 
1.9.1

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


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

2017-12-08 Thread Joe Perches
On Fri, 2017-12-08 at 16:39 +0100, Greg KH wrote:
> On Thu, Dec 07, 2017 at 12:11:07PM -0500, David Kershner wrote:
> > Move the visorbus driver out of staging (drivers/staging/unisys/visorbus)
> > and to drivers/visorbus. Modify the configuration and makefiles so they
> > now reference the new location. The s-Par header file visorbus.h that is
> > referenced by all s-Par drivers, is being moved into include/linux.

Perhaps moving visorbus.h and visorbus_private.h to
drivers/visorbus would be better than adding more
relatively localized #include files to include/linux/

what about controlvmchannel?


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


Re: [PATCH 6/6] x86/kvm: support Hyper-V reenlightenment

2017-12-08 Thread Roman Kagan
On Fri, Dec 08, 2017 at 11:50:00AM +0100, Vitaly Kuznetsov wrote:
> When we run nested KVM on Hyper-V guests we need to update masterclocks for
> all guests when L1 migrates to a host with different TSC frequency.
> Implement the procedure in the following way:
> - Pause all guests.
> - Tell our host (Hyper-V) to stop emulating TSC accesses.
> - Update our gtod copy, recompute clocks.
> - Unpause all guests.
> 
> This is somewhat similar to cpufreq but we have two important differences:
> we can only disable TSC emulation globally (on all CPUs) and we don't know
> the new TSC frequency until we turn the emulation off so we can't
> 'prepare' ourselves to the event.
> 
> Signed-off-by: Vitaly Kuznetsov 
> ---
>  arch/x86/kvm/x86.c | 45 +
>  1 file changed, 45 insertions(+)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 96e04a0cb921..04d90712ffd2 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -68,6 +68,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #define CREATE_TRACE_POINTS
>  #include "trace.h"
> @@ -5946,6 +5947,43 @@ static void tsc_khz_changed(void *data)
>   __this_cpu_write(cpu_tsc_khz, khz);
>  }
>  
> +void kvm_hyperv_tsc_notifier(void)
> +{
> +#ifdef CONFIG_X86_64
> + struct kvm *kvm;
> + struct kvm_vcpu *vcpu;
> + int cpu;
> +
> + spin_lock(&kvm_lock);
> + list_for_each_entry(kvm, &vm_list, vm_list)
> + kvm_make_mclock_inprogress_request(kvm);
> +
> + hyperv_stop_tsc_emulation();
> +
> + /* TSC frequency always matches when on Hyper-V */
> + for_each_present_cpu(cpu)
> + per_cpu(cpu_tsc_khz, cpu) = tsc_khz;
> + kvm_max_guest_tsc_khz = tsc_khz;
> +
> + list_for_each_entry(kvm, &vm_list, vm_list) {
> + struct kvm_arch *ka = &kvm->arch;
> +
> + spin_lock(&ka->pvclock_gtod_sync_lock);
> +
> + pvclock_update_vm_gtod_copy(kvm);
> +
> + kvm_for_each_vcpu(cpu, vcpu, kvm)
> + kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
> +
> + kvm_for_each_vcpu(cpu, vcpu, kvm)
> + kvm_clear_request(KVM_REQ_MCLOCK_INPROGRESS, vcpu);
> +
> + spin_unlock(&ka->pvclock_gtod_sync_lock);
> + }
> + spin_unlock(&kvm_lock);

Can't you skip all this if the tsc frequency hasn't changed (which
should probably be the case when the CPU supports tsc frequency
scaling)?

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


Re: [PATCH 3/6] x86/hyper-v: reenlightenment notifications support

2017-12-08 Thread Roman Kagan
On Fri, Dec 08, 2017 at 11:49:57AM +0100, Vitaly Kuznetsov wrote:
> Hyper-V supports Live Migration notification. This is supposed to be used
> in conjunction with TSC emulation: when we are migrated to a host with
> different TSC frequency for some short period host emulates our accesses
> to TSC and sends us an interrupt to notify about the event. When we're
> done updating everything we can disable TSC emulation and everything will
> start working fast again.
> 
> We didn't need these notifications before as Hyper-V guests are not
> supposed to use TSC as a clocksource: in Linux we even mark it as unstable
> on boot. Guests normally use 'tsc page' clocksouce and host updates its
> values on migrations automatically.
> 
> Things change when we want to run nested virtualization: even when we pass
> through PV clocksources (kvm-clock or tsc page) to our guests we need to
> know TSC frequency and when it changes.
> 
> Hyper-V Top Level Functional Specification (as of v5.0b) wrongly specifies
> EAX:BIT(12) of CPUID:0x4009 as the feature identification bit. The
> right one to check is EAX:BIT(13) of CPUID:0x4003. I was assured that
> the fix in on the way.
> 
> Signed-off-by: Vitaly Kuznetsov 
> ---
> RFC -> v1:
> - #include  [kbuild test robot]
> - use div64_u64() [kbuild test robot]
> - DECLARE_WORK -> DECLARE_DELAYED_WORK as testing showed there's some bug
>   in Hyper-V hypervisor and disabling emulation after receiving interrupt
>   may screw TSC counters.

Looks kinda fragile...

> ---
>  arch/x86/entry/entry_64.S  |  4 +++
>  arch/x86/hyperv/hv_init.c  | 71 
> ++
>  arch/x86/include/asm/entry_arch.h  |  4 +++
>  arch/x86/include/asm/hw_irq.h  |  1 +
>  arch/x86/include/asm/irq_vectors.h |  7 +++-
>  arch/x86/include/asm/mshyperv.h|  8 +
>  arch/x86/include/uapi/asm/hyperv.h | 27 +++
>  arch/x86/kernel/idt.c  |  3 ++
>  8 files changed, 124 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index f81d50d7ceac..a32730b260bc 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -826,6 +826,10 @@ apicinterrupt SPURIOUS_APIC_VECTOR   
> spurious_interrupt  smp_spurious_interrupt
>  apicinterrupt IRQ_WORK_VECTORirq_work_interrupt  
> smp_irq_work_interrupt
>  #endif
>  
> +#if IS_ENABLED(CONFIG_HYPERV)
> +apicinterrupt HYPERV_REENLIGHTENMENT_VECTOR  hyperv_reenlightenment_intr 
> smp_hyperv_reenlightenment_intr
> +#endif
> +
>  /*
>   * Exception entry points.
>   */
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index 1a6c63f721bc..bb62839ede81 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -102,6 +103,76 @@ static int hv_cpu_init(unsigned int cpu)
>   return 0;
>  }
>  
> +static void (*hv_reenlightenment_cb)(void);
> +
> +static void hv_reenlightenment_notify(struct work_struct *dummy)
> +{
> + if (hv_reenlightenment_cb)
> + hv_reenlightenment_cb();
> +}
> +static DECLARE_DELAYED_WORK(hv_reenlightenment_work, 
> hv_reenlightenment_notify);
> +
> +void hyperv_stop_tsc_emulation(void)
> +{
> + u64 freq;
> + struct hv_tsc_emulation_status emu_status;
> +
> + rdmsrl(HV_X64_MSR_TSC_EMULATION_STATUS, *(u64 *)&emu_status);
> + emu_status.inprogress = 0;
> + wrmsrl(HV_X64_MSR_TSC_EMULATION_STATUS, *(u64 *)&emu_status);
> +
> + rdmsrl(HV_X64_MSR_TSC_FREQUENCY, freq);

IIRC the availability of this msr is not guaranteed (I guess in reality
it's present if the reenlightenment is supported, but I'd rather check).

> + tsc_khz = div64_u64(freq, 1000);
> +}
> +EXPORT_SYMBOL_GPL(hyperv_stop_tsc_emulation);
> +
> +void register_hv_tsc_update(void (*cb)(void))
> +{

The function name seems unfortunate.  IMHO such a name suggests
registering a callback on a notifier chain (rather than unconditionally
replacing the old callback), and having no other side effects.

> + struct hv_reenlightenment_control re_ctrl = {
> + .vector = HYPERV_REENLIGHTENMENT_VECTOR,
> + .enabled = 1,
> + .target_vp = hv_vp_index[smp_processor_id()]
> + };
> + struct hv_tsc_emulation_control emu_ctrl = {.enabled = 1};
> +
> + if (!(ms_hyperv.features & HV_X64_ACCESS_REENLIGHTENMENT))
> + return;

What happens then?  L2 guests keep running with their clocks ticking at
a different speed?

> +
> + hv_reenlightenment_cb = cb;
> +
> + /* Make sure callback is registered before we write to MSRs */
> + wmb();
> +
> + wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
> + wrmsrl(HV_X64_MSR_TSC_EMULATION_CONTROL, *((u64 *)&emu_ctrl));
> +}
> +EXPORT_SYMBOL_GPL(register_hv_tsc_update);
> +
> +void unregister_hv_tsc_update(void)
> +{
>

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

2017-12-08 Thread Dan Carpenter
On Fri, Dec 08, 2017 at 04:39:13PM +0100, Greg KH wrote:
> On Thu, Dec 07, 2017 at 12:11:07PM -0500, David Kershner wrote:
> > Move the visorbus driver out of staging (drivers/staging/unisys/visorbus)
> > and to drivers/visorbus. Modify the configuration and makefiles so they
> > now reference the new location. The s-Par header file visorbus.h that is
> > referenced by all s-Par drivers, is being moved into include/linux.
> > 
> > Signed-off-by: David Kershner 
> > Reviewed-by: Tim Sell 
> 
> Nice work, now applied to my testing tree!

Congrats.  :)

regards,
dan carpenter

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


[PATCH] Staging: comedi: drivers: serial2002 fixed a blank line coding style

2017-12-08 Thread Vikash Kesarwani
Fixed a blank line coding style after a declaration

Signed-off-by: Vikash Kesarwani 
---
 drivers/staging/comedi/drivers/serial2002.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/comedi/drivers/serial2002.c 
b/drivers/staging/comedi/drivers/serial2002.c
index cc18e25103ca..c9d478fddead 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -107,6 +107,7 @@ static long serial2002_tty_ioctl(struct file *f, unsigned 
int op,
 static int serial2002_tty_write(struct file *f, unsigned char *buf, int count)
 {
loff_t pos = 0;
+
return kernel_write(f, buf, count, &pos);
 }
 
-- 
2.15.1

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


RE: [PATCHv2] tools: hv: hv_set_ifconfig.sh double check before setting ip

2017-12-08 Thread KY Srinivasan


> -Original Message-
> From: Olaf Hering [mailto:o...@aepfle.de]
> Sent: Friday, December 8, 2017 3:34 AM
> To: Eduardo Otubo 
> Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org; Stephen
> Hemminger ; Haiyang Zhang
> ; KY Srinivasan ;
> vkuzn...@redhat.com; mga...@redhat.com; cav...@redhat.com
> Subject: Re: [PATCHv2] tools: hv: hv_set_ifconfig.sh double check before
> setting ip
> 
> On Fri, Dec 08, Eduardo Otubo wrote:
> 
> >  tools/hv/hv_set_ifconfig.sh | 45
> +++--
> >  1 file changed, 43 insertions(+), 2 deletions(-)
> 
> > +# let's wait for 3 minutes
> 
> Was this codepath runtime tested?
> 
> Last time this came up, the conclusion was that Windows terminates the
> "KVP connection" after 60 seconds. After that, the VM must be rebooted
> because the kernel does not deal with the long-running script. It is
> also not clear what the kernel is supposed to do: either silently report
> success and hope the scripts reports success one day, or report error
> independent from what the script actually returns. New KVP requests
> would need to be queued either way.

Agreed; 180 seconds is more than what the host is willing to wait.

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


[PATCH] Staging: ks7010: ks_wlan_net: Fixing coding style warning

2017-12-08 Thread SUNIL KALLUR RAMEGOWDA
Removing the extra spaces before tabs, checkpatch:
WARNING: please, no space before tabs

Signed-off-by: SUNIL KALLUR RAMEGOWDA 
---
 drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 880085e..d3e6e6d 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2990,7 +2990,7 @@ int ks_wlan_net_stop(struct net_device *dev)
 /**
  * is_connect_status() - return true if status is 'connected'
  * @status: high bit is used as FORCE_DISCONNECT, low bits used for
- * connect status.
+ * connect status.
  */
 bool is_connect_status(u32 status)
 {
@@ -3000,7 +3000,7 @@ bool is_connect_status(u32 status)
 /**
  * is_disconnect_status() - return true if status is 'disconnected'
  * @status: high bit is used as FORCE_DISCONNECT, low bits used for
- * disconnect status.
+ * disconnect status.
  */
 bool is_disconnect_status(u32 status)
 {
-- 
2.7.4

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


Re: [PATCH v2] Staging: pi433: fix brace coding style issues in pi433_if.c

2017-12-08 Thread Tomas Marek
On 12/06/2017 07:01 AM, Greg KH wrote:

> On Mon, Dec 04, 2017 at 09:40:10PM +0100, Tomas Marek wrote:
>> This patch fix several brace on next line, braces not necessary, space
>> around =/<, and space before/after open/close parenthesis coding style
>> errors find by checkpatch in pi433_if.c.
>>
>> In addition, the interrupt routine DIO0_irq_handler logic is updated:
>> - use 'switch' statement instead of 'if/else if' combination for the
>>   sake of readability, and
>> - use dev_dbg_ratelimited instead of dev_dbg to avoid message flooding.
> When you have to add "in addition" to a changelog comment, that's a huge
> flag that the patch needs to be broken up into a patch series.  Please
> do that here, only doing one "logical" thing at a time.  As it is, it's
> hard to review this way.
>
> thanks,
>
> greg k-h
OK, I see, no problem.

Thanks

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


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

2017-12-08 Thread Kershner, David A
> -Original Message-
> From: Joe Perches [mailto:j...@perches.com]
> Sent: Friday, December 8, 2017 11:53 AM
> To: Greg KH ; Kershner, David A
> 
> Cc: jes.soren...@gmail.com; linux-ker...@vger.kernel.org; driverdev-
> de...@linuxdriverproject.org; *S-Par-Maintainer
> ; erik.arfvid...@gmail.com;
> wadgaonkar...@gmail.com
> Subject: Re: [PATCH v2] drivers: visorbus: move driver out of staging
> 
> On Fri, 2017-12-08 at 16:39 +0100, Greg KH wrote:
> > On Thu, Dec 07, 2017 at 12:11:07PM -0500, David Kershner wrote:
> > > Move the visorbus driver out of staging
(drivers/staging/unisys/visorbus)
> > > and to drivers/visorbus. Modify the configuration and makefiles so
they
> > > now reference the new location. The s-Par header file visorbus.h that
is
> > > referenced by all s-Par drivers, is being moved into include/linux.
> 
> Perhaps moving visorbus.h and visorbus_private.h to
> drivers/visorbus would be better than adding more
> relatively localized #include files to include/linux/
> 
> what about controlvmchannel?
> 

The file visorbus.h is currently included by 4 drivers: visorbus and 3
other drivers that are staying in staging for now, but we plan to move out
soon.

The files visorbus_private.h and controlvmchannel.h are only used by the
visorbus driver and belong solely in the visorbus directory, no one should
be including them besides the visorbus driver. 

David Kershner


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


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

2017-12-08 Thread Kershner, David A
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Friday, December 8, 2017 1:32 PM
> To: Greg KH 
> Cc: Kershner, David A ;
> wadgaonkar...@gmail.com; driverdev-devel@linuxdriverproject.org;
> jes.soren...@gmail.com; *S-Par-Maintainer
> ; linux-ker...@vger.kernel.org;
> erik.arfvid...@gmail.com
> Subject: Re: [PATCH v2] drivers: visorbus: move driver out of staging
> 
> On Fri, Dec 08, 2017 at 04:39:13PM +0100, Greg KH wrote:
> > On Thu, Dec 07, 2017 at 12:11:07PM -0500, David Kershner wrote:
> > > Move the visorbus driver out of staging
(drivers/staging/unisys/visorbus)
> > > and to drivers/visorbus. Modify the configuration and makefiles so
they
> > > now reference the new location. The s-Par header file visorbus.h that
is
> > > referenced by all s-Par drivers, is being moved into include/linux.
> > >
> > > Signed-off-by: David Kershner 
> > > Reviewed-by: Tim Sell 
> >
> > Nice work, now applied to my testing tree!
> 
> Congrats.  :)
> 

Thanks, and thanks for all the help getting to this point! 

David Kershner

> regards,
> dan carpenter



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


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

2017-12-08 Thread Joe Perches
On Fri, 2017-12-08 at 21:55 +, Kershner, David A wrote:
> > -Original Message-
> > From: Joe Perches [mailto:j...@perches.com]
> > Sent: Friday, December 8, 2017 11:53 AM
> > To: Greg KH ; Kershner, David A
> > 
> > Cc: jes.soren...@gmail.com; linux-ker...@vger.kernel.org; driverdev-
> > de...@linuxdriverproject.org; *S-Par-Maintainer
> > ; erik.arfvid...@gmail.com;
> > wadgaonkar...@gmail.com
> > Subject: Re: [PATCH v2] drivers: visorbus: move driver out of staging
> > 
> > On Fri, 2017-12-08 at 16:39 +0100, Greg KH wrote:
> > > On Thu, Dec 07, 2017 at 12:11:07PM -0500, David Kershner wrote:
> > > > Move the visorbus driver out of staging
> 
> (drivers/staging/unisys/visorbus)
> > > > and to drivers/visorbus. Modify the configuration and makefiles so
> 
> they
> > > > now reference the new location. The s-Par header file visorbus.h that
> 
> is
> > > > referenced by all s-Par drivers, is being moved into include/linux.
> > 
> > Perhaps moving visorbus.h and visorbus_private.h to
> > drivers/visorbus would be better than adding more
> > relatively localized #include files to include/linux/
> > 
> > what about controlvmchannel?
> > 
> 
> The file visorbus.h is currently included by 4 drivers: visorbus and 3
> other drivers that are staying in staging for now, but we plan to move out
> soon.

OK.

Where do you plan on moving the 3 other drivers?

Today, these drivers (visorhba, visorinput, and visornic)
are all under the staging/unisys directory

visorbus -> drivers/visorbus
visorhba -> ?
visorinput ->   ?
visornic -> ?

Perhaps all these, including visorbus, should be under virt/
or perhaps visorbus should be under virt/ and the others
under drivers/virt/

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