ww...@some.site

2017-12-18 Thread 铄石流金
说是道非___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc

2017-12-18 Thread Jia-Ju Bai
The kzalloc function is called with GFP_ATOMIC.
But according to driver call graph, it is not in atomic context,
namely no spinlock is held nor in an interrupt handler.

This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.

Signed-off-by: Jia-Ju Bai 
---
 drivers/hv/hv.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 8267439..b0d025a 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -150,7 +150,7 @@ int hv_synic_alloc(void)
int cpu;
 
hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-GFP_ATOMIC);
+GFP_KERNEL);
if (hv_context.hv_numa_map == NULL) {
pr_err("Unable to allocate NUMA map\n");
goto err;
-- 
1.7.9.5

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


Re: [PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc

2017-12-18 Thread Vitaly Kuznetsov
Jia-Ju Bai  writes:

> The kzalloc function is called with GFP_ATOMIC.
> But according to driver call graph, it is not in atomic context,
> namely no spinlock is held nor in an interrupt handler.
>
> This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.
>
> Signed-off-by: Jia-Ju Bai 
> ---
>  drivers/hv/hv.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 8267439..b0d025a 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -150,7 +150,7 @@ int hv_synic_alloc(void)
>   int cpu;
>
>   hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
> -  GFP_ATOMIC);
> +  GFP_KERNEL);
>   if (hv_context.hv_numa_map == NULL) {
>   pr_err("Unable to allocate NUMA map\n");
>   goto err;

Reviewed-by: Vitaly Kuznetsov 

The subject line is not very accurate: GFP_KERNEL you switch too is the
one supporting 'sleep' when there's not enough memory, not
GFP_ATOMIC so you don't actually "Fix unnecessary sleeping". I'd suggest
you use something like "hyper-v: use GFP_KERNEL for hv_context.hv_numa_map"

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


Re: [PATCH] hv: Fix unnecessary sleeping in hv_synic_alloc

2017-12-18 Thread Jia-Ju Bai



On 2017/12/18 16:54, Vitaly Kuznetsov wrote:

Jia-Ju Bai  writes:


The kzalloc function is called with GFP_ATOMIC.
But according to driver call graph, it is not in atomic context,
namely no spinlock is held nor in an interrupt handler.

This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.

Signed-off-by: Jia-Ju Bai 
---
  drivers/hv/hv.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 8267439..b0d025a 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -150,7 +150,7 @@ int hv_synic_alloc(void)
int cpu;

hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-GFP_ATOMIC);
+GFP_KERNEL);
if (hv_context.hv_numa_map == NULL) {
pr_err("Unable to allocate NUMA map\n");
goto err;

Reviewed-by: Vitaly Kuznetsov 

The subject line is not very accurate: GFP_KERNEL you switch too is the
one supporting 'sleep' when there's not enough memory, not
GFP_ATOMIC so you don't actually "Fix unnecessary sleeping". I'd suggest
you use something like "hyper-v: use GFP_KERNEL for hv_context.hv_numa_map"



Thanks for you suggestion :)
Okay, I found my description is not correct, too, sorry.
I will revise it and resubmit the patch.


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


[PATCH V2] hyper-v: use GFP_KERNEL for hv_context.hv_numa_map

2017-12-18 Thread Jia-Ju Bai
The kzalloc function is called with GFP_ATOMIC.
But according to driver call graph, it is not in atomic context,
namely no spinlock is held nor in an interrupt handler.

This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.

Signed-off-by: Jia-Ju Bai 
---
 drivers/hv/hv.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 8267439..b0d025a 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -150,7 +150,7 @@ int hv_synic_alloc(void)
int cpu;
 
hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-GFP_ATOMIC);
+GFP_KERNEL);
if (hv_context.hv_numa_map == NULL) {
pr_err("Unable to allocate NUMA map\n");
goto err;
-- 
1.7.9.5

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


[PATCH] staging: vt6655: Use GFP_KERNEL in kzalloc

2017-12-18 Thread Jia-Ju Bai
Four kzalloc functions are called with GFP_ATOMIC.
But according to driver call graph, they are not in atomic context,
namely no spinlock is held nor in an interrupt handler.

All these "GFP_ATOMIC"s are unnecessary,
and replace with with "GFP_KERNEL"s.

Signed-off-by: Jia-Ju Bai 
---
 drivers/staging/vt6655/device_main.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index 1123b4f..1688307 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -547,7 +547,7 @@ static void device_init_rd0_ring(struct vnt_private *priv)
for (i = 0; i < priv->opts.rx_descs0;
 i ++, curr += sizeof(struct vnt_rx_desc)) {
desc = &priv->aRD0Ring[i];
-   desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_ATOMIC);
+   desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_KERNEL);
 
if (!device_alloc_rx_buf(priv, desc))
dev_err(&priv->pcid->dev, "can not alloc rx bufs\n");
@@ -571,7 +571,7 @@ static void device_init_rd1_ring(struct vnt_private *priv)
for (i = 0; i < priv->opts.rx_descs1;
 i ++, curr += sizeof(struct vnt_rx_desc)) {
desc = &priv->aRD1Ring[i];
-   desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_ATOMIC);
+   desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_KERNEL);
 
if (!device_alloc_rx_buf(priv, desc))
dev_err(&priv->pcid->dev, "can not alloc rx bufs\n");
@@ -629,7 +629,7 @@ static void device_init_td0_ring(struct vnt_private *priv)
for (i = 0; i < priv->opts.tx_descs[0];
 i++, curr += sizeof(struct vnt_tx_desc)) {
desc = &priv->apTD0Rings[i];
-   desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC);
+   desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_KERNEL);
 
desc->td_info->buf = priv->tx0_bufs + i * PKT_BUF_SZ;
desc->td_info->buf_dma = priv->tx_bufs_dma0 + i * PKT_BUF_SZ;
@@ -654,7 +654,7 @@ static void device_init_td1_ring(struct vnt_private *priv)
for (i = 0; i < priv->opts.tx_descs[1];
 i++, curr += sizeof(struct vnt_tx_desc)) {
desc = &priv->apTD1Rings[i];
-   desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC);
+   desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_KERNEL);
 
desc->td_info->buf = priv->tx1_bufs + i * PKT_BUF_SZ;
desc->td_info->buf_dma = priv->tx_bufs_dma1 + i * PKT_BUF_SZ;
-- 
1.7.9.5

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


Re: [PATCH V2] hyper-v: use GFP_KERNEL for hv_context.hv_numa_map

2017-12-18 Thread Stephen Hemminger
On Mon, 18 Dec 2017 17:02:52 +0800
Jia-Ju Bai  wrote:

> The kzalloc function is called with GFP_ATOMIC.
> But according to driver call graph, it is not in atomic context,
> namely no spinlock is held nor in an interrupt handler.
> 
> This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.
> 
> Signed-off-by: Jia-Ju Bai 
> ---
>  drivers/hv/hv.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 8267439..b0d025a 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -150,7 +150,7 @@ int hv_synic_alloc(void)
>   int cpu;
>  
>   hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
> -  GFP_ATOMIC);
> +  GFP_KERNEL);
>   if (hv_context.hv_numa_map == NULL) {
>   pr_err("Unable to allocate NUMA map\n");
>   goto err;

Thanks, for fixing this.
While you are at it; wouldn't it make sense to use kcalloc here?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RFC 0/7] KVM: nVMX: enlightened VMCS initial implementation

2017-12-18 Thread Vitaly Kuznetsov
The original author of these patches does no longer work at Red Hat, I
agreed to take this over and send upstream. Here is his original
description:

"Makes KVM implement the enlightened VMCS feature per Hyper-V TLFS 5.0b.
I've measured about %5 improvement in cost of a nested VM exit (Hyper-V
enabled Windows Server 2016 nested in KVM)."

This is just an initial implementation. By leveraging clean fields mask
we can further improve performance. I'm also interested in implementing
the other part of the feature: consuming enlightened VMCS when KVM is
running on top of Hyper-V.

Ladi Prosek (7):
  KVM: x86: rename HV_X64_MSR_APIC_ASSIST_PAGE to
HV_X64_MSR_VP_ASSIST_PAGE
  KVM: nVMX: modify vmcs12 fields to match Hyper-V enlightened VMCS
  KVM: nVMX: add I/O exit ECX, ESI, EDI, EIP vmcs12 fields
  KVM: hyperv: define VP assist page structure and add helpers
  KVM: nVMX: add KVM_CAP_HYPERV_ENLIGHTENED_VMCS capability
  KVM: nVMX: add enlightened VMCS state
  KVM: nVMX: implement enlightened VMPTRLD

 arch/x86/include/asm/kvm_host.h|   3 +
 arch/x86/include/asm/vmx.h |   4 +
 arch/x86/include/uapi/asm/hyperv.h |  20 +-
 arch/x86/kvm/hyperv.c  |  31 ++-
 arch/x86/kvm/hyperv.h  |   4 +
 arch/x86/kvm/lapic.c   |   4 +-
 arch/x86/kvm/lapic.h   |   4 +-
 arch/x86/kvm/svm.c |   9 +
 arch/x86/kvm/vmx.c | 467 ++---
 arch/x86/kvm/x86.c |  19 +-
 include/uapi/linux/kvm.h   |   1 +
 11 files changed, 407 insertions(+), 159 deletions(-)

-- 
2.14.3

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


[PATCH RFC 1/7] KVM: x86: rename HV_X64_MSR_APIC_ASSIST_PAGE to HV_X64_MSR_VP_ASSIST_PAGE

2017-12-18 Thread Vitaly Kuznetsov
From: Ladi Prosek 

The assist page has been used only for the paravirtual EOI so far, hence
the "APIC" in the MSR name. Renaming to match the Hyper-V TLFS where it's
called "Virtual VP Assist MSR".

Signed-off-by: Ladi Prosek 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/include/uapi/asm/hyperv.h | 10 +-
 arch/x86/kvm/hyperv.c  |  8 
 arch/x86/kvm/lapic.h   |  2 +-
 arch/x86/kvm/x86.c |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index 1a5bfead93b4..a742af3e8408 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -186,7 +186,7 @@
 #define HV_X64_MSR_EOI 0x4070
 #define HV_X64_MSR_ICR 0x4071
 #define HV_X64_MSR_TPR 0x4072
-#define HV_X64_MSR_APIC_ASSIST_PAGE0x4073
+#define HV_X64_MSR_VP_ASSIST_PAGE  0x4073
 
 /* Define synthetic interrupt controller model specific registers. */
 #define HV_X64_MSR_SCONTROL0x4080
@@ -248,10 +248,10 @@
 #define HVCALL_POST_MESSAGE0x005c
 #define HVCALL_SIGNAL_EVENT0x005d
 
-#define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE 0x0001
-#define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT  12
-#define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_MASK   \
-   (~((1ull << HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
+#define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE   0x0001
+#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT12
+#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK \
+   (~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
 
 #define HV_X64_MSR_TSC_REFERENCE_ENABLE0x0001
 #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index dc97f2544b6f..9fb0ed9b1670 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1009,17 +1009,17 @@ static int kvm_hv_set_msr(struct kvm_vcpu *vcpu, u32 
msr, u64 data, bool host)
return 1;
hv->vp_index = (u32)data;
break;
-   case HV_X64_MSR_APIC_ASSIST_PAGE: {
+   case HV_X64_MSR_VP_ASSIST_PAGE: {
u64 gfn;
unsigned long addr;
 
-   if (!(data & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE)) {
+   if (!(data & HV_X64_MSR_VP_ASSIST_PAGE_ENABLE)) {
hv->hv_vapic = data;
if (kvm_lapic_enable_pv_eoi(vcpu, 0))
return 1;
break;
}
-   gfn = data >> HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT;
+   gfn = data >> HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT;
addr = kvm_vcpu_gfn_to_hva(vcpu, gfn);
if (kvm_is_error_hva(addr))
return 1;
@@ -1129,7 +1129,7 @@ static int kvm_hv_get_msr(struct kvm_vcpu *vcpu, u32 msr, 
u64 *pdata)
return kvm_hv_vapic_msr_read(vcpu, APIC_ICR, pdata);
case HV_X64_MSR_TPR:
return kvm_hv_vapic_msr_read(vcpu, APIC_TASKPRI, pdata);
-   case HV_X64_MSR_APIC_ASSIST_PAGE:
+   case HV_X64_MSR_VP_ASSIST_PAGE:
data = hv->hv_vapic;
break;
case HV_X64_MSR_VP_RUNTIME:
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 4b9935a38347..f7ee56819add 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -109,7 +109,7 @@ int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 msr, 
u64 *data);
 
 static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu)
 {
-   return vcpu->arch.hyperv.hv_vapic & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE;
+   return vcpu->arch.hyperv.hv_vapic & HV_X64_MSR_VP_ASSIST_PAGE_ENABLE;
 }
 
 int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index faf843c9b916..fc06af73128e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1026,7 +1026,7 @@ static u32 emulated_msrs[] = {
HV_X64_MSR_VP_RUNTIME,
HV_X64_MSR_SCONTROL,
HV_X64_MSR_STIMER0_CONFIG,
-   HV_X64_MSR_APIC_ASSIST_PAGE, MSR_KVM_ASYNC_PF_EN, MSR_KVM_STEAL_TIME,
+   HV_X64_MSR_VP_ASSIST_PAGE, MSR_KVM_ASYNC_PF_EN, MSR_KVM_STEAL_TIME,
MSR_KVM_PV_EOI_EN,
 
MSR_IA32_TSC_ADJUST,
-- 
2.14.3

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


[PATCH RFC 4/7] KVM: hyperv: define VP assist page structure and add helpers

2017-12-18 Thread Vitaly Kuznetsov
From: Ladi Prosek 

Structure layout is specified in Hyper-V TLFS 5.0b.

The state related to the VP assist page is still managed by the LAPIC
code in the pv_eoi field.

Signed-off-by: Ladi Prosek 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/include/uapi/asm/hyperv.h | 10 ++
 arch/x86/kvm/hyperv.c  | 23 +--
 arch/x86/kvm/hyperv.h  |  4 
 arch/x86/kvm/lapic.c   |  4 ++--
 arch/x86/kvm/lapic.h   |  2 +-
 arch/x86/kvm/x86.c |  2 +-
 6 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index a742af3e8408..032580cab492 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -385,6 +385,16 @@ struct hv_timer_message_payload {
__u64 delivery_time;/* When the message was delivered */
 };
 
+/* Define virtual processor assist page structure. */
+struct hv_vp_assist_page {
+   __u32 apic_assist;
+   __u32 reserved;
+   __u64 vtl_control[2];
+   __u64 nested_enlightenments_control[2];
+   __u32 enlighten_vmentry;
+   __u64 current_nested_vmcs;
+};
+
 #define HV_STIMER_ENABLE   (1ULL << 0)
 #define HV_STIMER_PERIODIC (1ULL << 1)
 #define HV_STIMER_LAZY (1ULL << 2)
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 9fb0ed9b1670..f91db96ee2d6 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -667,6 +667,24 @@ void kvm_hv_vcpu_uninit(struct kvm_vcpu *vcpu)
stimer_cleanup(&hv_vcpu->stimer[i]);
 }
 
+bool kvm_hv_assist_page_enabled(struct kvm_vcpu *vcpu)
+{
+   if (!(vcpu->arch.hyperv.hv_vapic & HV_X64_MSR_VP_ASSIST_PAGE_ENABLE))
+   return false;
+   return vcpu->arch.pv_eoi.msr_val & KVM_MSR_ENABLED;
+}
+EXPORT_SYMBOL_GPL(kvm_hv_assist_page_enabled);
+
+bool kvm_hv_get_assist_page(struct kvm_vcpu *vcpu,
+   struct hv_vp_assist_page *assist_page)
+{
+   if (!kvm_hv_assist_page_enabled(vcpu))
+   return false;
+   return !kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.pv_eoi.data,
+ assist_page, sizeof(*assist_page));
+}
+EXPORT_SYMBOL_GPL(kvm_hv_get_assist_page);
+
 static void stimer_prepare_msg(struct kvm_vcpu_hv_stimer *stimer)
 {
struct hv_message *msg = &stimer->msg;
@@ -1015,7 +1033,7 @@ static int kvm_hv_set_msr(struct kvm_vcpu *vcpu, u32 msr, 
u64 data, bool host)
 
if (!(data & HV_X64_MSR_VP_ASSIST_PAGE_ENABLE)) {
hv->hv_vapic = data;
-   if (kvm_lapic_enable_pv_eoi(vcpu, 0))
+   if (kvm_lapic_enable_pv_eoi(vcpu, 0, 0))
return 1;
break;
}
@@ -1028,7 +1046,8 @@ static int kvm_hv_set_msr(struct kvm_vcpu *vcpu, u32 msr, 
u64 data, bool host)
hv->hv_vapic = data;
kvm_vcpu_mark_page_dirty(vcpu, gfn);
if (kvm_lapic_enable_pv_eoi(vcpu,
-   gfn_to_gpa(gfn) | KVM_MSR_ENABLED))
+   gfn_to_gpa(gfn) | KVM_MSR_ENABLED,
+   sizeof(struct hv_vp_assist_page)))
return 1;
break;
}
diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h
index e637631a9574..d963ddb6cd63 100644
--- a/arch/x86/kvm/hyperv.h
+++ b/arch/x86/kvm/hyperv.h
@@ -62,6 +62,10 @@ void kvm_hv_vcpu_init(struct kvm_vcpu *vcpu);
 void kvm_hv_vcpu_postcreate(struct kvm_vcpu *vcpu);
 void kvm_hv_vcpu_uninit(struct kvm_vcpu *vcpu);
 
+bool kvm_hv_assist_page_enabled(struct kvm_vcpu *vcpu);
+bool kvm_hv_get_assist_page(struct kvm_vcpu *vcpu,
+   struct hv_vp_assist_page *assist_page);
+
 static inline struct kvm_vcpu_hv_stimer *vcpu_to_stimer(struct kvm_vcpu *vcpu,
int timer_index)
 {
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index e2c1fb8d35ce..846c1a192eb9 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2524,7 +2524,7 @@ int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 reg, 
u64 *data)
return 0;
 }
 
-int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data)
+int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data, unsigned long len)
 {
u64 addr = data & ~KVM_MSR_ENABLED;
if (!IS_ALIGNED(addr, 4))
@@ -2534,7 +2534,7 @@ int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 
data)
if (!pv_eoi_enabled(vcpu))
return 0;
return kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.pv_eoi.data,
-addr, sizeof(u8));
+addr, len);
 }
 
 void kvm_apic_accept_events(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/lapic.h b/arch

[PATCH RFC 2/7] KVM: nVMX: modify vmcs12 fields to match Hyper-V enlightened VMCS

2017-12-18 Thread Vitaly Kuznetsov
From: Ladi Prosek 

Reorders existing fields and adds fields specific to Hyper-V. The layout
now matches Hyper-V TLFS 5.0b 16.11.2 Enlightened VMCS.

Fields used by KVM but missing from Hyper-V are placed in the second half
of the VMCS page to minimize the chances they will clash with future
enlightened VMCS versions.

Signed-off-by: Ladi Prosek 
Signed-off-by: Vitaly Kuznetsov 
---
[Vitaly]: Update VMCS12_REVISION to some new arbitrary number.
---
 arch/x86/kvm/vmx.c | 321 +++--
 1 file changed, 187 insertions(+), 134 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 8eba631c4dbd..cd5f29a57880 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -239,159 +239,212 @@ struct __packed vmcs12 {
u32 revision_id;
u32 abort;
 
+   union {
+   u64 hv_vmcs[255];
+   struct {
+   u16 host_es_selector;
+   u16 host_cs_selector;
+   u16 host_ss_selector;
+   u16 host_ds_selector;
+   u16 host_fs_selector;
+   u16 host_gs_selector;
+   u16 host_tr_selector;
+
+   u64 host_ia32_pat;
+   u64 host_ia32_efer;
+
+   /*
+* To allow migration of L1 (complete with its L2
+* guests) between machines of different natural widths
+* (32 or 64 bit), we cannot have unsigned long fields
+* with no explicit size. We use u64 (aliased
+* natural_width) instead. Luckily, x86 is
+* little-endian.
+*/
+   natural_width host_cr0;
+   natural_width host_cr3;
+   natural_width host_cr4;
+
+   natural_width host_ia32_sysenter_esp;
+   natural_width host_ia32_sysenter_eip;
+   natural_width host_rip;
+   u32 host_ia32_sysenter_cs;
+
+   u32 pin_based_vm_exec_control;
+   u32 vm_exit_controls;
+   u32 secondary_vm_exec_control;
+
+   u64 io_bitmap_a;
+   u64 io_bitmap_b;
+   u64 msr_bitmap;
+
+   u16 guest_es_selector;
+   u16 guest_cs_selector;
+   u16 guest_ss_selector;
+   u16 guest_ds_selector;
+   u16 guest_fs_selector;
+   u16 guest_gs_selector;
+   u16 guest_ldtr_selector;
+   u16 guest_tr_selector;
+
+   u32 guest_es_limit;
+   u32 guest_cs_limit;
+   u32 guest_ss_limit;
+   u32 guest_ds_limit;
+   u32 guest_fs_limit;
+   u32 guest_gs_limit;
+   u32 guest_ldtr_limit;
+   u32 guest_tr_limit;
+   u32 guest_gdtr_limit;
+   u32 guest_idtr_limit;
+
+   u32 guest_es_ar_bytes;
+   u32 guest_cs_ar_bytes;
+   u32 guest_ss_ar_bytes;
+   u32 guest_ds_ar_bytes;
+   u32 guest_fs_ar_bytes;
+   u32 guest_gs_ar_bytes;
+   u32 guest_ldtr_ar_bytes;
+   u32 guest_tr_ar_bytes;
+
+   natural_width guest_es_base;
+   natural_width guest_cs_base;
+   natural_width guest_ss_base;
+   natural_width guest_ds_base;
+   natural_width guest_fs_base;
+   natural_width guest_gs_base;
+   natural_width guest_ldtr_base;
+   natural_width guest_tr_base;
+   natural_width guest_gdtr_base;
+   natural_width guest_idtr_base;
+
+   u64 padding64_1[3];
+
+   u64 vm_exit_msr_store_addr;
+   u64 vm_exit_msr_load_addr;
+   u64 vm_entry_msr_load_addr;
+
+   natural_width cr3_target_value0;
+   natural_width cr3_target_value1;
+   natural_width cr3_target_value2;
+   natural_width cr3_target_value3;
+
+   u32 page_fault_error_code_mask;
+   u32 page_fault_error_code_match;
+
+   u32 cr3_target_count;
+   u32 vm_exit_msr_store_count;
+   u32 vm_exit_msr_load_count;
+   u32 vm_entry_msr_load_count;
+
+   u64 tsc_offset;
+   u6

[PATCH RFC 3/7] KVM: nVMX: add I/O exit ECX, ESI, EDI, EIP vmcs12 fields

2017-12-18 Thread Vitaly Kuznetsov
From: Ladi Prosek 

These non-synthetic VMCS fields were not supported by KVM thus far. The
layout is according to Hyper-V TLFS 5.0b, the physical encoding according
to the Intel SDM.

Signed-off-by: Ladi Prosek 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/include/asm/vmx.h | 4 
 arch/x86/kvm/vmx.c | 9 -
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 8b6780751132..92a10aa839e6 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -298,6 +298,10 @@ enum vmcs_field {
CR3_TARGET_VALUE2   = 0x600c,
CR3_TARGET_VALUE3   = 0x600e,
EXIT_QUALIFICATION  = 0x6400,
+   EXIT_IO_INSTR_ECX   = 0x6402,
+   EXIT_IO_INSTR_ESI   = 0x6404,
+   EXIT_IO_INSTR_EDI   = 0x6406,
+   EXIT_IO_INSTR_EIP   = 0x6408,
GUEST_LINEAR_ADDRESS= 0x640a,
GUEST_CR0   = 0x6800,
GUEST_CR3   = 0x6802,
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index cd5f29a57880..f3215b6a0531 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -391,7 +391,10 @@ struct __packed vmcs12 {
u32 vmx_instruction_info;
 
natural_width exit_qualification;
-   natural_width padding64_3[4];
+   natural_width exit_io_instr_ecx;
+   natural_width exit_io_instr_esi;
+   natural_width exit_io_instr_edi;
+   natural_width exit_io_instr_eip;
 
natural_width guest_linear_address;
natural_width guest_rsp;
@@ -913,6 +916,10 @@ static const unsigned short vmcs_field_to_offset_table[] = 
{
FIELD(CR3_TARGET_VALUE2, cr3_target_value2),
FIELD(CR3_TARGET_VALUE3, cr3_target_value3),
FIELD(EXIT_QUALIFICATION, exit_qualification),
+   FIELD(EXIT_IO_INSTR_ECX, exit_io_instr_ecx),
+   FIELD(EXIT_IO_INSTR_ESI, exit_io_instr_esi),
+   FIELD(EXIT_IO_INSTR_EDI, exit_io_instr_edi),
+   FIELD(EXIT_IO_INSTR_EIP, exit_io_instr_eip),
FIELD(GUEST_LINEAR_ADDRESS, guest_linear_address),
FIELD(GUEST_CR0, guest_cr0),
FIELD(GUEST_CR3, guest_cr3),
-- 
2.14.3

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


[PATCH RFC 7/7] KVM: nVMX: implement enlightened VMPTRLD

2017-12-18 Thread Vitaly Kuznetsov
From: Ladi Prosek 

Per Hyper-V TLFS 5.0b:

"The L1 hypervisor may choose to use enlightened VMCSs by writing 1 to
the corresponding field in the VP assist page (see section 7.8.7).
Another field in the VP assist page controls the currently active
enlightened VMCS. Each enlightened VMCS is exactly one page (4 KB) in
size and must be initially zeroed. No VMPTRLD instruction must be
executed to make an enlightened VMCS active or current.

After the L1 hypervisor performs a VM entry with an enlightened VMCS,
the VMCS is considered active on the processor. An enlightened VMCS
can only be active on a single processor at the same time. The L1
hypervisor can execute a VMCLEAR instruction to transition an
enlightened VMCS from the active to the non-active state. Any VMREAD
or VMWRITE instructions while an enlightened VMCS is active is
unsupported and can result in unexpected behavior."

Note that we choose to not modify our VMREAD, VMWRITE, and VMPTRLD
handlers. They will not cause any explicit failure but may not have
the intended effect.

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

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 00b4a362351d..f7f6f7d18ade 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -20,6 +20,7 @@
 #include "mmu.h"
 #include "cpuid.h"
 #include "lapic.h"
+#include "hyperv.h"
 
 #include 
 #include 
@@ -7935,6 +7936,30 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
return kvm_skip_emulated_instruction(vcpu);
 }
 
+static int nested_vmx_handle_enlightened_vmptrld(struct kvm_vcpu *vcpu)
+{
+   struct vcpu_vmx *vmx = to_vmx(vcpu);
+   struct hv_vp_assist_page assist_page;
+
+   if (!vmx->nested.enlightened_vmcs_enabled)
+   return 1;
+
+   vmx->nested.enlightened_vmcs_active =
+   kvm_hv_get_assist_page(vcpu, &assist_page) &&
+   assist_page.enlighten_vmentry;
+
+   if (vmx->nested.enlightened_vmcs_active &&
+   assist_page.current_nested_vmcs != vmx->nested.current_vmptr) {
+   /*
+* This is an equivalent of the nested hypervisor executing
+* the vmptrld instruction.
+*/
+   set_current_vmptr(vmx, assist_page.current_nested_vmcs);
+   copy_enlightened_to_vmcs12(vmx);
+   }
+   return 1;
+}
+
 /* Emulate the VMPTRST instruction */
 static int handle_vmptrst(struct kvm_vcpu *vcpu)
 {
@@ -11045,6 +11070,9 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool 
launch)
if (!nested_vmx_check_permission(vcpu))
return 1;
 
+   if (!nested_vmx_handle_enlightened_vmptrld(vcpu))
+   return 1;
+
if (!nested_vmx_check_vmcs12(vcpu))
goto out;
 
-- 
2.14.3

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


[PATCH RFC 6/7] KVM: nVMX: add enlightened VMCS state

2017-12-18 Thread Vitaly Kuznetsov
From: Ladi Prosek 

Adds two bool fields and implements copy_enlightened_to_vmcs12() and
copy_enlightened_to_vmcs12().

Unlike shadow VMCS, enlightened VMCS is para-virtual and active only if
the nested guest explicitly enables it. The pattern repeating itself a
few times throughout this patch:

  if (vmx->nested.enlightened_vmcs_active) {
  /* enlightened! */
  } else if (enable_shadow_vmcs) {
  /* fall-back */
  }

reflects this. If the nested guest elects to not use enlightened VMCS,
the regular HW-assisted shadow VMCS feature is used, if enabled.
enlightened_vmcs_active is never going to be true if
enlightened_vmcs_enabled is not set.

Signed-off-by: Ladi Prosek 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/kvm/vmx.c | 60 ++
 1 file changed, 52 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 320bb6670413..00b4a362351d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -503,6 +503,16 @@ struct nested_vmx {
 * on what the enlightened VMCS supports.
 */
bool enlightened_vmcs_enabled;
+   /*
+* Indicates that the nested hypervisor performed the last vmentry with
+* a Hyper-V enlightened VMCS.
+*/
+   bool enlightened_vmcs_active;
+
+   /*
+* Indicates that the enlightened VMCS must be synced with vmcs12
+*/
+   bool sync_enlightened_vmcs;
 
/* vmcs02_list cache of VMCSs recently used to run L2 guests */
struct list_head vmcs02_pool;
@@ -991,6 +1001,7 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu,
 static bool guest_state_valid(struct kvm_vcpu *vcpu);
 static u32 vmx_segment_access_rights(struct kvm_segment *var);
 static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx);
+static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx);
 static bool vmx_get_nmi_mask(struct kvm_vcpu *vcpu);
 static void vmx_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked);
 static bool nested_vmx_is_page_fault_vmexit(struct vmcs12 *vmcs12,
@@ -7455,7 +7466,10 @@ static inline void nested_release_vmcs12(struct vcpu_vmx 
*vmx)
if (vmx->nested.current_vmptr == -1ull)
return;
 
-   if (enable_shadow_vmcs) {
+   if (vmx->nested.enlightened_vmcs_active) {
+   copy_enlightened_to_vmcs12(vmx);
+   vmx->nested.sync_enlightened_vmcs = false;
+   } else if (enable_shadow_vmcs) {
/* copy to memory all shadowed fields in case
   they were modified */
copy_shadow_to_vmcs12(vmx);
@@ -7642,6 +7656,20 @@ static inline int vmcs12_write_any(struct kvm_vcpu *vcpu,
 
 }
 
+static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx)
+{
+   kvm_vcpu_read_guest_page(&vmx->vcpu,
+vmx->nested.current_vmptr >> PAGE_SHIFT,
+vmx->nested.cached_vmcs12, 0, VMCS12_SIZE);
+}
+
+static void copy_vmcs12_to_enlightened(struct vcpu_vmx *vmx)
+{
+   kvm_vcpu_write_guest_page(&vmx->vcpu,
+ vmx->nested.current_vmptr >> PAGE_SHIFT,
+ vmx->nested.cached_vmcs12, 0, VMCS12_SIZE);
+}
+
 static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
 {
int i;
@@ -7841,7 +7869,9 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
 static void set_current_vmptr(struct vcpu_vmx *vmx, gpa_t vmptr)
 {
vmx->nested.current_vmptr = vmptr;
-   if (enable_shadow_vmcs) {
+   if (vmx->nested.enlightened_vmcs_active) {
+   vmx->nested.sync_enlightened_vmcs = true;
+   } else if (enable_shadow_vmcs) {
vmcs_set_bits(SECONDARY_VM_EXEC_CONTROL,
  SECONDARY_EXEC_SHADOW_VMCS);
vmcs_write64(VMCS_LINK_POINTER,
@@ -9396,7 +9426,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
vmcs_write32(PLE_WINDOW, vmx->ple_window);
}
 
-   if (vmx->nested.sync_shadow_vmcs) {
+   if (vmx->nested.sync_enlightened_vmcs) {
+   copy_vmcs12_to_enlightened(vmx);
+   vmx->nested.sync_enlightened_vmcs = false;
+   } else if (vmx->nested.sync_shadow_vmcs) {
copy_vmcs12_to_shadow(vmx);
vmx->nested.sync_shadow_vmcs = false;
}
@@ -11017,7 +11050,9 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool 
launch)
 
vmcs12 = get_vmcs12(vcpu);
 
-   if (enable_shadow_vmcs)
+   if (vmx->nested.enlightened_vmcs_active)
+   copy_enlightened_to_vmcs12(vmx);
+   else if (enable_shadow_vmcs)
copy_shadow_to_vmcs12(vmx);
 
/*
@@ -11634,8 +11669,12 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, 
u32 exit_reason,
 */
kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
 
-   if (enable_shadow_vmcs && exit_reason != -1)
-   vmx->nested.sync_shadow_vmcs = true;
+   if (exit_reason != 

[PATCH RFC 5/7] KVM: nVMX: add KVM_CAP_HYPERV_ENLIGHTENED_VMCS capability

2017-12-18 Thread Vitaly Kuznetsov
From: Ladi Prosek 

Enlightened VMCS is opt-in. The current version does not contain all
fields supported by nested VMX so we must not advertise the
corresponding VMX features if enlightened VMCS is enabled.

Userspace is given the enlightened VMCS version supported by KVM as
part of enabling KVM_CAP_HYPERV_ENLIGHTENED_VMCS. The version is to
be advertised to the nested hypervisor, currently done via a cpuid
leaf for Hyper-V.

Signed-off-by: Ladi Prosek 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/include/asm/kvm_host.h |  3 +++
 arch/x86/kvm/svm.c  |  9 
 arch/x86/kvm/vmx.c  | 51 +
 arch/x86/kvm/x86.c  | 15 
 include/uapi/linux/kvm.h|  1 +
 5 files changed, 79 insertions(+)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 516798431328..79c188ae7837 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1079,6 +1079,9 @@ struct kvm_x86_ops {
int (*pre_enter_smm)(struct kvm_vcpu *vcpu, char *smstate);
int (*pre_leave_smm)(struct kvm_vcpu *vcpu, u64 smbase);
int (*enable_smi_window)(struct kvm_vcpu *vcpu);
+
+   int (*enable_enlightened_vmcs)(struct kvm_vcpu *vcpu,
+  uint16_t *vmcs_version);
 };
 
 struct kvm_arch_async_pf {
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index eb714f1cdf7e..6dc28d53bb89 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -5505,6 +5505,13 @@ static int enable_smi_window(struct kvm_vcpu *vcpu)
return 0;
 }
 
+static int enable_enlightened_vmcs(struct kvm_vcpu *vcpu,
+  uint16_t *vmcs_version)
+{
+   /* Intel-only feature */
+   return -ENODEV;
+}
+
 static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
.cpu_has_kvm_support = has_svm,
.disabled_by_bios = is_disabled,
@@ -5620,6 +5627,8 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
.pre_enter_smm = svm_pre_enter_smm,
.pre_leave_smm = svm_pre_leave_smm,
.enable_smi_window = enable_smi_window,
+
+   .enable_enlightened_vmcs = enable_enlightened_vmcs,
 };
 
 static int __init svm_init(void)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f3215b6a0531..320bb6670413 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -464,6 +464,8 @@ struct __packed vmcs12 {
  */
 #define VMCS12_SIZE 0x1000
 
+#define ENLIGHTENED_VMCS_VERSION (1 | (1u << 8))
+
 /* Used to remember the last vmcs02 used for some recently used vmcs12s */
 struct vmcs02_list {
struct list_head list;
@@ -495,6 +497,13 @@ struct nested_vmx {
 */
bool sync_shadow_vmcs;
 
+   /*
+* Enlightened VMCS has been enabled. It does not mean that L1 has to
+* use it. However, VMX features available to L1 will be limited based
+* on what the enlightened VMCS supports.
+*/
+   bool enlightened_vmcs_enabled;
+
/* vmcs02_list cache of VMCSs recently used to run L2 guests */
struct list_head vmcs02_pool;
int vmcs02_num;
@@ -12129,6 +12138,46 @@ static int enable_smi_window(struct kvm_vcpu *vcpu)
return 0;
 }
 
+static int enable_enlightened_vmcs(struct kvm_vcpu *vcpu,
+  uint16_t *vmcs_version)
+{
+   struct vcpu_vmx *vmx = to_vmx(vcpu);
+
+   /* We don't support disabling the feature for simplicity. */
+   if (vmx->nested.enlightened_vmcs_enabled)
+   return 0;
+   vmx->nested.enlightened_vmcs_enabled = true;
+   *vmcs_version = ENLIGHTENED_VMCS_VERSION;
+
+   /*
+* Enlightened VMCS doesn't have the POSTED_INTR_DESC_ADDR,
+* POSTED_INTR_NV, VMX_PREEMPTION_TIMER_VALUE,
+* GUEST_IA32_PERF_GLOBAL_CTRL, and HOST_IA32_PERF_GLOBAL_CTRL
+* fields.
+*/
+   vmx->nested.nested_vmx_pinbased_ctls_high &=
+   ~(PIN_BASED_POSTED_INTR |
+ PIN_BASED_VMX_PREEMPTION_TIMER);
+   vmx->nested.nested_vmx_entry_ctls_high &=
+   ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
+   vmx->nested.nested_vmx_exit_ctls_high &=
+   ~VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL;
+
+   /*
+* Enlightened VMCS doesn't have the APIC_ACCESS_ADDR,
+* EOI_EXIT_BITMAP*, GUEST_INTR_STATUS, VM_FUNCTION_CONTROL,
+* EPTP_LIST_ADDRESS, PML_ADDRESS, and GUEST_PML_INDEX fields.
+*/
+   vmx->nested.nested_vmx_secondary_ctls_high &=
+   ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
+ SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
+ SECONDARY_EXEC_ENABLE_VMFUNC |
+ SECONDARY_EXEC_ENABLE_PML);
+   vmx->nested.nested_vmx_vmfunc_controls &=
+   ~VMX_VMFUNC_EPTP_SWITCHING;
+   return 0;
+}
+
 static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
.cpu_has_kvm_support = cpu_has_kvm_support,
.dis

[PATCH] Staging: Pi433: Bugfix for wrong argument for sizeof() in TX thread

2017-12-18 Thread Marcus Wolf
sizeof(array) != sizeof(pointer to array)
Fixes: "staging: pi433: reduce stack size in tx thread"

Signed-off-by: Marcus Wolf 
---
 drivers/staging/pi433/pi433_if.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 1f3ba55..6e6f595 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -565,7 +565,6 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
struct pi433_device *device = data;
struct spi_device *spi = device->spi;
struct pi433_tx_cfg tx_cfg;
-   u8 *buffer = device->buffer;
size_t size;
bool   rx_interrupted = false;
intposition, repetitions;
@@ -614,19 +613,19 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
size++;
 
/* prime buffer */
-   memset(buffer, 0, size);
+   memset(device->buffer, 0, size);
position = 0;
 
/* add length byte, if requested */
if (tx_cfg.enable_length_byte  == OPTION_ON)
-   buffer[position++] = size - 1; /* according to spec 
length byte itself must be excluded from the length calculation */
+   device->buffer[position++] = size - 1; /* according to 
spec length byte itself must be excluded from the length calculation */
 
/* add adr byte, if requested */
if (tx_cfg.enable_address_byte == OPTION_ON)
-   buffer[position++] = tx_cfg.address_byte;
+   device->buffer[position++] = tx_cfg.address_byte;
 
/* finally get message data from fifo */
-   retval = kfifo_out(&device->tx_fifo, &buffer[position], 
sizeof(buffer) - position);
+   retval = kfifo_out(&device->tx_fifo, &device->buffer[position], 
sizeof(device->buffer) - position);
dev_dbg(device->dev, "read %d message byte(s) from fifo 
queue.", retval);
mutex_unlock(&device->tx_fifo_lock);
 
@@ -708,7 +707,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
int temp = device->free_in_fifo;
device->free_in_fifo = 0;
rf69_write_fifo(spi,
-   &buffer[position],
+   &device->buffer[position],
temp);
position += temp;
} else {
@@ -716,7 +715,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
device->free_in_fifo -= size;
repetitions--;
rf69_write_fifo(spi,
-   &buffer[position],
+   &device->buffer[position],
(size - position));
position = 0; /* reset for next repetition */
}
-- 
1.7.10.4

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


Re: [PATCH v2 13/17] media: v4l2-async: simplify v4l2_async_subdev structure

2017-12-18 Thread Mauro Carvalho Chehab
Em Sat, 30 Sep 2017 01:05:24 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> (Removing the non-list recipients.)
> 
> On Fri, Sep 29, 2017 at 06:27:13AM -0300, Mauro Carvalho Chehab wrote:
> > Em Thu, 28 Sep 2017 15:09:21 +0300
> > Sakari Ailus  escreveu:
> >   
> > > Hi Mauro,
> > > 
> > > On Wed, Sep 27, 2017 at 06:46:56PM -0300, Mauro Carvalho Chehab wrote:  
> > > > The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> > > > struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> > > > match criteria requires just a device name.
> > > > 
> > > > So, it doesn't make sense to enclose those into structs,
> > > > as the criteria can go directly into the union.
> > > > 
> > > > That makes easier to document it, as we don't need to document
> > > > weird senseless structs.
> > > 
> > > The idea is that in the union, there's a struct which is specific to the
> > > match_type field. I wouldn't call it senseless.  
> > 
> > Why a struct for each specific match_type is **needed**? It it is not
> > needed, then it is senseless per definition :-) 
> > 
> > In the specific case of fwnode, there's already a named struct
> > for fwnode_handle. The only thing is that it is declared outside
> > enum v4l2_async_match_type. So, I don't see any reason to do things
> > like:
> > 
> > struct {
> > struct fwnode_handle *fwnode;
> > } fwnode;
> > 
> > If you're in doubt about that, think on how would you document
> > both fwnode structs. Both fwnode structs specify the match
> > criteria if %V4L2_ASYNC_MATCH_FWNODE.
> > 
> > The same applies to this:
> > 
> > struct {
> > const char *name;
> > } device_name;
> > 
> > Both device_name and name specifies the match criteria if
> > %V4L2_ASYNC_MATCH_DEVNAME.
> >   
> > > 
> > > In the two cases there's just a single field in the containing struct. You
> > > could remove the struct in that case as you do in this patch, and just use
> > > the field. But I think the result is less clean and so I wouldn't make 
> > > this
> > > change.  
> > 
> > It is actually cleaner without the stucts.
> > 
> > Without the useless struct, if one wants to match a firmware node, it
> > should be doing:
> > 
> > pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> > pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);  
> 
> This code should be and will be moved out of drivers. See:
> 
> http://www.spinics.net/lists/linux-media/msg122688.html>
> 
> So there are going to be quite a bit fewer instances of it, and none should
> remain in drivers. I frankly don't have a strong opinion on this; there are
> arguments for and against. I just don't see a reason to change it.

There are still a few occurrences on drivers. Just rebased it.
I'll post it in a few, inside a new patch series.

Simplifying the name of the match rules makes easier to understand
what's going on.


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


[PATCH] Staging: irda: Do not check for NOT NULL before kfree()

2017-12-18 Thread Shreeya Patel
Do not check for NOT NULL before calling kfree because if the
pointer is NULL, no action occurs.
Done using the following semantic patch by coccinelle.

@@
expression ptr;
@@

- if (ptr != NULL) {
  kfree(ptr);
  ptr = NULL;
- }

The semantic patch has the effect of adding an assignment
of ptr to NULL in the case where ptr is NULL already.

Signed-off-by: Shreeya Patel 
---
 drivers/staging/irda/net/irnet/irnet_irda.c | 28 ++--
 drivers/staging/irda/net/irnet/irnet_ppp.c  | 10 --
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/irda/net/irnet/irnet_irda.c 
b/drivers/staging/irda/net/irnet/irnet_irda.c
index e390bce..9fb79fe 100644
--- a/drivers/staging/irda/net/irnet/irnet_irda.c
+++ b/drivers/staging/irda/net/irnet/irnet_irda.c
@@ -659,13 +659,9 @@ irda_irnet_destroy(irnet_socket *  self)
   self->iriap = NULL;
 }
 
-  /* Cleanup eventual discoveries from connection attempt or control channel */
-  if(self->discoveries != NULL)
-{
-  /* Cleanup our copy of the discovery log */
-  kfree(self->discoveries);
-  self->discoveries = NULL;
-}
+  /* Cleanup our copy of the discovery log */
+  kfree(self->discoveries);
+  self->discoveries = NULL;
 
   /* Close our IrTTP connection */
   if(self->tsap)
@@ -874,11 +870,9 @@ irnet_connect_socket(irnet_socket *server,
   iriap_close(new->iriap);
   new->iriap = NULL;
 }
-  if(new->discoveries != NULL)
-{
-  kfree(new->discoveries);
-  new->discoveries = NULL;
-}
+
+  kfree(new->discoveries);
+  new->discoveries = NULL;
 
 #ifdef CONNECT_INDIC_KICK
   /* As currently we don't block packets in ppp_irnet_send() while passive,
@@ -1605,12 +1599,10 @@ irnet_discovervalue_confirm(int result,
   /* No more items : remove the log and signal termination */
   DEBUG(IRDA_OCB_INFO, "Cleaning up log (0x%p)\n",
self->discoveries);
-  if(self->discoveries != NULL)
-{
-  /* Cleanup our copy of the discovery log */
-  kfree(self->discoveries);
-  self->discoveries = NULL;
-}
+
+  /* Cleanup our copy of the discovery log */
+  kfree(self->discoveries);
+  self->discoveries = NULL;
   self->disco_number = -1;
 
   /* Check out what we found */
diff --git a/drivers/staging/irda/net/irnet/irnet_ppp.c 
b/drivers/staging/irda/net/irnet/irnet_ppp.c
index 7025dcb..855ce58 100644
--- a/drivers/staging/irda/net/irnet/irnet_ppp.c
+++ b/drivers/staging/irda/net/irnet/irnet_ppp.c
@@ -259,12 +259,10 @@ irnet_read_discovery_log(irnet_socket *ap, char *event, 
int buf_size)
   /* No more items : remove the log and signal termination */
   DEBUG(CTRL_INFO, "Cleaning up log (0x%p)\n",
ap->discoveries);
-  if(ap->discoveries != NULL)
-   {
- /* Cleanup our copy of the discovery log */
- kfree(ap->discoveries);
- ap->discoveries = NULL;
-   }
+
+  /* Cleanup our copy of the discovery log */
+  kfree(ap->discoveries);
+  ap->discoveries = NULL;
   ap->disco_number = -1;
 }
 
-- 
2.7.4

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


Re: [PATCH] staging: android: ion: Fix dma direction for dma_sync_sg_for_cpu/device

2017-12-18 Thread Laura Abbott

On 12/15/2017 12:59 PM, Sushmita Susheelendra wrote:

Use the direction argument passed into begin_cpu_access
and end_cpu_access when calling the dma_sync_sg_for_cpu/device.
The actual cache primitive called depends on the direction
passed in.



Acked-by: Laura Abbott 


Signed-off-by: Sushmita Susheelendra 
---
  drivers/staging/android/ion/ion.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index a7d9b0e..f480885 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -346,7 +346,7 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf 
*dmabuf,
mutex_lock(&buffer->lock);
list_for_each_entry(a, &buffer->attachments, list) {
dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
-   DMA_BIDIRECTIONAL);
+   direction);
}
mutex_unlock(&buffer->lock);
  
@@ -368,7 +368,7 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf,

mutex_lock(&buffer->lock);
list_for_each_entry(a, &buffer->attachments, list) {
dma_sync_sg_for_device(a->dev, a->table->sgl, a->table->nents,
-  DMA_BIDIRECTIONAL);
+  direction);
}
mutex_unlock(&buffer->lock);
  



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


Re: [PATCH] Staging: irda: Do not check for NOT NULL before kfree()

2017-12-18 Thread Stephen Hemminger
On Tue, 19 Dec 2017 00:41:30 +0530
Shreeya Patel  wrote:

> Do not check for NOT NULL before calling kfree because if the
> pointer is NULL, no action occurs.
> Done using the following semantic patch by coccinelle.
> 
> @@
> expression ptr;
> @@
> 
> - if (ptr != NULL) {
>   kfree(ptr);
>   ptr = NULL;
> - }
> 
> The semantic patch has the effect of adding an assignment
> of ptr to NULL in the case where ptr is NULL already.
> 
> Signed-off-by: Shreeya Patel 

Please read drivers/staging/irda/TODO

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


Re: [PATCH] Staging: irda: Do not check for NOT NULL before kfree()

2017-12-18 Thread Shreeya Patel
On Mon, 2017-12-18 at 11:20 -0800, Stephen Hemminger wrote:
> On Tue, 19 Dec 2017 00:41:30 +0530
> Shreeya Patel  wrote:
> 
> > 
> > Do not check for NOT NULL before calling kfree because if the
> > pointer is NULL, no action occurs.
> > Done using the following semantic patch by coccinelle.
> > 
> > @@
> > expression ptr;
> > @@
> > 
> > - if (ptr != NULL) {
> >   kfree(ptr);
> >   ptr = NULL;
> > - }
> > 
> > The semantic patch has the effect of adding an assignment
> > of ptr to NULL in the case where ptr is NULL already.
> > 
> > Signed-off-by: Shreeya Patel 
> Please read drivers/staging/irda/TODO

Oh, I was not knowing about it.

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


[PATCH 0/8] Some V4L2 documentation pending patches

2017-12-18 Thread Mauro Carvalho Chehab
This series contain the patches of a /17 and a /24 series
of documentation that required non-trivial changes.

Mauro Carvalho Chehab (8):
  media: v4l2-device.h: document helper macros
  media: v4l2-ioctl.h: convert debug into an enum of bits
  media: v4l2-async: simplify v4l2_async_subdev structure
  media: v4l2-async: better describe match union at async match struct
  media: v4l2-mediabus: convert flags to enums and document them
  media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro
  media: v4l2-subdev: document remaining undocumented functions
  media: v4l2-subdev: use kernel-doc markups to document subdev flags

 drivers/media/i2c/adv7180.c|  10 +-
 drivers/media/i2c/ml86v7667.c  |   5 +-
 drivers/media/i2c/mt9m111.c|   8 +-
 drivers/media/i2c/ov6650.c |  19 +-
 drivers/media/i2c/soc_camera/imx074.c  |   6 +-
 drivers/media/i2c/soc_camera/mt9m001.c |  10 +-
 drivers/media/i2c/soc_camera/mt9t031.c |  11 +-
 drivers/media/i2c/soc_camera/mt9t112.c |  11 +-
 drivers/media/i2c/soc_camera/mt9v022.c |  16 +-
 drivers/media/i2c/soc_camera/ov5642.c  |   5 +-
 drivers/media/i2c/soc_camera/ov772x.c  |  10 +-
 drivers/media/i2c/soc_camera/ov9640.c  |  10 +-
 drivers/media/i2c/soc_camera/ov9740.c  |  10 +-
 drivers/media/i2c/soc_camera/rj54n1cb0c.c  |  12 +-
 drivers/media/i2c/soc_camera/tw9910.c  |  13 +-
 drivers/media/i2c/tc358743.c   |  10 +-
 drivers/media/i2c/tvp5150.c|   6 +-
 drivers/media/platform/am437x/am437x-vpfe.c|   6 +-
 drivers/media/platform/atmel/atmel-isc.c   |   2 +-
 drivers/media/platform/atmel/atmel-isi.c   |   2 +-
 drivers/media/platform/davinci/vpif_capture.c  |   4 +-
 drivers/media/platform/exynos4-is/media-dev.c  |   4 +-
 drivers/media/platform/pxa_camera.c|  10 +-
 drivers/media/platform/qcom/camss-8x16/camss.c |   2 +-
 drivers/media/platform/rcar-vin/rcar-core.c|   6 +-
 drivers/media/platform/rcar-vin/rcar-dma.c |   4 +-
 drivers/media/platform/rcar_drif.c |   4 +-
 .../platform/soc_camera/sh_mobile_ceu_camera.c |   2 +-
 drivers/media/platform/soc_camera/soc_camera.c |   5 +-
 .../platform/soc_camera/soc_camera_platform.c  |   2 +-
 drivers/media/platform/soc_camera/soc_mediabus.c   |   2 +-
 drivers/media/platform/stm32/stm32-dcmi.c  |   2 +-
 drivers/media/platform/ti-vpe/cal.c|   2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c|   2 +-
 drivers/media/v4l2-core/v4l2-async.c   |  16 +-
 drivers/media/v4l2-core/v4l2-dev.c |  18 +-
 drivers/media/v4l2-core/v4l2-fwnode.c  |  15 +-
 drivers/media/v4l2-core/v4l2-ioctl.c   |   7 +-
 drivers/staging/media/imx/imx-media-dev.c  |   4 +-
 include/media/v4l2-async.h |  33 ++-
 include/media/v4l2-device.h| 246 ++---
 include/media/v4l2-fwnode.h|   4 +-
 include/media/v4l2-ioctl.h |  33 +--
 include/media/v4l2-mediabus.h  | 145 
 include/media/v4l2-subdev.h| 143 +---
 45 files changed, 632 insertions(+), 265 deletions(-)

-- 
2.14.3


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


[PATCH 3/8] media: v4l2-async: simplify v4l2_async_subdev structure

2017-12-18 Thread Mauro Carvalho Chehab
The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
match criteria requires just a device name.

So, it doesn't make sense to enclose those into structs,
as the criteria can go directly into the union.

That makes easier to document it, as we don't need to document
weird senseless structs.

At drivers, this makes even clearer about the match criteria.

Acked-by: Sylwester Nawrocki 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/platform/am437x/am437x-vpfe.c|  6 +++---
 drivers/media/platform/atmel/atmel-isc.c   |  2 +-
 drivers/media/platform/atmel/atmel-isi.c   |  2 +-
 drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
 drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
 drivers/media/platform/pxa_camera.c|  2 +-
 drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
 drivers/media/platform/rcar-vin/rcar-core.c|  2 +-
 drivers/media/platform/rcar_drif.c |  4 ++--
 drivers/media/platform/soc_camera/soc_camera.c |  2 +-
 drivers/media/platform/stm32/stm32-dcmi.c  |  2 +-
 drivers/media/platform/ti-vpe/cal.c|  2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c|  2 +-
 drivers/media/v4l2-core/v4l2-async.c   | 16 
 drivers/media/v4l2-core/v4l2-fwnode.c  | 10 +-
 drivers/staging/media/imx/imx-media-dev.c  |  4 ++--
 include/media/v4l2-async.h |  8 ++--
 17 files changed, 35 insertions(+), 39 deletions(-)

diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
b/drivers/media/platform/am437x/am437x-vpfe.c
index 0997c640191d..601ae6487617 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
 
for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
-   if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
-   asd[i].match.fwnode.fwnode) {
+   if (vpfe->cfg->asd[i]->match.fwnode ==
+   asd[i].match.fwnode) {
sdinfo = &vpfe->cfg->sub_devs[i];
vpfe->sd[i] = subdev;
vpfe->sd[i]->grp_id = sdinfo->grp_id;
@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
}
 
pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
-   pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
+   pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
of_node_put(rem);
}
 
diff --git a/drivers/media/platform/atmel/atmel-isc.c 
b/drivers/media/platform/atmel/atmel-isc.c
index 0c2635647f69..34676409ca08 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
 
subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-   subdev_entity->asd->match.fwnode.fwnode =
+   subdev_entity->asd->match.fwnode =
of_fwnode_handle(rem);
list_add_tail(&subdev_entity->list, &isc->subdev_entities);
}
diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index e900995143a3..9958918e2449 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct 
device_node *node)
/* Remote node to connect */
isi->entity.node = remote;
isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-   isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
+   isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
return 0;
}
 }
diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index e45916f69def..e1c273c8b9a6 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier 
*notifier,
 
for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
-   const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
+   const struct fwnode_handle *fwnode = _asd->match.fwnode;
 
if (fwnode == subdev->fwnode) {
vpif_obj.sd[i] = subdev;
@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
}
 
pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;

Re: [PATCH 3/8] media: v4l2-async: simplify v4l2_async_subdev structure

2017-12-18 Thread Benoit Parrot
For am437x/am437x-vpfe.c & ti-vpe/cal.c

Acked-by: Benoit Parrot 

Mauro Carvalho Chehab  wrote on Mon [2017-Dec-18 
17:53:57 -0200]:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 
> Acked-by: Sylwester Nawrocki 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c|  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c   |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c   |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c|  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c|  2 +-
>  drivers/media/platform/rcar_drif.c |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c  |  2 +-
>  drivers/media/platform/ti-vpe/cal.c|  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c|  2 +-
>  drivers/media/v4l2-core/v4l2-async.c   | 16 
>  drivers/media/v4l2-core/v4l2-fwnode.c  | 10 +-
>  drivers/staging/media/imx/imx-media-dev.c  |  4 ++--
>  include/media/v4l2-async.h |  8 ++--
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
>   vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
>  
>   for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> - if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> - asd[i].match.fwnode.fwnode) {
> + if (vpfe->cfg->asd[i]->match.fwnode ==
> + asd[i].match.fwnode) {
>   sdinfo = &vpfe->cfg->sub_devs[i];
>   vpfe->sd[i] = subdev;
>   vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>   }
>  
>   pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> - pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> + pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>   of_node_put(rem);
>   }
>  
> diff --git a/drivers/media/platform/atmel/atmel-isc.c 
> b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct 
> isc_device *isc)
>   subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
>  
>   subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> - subdev_entity->asd->match.fwnode.fwnode =
> + subdev_entity->asd->match.fwnode =
>   of_fwnode_handle(rem);
>   list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>   }
> diff --git a/drivers/media/platform/atmel/atmel-isi.c 
> b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, 
> struct device_node *node)
>   /* Remote node to connect */
>   isi->entity.node = remote;
>   isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> - isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> + isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>   return 0;
>   }
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c 
> b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier 
> *notifier,
>  
>   for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>   struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> - const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
> + const struct fwnode_handle *fwnode = _asd->match.

[PATCH 0/5] staging: rtl8712: fix several checkpatch style issues

2017-12-18 Thread Martin Homuth
This patch series fixes some coding style issues reported by checkpatch.pl.

It is based on next-20171218

Martin Homuth (5):
  staging: rtl8712: style fix over 80 characters warnings
  staging: rtl8712: style fix multiple line dereferences
  staging: rtl8712: style fix indentation
  staging: rtl8712: style fix unneeded else
  staging: rtl8712: style fix returned error code

 drivers/staging/rtl8712/ieee80211.c   |  6 ++-
 drivers/staging/rtl8712/os_intfs.c|  5 +-
 drivers/staging/rtl8712/rtl8712_cmd.c | 18 ---
 drivers/staging/rtl8712/rtl8712_recv.c|  8 +--
 drivers/staging/rtl8712/rtl8712_xmit.c|  3 +-
 drivers/staging/rtl8712/rtl871x_cmd.c | 36 +++---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 72
++-
 drivers/staging/rtl8712/rtl871x_ioctl_set.c   | 72
+--
 drivers/staging/rtl8712/rtl871x_mlme.c|  6 +--
 drivers/staging/rtl8712/rtl871x_mlme.h|  3 +-
 drivers/staging/rtl8712/rtl871x_security.c| 37 +++---
 drivers/staging/rtl8712/usb_ops_linux.c   |  2 +-
 12 files changed, 140 insertions(+), 128 deletions(-)

-- 
2.15.1

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


[PATCH 1/5] staging: rtl8712: style fix over 80 characters warnings

2017-12-18 Thread Martin Homuth
This patch fixes various coding style issues in the rtl8712 module as
noted by checkpatch.pl by reducing the characters per line to under
80.

It fixes the following checkpatch.pl warning:

WARNING: line over 80 characters

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/ieee80211.c|  6 --
 drivers/staging/rtl8712/os_intfs.c |  5 -
 drivers/staging/rtl8712/rtl8712_cmd.c  | 18 ++
 drivers/staging/rtl8712/rtl8712_xmit.c |  3 ++-
 drivers/staging/rtl8712/rtl871x_mlme.h |  3 ++-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8712/ieee80211.c
b/drivers/staging/rtl8712/ieee80211.c
index 33e82a9dd462..987270395635 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -169,12 +169,13 @@ int r8712_generate_ie(struct registry_priv
*pregistrypriv)
int sz = 0, rate_len;
struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
u8 *ie = pdev_network->IEs;
+   u16 beaconPeriod = (u16)pdev_network->Configuration.BeaconPeriod;

/*timestamp will be inserted by hardware*/
sz += 8;
ie += sz;
/*beacon interval : 2bytes*/
-   *(__le16 *)ie =
cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
+   *(__le16 *)ie = cpu_to_le16(beaconPeriod);
sz += 2;
ie += 2;
/*capability info*/
@@ -221,7 +222,8 @@ unsigned char *r8712_get_wpa_ie(unsigned char *pie,
int *wpa_ie_len, int limit)
pbuf = r8712_get_ie(pbuf, _WPA_IE_ID_, &len, limit);
if (pbuf) {
/*check if oui matches...*/
-   if (memcmp((pbuf + 2), wpa_oui_type, 
sizeof(wpa_oui_type)))
+   if (memcmp((pbuf + 2), wpa_oui_type,
+  sizeof(wpa_oui_type)))
goto check_next_ie;
/*check version...*/
memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
diff --git a/drivers/staging/rtl8712/os_intfs.c
b/drivers/staging/rtl8712/os_intfs.c
index 95caf8df9a13..e7df5d7986fc 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -238,10 +238,13 @@ static u32 start_drv_threads(struct _adapter
*padapter)

 void r8712_stop_drv_threads(struct _adapter *padapter)
 {
+   struct completion *completion =
+   &padapter->cmdpriv.terminate_cmdthread_comp;
+
/*Below is to terminate r8712_cmd_thread & event_thread...*/
complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
-   
wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
+   wait_for_completion_interruptible(completion);
padapter->cmdpriv.cmd_seq = 1;
 }

diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c
b/drivers/staging/rtl8712/rtl8712_cmd.c
index 3c88994fdfcd..9c8e0c50a804 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -321,10 +321,13 @@ int r8712_cmd_thread(void *context)
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct _adapter *padapter = context;
struct  cmd_priv*pcmdpriv = &(padapter->cmdpriv);
+   struct completion *cmd_queue_comp =
+   &pcmdpriv->cmd_queue_comp;
+   struct mutex *pwctrl_lock = &padapter->pwrctrlpriv.mutex_lock;

allow_signal(SIGTERM);
while (1) {
-   if 
(wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
+   if (wait_for_completion_interruptible(cmd_queue_comp))
break;
if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
break;
@@ -343,6 +346,7 @@ int r8712_cmd_thread(void *context)
if (pcmd) { /* if pcmd != NULL, cmd will be handled by f/w */
struct dvobj_priv *pdvobj = &padapter->dvobjpriv;
u8 blnPending = 0;
+   u16 cmdcode = pcmd->cmdcode;

pcmdpriv->cmd_issued_cnt++;
cmdsz = round_up(pcmd->cmdsz, 8);
@@ -387,20 +391,18 @@ int r8712_cmd_thread(void *context)
r8712_write_mem(padapter, RTL8712_DMA_H2CCMD, wr_sz,
(u8 *)pdesc);
pcmdpriv->cmd_seq++;
-   if (pcmd->cmdcode == GEN_CMD_CODE(_CreateBss)) {
+   if (cmdcode == GEN_CMD_CODE(_CreateBss)) {
pcmd->res = H2C_SUCCESS;
-   pcmd_callback = cmd_callback[pcmd->
-   cmdcode].callback;
+   pcmd_callback = cmd_callback[cmdcode].callback;
if (pcmd_callback)
pcmd_callback(padapter, pcmd);
   

[PATCH 3/5] staging: rtl8712: style fix indentation

2017-12-18 Thread Martin Homuth
This patch fixes various coding style issues in the rtl8712 module as
noted by checkpatch.pl related to indentation.

It fixes the following checkpatch.pl warning:

WARNING: suspect code indent for conditional statements

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 12 ++--
 drivers/staging/rtl8712/rtl871x_security.c| 12 ++--
 drivers/staging/rtl8712/usb_ops_linux.c   |  2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index e339d3ff479e..08b8b396abd2 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1723,12 +1723,12 @@ static int r871x_wx_set_auth(struct net_device *dev,
 */
if (padapter->securitypriv.ndisencryptstatus ==
Ndis802_11Encryption1Enabled) {
-   /* it means init value, or using wep,
-* ndisencryptstatus =
-*  Ndis802_11Encryption1Enabled,
-* then it needn't reset it;
-*/
-   break;
+   /* it means init value, or using wep,
+* ndisencryptstatus =
+*  Ndis802_11Encryption1Enabled,
+* then it needn't reset it;
+*/
+   break;
}

if (paramval) {
diff --git a/drivers/staging/rtl8712/rtl871x_security.c
b/drivers/staging/rtl8712/rtl871x_security.c
index 4cea9bacb8e2..75d86998fd58 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -1069,16 +1069,16 @@ static sint aes_cipher(u8 *key, uinthdrlen,
if ((frtype == WIFI_DATA_CFACK) ||
 (frtype == WIFI_DATA_CFPOLL) ||
 (frtype == WIFI_DATA_CFACKPOLL)) {
-   qc_exists = 1;
-   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-   hdrlen += 2;
+   qc_exists = 1;
+   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
+   hdrlen += 2;
} else if ((frsubtype == 0x08) ||
   (frsubtype == 0x09) ||
   (frsubtype == 0x0a) ||
   (frsubtype == 0x0b)) {
-   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-   hdrlen += 2;
-   qc_exists = 1;
+   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
+   hdrlen += 2;
+   qc_exists = 1;
} else {
qc_exists = 0;
}
diff --git a/drivers/staging/rtl8712/usb_ops_linux.c
b/drivers/staging/rtl8712/usb_ops_linux.c
index 441e76b8959d..6d12a96fa65f 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -145,7 +145,7 @@ static unsigned int ffaddr2pipehdl(struct dvobj_priv
*pdvobj, u32 addr)
break;
}
} else {
-  pipe = 0;
+   pipe = 0;
}
return pipe;
 }
-- 
2.15.1

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


[PATCH 4/5] staging: rtl8712: style fix unneeded else

2017-12-18 Thread Martin Homuth
This patch fixes a coding style issues in the rtl8712 module as noted
by checkpatch.pl where an unnecessary else is used.

It fixes the following checkpatch.pl warning:

WARNING: else is not generally useful after a break or return

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl871x_ioctl_set.c | 72
++---
 1 file changed, 35 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index 8a5ced4fa9d3..f4a53df7f2c1 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -55,6 +55,7 @@ static u8 do_join(struct _adapter *padapter)
u8 *pibss = NULL;
struct  mlme_priv   *pmlmepriv = &(padapter->mlmepriv);
struct  __queue *queue  = &(pmlmepriv->scanned_queue);
+   int ret;

phead = &queue->queue;
plist = phead->next;
@@ -74,45 +75,42 @@ static u8 do_join(struct _adapter *padapter)
if (!pmlmepriv->sitesurveyctrl.traffic_busy)
r8712_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid);
return true;
-   } else {
-   int ret;
+   }

-   ret = r8712_select_and_join_from_scan(pmlmepriv);
-   if (ret == _SUCCESS) {
-   mod_timer(&pmlmepriv->assoc_timer,
- jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
+   ret = r8712_select_and_join_from_scan(pmlmepriv);
+   if (ret == _SUCCESS) {
+   mod_timer(&pmlmepriv->assoc_timer,
+ jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
+   } else {
+   if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
+   /* submit r8712_createbss_cmd to change to an
+* ADHOC_MASTER pmlmepriv->lock has been
+* acquired by caller...
+*/
+   struct wlan_bssid_ex *pdev_network =
+   &(padapter->registrypriv.dev_network);
+   pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
+   pibss = padapter->registrypriv.dev_network.MacAddress;
+   memcpy(&pdev_network->Ssid,
+  &pmlmepriv->assoc_ssid,
+  sizeof(struct ndis_802_11_ssid));
+   r8712_update_registrypriv_dev_network(padapter);
+   r8712_generate_random_ibss(pibss);
+   if (r8712_createbss_cmd(padapter) != _SUCCESS)
+   return false;
+   pmlmepriv->to_join = false;
} else {
-   if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-   /* submit r8712_createbss_cmd to change to an
-* ADHOC_MASTER pmlmepriv->lock has been
-* acquired by caller...
-*/
-   struct wlan_bssid_ex *pdev_network =
-   &(padapter->registrypriv.dev_network);
-   pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
-   pibss = padapter->registrypriv.dev_network.
-   MacAddress;
-   memcpy(&pdev_network->Ssid,
-   &pmlmepriv->assoc_ssid,
-   sizeof(struct ndis_802_11_ssid));
-   r8712_update_registrypriv_dev_network(padapter);
-   r8712_generate_random_ibss(pibss);
-   if (r8712_createbss_cmd(padapter) != _SUCCESS)
-   return false;
-   pmlmepriv->to_join = false;
-   } else {
-   /* can't associate ; reset under-linking */
-   if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
-   pmlmepriv->fw_state ^=
-_FW_UNDER_LINKING;
-   /* when set_ssid/set_bssid for do_join(), but
-* there are no desired bss in scanning queue
-* we try to issue sitesurvey first
-*/
-   if (!pmlmepriv->sitesurveyctrl.traffic_busy)
-   r8712_sitesurvey_cmd(padapter,
-  &pmlmepriv->assoc_ssid);
-   }
+   /* can't associate ; reset under-linking */
+   if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
+   pmlmepriv->fw_

[PATCH 2/5] staging: rtl8712: style fix multiple line dereferences

2017-12-18 Thread Martin Homuth
This patch fixes various coding style issues in the rtl8712 module as
noted by checkpatch.pl related to dereferencing over multiple lines.

It fixes the following checkpatch.pl warning:

WARNING: Avoid multiple line dereference - prefer %s

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl8712_recv.c|  8 ++--
 drivers/staging/rtl8712/rtl871x_cmd.c | 36 -
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 58
++-
 drivers/staging/rtl8712/rtl871x_mlme.c|  6 +--
 drivers/staging/rtl8712/rtl871x_security.c| 25 ++--
 5 files changed, 69 insertions(+), 64 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c
b/drivers/staging/rtl8712/rtl8712_recv.c
index 8f555e6e1b3f..8395b90d60b6 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -918,8 +918,8 @@ static void process_link_qual(struct _adapter *padapter,
}
padapter->recvpriv.signal_qual_data.total_val +=
  pattrib->signal_qual;
-   padapter->recvpriv.signal_qual_data.elements[padapter->
- recvpriv.signal_qual_data.index++] =
+   padapter->recvpriv.signal_qual_data.elements
+   [padapter->recvpriv.signal_qual_data.index++] =
  pattrib->signal_qual;
if (padapter->recvpriv.signal_qual_data.index >=
PHY_LINKQUALITY_SLID_WIN_MAX)
@@ -947,8 +947,8 @@ static void process_rssi(struct _adapter *padapter,
union recv_frame *prframe)
}
padapter->recvpriv.signal_strength_data.total_val +=
pattrib->signal_strength;
-   padapter->recvpriv.signal_strength_data.elements[padapter->recvpriv.
-   signal_strength_data.index++] =
+   padapter->recvpriv.signal_strength_data.elements
+   [padapter->recvpriv.signal_strength_data.index++] =
pattrib->signal_strength;
if (padapter->recvpriv.signal_strength_data.index >=
PHY_RSSI_SLID_WIN_MAX)
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c
b/drivers/staging/rtl8712/rtl871x_cmd.c
index a424f447a725..620cee8b8514 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -455,8 +455,8 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter,
struct wlan_network *pnetwork)
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
struct security_priv*psecuritypriv = &padapter->securitypriv;
struct registry_priv*pregistrypriv = &padapter->registrypriv;
-   enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork->
-   network.InfrastructureMode;
+   enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode =
+   pnetwork->network.InfrastructureMode;

padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
@@ -862,22 +862,22 @@ void r8712_createbss_cmd_callback(struct _adapter
*padapter,
pnetwork->Privacy = le32_to_cpu(pnetwork->Privacy);
pnetwork->Rssi = le32_to_cpu(pnetwork->Rssi);
pnetwork->NetworkTypeInUse = le32_to_cpu(pnetwork->NetworkTypeInUse);
-   pnetwork->Configuration.ATIMWindow = le32_to_cpu(pnetwork->
-   Configuration.ATIMWindow);
-   pnetwork->Configuration.DSConfig = le32_to_cpu(pnetwork->
-   Configuration.DSConfig);
-   pnetwork->Configuration.FHConfig.DwellTime = le32_to_cpu(pnetwork->
-   Configuration.FHConfig.DwellTime);
-   pnetwork->Configuration.FHConfig.HopPattern = le32_to_cpu(pnetwork->
-   Configuration.FHConfig.HopPattern);
-   pnetwork->Configuration.FHConfig.HopSet = le32_to_cpu(pnetwork->
-   Configuration.FHConfig.HopSet);
-   pnetwork->Configuration.FHConfig.Length = le32_to_cpu(pnetwork->
-   Configuration.FHConfig.Length);
-   pnetwork->Configuration.Length = le32_to_cpu(pnetwork->
-   Configuration.Length);
-   pnetwork->InfrastructureMode = le32_to_cpu(pnetwork->
-  InfrastructureMode);
+   pnetwork->Configuration.ATIMWindow =
+   le32_to_cpu(pnetwork->Configuration.ATIMWindow);
+   pnetwork->Configuration.DSConfig =
+   le32_to_cpu(pnetwork->Configuration.DSConfig);
+   pnetwork->Configuration.FHConfig.DwellTime =
+   le32_to_cpu(pnetwork->Configuration.FHConfig.DwellTime);
+   pnetwork->Configuration.FHConfig.HopPattern =
+   le32_to_cpu(pnetwork->Configuration.FHConfig.HopPattern);
+   pnetwork->Configuration.FHConfig.HopSet =
+ 

[PATCH 5/5] staging: rtl8712: style fix returned error code

2017-12-18 Thread Martin Homuth
This patch fixes a coding style issues in the rtl8712 module as noted
by checkpatch.pl regarding the returned error code.

It fixes the following checkpatch.pl warning:

WARNING: ENOSYS means 'invalid syscall nr' and nothing else

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 08b8b396abd2..ba5f08f1247e 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1857,7 +1857,7 @@ static int dummy(struct net_device *dev,
struct iw_request_info *a,
union iwreq_data *wrqu, char *b)
 {
-   return -ENOSYS;
+   return -EINVAL;
 }

 static int r8711_drvext_hdl(struct net_device *dev,
-- 
2.15.1

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


Re: [PATCH 3/8] media: v4l2-async: simplify v4l2_async_subdev structure

2017-12-18 Thread Alexandre Belloni
On 18/12/2017 at 17:53:57 -0200, Mauro Carvalho Chehab wrote:
> The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one
> struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME
> match criteria requires just a device name.
> 
> So, it doesn't make sense to enclose those into structs,
> as the criteria can go directly into the union.
> 
> That makes easier to document it, as we don't need to document
> weird senseless structs.
> 
> At drivers, this makes even clearer about the match criteria.
> 

For atmel:
Acked-by: Alexandre Belloni 

> Acked-by: Sylwester Nawrocki 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  drivers/media/platform/am437x/am437x-vpfe.c|  6 +++---
>  drivers/media/platform/atmel/atmel-isc.c   |  2 +-
>  drivers/media/platform/atmel/atmel-isi.c   |  2 +-
>  drivers/media/platform/davinci/vpif_capture.c  |  4 ++--
>  drivers/media/platform/exynos4-is/media-dev.c  |  4 ++--
>  drivers/media/platform/pxa_camera.c|  2 +-
>  drivers/media/platform/qcom/camss-8x16/camss.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c|  2 +-
>  drivers/media/platform/rcar_drif.c |  4 ++--
>  drivers/media/platform/soc_camera/soc_camera.c |  2 +-
>  drivers/media/platform/stm32/stm32-dcmi.c  |  2 +-
>  drivers/media/platform/ti-vpe/cal.c|  2 +-
>  drivers/media/platform/xilinx/xilinx-vipp.c|  2 +-
>  drivers/media/v4l2-core/v4l2-async.c   | 16 
>  drivers/media/v4l2-core/v4l2-fwnode.c  | 10 +-
>  drivers/staging/media/imx/imx-media-dev.c  |  4 ++--
>  include/media/v4l2-async.h |  8 ++--
>  17 files changed, 35 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 0997c640191d..601ae6487617 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,
>   vpfe_dbg(1, vpfe, "vpfe_async_bound\n");
>  
>   for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) {
> - if (vpfe->cfg->asd[i]->match.fwnode.fwnode ==
> - asd[i].match.fwnode.fwnode) {
> + if (vpfe->cfg->asd[i]->match.fwnode ==
> + asd[i].match.fwnode) {
>   sdinfo = &vpfe->cfg->sub_devs[i];
>   vpfe->sd[i] = subdev;
>   vpfe->sd[i]->grp_id = sdinfo->grp_id;
> @@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev)
>   }
>  
>   pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_FWNODE;
> - pdata->asd[i]->match.fwnode.fwnode = of_fwnode_handle(rem);
> + pdata->asd[i]->match.fwnode = of_fwnode_handle(rem);
>   of_node_put(rem);
>   }
>  
> diff --git a/drivers/media/platform/atmel/atmel-isc.c 
> b/drivers/media/platform/atmel/atmel-isc.c
> index 0c2635647f69..34676409ca08 100644
> --- a/drivers/media/platform/atmel/atmel-isc.c
> +++ b/drivers/media/platform/atmel/atmel-isc.c
> @@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct 
> isc_device *isc)
>   subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW;
>  
>   subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> - subdev_entity->asd->match.fwnode.fwnode =
> + subdev_entity->asd->match.fwnode =
>   of_fwnode_handle(rem);
>   list_add_tail(&subdev_entity->list, &isc->subdev_entities);
>   }
> diff --git a/drivers/media/platform/atmel/atmel-isi.c 
> b/drivers/media/platform/atmel/atmel-isi.c
> index e900995143a3..9958918e2449 100644
> --- a/drivers/media/platform/atmel/atmel-isi.c
> +++ b/drivers/media/platform/atmel/atmel-isi.c
> @@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, 
> struct device_node *node)
>   /* Remote node to connect */
>   isi->entity.node = remote;
>   isi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> - isi->entity.asd.match.fwnode.fwnode = of_fwnode_handle(remote);
> + isi->entity.asd.match.fwnode = of_fwnode_handle(remote);
>   return 0;
>   }
>  }
> diff --git a/drivers/media/platform/davinci/vpif_capture.c 
> b/drivers/media/platform/davinci/vpif_capture.c
> index e45916f69def..e1c273c8b9a6 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier 
> *notifier,
>  
>   for (i = 0; i < vpif_obj.config->asd_sizes[0]; i++) {
>   struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i];
> - const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode;
> + const struct fwnode_handle *fwnode = _asd->match.fwnode;
>  
>   if

[PATCH] hv: Synthetic typo correction

2017-12-18 Thread Joe Perches
Just a trivial tyop fix.

Signed-off-by: Joe Perches 
---
 drivers/hv/hv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 8267439dd1ee..8ae587b2ac26 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -220,7 +220,7 @@ void hv_synic_free(void)
 }
 
 /*
- * hv_synic_init - Initialize the Synthethic Interrupt Controller.
+ * hv_synic_init - Initialize the Synthetic Interrupt Controller.
  *
  * If it is already initialized by another entity (ie x2v shim), we need to
  * retrieve the initialized message and event pages.  Otherwise, we create and
-- 
2.15.0

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


[PATCH v2 0/5] staging: rtl8712: fix several checkpatch style issues

2017-12-18 Thread Martin Homuth
This patch series fixes some coding style issues reported by checkpatch.pl.

It is based on next-20171218

v2:
 - avoid line-wrapping by thunderbird
 - use temporary pointers to avoid index in separate line ([2/5])

Martin Homuth (5):
  staging: rtl8712: style fix over 80 characters warnings
  staging: rtl8712: style fix multiple line dereferences
  staging: rtl8712: style fix indentation
  staging: rtl8712: style fix unneeded else
  staging: rtl8712: style fix returned error code

 drivers/staging/rtl8712/ieee80211.c   |  6 ++-
 drivers/staging/rtl8712/os_intfs.c|  5 +-
 drivers/staging/rtl8712/rtl8712_cmd.c | 18 ---
 drivers/staging/rtl8712/rtl8712_recv.c| 14 +++--
 drivers/staging/rtl8712/rtl8712_xmit.c|  3 +-
 drivers/staging/rtl8712/rtl871x_cmd.c | 36 ++---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 75 ++-
 drivers/staging/rtl8712/rtl871x_ioctl_set.c   | 72 +
 drivers/staging/rtl8712/rtl871x_mlme.c|  9 ++--
 drivers/staging/rtl8712/rtl871x_mlme.h|  3 +-
 drivers/staging/rtl8712/rtl871x_security.c| 37 ++---
 drivers/staging/rtl8712/usb_ops_linux.c   |  2 +-
 12 files changed, 143 insertions(+), 137 deletions(-)

-- 
2.15.1

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


[PATCH v2 2/5] staging: rtl8712: style fix multiple line dereferences

2017-12-18 Thread Martin Homuth
This patch fixes various coding style issues in the rtl8712 module as
noted by checkpatch.pl related to dereferencing over multiple lines.

It fixes the following checkpatch.pl warning:

WARNING: Avoid multiple line dereference - prefer %s

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl8712_recv.c| 14 +++---
 drivers/staging/rtl8712/rtl871x_cmd.c | 36 
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 61 ++-
 drivers/staging/rtl8712/rtl871x_mlme.c|  9 ++--
 drivers/staging/rtl8712/rtl871x_security.c| 25 +--
 5 files changed, 72 insertions(+), 73 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c 
b/drivers/staging/rtl8712/rtl8712_recv.c
index 8f555e6e1b3f..7665c00b2485 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -899,6 +899,7 @@ static void process_link_qual(struct _adapter *padapter,
 {
u32 last_evm = 0, tmpVal;
struct rx_pkt_attrib *pattrib;
+   struct smooth_rssi_data *sqd = &padapter->recvpriv.signal_qual_data;
 
if (prframe == NULL || padapter == NULL)
return;
@@ -918,9 +919,8 @@ static void process_link_qual(struct _adapter *padapter,
}
padapter->recvpriv.signal_qual_data.total_val +=
  pattrib->signal_qual;
-   padapter->recvpriv.signal_qual_data.elements[padapter->
- recvpriv.signal_qual_data.index++] =
- pattrib->signal_qual;
+   padapter->recvpriv.signal_qual_data.elements[sqd->index++] =
+   pattrib->signal_qual;
if (padapter->recvpriv.signal_qual_data.index >=
PHY_LINKQUALITY_SLID_WIN_MAX)
padapter->recvpriv.signal_qual_data.index = 0;
@@ -936,20 +936,18 @@ static void process_rssi(struct _adapter *padapter, union 
recv_frame *prframe)
 {
u32 last_rssi, tmp_val;
struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
+   struct smooth_rssi_data *ssd = &padapter->recvpriv.signal_strength_data;
 
if (padapter->recvpriv.signal_strength_data.total_num++ >=
PHY_RSSI_SLID_WIN_MAX) {
padapter->recvpriv.signal_strength_data.total_num =
 PHY_RSSI_SLID_WIN_MAX;
-   last_rssi = padapter->recvpriv.signal_strength_data.elements
-   [padapter->recvpriv.signal_strength_data.index];
+   last_rssi = ssd->elements[ssd->index];
padapter->recvpriv.signal_strength_data.total_val -= last_rssi;
}
padapter->recvpriv.signal_strength_data.total_val +=
pattrib->signal_strength;
-   padapter->recvpriv.signal_strength_data.elements[padapter->recvpriv.
-   signal_strength_data.index++] =
-   pattrib->signal_strength;
+   ssd->elements[ssd->index++] = pattrib->signal_strength;
if (padapter->recvpriv.signal_strength_data.index >=
PHY_RSSI_SLID_WIN_MAX)
padapter->recvpriv.signal_strength_data.index = 0;
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
b/drivers/staging/rtl8712/rtl871x_cmd.c
index a424f447a725..620cee8b8514 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -455,8 +455,8 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct 
wlan_network *pnetwork)
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
struct security_priv*psecuritypriv = &padapter->securitypriv;
struct registry_priv*pregistrypriv = &padapter->registrypriv;
-   enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork->
-   network.InfrastructureMode;
+   enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode =
+   pnetwork->network.InfrastructureMode;
 
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
@@ -862,22 +862,22 @@ void r8712_createbss_cmd_callback(struct _adapter 
*padapter,
pnetwork->Privacy = le32_to_cpu(pnetwork->Privacy);
pnetwork->Rssi = le32_to_cpu(pnetwork->Rssi);
pnetwork->NetworkTypeInUse = le32_to_cpu(pnetwork->NetworkTypeInUse);
-   pnetwork->Configuration.ATIMWindow = le32_to_cpu(pnetwork->
-   Configuration.ATIMWindow);
-   pnetwork->Configuration.DSConfig = le32_to_cpu(pnetwork->
-   Configuration.DSConfig);
-   pnetwork->Configuration.FHConfig.DwellTime = le32_to_cpu(pnetwork->
-   Configuration.FHConfig.DwellTime);
-   pnetwork->Configuration.FHConfig.HopPattern = le32_to_cpu(pnetwork->
-   Configuration.FHConfig.HopPattern

[PATCH v2 1/5] staging: rtl8712: style fix over 80 characters warnings

2017-12-18 Thread Martin Homuth
This patch fixes various coding style issues in the rtl8712 module as
noted by checkpatch.pl by reducing the characters per line to under
80.

It fixes the following checkpatch.pl warning:

WARNING: line over 80 characters

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/ieee80211.c|  6 --
 drivers/staging/rtl8712/os_intfs.c |  5 -
 drivers/staging/rtl8712/rtl8712_cmd.c  | 18 ++
 drivers/staging/rtl8712/rtl8712_xmit.c |  3 ++-
 drivers/staging/rtl8712/rtl871x_mlme.h |  3 ++-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8712/ieee80211.c 
b/drivers/staging/rtl8712/ieee80211.c
index 33e82a9dd462..987270395635 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -169,12 +169,13 @@ int r8712_generate_ie(struct registry_priv *pregistrypriv)
int sz = 0, rate_len;
struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
u8 *ie = pdev_network->IEs;
+   u16 beaconPeriod = (u16)pdev_network->Configuration.BeaconPeriod;
 
/*timestamp will be inserted by hardware*/
sz += 8;
ie += sz;
/*beacon interval : 2bytes*/
-   *(__le16 *)ie = 
cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
+   *(__le16 *)ie = cpu_to_le16(beaconPeriod);
sz += 2;
ie += 2;
/*capability info*/
@@ -221,7 +222,8 @@ unsigned char *r8712_get_wpa_ie(unsigned char *pie, int 
*wpa_ie_len, int limit)
pbuf = r8712_get_ie(pbuf, _WPA_IE_ID_, &len, limit);
if (pbuf) {
/*check if oui matches...*/
-   if (memcmp((pbuf + 2), wpa_oui_type, 
sizeof(wpa_oui_type)))
+   if (memcmp((pbuf + 2), wpa_oui_type,
+  sizeof(wpa_oui_type)))
goto check_next_ie;
/*check version...*/
memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
diff --git a/drivers/staging/rtl8712/os_intfs.c 
b/drivers/staging/rtl8712/os_intfs.c
index 95caf8df9a13..e7df5d7986fc 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -238,10 +238,13 @@ static u32 start_drv_threads(struct _adapter *padapter)
 
 void r8712_stop_drv_threads(struct _adapter *padapter)
 {
+   struct completion *completion =
+   &padapter->cmdpriv.terminate_cmdthread_comp;
+
/*Below is to terminate r8712_cmd_thread & event_thread...*/
complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
-   
wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
+   wait_for_completion_interruptible(completion);
padapter->cmdpriv.cmd_seq = 1;
 }
 
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c 
b/drivers/staging/rtl8712/rtl8712_cmd.c
index 3c88994fdfcd..9c8e0c50a804 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -321,10 +321,13 @@ int r8712_cmd_thread(void *context)
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct _adapter *padapter = context;
struct  cmd_priv*pcmdpriv = &(padapter->cmdpriv);
+   struct completion *cmd_queue_comp =
+   &pcmdpriv->cmd_queue_comp;
+   struct mutex *pwctrl_lock = &padapter->pwrctrlpriv.mutex_lock;
 
allow_signal(SIGTERM);
while (1) {
-   if 
(wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
+   if (wait_for_completion_interruptible(cmd_queue_comp))
break;
if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
break;
@@ -343,6 +346,7 @@ int r8712_cmd_thread(void *context)
if (pcmd) { /* if pcmd != NULL, cmd will be handled by f/w */
struct dvobj_priv *pdvobj = &padapter->dvobjpriv;
u8 blnPending = 0;
+   u16 cmdcode = pcmd->cmdcode;
 
pcmdpriv->cmd_issued_cnt++;
cmdsz = round_up(pcmd->cmdsz, 8);
@@ -387,20 +391,18 @@ int r8712_cmd_thread(void *context)
r8712_write_mem(padapter, RTL8712_DMA_H2CCMD, wr_sz,
(u8 *)pdesc);
pcmdpriv->cmd_seq++;
-   if (pcmd->cmdcode == GEN_CMD_CODE(_CreateBss)) {
+   if (cmdcode == GEN_CMD_CODE(_CreateBss)) {
pcmd->res = H2C_SUCCESS;
-   pcmd_callback = cmd_callback[pcmd->
-   cmdcode].callback;
+   pcmd_callback = cmd_callback[cmdcode].callback;
if (pcmd_callback)
pcmd_callback(padapter, pcmd);
 

[PATCH v2 4/5] staging: rtl8712: style fix unneeded else

2017-12-18 Thread Martin Homuth
This patch fixes a coding style issues in the rtl8712 module as noted
by checkpatch.pl where an unnecessary else is used.

It fixes the following checkpatch.pl warning:

WARNING: else is not generally useful after a break or return

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl871x_ioctl_set.c | 72 ++---
 1 file changed, 35 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index 8a5ced4fa9d3..f4a53df7f2c1 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -55,6 +55,7 @@ static u8 do_join(struct _adapter *padapter)
u8 *pibss = NULL;
struct  mlme_priv   *pmlmepriv = &(padapter->mlmepriv);
struct  __queue *queue  = &(pmlmepriv->scanned_queue);
+   int ret;
 
phead = &queue->queue;
plist = phead->next;
@@ -74,45 +75,42 @@ static u8 do_join(struct _adapter *padapter)
if (!pmlmepriv->sitesurveyctrl.traffic_busy)
r8712_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid);
return true;
-   } else {
-   int ret;
+   }
 
-   ret = r8712_select_and_join_from_scan(pmlmepriv);
-   if (ret == _SUCCESS) {
-   mod_timer(&pmlmepriv->assoc_timer,
- jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
+   ret = r8712_select_and_join_from_scan(pmlmepriv);
+   if (ret == _SUCCESS) {
+   mod_timer(&pmlmepriv->assoc_timer,
+ jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
+   } else {
+   if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
+   /* submit r8712_createbss_cmd to change to an
+* ADHOC_MASTER pmlmepriv->lock has been
+* acquired by caller...
+*/
+   struct wlan_bssid_ex *pdev_network =
+   &(padapter->registrypriv.dev_network);
+   pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
+   pibss = padapter->registrypriv.dev_network.MacAddress;
+   memcpy(&pdev_network->Ssid,
+  &pmlmepriv->assoc_ssid,
+  sizeof(struct ndis_802_11_ssid));
+   r8712_update_registrypriv_dev_network(padapter);
+   r8712_generate_random_ibss(pibss);
+   if (r8712_createbss_cmd(padapter) != _SUCCESS)
+   return false;
+   pmlmepriv->to_join = false;
} else {
-   if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-   /* submit r8712_createbss_cmd to change to an
-* ADHOC_MASTER pmlmepriv->lock has been
-* acquired by caller...
-*/
-   struct wlan_bssid_ex *pdev_network =
-   &(padapter->registrypriv.dev_network);
-   pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
-   pibss = padapter->registrypriv.dev_network.
-   MacAddress;
-   memcpy(&pdev_network->Ssid,
-   &pmlmepriv->assoc_ssid,
-   sizeof(struct ndis_802_11_ssid));
-   r8712_update_registrypriv_dev_network(padapter);
-   r8712_generate_random_ibss(pibss);
-   if (r8712_createbss_cmd(padapter) != _SUCCESS)
-   return false;
-   pmlmepriv->to_join = false;
-   } else {
-   /* can't associate ; reset under-linking */
-   if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
-   pmlmepriv->fw_state ^=
-_FW_UNDER_LINKING;
-   /* when set_ssid/set_bssid for do_join(), but
-* there are no desired bss in scanning queue
-* we try to issue sitesurvey first
-*/
-   if (!pmlmepriv->sitesurveyctrl.traffic_busy)
-   r8712_sitesurvey_cmd(padapter,
-  &pmlmepriv->assoc_ssid);
-   }
+   /* can't associate ; reset under-linking */
+   if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
+   pmlmepriv->

[PATCH v2 3/5] staging: rtl8712: style fix indentation

2017-12-18 Thread Martin Homuth
This patch fixes various coding style issues in the rtl8712 module as
noted by checkpatch.pl related to indentation.

It fixes the following checkpatch.pl warning:

WARNING: suspect code indent for conditional statements

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 12 ++--
 drivers/staging/rtl8712/rtl871x_security.c| 12 ++--
 drivers/staging/rtl8712/usb_ops_linux.c   |  2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 50e6582b9955..2c8b99d48f22 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1722,12 +1722,12 @@ static int r871x_wx_set_auth(struct net_device *dev,
 */
if (padapter->securitypriv.ndisencryptstatus ==
Ndis802_11Encryption1Enabled) {
-   /* it means init value, or using wep,
-* ndisencryptstatus =
-*  Ndis802_11Encryption1Enabled,
-* then it needn't reset it;
-*/
-   break;
+   /* it means init value, or using wep,
+* ndisencryptstatus =
+*  Ndis802_11Encryption1Enabled,
+* then it needn't reset it;
+*/
+   break;
}
 
if (paramval) {
diff --git a/drivers/staging/rtl8712/rtl871x_security.c 
b/drivers/staging/rtl8712/rtl871x_security.c
index 4cea9bacb8e2..75d86998fd58 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -1069,16 +1069,16 @@ static sint aes_cipher(u8 *key, uinthdrlen,
if ((frtype == WIFI_DATA_CFACK) ||
 (frtype == WIFI_DATA_CFPOLL) ||
 (frtype == WIFI_DATA_CFACKPOLL)) {
-   qc_exists = 1;
-   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-   hdrlen += 2;
+   qc_exists = 1;
+   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
+   hdrlen += 2;
} else if ((frsubtype == 0x08) ||
   (frsubtype == 0x09) ||
   (frsubtype == 0x0a) ||
   (frsubtype == 0x0b)) {
-   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
-   hdrlen += 2;
-   qc_exists = 1;
+   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
+   hdrlen += 2;
+   qc_exists = 1;
} else {
qc_exists = 0;
}
diff --git a/drivers/staging/rtl8712/usb_ops_linux.c 
b/drivers/staging/rtl8712/usb_ops_linux.c
index 441e76b8959d..6d12a96fa65f 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -145,7 +145,7 @@ static unsigned int ffaddr2pipehdl(struct dvobj_priv 
*pdvobj, u32 addr)
break;
}
} else {
-  pipe = 0;
+   pipe = 0;
}
return pipe;
 }
-- 
2.15.1

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


[PATCH v2 5/5] staging: rtl8712: style fix returned error code

2017-12-18 Thread Martin Homuth
This patch fixes a coding style issues in the rtl8712 module as noted
by checkpatch.pl regarding the returned error code.

It fixes the following checkpatch.pl warning:

WARNING: ENOSYS means 'invalid syscall nr' and nothing else

Signed-off-by: Martin Homuth 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 2c8b99d48f22..d17b16079778 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1856,7 +1856,7 @@ static int dummy(struct net_device *dev,
struct iw_request_info *a,
union iwreq_data *wrqu, char *b)
 {
-   return -ENOSYS;
+   return -EINVAL;
 }
 
 static int r8711_drvext_hdl(struct net_device *dev,
-- 
2.15.1

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


Re: [PATCH v2 2/5] staging: rtl8712: style fix multiple line dereferences

2017-12-18 Thread Joe Perches
On Tue, 2017-12-19 at 00:18 +0100, Martin Homuth wrote:
> This patch fixes various coding style issues in the rtl8712 module as
> noted by checkpatch.pl related to dereferencing over multiple lines.
[]
> diff --git a/drivers/staging/rtl8712/rtl8712_recv.c 
> b/drivers/staging/rtl8712/rtl8712_recv.c
[]
> @@ -899,6 +899,7 @@ static void process_link_qual(struct _adapter *padapter,
>  {
>   u32 last_evm = 0, tmpVal;
>   struct rx_pkt_attrib *pattrib;
> + struct smooth_rssi_data *sqd = &padapter->recvpriv.signal_qual_data;
>  
>   if (prframe == NULL || padapter == NULL)
>   return;
> @@ -918,9 +919,8 @@ static void process_link_qual(struct _adapter *padapter,
>   }
>   padapter->recvpriv.signal_qual_data.total_val +=
> pattrib->signal_qual;
> - padapter->recvpriv.signal_qual_data.elements[padapter->
> -   recvpriv.signal_qual_data.index++] =
> -   pattrib->signal_qual;
> + padapter->recvpriv.signal_qual_data.elements[sqd->index++] =
> + pattrib->signal_qual;

This should now become

sqd->elements[sqd->index++] = pattrib->signal_qual;

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