[PATCH] staging:rtl8188eu Remove unnecessary {} braces in

2017-09-20 Thread Janani Sankara Babu
This patch is created to solve coding style issues by removing curly braces
from single statement code blocks

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/rtl8188eu/hal/phy.c | 20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/phy.c 
b/drivers/staging/rtl8188eu/hal/phy.c
index 3039bbe..00552cb 100644
--- a/drivers/staging/rtl8188eu/hal/phy.c
+++ b/drivers/staging/rtl8188eu/hal/phy.c
@@ -728,9 +728,9 @@ static void patha_fill_iqk(struct adapter *adapt, bool 
iqkok, s32 result[][8],
u32 oldval_0, x, tx0_a, reg;
s32 y, tx0_c;
 
-   if (final_candidate == 0xFF) {
+   if (final_candidate == 0xFF)
return;
-   } else if (iqkok) {
+   else if (iqkok) {
oldval_0 = (phy_query_bb_reg(adapt, rOFDM0_XATxIQImbalance, 
bMaskDWord) >> 22) & 0x3FF;
 
x = result[final_candidate][0];
@@ -774,9 +774,9 @@ static void pathb_fill_iqk(struct adapter *adapt, bool 
iqkok, s32 result[][8],
u32 oldval_1, x, tx1_a, reg;
s32 y, tx1_c;
 
-   if (final_candidate == 0xFF) {
+   if (final_candidate == 0xFF)
return;
-   } else if (iqkok) {
+   else if (iqkok) {
oldval_1 = (phy_query_bb_reg(adapt, rOFDM0_XBTxIQImbalance, 
bMaskDWord) >> 22) & 0x3FF;
 
x = result[final_candidate][4];
@@ -820,9 +820,8 @@ static void save_adda_registers(struct adapter *adapt, u32 
*addareg,
 {
u32 i;
 
-   for (i = 0; i < register_num; i++) {
+   for (i = 0; i < register_num; i++)
backup[i] = phy_query_bb_reg(adapt, addareg[i], bMaskDWord);
-   }
 }
 
 static void save_mac_registers(struct adapter *adapt, u32 *mac_reg,
@@ -830,9 +829,8 @@ static void save_mac_registers(struct adapter *adapt, u32 
*mac_reg,
 {
u32 i;
 
-   for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) {
+   for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++)
backup[i] = usb_read8(adapt, mac_reg[i]);
-   }
backup[i] = usb_read32(adapt, mac_reg[i]);
 }
 
@@ -850,9 +848,8 @@ static void reload_mac_registers(struct adapter *adapt,
 {
u32 i;
 
-   for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) {
+   for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++)
usb_write8(adapt, mac_reg[i], (u8)backup[i]);
-   }
usb_write32(adapt, mac_reg[i], backup[i]);
 }
 
@@ -880,9 +877,8 @@ static void mac_setting_calibration(struct adapter *adapt, 
u32 *mac_reg, u32 *ba
 
usb_write8(adapt, mac_reg[i], 0x3F);
 
-   for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) {
+   for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++)
usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(3;
-   }
usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(5;
 }
 
-- 
1.9.1

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


[PATCH] staging:ccree Fix avoid externs in .c files

2017-09-20 Thread Janani Sankara Babu
This patch solves the warning shown by the checkpatch script
WARNING: externs should be avoided in .c files

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/ccree/ssi_fips_local.c | 14 --
 drivers/staging/ccree/ssi_fips_local.h | 13 +
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/ccree/ssi_fips_local.c 
b/drivers/staging/ccree/ssi_fips_local.c
index aefb71d..f019041 100644
--- a/drivers/staging/ccree/ssi_fips_local.c
+++ b/drivers/staging/ccree/ssi_fips_local.c
@@ -48,20 +48,6 @@ struct ssi_fips_handle {
 #endif
 };
 
-extern int ssi_fips_get_state(enum cc_fips_state_t *p_state);
-extern int ssi_fips_get_error(enum cc_fips_error *p_err);
-extern int ssi_fips_ext_set_state(enum cc_fips_state_t state);
-extern int ssi_fips_ext_set_error(enum cc_fips_error err);
-
-/* FIPS power-up tests */
-extern enum cc_fips_error ssi_cipher_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
-extern enum cc_fips_error ssi_cmac_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
-extern enum cc_fips_error ssi_hash_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
-extern enum cc_fips_error ssi_hmac_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
-extern enum cc_fips_error ssi_ccm_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
-extern enum cc_fips_error ssi_gcm_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
-extern size_t ssi_fips_max_mem_alloc_size(void);
-
 /* The function called once at driver entry point to check whether TEE FIPS 
error occured.*/
 static enum ssi_fips_error ssi_fips_get_tee_error(struct ssi_drvdata *drvdata)
 {
diff --git a/drivers/staging/ccree/ssi_fips_local.h 
b/drivers/staging/ccree/ssi_fips_local.h
index 8c7994f..b906190 100644
--- a/drivers/staging/ccree/ssi_fips_local.h
+++ b/drivers/staging/ccree/ssi_fips_local.h
@@ -65,3 +65,16 @@ static inline void ssi_fips_fini(struct ssi_drvdata 
*drvdata) {}
 
 #endif  /*__SSI_FIPS_LOCAL_H__*/
 
+extern int ssi_fips_get_state(enum cc_fips_state_t *p_state);
+extern int ssi_fips_get_error(enum cc_fips_error *p_err);
+extern int ssi_fips_ext_set_state(enum cc_fips_state_t state);
+extern int ssi_fips_ext_set_error(enum cc_fips_error err);
+
+/* FIPS power-up tests */
+extern enum cc_fips_error ssi_cipher_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
+extern enum cc_fips_error ssi_cmac_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
+extern enum cc_fips_error ssi_hash_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
+extern enum cc_fips_error ssi_hmac_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
+extern enum cc_fips_error ssi_ccm_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
+extern enum cc_fips_error ssi_gcm_fips_power_up_tests(struct ssi_drvdata 
*drvdata, void *cpu_addr_buffer, dma_addr_t dma_coherent_buffer);
+extern size_t ssi_fips_max_mem_alloc_size(void);
-- 
1.9.1

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


[PATCH] staging:ccree Fix char * array declaration

2017-09-20 Thread Janani Sankara Babu
This patch solves the following warning shown by the checkpatch script
Warning: char * array declaration might be better as static const

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/ccree/ssi_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ccree/ssi_sysfs.c 
b/drivers/staging/ccree/ssi_sysfs.c
index dbcd163..87cef46 100644
--- a/drivers/staging/ccree/ssi_sysfs.c
+++ b/drivers/staging/ccree/ssi_sysfs.c
@@ -300,7 +300,7 @@ static ssize_t ssi_sys_regdump_show(struct kobject *kobj,
 static ssize_t ssi_sys_help_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
 {
-   char *help_str[] = {
+   static const char *help_str[] = {
"cat reg_dump  ", "Print several of 
CC register values",
#if defined CC_CYCLE_COUNT
"cat stats_host", "Print host 
statistics",
-- 
1.9.1

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


[PATCH] staging:ccree Fix use BIT macro

2017-09-20 Thread Janani Sankara Babu
This patch is created to solve the following warning shown by the checkpatch
script Warning: Replace all occurences of (1<
---
 drivers/staging/ccree/ssi_cipher.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ccree/ssi_cipher.h 
b/drivers/staging/ccree/ssi_cipher.h
index 296b375..6fbcf9d 100644
--- a/drivers/staging/ccree/ssi_cipher.h
+++ b/drivers/staging/ccree/ssi_cipher.h
@@ -27,11 +27,11 @@
 #include "ssi_buffer_mgr.h"
 
 /* Crypto cipher flags */
-#define CC_CRYPTO_CIPHER_KEY_KFDE0(1 << 0)
-#define CC_CRYPTO_CIPHER_KEY_KFDE1(1 << 1)
-#define CC_CRYPTO_CIPHER_KEY_KFDE2(1 << 2)
-#define CC_CRYPTO_CIPHER_KEY_KFDE3(1 << 3)
-#define CC_CRYPTO_CIPHER_DU_SIZE_512B (1 << 4)
+#define CC_CRYPTO_CIPHER_KEY_KFDE0BIT(0)
+#define CC_CRYPTO_CIPHER_KEY_KFDE1BIT(1)
+#define CC_CRYPTO_CIPHER_KEY_KFDE2BIT(2)
+#define CC_CRYPTO_CIPHER_KEY_KFDE3BIT(3)
+#define CC_CRYPTO_CIPHER_DU_SIZE_512B BIT(4)
 
 #define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | 
CC_CRYPTO_CIPHER_KEY_KFDE1 | CC_CRYPTO_CIPHER_KEY_KFDE2 | 
CC_CRYPTO_CIPHER_KEY_KFDE3)
 
-- 
1.9.1

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


[PATCH] staging:ccree Fix code style issues

2017-09-20 Thread Janani Sankara Babu
This patch solves the coding style issues by giving same indent for 
switch and case

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/ccree/ssi_hash.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index 08eaa56..60a13c2 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -1176,12 +1176,12 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash,
CHECK_AND_RETURN_UPON_FIPS_ERROR();
 
switch (keylen) {
-   case AES_KEYSIZE_128:
-   case AES_KEYSIZE_192:
-   case AES_KEYSIZE_256:
-   break;
-   default:
-   return -EINVAL;
+   case AES_KEYSIZE_128:
+   case AES_KEYSIZE_192:
+   case AES_KEYSIZE_256:
+   break;
+   default:
+   return -EINVAL;
}
 
ctx->key_params.keylen = keylen;
@@ -1264,12 +1264,12 @@ static int ssi_cmac_setkey(struct crypto_ahash *ahash,
ctx->is_hmac = true;
 
switch (keylen) {
-   case AES_KEYSIZE_128:
-   case AES_KEYSIZE_192:
-   case AES_KEYSIZE_256:
-   break;
-   default:
-   return -EINVAL;
+   case AES_KEYSIZE_128:
+   case AES_KEYSIZE_192:
+   case AES_KEYSIZE_256:
+   break;
+   default:
+   return -EINVAL;
}
 
ctx->key_params.keylen = keylen;
-- 
1.9.1

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


[PATCH] staging:ccree Fix dont use assignment in if condition

2017-09-20 Thread Janani Sankara Babu
This patch solves the following error shown by checkpatch script
ERROR: do not use assignment in if condition

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/ccree/ssi_hash.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index ae8f36a..08eaa56 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -601,8 +601,8 @@ static int ssi_hash_update(struct ahash_req_ctx *state,
/* no real updates required */
return 0;
}
-
-   if (unlikely(rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, 
state, src, nbytes, block_size))) {
+   rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, src, 
nbytes, block_size);
+   if (unlikely(rc)) {
if (rc == 1) {
SSI_LOG_DEBUG(" data size not require HW update %x\n",
 nbytes);
@@ -1403,8 +1403,8 @@ static int ssi_mac_update(struct ahash_request *req)
}
 
state->xcbc_count++;
-
-   if (unlikely(rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, 
state, req->src, req->nbytes, block_size))) {
+   rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, 
req->src, req->nbytes, block_size);
+   if (unlikely(rc)) {
if (rc == 1) {
SSI_LOG_DEBUG(" data size not require HW update %x\n",
 req->nbytes);
-- 
1.9.1

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


[PATCH] staging:vme Fix use BIT macro

2017-09-20 Thread Janani Sankara Babu
This patch is created to solve the following warning shown by the checkpatch
script Warning: Replace all occurences of (1<
---
 drivers/staging/vme/devices/vme_pio2.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_pio2.h 
b/drivers/staging/vme/devices/vme_pio2.h
index ac4a4ba..e9c3cf6 100644
--- a/drivers/staging/vme/devices/vme_pio2.h
+++ b/drivers/staging/vme/devices/vme_pio2.h
@@ -179,7 +179,7 @@
PIO2_REGS_CTRL_WRD1 };
 
 #define PIO2_CNTR_SC_DEV0  0
-#define PIO2_CNTR_SC_DEV1  (1 << 6)
+#define PIO2_CNTR_SC_DEV1  BIT(6)
 #define PIO2_CNTR_SC_DEV2  (2 << 6)
 #define PIO2_CNTR_SC_RDBACK(3 << 6)
 
@@ -188,12 +188,12 @@
PIO2_CNTR_SC_DEV1, PIO2_CNTR_SC_DEV2 };
 
 #define PIO2_CNTR_RW_LATCH 0
-#define PIO2_CNTR_RW_LSB   (1 << 4)
+#define PIO2_CNTR_RW_LSB   BIT(4)
 #define PIO2_CNTR_RW_MSB   (2 << 4)
 #define PIO2_CNTR_RW_BOTH  (3 << 4)
 
 #define PIO2_CNTR_MODE00
-#define PIO2_CNTR_MODE1(1 << 1)
+#define PIO2_CNTR_MODE1BIT(1)
 #define PIO2_CNTR_MODE2(2 << 1)
 #define PIO2_CNTR_MODE3(3 << 1)
 #define PIO2_CNTR_MODE4(4 << 1)
-- 
1.9.1

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


[PATCH] staging:rtl8188eu Fix remove semicolon in do {}while(0)

2017-09-20 Thread Janani Sankara Babu
This patch removes the semicolon at the end of while statement in the
do while macro , inorder to avoid it behaving like compound statement.

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/rtl8188eu/core/rtw_security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c 
b/drivers/staging/rtl8188eu/core/rtw_security.c
index b283a490..5b1ef22 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -1690,4 +1690,4 @@ u32   rtw_aes_decrypt(struct adapter *padapter, u8 
*precvframe)
d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \
-} while (0);
+} while (0)
-- 
1.9.1

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


[PATCH] staging:rtl8188eu:hal Fix wrong comparison to False

2017-09-20 Thread Janani Sankara Babu
This patch solves the warning "Using comparison to false is error prone"

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/rtl8188eu/hal/odm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/odm.c 
b/drivers/staging/rtl8188eu/hal/odm.c
index ec8aae7..001d626 100644
--- a/drivers/staging/rtl8188eu/hal/odm.c
+++ b/drivers/staging/rtl8188eu/hal/odm.c
@@ -382,7 +382,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm)
}
 
/* add by Neil Chen to avoid PSD is processing */
-   if (pDM_Odm->bDMInitialGainEnable == false) {
+   if (!pDM_Odm->bDMInitialGainEnable) {
ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() 
Return: PSD is Processing\n"));
return;
}
-- 
1.9.1

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


[PATCH v2 26/31] staging/comedi/das16: Make timer initialization unconditional

2017-09-20 Thread Kees Cook
With timer initialization made unconditional, there is no reason to
make del_timer_sync() calls conditionally, there by removing the test
of the .data field.

Cc: Ian Abbott 
Cc: H Hartley Sweeten 
Cc: Greg Kroah-Hartman 
Cc: de...@driverdev.osuosl.org
Signed-off-by: Kees Cook 
---
 drivers/staging/comedi/drivers/das16.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 5d157951f63f..2b2a446af3f5 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -934,6 +934,9 @@ static void das16_alloc_dma(struct comedi_device *dev, 
unsigned int dma_chan)
 {
struct das16_private_struct *devpriv = dev->private;
 
+   setup_timer(&devpriv->timer, das16_timer_interrupt,
+   (unsigned long)dev);
+
/* only DMA channels 3 and 1 are valid */
if (!(dma_chan == 1 || dma_chan == 3))
return;
@@ -941,10 +944,6 @@ static void das16_alloc_dma(struct comedi_device *dev, 
unsigned int dma_chan)
/* DMA uses two buffers */
devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
   DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
-   if (devpriv->dma) {
-   setup_timer(&devpriv->timer, das16_timer_interrupt,
-   (unsigned long)dev);
-   }
 }
 
 static void das16_free_dma(struct comedi_device *dev)
@@ -952,8 +951,7 @@ static void das16_free_dma(struct comedi_device *dev)
struct das16_private_struct *devpriv = dev->private;
 
if (devpriv) {
-   if (devpriv->timer.data)
-   del_timer_sync(&devpriv->timer);
+   del_timer_sync(&devpriv->timer);
comedi_isadma_free(devpriv->dma);
}
 }
-- 
2.7.4

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


[PATCH v2 13/31] timer: Remove meaningless .data/.function assignments

2017-09-20 Thread Kees Cook
Several timer users needlessly reset their .function/.data fields during
their timer callback, but nothing else changes them. Some users do not
use their .data field at all. Each instance is removed here.

Cc: Krzysztof Halasa 
Cc: Aditya Shankar 
Cc: Ganesh Krishna 
Cc: Greg Kroah-Hartman 
Cc: Jens Axboe 
Cc: net...@vger.kernel.org
Cc: linux-wirel...@vger.kernel.org
Cc: de...@driverdev.osuosl.org
Signed-off-by: Kees Cook 
Acked-by: Greg Kroah-Hartman  # for staging
Acked-by: Krzysztof Halasa  # for wan/hdlc*
Acked-by: Jens Axboe  # for amiflop
---
 drivers/block/amiflop.c   | 3 +--
 drivers/net/wan/hdlc_cisco.c  | 2 --
 drivers/net/wan/hdlc_fr.c | 2 --
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 +---
 4 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index c4b1cba27178..6680d75bc857 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -323,7 +323,7 @@ static void fd_deselect (int drive)
 
 }
 
-static void motor_on_callback(unsigned long nr)
+static void motor_on_callback(unsigned long ignored)
 {
if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) {
complete_all(&motor_on_completion);
@@ -344,7 +344,6 @@ static int fd_motor_on(int nr)
fd_select(nr);
 
reinit_completion(&motor_on_completion);
-   motor_on_timer.data = nr;
mod_timer(&motor_on_timer, jiffies + HZ/2);
 
on_attempts = 10;
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index c696d42f4502..6c98d85f2773 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -276,8 +276,6 @@ static void cisco_timer(unsigned long arg)
spin_unlock(&st->lock);
 
st->timer.expires = jiffies + st->settings.interval * HZ;
-   st->timer.function = cisco_timer;
-   st->timer.data = arg;
add_timer(&st->timer);
 }
 
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index de42faca076a..7da2424c28a4 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -644,8 +644,6 @@ static void fr_timer(unsigned long arg)
state(hdlc)->settings.t391 * HZ;
}
 
-   state(hdlc)->timer.function = fr_timer;
-   state(hdlc)->timer.data = arg;
add_timer(&state(hdlc)->timer);
 }
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index ac5aaafa461c..60f088babf27 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -266,7 +266,7 @@ static void update_scan_time(void)
last_scanned_shadow[i].time_scan = jiffies;
 }
 
-static void remove_network_from_shadow(unsigned long arg)
+static void remove_network_from_shadow(unsigned long unused)
 {
unsigned long now = jiffies;
int i, j;
@@ -287,7 +287,6 @@ static void remove_network_from_shadow(unsigned long arg)
}
 
if (last_scanned_cnt != 0) {
-   hAgingTimer.data = arg;
mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
}
 }
@@ -304,7 +303,6 @@ static int is_network_in_shadow(struct network_info 
*pstrNetworkInfo,
int i;
 
if (last_scanned_cnt == 0) {
-   hAgingTimer.data = (unsigned long)user_void;
mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
state = -1;
} else {
-- 
2.7.4

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


[PATCH] staging: rtl8723bs: add missing range check on id

2017-09-20 Thread Colin King
From: Colin Ian King 

The value of the u8 id needs to be upper bounds checked to ensure
the cam_cache array on the adapter dvobj is not indexed outside
of the allowed range of 0..TOTAL_CAM_ENTRY-1. This can currently
occur if id is >= TOTAL_CAM_ENTRY when calling write_cam_from_cache.
Fix this by adding an upper range check.

Detected by CoverityScan, CID#1428464 ("Use of untrusted scalar value")

Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Signed-off-by: Colin Ian King 
---
 drivers/staging/rtl8723bs/os_dep/rtw_proc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c 
b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
index 92277457aba4..ce1dd6f9036f 100644
--- a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
+++ b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c
@@ -311,6 +311,8 @@ static ssize_t proc_set_cam(struct file *file, const char 
__user *buffer, size_t
 
if (num < 2)
return count;
+   if (id >= TOTAL_CAM_ENTRY)
+   return -EINVAL;
 
if (strcmp("c", cmd) == 0) {
_clear_cam_entry(adapter, id);
-- 
2.14.1

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


[PATCH v2] [media] staging: atomisp: use clock framework for camera clocks

2017-09-20 Thread Pierre-Louis Bossart
The Atom ISP driver initializes and configures PMC clocks which are
already handled by the clock framework.

Remove all legacy vlv2_platform_clock stuff and move to the clk API to
avoid conflicts, e.g. with audio machine drivers enabling the MCLK for
external codecs

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Tested-by: Carlo Caione 
Reviewed-by: Andy Shevchenko 
Signed-off-by: Pierre-Louis Bossart 
---
v2: added Andy's Reviewed-by and Fixes tag

 drivers/staging/media/atomisp/Kconfig  |   1 +
 drivers/staging/media/atomisp/platform/Makefile|   1 -
 .../staging/media/atomisp/platform/clock/Makefile  |   6 -
 .../platform/clock/platform_vlv2_plat_clk.c|  40 
 .../platform/clock/platform_vlv2_plat_clk.h|  27 ---
 .../media/atomisp/platform/clock/vlv2_plat_clock.c | 247 -
 .../platform/intel-mid/atomisp_gmin_platform.c |  63 +-
 7 files changed, 52 insertions(+), 333 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/platform/clock/Makefile
 delete mode 100644 
drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.c
 delete mode 100644 
drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.h
 delete mode 100644 
drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c

diff --git a/drivers/staging/media/atomisp/Kconfig 
b/drivers/staging/media/atomisp/Kconfig
index 8eb13c3ba29c..7cdebea35ccf 100644
--- a/drivers/staging/media/atomisp/Kconfig
+++ b/drivers/staging/media/atomisp/Kconfig
@@ -1,6 +1,7 @@
 menuconfig INTEL_ATOMISP
 bool "Enable support to Intel MIPI camera drivers"
 depends on X86 && EFI && MEDIA_CONTROLLER && PCI && ACPI
+   select COMMON_CLK
 help
   Enable support for the Intel ISP2 camera interfaces and MIPI
   sensor drivers.
diff --git a/drivers/staging/media/atomisp/platform/Makefile 
b/drivers/staging/media/atomisp/platform/Makefile
index df157630bda9..0e3b7e1c81c6 100644
--- a/drivers/staging/media/atomisp/platform/Makefile
+++ b/drivers/staging/media/atomisp/platform/Makefile
@@ -2,5 +2,4 @@
 # Makefile for camera drivers.
 #
 
-obj-$(CONFIG_INTEL_ATOMISP) += clock/
 obj-$(CONFIG_INTEL_ATOMISP) += intel-mid/
diff --git a/drivers/staging/media/atomisp/platform/clock/Makefile 
b/drivers/staging/media/atomisp/platform/clock/Makefile
deleted file mode 100644
index 82fbe8b6968a..
--- a/drivers/staging/media/atomisp/platform/clock/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Makefile for clock devices.
-#
-
-obj-$(CONFIG_INTEL_ATOMISP)+= vlv2_plat_clock.o
-obj-$(CONFIG_INTEL_ATOMISP) += platform_vlv2_plat_clk.o
diff --git 
a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.c 
b/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.c
deleted file mode 100644
index 0aae9b0283bb..
--- a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * platform_vlv2_plat_clk.c - VLV2 platform clock driver
- * Copyright (C) 2013 Intel Corporation
- *
- * Author: Asutosh Pathak 
- * Author: Chandra Sekhar Anagani 
- * Author: Sergio Aguirre 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int __init vlv2_plat_clk_init(void)
-{
-   struct platform_device *pdev;
-
-   pdev = platform_device_register_simple("vlv2_plat_clk", -1, NULL, 0);
-   if (IS_ERR(pdev)) {
-   pr_err("platform_vlv2_plat_clk:register failed: %ld\n",
-   PTR_ERR(pdev));
-   return PTR_ERR(pdev);
-   }
-
-   return 0;
-}
-
-device_initcall(vlv2_plat_clk_init);
diff --git 
a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.h 
b/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.h
deleted file mode 100644
index b730ab0e8223..
--- a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * platform_vlv2_plat_clk.h: platform clock driver library header file
- * Copyright (C) 2013 Intel Corporation
- *
- * Author: Asutosh Pathak 
- * Author: Chandra Sekhar Anagani 
- * Author: Sergio Aguirre 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without eve

Re: [PATCH] [media] staging: atomisp: use clock framework for camera clocks

2017-09-20 Thread Andy Shevchenko
On Wed, 2017-09-20 at 12:01 -0500, Pierre-Louis Bossart wrote:
> 
> On 09/20/2017 04:12 AM, Andy Shevchenko wrote:
> > On Tue, 2017-09-19 at 15:45 -0500, Pierre-Louis Bossart wrote:
> > > The Atom ISP driver initializes and configures PMC clocks which
> > > are
> > > already handled by the clock framework.
> > > 
> > > Remove all legacy vlv2_platform_clock stuff and move to the clk
> > > API to
> > > avoid conflicts, e.g. with audio machine drivers enabling the MCLK
> > > for
> > > external codecs
> > > 
> > 
> > I think it might have a Fixes: tag as well (though I dunno which
> > commit
> > could be considered as anchor).
> 
> The initial integration of the atomisp driver already had this
> problem, 
> i'll add a reference to
> 'a49d25364dfb9 ("staging/atomisp: Add support for the Intel IPU v2")'

...which seems to be the best choice (you can check how many new commits
use that one as an origin for Fixes: tag).

> > 
> > (I doubt Git is so clever to remove files based on information out
> > of
> > the diff, can you check it and if needed to resend without -D
> > implied?)
> 
> Gee, I thought -C -M -D were the standard options to checkpatch,
> never 
> realized it'd prevent patches from applying. Thanks for the tip.

-C -M — yes for sure.

Last time I checked patches, generated with help of -D, do not remove
the files when you do git am. So, I don't know if it still the case.
Safe option is to use -C -M for public (+ -D locally only to see less
noise).

-- 
Andy Shevchenko 
Intel Finland Oy
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/16] hyper-v: trace vmbus_on_message()

2017-09-20 Thread Steven Rostedt
On Wed, 20 Sep 2017 19:21:53 +0200
Vitaly Kuznetsov  wrote:

> diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
> index 9a29ef55477d..72911dfc9682 100644
> --- a/drivers/hv/hv_trace.h
> +++ b/drivers/hv/hv_trace.h
> @@ -14,6 +14,14 @@ TRACE_EVENT(vmbus_on_msg_dpc,
>   TP_printk("message %u received", __entry->msgtype)
>   );
>  
> +TRACE_EVENT(vmbus_on_message,
> + TP_PROTO(const struct vmbus_channel_message_header *hdr),
> + TP_ARGS(hdr),
> + TP_STRUCT__entry(__field(unsigned int, msgtype)),
> + TP_fast_assign(__entry->msgtype = hdr->msgtype),
> + TP_printk("processing message %u", __entry->msgtype)
> + );

Whenever you have two trace events with everything the same but the
TP_printk(), you can save a little space by using DEFINE_EVENT_PRINT()

DECLARE_EVENT_CLASS(vmbus_hdr_msg,
TP_PROTO(const struct vmbus_channel_message_header *hdr),
TP_ARGS(hdr),
TP_STRUCT__entry(__field(unsigned int, msgtype),
TP_fast_assign(__entry->msg = hdr->msgtype;),
TP_printk("msgtype=%d", __entry->msgtype)
);

DEFINE_EVENT_PRINT(vmbus_hdr_msg, vmbus_on_msg_dpc,
TP_PROTO(const struct vmbus_channel_message_header *hdr),
TP_ARGS(hdr),
TP_printk("message %u received", __entry->msgtype));

DEFINE_EVENT_PRINT(vmbus_hdr_msg, vmbus_on_message,
TP_PROTO(const struct vmbus_channel_message_header *hdr),
TP_ARGS(hdr),
TP_printk("processing message %u", __entry->msgtype));

This will use the same functions required to save and record the
message but will use a different function to output it to the trace.

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


[PATCH] staging: rtl8723bs: avoid null pointer dereference on pmlmepriv

2017-09-20 Thread Colin King
From: Colin Ian King 

There is a check to see if pmlmepriv is null before vfree'ing
pmlmepriv->free_bss_buf hence implying pmlmepriv could potenially be
null. However, a previous call to rtw_free_mlme_priv_ie_data
can also dereference pmlmepriv, so move this call so that it is only
called if pmlmepriv non-null.

Detected by CoverityScan, CID#1077739 ("Dereference before null check")

Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Signed-off-by: Colin Ian King 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 37b683d4d1fa..0d94ced985c0 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -119,9 +119,8 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
 
 void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 {
-   rtw_free_mlme_priv_ie_data(pmlmepriv);
-
if (pmlmepriv) {
+   rtw_free_mlme_priv_ie_data(pmlmepriv);
if (pmlmepriv->free_bss_buf) {
vfree(pmlmepriv->free_bss_buf);
}
-- 
2.14.1

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


[PATCH 12/16] hyper-v: trace vmbus_establish_gpadl()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_GPADL_HEADER/CHANNELMSG_GPADL_BODY sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel.c  |  6 ++
 drivers/hv/hv_trace.h | 42 ++
 2 files changed, 48 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 9fe4c0624dbd..f51ddc89c85a 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -435,6 +435,9 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, 
void *kbuffer,
 
ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
 sizeof(*msginfo), true);
+
+   trace_vmbus_establish_gpadl_header(gpadlmsg, ret);
+
if (ret != 0)
goto cleanup;
 
@@ -450,6 +453,9 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, 
void *kbuffer,
ret = vmbus_post_msg(gpadl_body,
 submsginfo->msgsize - sizeof(*submsginfo),
 true);
+
+   trace_vmbus_establish_gpadl_body(gpadl_body, ret);
+
if (ret != 0)
goto cleanup;
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index a8c4bcd1fc8e..a77a1f3b83ed 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -170,6 +170,48 @@ TRACE_EVENT(vmbus_close_internal,
__entry->ret)
);
 
+TRACE_EVENT(vmbus_establish_gpadl_header,
+   TP_PROTO(const struct vmbus_channel_gpadl_header *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, gpadl)
+   __field(u16, range_buflen)
+   __field(u16, rangecount)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->gpadl = msg->gpadl;
+   __entry->range_buflen = msg->range_buflen;
+   __entry->rangecount = msg->rangecount;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, gpadl 0x%x, range_buflen %d "
+ "rangecount %d, ret %d",
+ __entry->child_relid, __entry->gpadl,
+ __entry->range_buflen, __entry->rangecount, __entry->ret
+   )
+   );
+
+TRACE_EVENT(vmbus_establish_gpadl_body,
+   TP_PROTO(const struct vmbus_channel_gpadl_body *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, msgnumber)
+   __field(u32, gpadl)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->msgnumber = msg->msgnumber;
+   __entry->gpadl = msg->gpadl;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending msgnumber %d, gpadl 0x%x, ret %d",
+ __entry->msgnumber, __entry->gpadl, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 08/16] hyper-v: trace vmbus_onversion_response()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_VERSION_RESPONSE handler.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c |  3 +++
 drivers/hv/hv_trace.h | 11 +++
 2 files changed, 14 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 1ff2cc064850..a9a1fc1424c6 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1121,6 +1121,9 @@ static void vmbus_onversion_response(
unsigned long flags;
 
version_response = (struct vmbus_channel_version_response *)hdr;
+
+   trace_vmbus_onversion_response(version_response);
+
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 
list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 67e43dd59771..1478ec36967e 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -109,6 +109,17 @@ TRACE_EVENT(vmbus_ongpadl_torndown,
TP_printk("gpadl 0x%x", __entry->gpadl)
);
 
+TRACE_EVENT(vmbus_onversion_response,
+   TP_PROTO(const struct vmbus_channel_version_response *response),
+   TP_ARGS(response),
+   TP_STRUCT__entry(
+   __field(u8, ver)
+   ),
+   TP_fast_assign(__entry->ver = response->version_supported;
+   ),
+   TP_printk("version_supported %d", __entry->ver)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 11/16] hyper-v: trace vmbus_close_internal()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_CLOSECHANNEL sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel.c  |  2 ++
 drivers/hv/hv_trace.h | 15 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 7b114b390871..9fe4c0624dbd 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -591,6 +591,8 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel),
 true);
 
+   trace_vmbus_close_internal(msg, ret);
+
if (ret) {
pr_err("Close failed: close post msg return is %d\n", ret);
/*
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index aefbbb56e686..a8c4bcd1fc8e 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -155,6 +155,21 @@ TRACE_EVENT(vmbus_open,
)
);
 
+TRACE_EVENT(vmbus_close_internal,
+   TP_PROTO(const struct vmbus_channel_close_channel *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, ret %d", __entry->child_relid,
+   __entry->ret)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 14/16] hyper-v: trace vmbus_negotiate_version()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_INITIATE_CONTACT sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/connection.c |  3 +++
 drivers/hv/hv_trace.h   | 26 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index f41901f80b64..5e36f86d0b0c 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -117,6 +117,9 @@ static int vmbus_negotiate_version(struct 
vmbus_channel_msginfo *msginfo,
ret = vmbus_post_msg(msg,
 sizeof(struct vmbus_channel_initiate_contact),
 true);
+
+   trace_vmbus_negotiate_version(msg, ret);
+
if (ret != 0) {
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&msginfo->msglistentry);
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 98c2e9e9ad5e..70a4ae28e843 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -230,6 +230,32 @@ TRACE_EVENT(vmbus_teardown_gpadl,
)
);
 
+TRACE_EVENT(vmbus_negotiate_version,
+   TP_PROTO(const struct vmbus_channel_initiate_contact *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, ver)
+   __field(u32, target_vcpu)
+   __field(int, ret)
+   __field(u64, int_page)
+   __field(u64, mon_page1)
+   __field(u64, mon_page2)
+   ),
+   TP_fast_assign(
+   __entry->ver = msg->vmbus_version_requested;
+   __entry->target_vcpu = msg->target_vcpu;
+   __entry->int_page = msg->interrupt_page;
+   __entry->mon_page1 = msg->monitor_page1;
+   __entry->mon_page2 = msg->monitor_page2;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending vmbus_version_requested %d, target_vcpu 0x%x, "
+ "pages %llx:%llx:%llx, ret %d",
+ __entry->ver, __entry->target_vcpu, __entry->int_page,
+ __entry->mon_page1, __entry->mon_page2, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 13/16] hyper-v: trace vmbus_teardown_gpadl()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_GPADL_TEARDOWN sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel.c  |  2 ++
 drivers/hv/hv_trace.h | 18 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index f51ddc89c85a..2422ef6f9164 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -519,6 +519,8 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 
gpadl_handle)
ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_gpadl_teardown),
 true);
 
+   trace_vmbus_teardown_gpadl(msg, ret);
+
if (ret)
goto post_msg_err;
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index a77a1f3b83ed..98c2e9e9ad5e 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -212,6 +212,24 @@ TRACE_EVENT(vmbus_establish_gpadl_body,
)
);
 
+TRACE_EVENT(vmbus_teardown_gpadl,
+   TP_PROTO(const struct vmbus_channel_gpadl_teardown *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, gpadl)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->gpadl = msg->gpadl;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, gpadl 0x%x, ret %d",
+ __entry->child_relid, __entry->gpadl, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 15/16] hyper-v: trace vmbus_release_relid()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_RELID_RELEASED sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c |  7 +--
 drivers/hv/hv_trace.h | 16 
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 5c39388545f5..ca2dea638bfb 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -373,12 +373,15 @@ static void percpu_channel_deq(void *arg)
 static void vmbus_release_relid(u32 relid)
 {
struct vmbus_channel_relid_released msg;
+   int ret;
 
memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
msg.child_relid = relid;
msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
-   vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released),
-  true);
+   ret = vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released),
+true);
+
+   trace_vmbus_release_relid(&msg, ret);
 }
 
 void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 70a4ae28e843..f2c1f45df647 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -256,6 +256,22 @@ TRACE_EVENT(vmbus_negotiate_version,
)
);
 
+TRACE_EVENT(vmbus_release_relid,
+   TP_PROTO(const struct vmbus_channel_relid_released *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, ret %d",
+ __entry->child_relid, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 16/16] hyper-v: trace vmbus_send_tl_connect_request()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_TL_CONNECT_REQUEST sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel.c  |  7 ++-
 drivers/hv/hv_trace.h | 20 
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 2422ef6f9164..71bdd2bb6647 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -236,13 +236,18 @@ int vmbus_send_tl_connect_request(const uuid_le 
*shv_guest_servie_id,
  const uuid_le *shv_host_servie_id)
 {
struct vmbus_channel_tl_connect_request conn_msg;
+   int ret;
 
memset(&conn_msg, 0, sizeof(conn_msg));
conn_msg.header.msgtype = CHANNELMSG_TL_CONNECT_REQUEST;
conn_msg.guest_endpoint_id = *shv_guest_servie_id;
conn_msg.host_service_id = *shv_host_servie_id;
 
-   return vmbus_post_msg(&conn_msg, sizeof(conn_msg), true);
+   ret = vmbus_post_msg(&conn_msg, sizeof(conn_msg), true);
+
+   trace_vmbus_send_tl_connect_request(&conn_msg, ret);
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(vmbus_send_tl_connect_request);
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index f2c1f45df647..1d7e90fbeaa0 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -272,6 +272,26 @@ TRACE_EVENT(vmbus_release_relid,
)
);
 
+TRACE_EVENT(vmbus_send_tl_connect_request,
+   TP_PROTO(const struct vmbus_channel_tl_connect_request *msg,
+int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __array(char, guest_id, 16)
+   __array(char, host_id, 16)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   memcpy(__entry->guest_id, &msg->guest_endpoint_id.b, 16);
+   memcpy(__entry->host_id, &msg->host_service_id.b, 16);
+   __entry->ret = ret;
+   ),
+   TP_printk("sending guest_endpoint_id %pUl, host_service_id %pUl, "
+ "ret %d",
+ __entry->guest_id, __entry->host_id, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 04/16] hyper-v: trace vmbus_onoffer_rescind()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_RESCIND_CHANNELOFFER handler.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c | 2 ++
 drivers/hv/hv_trace.h | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 290ea25ce409..563653a02ab6 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -841,6 +841,8 @@ static void vmbus_onoffer_rescind(struct 
vmbus_channel_message_header *hdr)
 
rescind = (struct vmbus_channel_rescind_offer *)hdr;
 
+   trace_vmbus_onoffer_rescind(rescind);
+
/*
 * The offer msg and the corresponding rescind msg
 * from the host are guranteed to be ordered -
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 8376fdf9d054..d2a5a97dcf2a 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -59,6 +59,14 @@ TRACE_EVENT(vmbus_onoffer,
)
);
 
+TRACE_EVENT(vmbus_onoffer_rescind,
+   TP_PROTO(const struct vmbus_channel_rescind_offer *offer),
+   TP_ARGS(offer),
+   TP_STRUCT__entry(__field(u32, child_relid)),
+   TP_fast_assign(__entry->child_relid = offer->child_relid),
+   TP_printk("child_relid 0x%x", __entry->child_relid)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 09/16] hyper-v: trace vmbus_request_offers()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_REQUESTOFFERS sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c | 4 +++-
 drivers/hv/hv_trace.h | 8 
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index a9a1fc1424c6..5c39388545f5 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1218,9 +1218,11 @@ int vmbus_request_offers(void)
 
msg->msgtype = CHANNELMSG_REQUESTOFFERS;
 
-
ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_message_header),
 true);
+
+   trace_vmbus_request_offers(ret);
+
if (ret != 0) {
pr_err("Unable to request offers - %d\n", ret);
 
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 1478ec36967e..b8d8460afc07 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -120,6 +120,14 @@ TRACE_EVENT(vmbus_onversion_response,
TP_printk("version_supported %d", __entry->ver)
);
 
+TRACE_EVENT(vmbus_request_offers,
+   TP_PROTO(int ret),
+   TP_ARGS(ret),
+   TP_STRUCT__entry(__field(int, ret)),
+   TP_fast_assign(__entry->ret = ret),
+   TP_printk("sending ret %d", __entry->ret)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 10/16] hyper-v: trace vmbus_open()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_OPENCHANNEL sender.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel.c  |  2 ++
 drivers/hv/hv_trace.h | 27 +++
 2 files changed, 29 insertions(+)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 676a130f0575..7b114b390871 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -185,6 +185,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
send_ringbuffer_size,
ret = vmbus_post_msg(open_msg,
 sizeof(struct vmbus_channel_open_channel), true);
 
+   trace_vmbus_open(open_msg, ret);
+
if (ret != 0) {
err = ret;
goto error_clean_msglist;
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index b8d8460afc07..aefbbb56e686 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -128,6 +128,33 @@ TRACE_EVENT(vmbus_request_offers,
TP_printk("sending ret %d", __entry->ret)
);
 
+TRACE_EVENT(vmbus_open,
+   TP_PROTO(const struct vmbus_channel_open_channel *msg, int ret),
+   TP_ARGS(msg, ret),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, openid)
+   __field(u32, gpadlhandle)
+   __field(u32, target_vp)
+   __field(u32, offset)
+   __field(int, ret)
+   ),
+   TP_fast_assign(
+   __entry->child_relid = msg->child_relid;
+   __entry->openid = msg->openid;
+   __entry->gpadlhandle = msg->ringbuffer_gpadlhandle;
+   __entry->target_vp = msg->target_vp;
+   __entry->offset = msg->downstream_ringbuffer_pageoffset;
+   __entry->ret = ret;
+   ),
+   TP_printk("sending child_relid 0x%x, openid %d, "
+ "gpadlhandle 0x%x, target_vp 0x%x, offset 0x%x, ret %d",
+ __entry->child_relid,  __entry->openid,
+ __entry->gpadlhandle, __entry->target_vp,
+ __entry->offset, __entry->ret
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 03/16] hyper-v: trace vmbus_onoffer()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_OFFERCHANNEL handler.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c |  2 ++
 drivers/hv/hv_trace.h | 37 +
 2 files changed, 39 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index ddeebba8971e..290ea25ce409 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -797,6 +797,8 @@ static void vmbus_onoffer(struct 
vmbus_channel_message_header *hdr)
 
offer = (struct vmbus_channel_offer_channel *)hdr;
 
+   trace_vmbus_onoffer(offer);
+
/* Allocate the channel object and save this offer. */
newchannel = alloc_channel();
if (!newchannel) {
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 72911dfc9682..8376fdf9d054 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -22,6 +22,43 @@ TRACE_EVENT(vmbus_on_message,
TP_printk("processing message %u", __entry->msgtype)
);
 
+TRACE_EVENT(vmbus_onoffer,
+   TP_PROTO(const struct vmbus_channel_offer_channel *offer),
+   TP_ARGS(offer),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u8, monitorid)
+   __field(u16, is_ddc_int)
+   __field(u32, connection_id)
+   __array(char, if_type, 16)
+   __array(char, if_instance, 16)
+   __field(u16, chn_flags)
+   __field(u16, mmio_mb)
+   __field(u16, sub_idx)
+   ),
+   TP_fast_assign(__entry->child_relid = offer->child_relid;
+  __entry->monitorid = offer->monitorid;
+  __entry->is_ddc_int = offer->is_dedicated_interrupt;
+  __entry->connection_id = offer->connection_id;
+  memcpy(__entry->if_type,
+ &offer->offer.if_type.b, 16);
+  memcpy(__entry->if_instance,
+ &offer->offer.if_instance.b, 16);
+  __entry->chn_flags = offer->offer.chn_flags;
+  __entry->mmio_mb = offer->offer.mmio_megabytes;
+  __entry->sub_idx = offer->offer.sub_channel_index;
+   ),
+   TP_printk("child_relid 0x%x, monitorid 0x%x, is_dedicated %d, "
+ "connection_id 0x%x, if_type %pUl, if_instance %pUl, "
+ "chn_flags 0x%x, mmio_megabytes %d, sub_channel_index %d",
+ __entry->child_relid, __entry->monitorid,
+ __entry->is_ddc_int, __entry->connection_id,
+ __entry->if_type, __entry->if_instance,
+ __entry->chn_flags, __entry->mmio_mb,
+ __entry->sub_idx
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 07/16] hyper-v: trace vmbus_ongpadl_torndown()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_GPADL_TORNDOWN handler.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c | 2 ++
 drivers/hv/hv_trace.h | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index af2448e245ca..1ff2cc064850 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1076,6 +1076,8 @@ static void vmbus_ongpadl_torndown(
 
gpadl_torndown = (struct vmbus_channel_gpadl_torndown *)hdr;
 
+   trace_vmbus_ongpadl_torndown(gpadl_torndown);
+
/*
 * Find the open msg, copy the result and signal/unblock the wait event
 */
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 99e2b8858e18..67e43dd59771 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -101,6 +101,14 @@ TRACE_EVENT(vmbus_ongpadl_created,
)
);
 
+TRACE_EVENT(vmbus_ongpadl_torndown,
+   TP_PROTO(const struct vmbus_channel_gpadl_torndown *gpadltorndown),
+   TP_ARGS(gpadltorndown),
+   TP_STRUCT__entry(__field(u32, gpadl)),
+   TP_fast_assign(__entry->gpadl = gpadltorndown->gpadl),
+   TP_printk("gpadl 0x%x", __entry->gpadl)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 06/16] hyper-v: trace vmbus_ongpadl_created()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_GPADL_CREATED handler.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c |  2 ++
 drivers/hv/hv_trace.h | 17 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 2abe0563876b..af2448e245ca 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1026,6 +1026,8 @@ static void vmbus_ongpadl_created(struct 
vmbus_channel_message_header *hdr)
 
gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr;
 
+   trace_vmbus_ongpadl_created(gpadlcreated);
+
/*
 * Find the establish msg, copy the result and signal/unblock the wait
 * event
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index c98d66d683f4..99e2b8858e18 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -84,6 +84,23 @@ TRACE_EVENT(vmbus_onopen_result,
)
);
 
+TRACE_EVENT(vmbus_ongpadl_created,
+   TP_PROTO(const struct vmbus_channel_gpadl_created *gpadlcreated),
+   TP_ARGS(gpadlcreated),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, gpadl)
+   __field(u32, status)
+   ),
+   TP_fast_assign(__entry->child_relid = gpadlcreated->child_relid;
+  __entry->gpadl = gpadlcreated->gpadl;
+  __entry->status = gpadlcreated->creation_status;
+   ),
+   TP_printk("child_relid 0x%x, gpadl 0x%x, creation_status %d",
+ __entry->child_relid,  __entry->gpadl,  __entry->status
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 05/16] hyper-v: trace vmbus_onopen_result()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to CHANNELMSG_OPENCHANNEL_RESULT handler.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c |  2 ++
 drivers/hv/hv_trace.h | 17 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 563653a02ab6..2abe0563876b 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -980,6 +980,8 @@ static void vmbus_onopen_result(struct 
vmbus_channel_message_header *hdr)
 
result = (struct vmbus_channel_open_result *)hdr;
 
+   trace_vmbus_onopen_result(result);
+
/*
 * Find the open msg, copy the result and signal/unblock the wait event
 */
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index d2a5a97dcf2a..c98d66d683f4 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -67,6 +67,23 @@ TRACE_EVENT(vmbus_onoffer_rescind,
TP_printk("child_relid 0x%x", __entry->child_relid)
);
 
+TRACE_EVENT(vmbus_onopen_result,
+   TP_PROTO(const struct vmbus_channel_open_result *result),
+   TP_ARGS(result),
+   TP_STRUCT__entry(
+   __field(u32, child_relid)
+   __field(u32, openid)
+   __field(u32, status)
+   ),
+   TP_fast_assign(__entry->child_relid = result->child_relid;
+  __entry->openid = result->openid;
+  __entry->status = result->status;
+   ),
+   TP_printk("child_relid 0x%x, openid %d, status %d",
+ __entry->child_relid,  __entry->openid,  __entry->status
+   )
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 02/16] hyper-v: trace vmbus_on_message()

2017-09-20 Thread Vitaly Kuznetsov
Add tracepoint to vmbus_on_message() which is called when we start
processing a blocking from work context.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/channel_mgmt.c | 2 ++
 drivers/hv/hv_trace.h | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 060df71c2e8b..ddeebba8971e 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -1170,6 +1170,8 @@ void vmbus_onmessage(void *context)
hdr = (struct vmbus_channel_message_header *)msg->u.payload;
size = msg->header.payload_size;
 
+   trace_vmbus_on_message(hdr);
+
if (hdr->msgtype >= CHANNELMSG_COUNT) {
pr_err("Received invalid channel message type %d size %d\n",
   hdr->msgtype, size);
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 9a29ef55477d..72911dfc9682 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -14,6 +14,14 @@ TRACE_EVENT(vmbus_on_msg_dpc,
TP_printk("message %u received", __entry->msgtype)
);
 
+TRACE_EVENT(vmbus_on_message,
+   TP_PROTO(const struct vmbus_channel_message_header *hdr),
+   TP_ARGS(hdr),
+   TP_STRUCT__entry(__field(unsigned int, msgtype)),
+   TP_fast_assign(__entry->msgtype = hdr->msgtype),
+   TP_printk("processing message %u", __entry->msgtype)
+   );
+
 #undef TRACE_INCLUDE_PATH
 #define TRACE_INCLUDE_PATH .
 #undef TRACE_INCLUDE_FILE
-- 
2.13.5

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


[PATCH 00/16] Hyper-V: add tracing to VMBus module and trace all messages

2017-09-20 Thread Vitaly Kuznetsov
Messages between guest and host are used in Hyper-V as control flow. To
simplify debugging various issues which are often hard to reproduce add
tracepoints to all message senders and handlers. This is not a performance
critical path and tracing overhead should be negligible.

The example usage and output is:

Enable all tracing events:
# echo 1 > /sys/kernel/debug/tracing/events/hyperv/enable 

Do something which causes messages to be sent between host and guest, e.g.
hot remove a VMBus device.

Check events:
# cat /sys/kernel/debug/tracing/trace 

# tracer: nop
#
#  _-=> irqs-off
# / _=> need-resched
#| / _---=> hardirq/softirq
#|| / _--=> preempt-depth
#||| / delay
#   TASK-PID   CPU#  TIMESTAMP  FUNCTION
#  | |   |      | |
  -0 [005] .Ns.   465.923970: vmbus_on_msg_dpc: message 2 
received
 ksoftirqd/5-41[005] ..s.   465.923998: vmbus_on_msg_dpc: message 2 
received
 kworker/5:1-64[005]    465.924005: vmbus_on_message: processing 
message 2
 kworker/5:1-64[005]    465.924005: vmbus_onoffer_rescind: 
child_relid 0x16
  -0 [005] ..s.   465.924114: vmbus_on_msg_dpc: message 2 
received
  -0 [005] ..s.   465.924120: vmbus_on_msg_dpc: message 2 
received
  -0 [005] .Ns.   465.924502: vmbus_on_msg_dpc: message 2 
received
 kworker/5:2-208   [005]    465.924520: vmbus_on_message: processing 
message 2
 kworker/5:2-208   [005]    465.924520: vmbus_onoffer_rescind: 
child_relid 0x18
 kworker/5:0-2533  [005]    465.924713: vmbus_on_message: processing 
message 2
 kworker/5:0-2533  [005]    465.924713: vmbus_onoffer_rescind: 
child_relid 0x17
 kworker/5:3-2534  [005]    465.924810: vmbus_on_message: processing 
message 2
 kworker/5:3-2534  [005]    465.924810: vmbus_onoffer_rescind: 
child_relid 0x15
 kworker/5:4-2535  [005]    465.924900: vmbus_on_message: processing 
message 2
 kworker/5:4-2535  [005]    465.924901: vmbus_onoffer_rescind: 
child_relid 0x10
 kworker/5:4-2535  [005]    465.932588: vmbus_close_internal: sending 
child_relid 0x15, ret 0
 kworker/5:4-2535  [005]    465.932623: vmbus_close_internal: sending 
child_relid 0x16, ret 0
 kworker/5:4-2535  [005]    465.932656: vmbus_close_internal: sending 
child_relid 0x17, ret 0
 kworker/5:4-2535  [005]    465.932683: vmbus_close_internal: sending 
child_relid 0x18, ret 0
 kworker/5:4-2535  [005]    465.932709: vmbus_close_internal: sending 
child_relid 0x10, ret 0
 kworker/5:4-2535  [005]    465.986417: vmbus_release_relid: sending 
child_relid 0x10, ret 0

CHANNELMSG_UNLOAD/CHANNELMSG_UNLOAD_RESPONSE are not traced as these are
mostly used on crash.

Vitaly Kuznetsov (16):
  hyper-v: trace vmbus_on_msg_dpc()
  hyper-v: trace vmbus_on_message()
  hyper-v: trace vmbus_onoffer()
  hyper-v: trace vmbus_onoffer_rescind()
  hyper-v: trace vmbus_onopen_result()
  hyper-v: trace vmbus_ongpadl_created()
  hyper-v: trace vmbus_ongpadl_torndown()
  hyper-v: trace vmbus_onversion_response()
  hyper-v: trace vmbus_request_offers()
  hyper-v: trace vmbus_open()
  hyper-v: trace vmbus_close_internal()
  hyper-v: trace vmbus_establish_gpadl()
  hyper-v: trace vmbus_teardown_gpadl()
  hyper-v: trace vmbus_negotiate_version()
  hyper-v: trace vmbus_release_relid()
  hyper-v: trace vmbus_send_tl_connect_request()

 drivers/hv/Makefile   |   4 +-
 drivers/hv/channel.c  |  19 ++-
 drivers/hv/channel_mgmt.c |  26 +++-
 drivers/hv/connection.c   |   3 +
 drivers/hv/hv_trace.c |   4 +
 drivers/hv/hv_trace.h | 302 ++
 drivers/hv/hyperv_vmbus.h |   2 +
 drivers/hv/vmbus_drv.c|   2 +
 8 files changed, 357 insertions(+), 5 deletions(-)
 create mode 100644 drivers/hv/hv_trace.c
 create mode 100644 drivers/hv/hv_trace.h

-- 
2.13.5

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


[PATCH 01/16] hyper-v: trace vmbus_on_msg_dpc()

2017-09-20 Thread Vitaly Kuznetsov
Add tracing subsystem to Hyper-V VMBus module and add tracepoint
to vmbus_on_msg_dpc() which is called when we receive a message from host.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/Makefile   |  4 +++-
 drivers/hv/hv_trace.c |  4 
 drivers/hv/hv_trace.h | 24 
 drivers/hv/hyperv_vmbus.h |  2 ++
 drivers/hv/vmbus_drv.c|  2 ++
 5 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 drivers/hv/hv_trace.c
 create mode 100644 drivers/hv/hv_trace.h

diff --git a/drivers/hv/Makefile b/drivers/hv/Makefile
index 39c9b2c08d33..ad791e00230f 100644
--- a/drivers/hv/Makefile
+++ b/drivers/hv/Makefile
@@ -2,7 +2,9 @@ obj-$(CONFIG_HYPERV)+= hv_vmbus.o
 obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o
 obj-$(CONFIG_HYPERV_BALLOON)   += hv_balloon.o
 
+CFLAGS_hv_trace.o = -I$(src)
+
 hv_vmbus-y := vmbus_drv.o \
 hv.o connection.o channel.o \
-channel_mgmt.o ring_buffer.o
+channel_mgmt.o ring_buffer.o hv_trace.o
 hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o hv_utils_transport.o
diff --git a/drivers/hv/hv_trace.c b/drivers/hv/hv_trace.c
new file mode 100644
index ..df47acd01a81
--- /dev/null
+++ b/drivers/hv/hv_trace.c
@@ -0,0 +1,4 @@
+#include "hyperv_vmbus.h"
+
+#define CREATE_TRACE_POINTS
+#include "hv_trace.h"
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
new file mode 100644
index ..9a29ef55477d
--- /dev/null
+++ b/drivers/hv/hv_trace.h
@@ -0,0 +1,24 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hyperv
+
+#if !defined(_HV_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _HV_TRACE_H
+
+#include 
+
+TRACE_EVENT(vmbus_on_msg_dpc,
+   TP_PROTO(const struct vmbus_channel_message_header *hdr),
+   TP_ARGS(hdr),
+   TP_STRUCT__entry(__field(unsigned int, msgtype)),
+   TP_fast_assign(__entry->msgtype = hdr->msgtype),
+   TP_printk("message %u received", __entry->msgtype)
+   );
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE hv_trace
+#endif /* _HV_TRACE_H */
+
+/* This part must be outside protection */
+#include 
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 49569f8fe038..82eb082f3302 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -31,6 +31,8 @@
 #include 
 #include 
 
+#include "hv_trace.h"
+
 /*
  * Timeout for services such as KVP and fcopy.
  */
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index a9d49f6f6501..ced33b1982c4 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -834,6 +834,8 @@ void vmbus_on_msg_dpc(unsigned long data)
 
hdr = (struct vmbus_channel_message_header *)msg->u.payload;
 
+   trace_vmbus_on_msg_dpc(hdr);
+
if (hdr->msgtype >= CHANNELMSG_COUNT) {
WARN_ONCE(1, "unknown msgtype=%d\n", hdr->msgtype);
goto msg_handled;
-- 
2.13.5

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


Re: [PATCH] [media] staging: atomisp: use clock framework for camera clocks

2017-09-20 Thread Pierre-Louis Bossart



On 09/20/2017 04:12 AM, Andy Shevchenko wrote:

On Tue, 2017-09-19 at 15:45 -0500, Pierre-Louis Bossart wrote:

The Atom ISP driver initializes and configures PMC clocks which are
already handled by the clock framework.

Remove all legacy vlv2_platform_clock stuff and move to the clk API to
avoid conflicts, e.g. with audio machine drivers enabling the MCLK for
external codecs


I think it might have a Fixes: tag as well (though I dunno which commit
could be considered as anchor).
The initial integration of the atomisp driver already had this problem, 
i'll add a reference to

'a49d25364dfb9 ("staging/atomisp: Add support for the Intel IPU v2")'


(I doubt Git is so clever to remove files based on information out of
the diff, can you check it and if needed to resend without -D implied?)
Gee, I thought -C -M -D were the standard options to checkpatch, never 
realized it'd prevent patches from applying. Thanks for the tip.




Other than that - nice clean up!

Reviewed-by: Andy Shevchenko 

I'll add your Reviewed-by in the v2. Thanks for the review.




Tested-by: Carlo Caione 
Signed-off-by: Pierre-Louis Bossart 
---
  drivers/staging/media/atomisp/Kconfig  |   1 +
  drivers/staging/media/atomisp/platform/Makefile|   1 -
  .../staging/media/atomisp/platform/clock/Makefile  |   6 -
  .../platform/clock/platform_vlv2_plat_clk.c|  40 
  .../platform/clock/platform_vlv2_plat_clk.h|  27 ---
  .../media/atomisp/platform/clock/vlv2_plat_clock.c | 247 
-
  .../platform/intel-mid/atomisp_gmin_platform.c |  63 +-
  7 files changed, 52 insertions(+), 333 deletions(-)
  delete mode 100644
drivers/staging/media/atomisp/platform/clock/Makefile
  delete mode 100644
drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.c
  delete mode 100644
drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.h
  delete mode 100644
drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c

diff --git a/drivers/staging/media/atomisp/Kconfig
b/drivers/staging/media/atomisp/Kconfig
index 8eb13c3ba29c..7cdebea35ccf 100644
--- a/drivers/staging/media/atomisp/Kconfig
+++ b/drivers/staging/media/atomisp/Kconfig
@@ -1,6 +1,7 @@
  menuconfig INTEL_ATOMISP
  bool "Enable support to Intel MIPI camera drivers"
  depends on X86 && EFI && MEDIA_CONTROLLER && PCI && ACPI
+   select COMMON_CLK
  help
Enable support for the Intel ISP2 camera interfaces and
MIPI
sensor drivers.
diff --git a/drivers/staging/media/atomisp/platform/Makefile
b/drivers/staging/media/atomisp/platform/Makefile
index df157630bda9..0e3b7e1c81c6 100644
--- a/drivers/staging/media/atomisp/platform/Makefile
+++ b/drivers/staging/media/atomisp/platform/Makefile
@@ -2,5 +2,4 @@
  # Makefile for camera drivers.
  #
  
-obj-$(CONFIG_INTEL_ATOMISP) += clock/

  obj-$(CONFIG_INTEL_ATOMISP) += intel-mid/
diff --git a/drivers/staging/media/atomisp/platform/clock/Makefile
b/drivers/staging/media/atomisp/platform/clock/Makefile
deleted file mode 100644
index 82fbe8b6968a..
diff --git
a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
c
b/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
c
deleted file mode 100644
index 0aae9b0283bb..
diff --git
a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
h
b/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
h
deleted file mode 100644
index b730ab0e8223..
diff --git
a/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
b/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
deleted file mode 100644
index f96789a31819..
diff --git a/drivers/staging/media/atomisp/platform/intel-
mid/atomisp_gmin_platform.c
b/drivers/staging/media/atomisp/platform/intel-
mid/atomisp_gmin_platform.c
index edaae93af8f9..17b4cfae5abf 100644
--- a/drivers/staging/media/atomisp/platform/intel-
mid/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/platform/intel-
mid/atomisp_gmin_platform.c
@@ -4,10 +4,10 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
-#include "../../include/linux/vlv2_plat_clock.h"
  #include 
  #include 
  #include 
@@ -17,11 +17,7 @@
  
  #define MAX_SUBDEVS 8
  
-/* Should be defined in vlv2_plat_clock API, isn't: */

-#define VLV2_CLK_PLL_19P2MHZ 1
-#define VLV2_CLK_XTAL_19P2MHZ 0
-#define VLV2_CLK_ON  1
-#define VLV2_CLK_OFF 2
+#define VLV2_CLK_PLL_19P2MHZ 1 /* XTAL on CHT */
  #define ELDO1_SEL_REG 0x19
  #define ELDO1_1P8V0x16
  #define ELDO1_CTRL_SHIFT 0x00
@@ -33,6 +29,7 @@ struct gmin_subdev {
struct v4l2_subdev *subdev;
int clock_num;
int clock_src;
+   struct clk *pmc_clk;
struct gpio_desc *gpio0;
struct gpio_desc *gpio1;
struct regulator *v1p8_reg;
@@ -344,6 +341,9 @@ static int gmin_platform_deinit(void)
return 0;
  }
  
+#define GMIN_PM

Re: [PATCH 1/2] mux: add mux_control_get_optional() API

2017-09-20 Thread Stephen Boyd
Quoting Hans de Goede (2017-09-19 11:35:50)
> Hi,
> 
> On 09/08/2017 05:54 PM, Peter Rosin wrote:
> > On 2017-09-08 17:45, Peter Rosin wrote:
> >> From: Stephen Boyd 
> >>
> >> Sometimes drivers only use muxes under certain scenarios. For
> >> example, the chipidea usb controller may be connected to a usb
> >> switch on some platforms, and connected directly to a usb port on
> >> others. The driver won't know one way or the other though, so add
> >> a mux_control_get_optional() API that allows the driver to
> >> differentiate errors getting the mux from there not being a mux
> >> for the driver to use at all.
> >> ---
> >>   Documentation/driver-model/devres.txt |   1 +
> >>   drivers/mux/core.c| 104 
> >> +++---
> >>   include/linux/mux/consumer.h  |   4 ++
> >>   3 files changed, 89 insertions(+), 20 deletions(-)
> >>
> >> I haven't tested this patch, and hence I have not signed it and I also
> >> removed the sign-off from Stephen...
> > 
> > Huh, I definitely intended to mention that this patch is based on [1]
> > from Stephen, but that I've made changes according to the comments in
> > that thread (and more). And those changes are what made me remove the
> > sign-off from Stephen...
> 
> AFAIK normally a Signed-off-by is kept if some (small-ish) changes
> are made. The S-o-b is mostly an indication that the author is
> ok with adding the code to the kernel under the GPL.
> 
> Anyways, Stephen are you ok with re-adding your S-o-b to
> the version modified by Peter?
> 

Please add my sign off

Signed-off-by: Stephen Boyd 

and I would expect Peter to have one as well with a maintainer tag
indicating what changed from my patch.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] android: binder: fix type mismatch warning

2017-09-20 Thread Arnd Bergmann
On Wed, Sep 20, 2017 at 12:24 PM, Martijn Coenen  wrote:
> On Wed, Sep 20, 2017 at 11:58 AM, Arnd Bergmann  wrote:
>>
>> - Since you say there are existing users of recent 32-bit Android
>>   including Oreo, I also think that removing support for the v7 ABI
>>   is no longer an option. I only made that suggestion under the
>>   assumption that there is no user space requiring that. Linux
>>   has no real way of "deprecating" an existing ABI, either it is
>>   currently used and has to stay around, or it is not used at all
>>   and can be removed without anybody noticing.
>
> I don't know of any Android devices shipping with 4.14 - we don't even
> have a common tree for 4.14 (4.9 is the latest). So I don't think
> we're hurting anyone in the Android ecosystem if we remove v7 from
> 4.14. From what I know, it's extremely rare for an Android device to
> change their kernel version after a device ships, but even if someone
> hypothetically did update their Android device to use 4.14, they can
> pretty easily switch the build-time config option. I understand that
> this is against Linux' philosophy around not breaking userspace, I
> just want to point out that I think from an Android POV, removing v7
> from 4.14 is not an issue. I'm not sure if that is good enough.

I'm not really worried about shipping Android products, for those
there is no big problem using the compile-time option as they build
everything together.

The case that gets interesting is a any kind of user that wants to
run an Android application on a regular Linux box without
using virtual machines or emulation, e.g. a an app developer,
or a user that wants to run some Android app on their desktop
using anbox.

This obviously requires enabling the module, but it should not
require enabling an option to support one version of the user
space while breaking another version.

>> If we end up doing a runtime switch between the ABIs instead,
>> I see two ways of doing that:
>>
>> The easiest implementation would make it a module parameter:
>> Since there is only one instance of the binder in any given
>> system, and presumably all processes talking to it have to use
>> the same ABI, this should be sufficient. The main downside is
>> that it prevents us from having incompatible versions per
>> namespace if we ever get a containerized version of binder.
>
> Namespace support for binder is currently being investigated, but I'm
> not sure we'd ever have a system where we want to mix v7 and v8. There
> really is no good reason to use v7 anymore (even on 32-bit mahcines),
> we just should have removed it from our userspace a lot earlier.

The only possible reason for v7 is backwards compatibility. I agree
we don't need a single machine (or container) to support a mix of
v7 and v8 applications, but I can see someone using a v7 based
chroot user space today to keep running that in a container in the
future while using another container for an updated image.

This is clearly a corner case that we could decide to ignore, it
just feels like a bit of a hack.

>> The correct way to do it would be to unify the two versions of
>> the ABI so they can be used interchangeably: any 32-bit
>> process would start out with the v7 interface and a 64-bit
>> process would start out with the v8 interface
>
> This wouldn't work with the current implementation - if a 32-bit and
> 64-bit process communicate, then userspace would make wrong
> assumptions about the sizes of transactions. Or is this what you're
> proposing to fix?

The scenario I had in mind is like this:

- Any 64-bit process would use the v8 ABI all the time. When the binder
  device has been opened by a 64-bit process already, this forces
  all other processes opening it to also use v8.

- An existing 32-bit process would keep using the v7 ABI, but as long
  as the the v7 interface is in use, no other process may use the v8 ABI.
  This would exclude all 64-bit processes, as well as prevent 32-bit
  processes other than the first one from switching binder to the v8
  ABI

- Future binder user space implementations on 32-bit include a
  call to a new ioctl for switching from v7 to v8. The binder user space
  calls this immediately after opening the device to tell the kernel that
  it wants to use the v8 ABI, and from that point on, it behaves like
  the first case (opened by a 64-bit process).

To support both ABIs in the same kernel module, that has to convert
between the data structures. This is not much different between the
module parameter method and the ioctl switch.
It can continue using the v8 structures
internally and then do:

static bool abi_v8 = !BINDER_IPC_32BIT;
module_parm(abi_v8, bool, S_IRUGO);

static long binder_ioctl_v8(struct file *filp, unsigned int cmd,
unsigned long arg)
{
/* the current binder_ioctl() function, built for v8 */
}

static long binder_ioctl_v7(struct file *filp, unsigned int cmd,
unsigned long arg)
{
   if (cmd == BINDER_SET_V8_ABI && !binder_in_use) {

Re: [PATCH] android: binder: fix type mismatch warning

2017-09-20 Thread Martijn Coenen
On Wed, Sep 20, 2017 at 11:58 AM, Arnd Bergmann  wrote:
> - On stable mainline kernels (unlike android-common), the v8
>   interface has never been available as a build option, and making
>   it user-selectable will required additional patches to make it
>   actually build on 32-bit ARM. This is fixable if Greg is willing
>   to take the backports into stable kernels

Yeah that would need to be fixed indeed.

>
> - Having a compile-time option to pick between two incompatible
>   ABIs is a really bad idea, we don't do that anywhere else in
>   the kernel except for things like the choice between big-endian
>   and little-endian kernels that can't be done otherwise. If we
>   want to keep supporting both ABIs going forward, I think it
>   needs to be a runtime option instead, to allow users to migrate
>   between kernel versions.

I definitely don't want to keep it going forward, just maintain the
option for older kernels.

>
> - Since you say there are existing users of recent 32-bit Android
>   including Oreo, I also think that removing support for the v7 ABI
>   is no longer an option. I only made that suggestion under the
>   assumption that there is no user space requiring that. Linux
>   has no real way of "deprecating" an existing ABI, either it is
>   currently used and has to stay around, or it is not used at all
>   and can be removed without anybody noticing.

I don't know of any Android devices shipping with 4.14 - we don't even
have a common tree for 4.14 (4.9 is the latest). So I don't think
we're hurting anyone in the Android ecosystem if we remove v7 from
4.14. From what I know, it's extremely rare for an Android device to
change their kernel version after a device ships, but even if someone
hypothetically did update their Android device to use 4.14, they can
pretty easily switch the build-time config option. I understand that
this is against Linux' philosophy around not breaking userspace, I
just want to point out that I think from an Android POV, removing v7
from 4.14 is not an issue. I'm not sure if that is good enough.

> If we end up doing a runtime switch between the ABIs instead,
> I see two ways of doing that:
>
> The easiest implementation would make it a module parameter:
> Since there is only one instance of the binder in any given
> system, and presumably all processes talking to it have to use
> the same ABI, this should be sufficient. The main downside is
> that it prevents us from having incompatible versions per
> namespace if we ever get a containerized version of binder.

Namespace support for binder is currently being investigated, but I'm
not sure we'd ever have a system where we want to mix v7 and v8. There
really is no good reason to use v7 anymore (even on 32-bit mahcines),
we just should have removed it from our userspace a lot earlier.

>
> The correct way to do it would be to unify the two versions of
> the ABI so they can be used interchangeably: any 32-bit
> process would start out with the v7 interface and a 64-bit
> process would start out with the v8 interface

This wouldn't work with the current implementation - if a 32-bit and
64-bit process communicate, then userspace would make wrong
assumptions about the sizes of transactions. Or is this what you're
proposing to fix?

> and any new
> version of the 32-bit binder user space would issue a special
> ioctl to switch to the v8 version. If we ever get a v9 version
> of the ABI, that would then add another set of ioctl commands
> with different numbers that don't conflict with the v8 interface
> but are implemented by the same kernel module.
> Actually implementing the combined v7/v8 ioctl stuff is
> of course nontrivial.

Yes, this would be a lot of work. I'll let others chime in, but I
would still prefer to remove v7 from 4.14 onward altogether.

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


Re: [PATCH] android: binder: fix type mismatch warning

2017-09-20 Thread Arnd Bergmann
On Wed, Sep 20, 2017 at 11:08 AM, Martijn Coenen  wrote:
> On Mon, Sep 18, 2017 at 9:49 PM, Arnd Bergmann  wrote:
>> The current Kconfig comment says that v7 of the ABI is also
>> incompatible with Android 4.5 and later user space. Can someone
>> confirm that?
>
> That is not actually true - v7 does work with all versions of Android
> (up to and including Oreo). In fact, we've polled some vendors, and
> all vendors with a 32-bit SoC are using the v7 interface, even on
> recent Android versions.

Ah, good to know, thanks for providing that data point!

>> The code looks like it's written under the assumption
>> that user space would dynamically pick between v7 and v8 based
>> on the return value of ioctl(..., BINDER_VERSION).
>
> It's a build-time configuration option in Android userspace.

Ok.

>> b) Treat the fact that we implemented the v7 binder ABI as a bug,
>> since real Android uses v8, removing all traces of the v7 code from
>> the kernel, and requiring users of Android 4.4 and earlier to upgrade
>> their binder to a version that runs on modern kernels.
>
> This would be my proposal as well. In fact, we have already planned to
> officially remove support for the v7 interface in Android P, and
> require all devices using Android P to use the 64-bit v8 interface
> (regardless of whether the machine is 32-bit or 64-bit). The one
> caveat is that for stable/longterm, I think we want to leave the
> config option, but perhaps flip the default (to v8). The main reason
> is that some vendors may have existing devices on the v7 interface,
> and maybe they're just pushing security updates. We don't want to
> force them to switch to 64-bit just by pulling in the latest stable.
> Does that sound reasonable?

I see multiple problems with that:

- On stable mainline kernels (unlike android-common), the v8
  interface has never been available as a build option, and making
  it user-selectable will required additional patches to make it
  actually build on 32-bit ARM. This is fixable if Greg is willing
  to take the backports into stable kernels

- Having a compile-time option to pick between two incompatible
  ABIs is a really bad idea, we don't do that anywhere else in
  the kernel except for things like the choice between big-endian
  and little-endian kernels that can't be done otherwise. If we
  want to keep supporting both ABIs going forward, I think it
  needs to be a runtime option instead, to allow users to migrate
  between kernel versions.

- Since you say there are existing users of recent 32-bit Android
  including Oreo, I also think that removing support for the v7 ABI
  is no longer an option. I only made that suggestion under the
  assumption that there is no user space requiring that. Linux
  has no real way of "deprecating" an existing ABI, either it is
  currently used and has to stay around, or it is not used at all
  and can be removed without anybody noticing.

If we end up doing a runtime switch between the ABIs instead,
I see two ways of doing that:

The easiest implementation would make it a module parameter:
Since there is only one instance of the binder in any given
system, and presumably all processes talking to it have to use
the same ABI, this should be sufficient. The main downside is
that it prevents us from having incompatible versions per
namespace if we ever get a containerized version of binder.

The correct way to do it would be to unify the two versions of
the ABI so they can be used interchangeably: any 32-bit
process would start out with the v7 interface and a 64-bit
process would start out with the v8 interface, and any new
version of the 32-bit binder user space would issue a special
ioctl to switch to the v8 version. If we ever get a v9 version
of the ABI, that would then add another set of ioctl commands
with different numbers that don't conflict with the v8 interface
but are implemented by the same kernel module.
Actually implementing the combined v7/v8 ioctl stuff is
of course nontrivial.

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


Re: [PATCH] [media] staging: atomisp: use clock framework for camera clocks

2017-09-20 Thread Andy Shevchenko
On Tue, 2017-09-19 at 15:45 -0500, Pierre-Louis Bossart wrote:
> The Atom ISP driver initializes and configures PMC clocks which are
> already handled by the clock framework.
> 
> Remove all legacy vlv2_platform_clock stuff and move to the clk API to
> avoid conflicts, e.g. with audio machine drivers enabling the MCLK for
> external codecs
> 

I think it might have a Fixes: tag as well (though I dunno which commit
could be considered as anchor).

(I doubt Git is so clever to remove files based on information out of
the diff, can you check it and if needed to resend without -D implied?)

Other than that - nice clean up!

Reviewed-by: Andy Shevchenko 


> Tested-by: Carlo Caione 
> Signed-off-by: Pierre-Louis Bossart  com>
> ---
>  drivers/staging/media/atomisp/Kconfig  |   1 +
>  drivers/staging/media/atomisp/platform/Makefile|   1 -
>  .../staging/media/atomisp/platform/clock/Makefile  |   6 -
>  .../platform/clock/platform_vlv2_plat_clk.c|  40 
>  .../platform/clock/platform_vlv2_plat_clk.h|  27 ---
>  .../media/atomisp/platform/clock/vlv2_plat_clock.c | 247 
> -
>  .../platform/intel-mid/atomisp_gmin_platform.c |  63 +-
>  7 files changed, 52 insertions(+), 333 deletions(-)
>  delete mode 100644
> drivers/staging/media/atomisp/platform/clock/Makefile
>  delete mode 100644
> drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.c
>  delete mode 100644
> drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.h
>  delete mode 100644
> drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
> 
> diff --git a/drivers/staging/media/atomisp/Kconfig
> b/drivers/staging/media/atomisp/Kconfig
> index 8eb13c3ba29c..7cdebea35ccf 100644
> --- a/drivers/staging/media/atomisp/Kconfig
> +++ b/drivers/staging/media/atomisp/Kconfig
> @@ -1,6 +1,7 @@
>  menuconfig INTEL_ATOMISP
>  bool "Enable support to Intel MIPI camera drivers"
>  depends on X86 && EFI && MEDIA_CONTROLLER && PCI && ACPI
> + select COMMON_CLK
>  help
>Enable support for the Intel ISP2 camera interfaces and
> MIPI
>sensor drivers.
> diff --git a/drivers/staging/media/atomisp/platform/Makefile
> b/drivers/staging/media/atomisp/platform/Makefile
> index df157630bda9..0e3b7e1c81c6 100644
> --- a/drivers/staging/media/atomisp/platform/Makefile
> +++ b/drivers/staging/media/atomisp/platform/Makefile
> @@ -2,5 +2,4 @@
>  # Makefile for camera drivers.
>  #
>  
> -obj-$(CONFIG_INTEL_ATOMISP) += clock/
>  obj-$(CONFIG_INTEL_ATOMISP) += intel-mid/
> diff --git a/drivers/staging/media/atomisp/platform/clock/Makefile
> b/drivers/staging/media/atomisp/platform/clock/Makefile
> deleted file mode 100644
> index 82fbe8b6968a..
> diff --git
> a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
> c
> b/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
> c
> deleted file mode 100644
> index 0aae9b0283bb..
> diff --git
> a/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
> h
> b/drivers/staging/media/atomisp/platform/clock/platform_vlv2_plat_clk.
> h
> deleted file mode 100644
> index b730ab0e8223..
> diff --git
> a/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
> b/drivers/staging/media/atomisp/platform/clock/vlv2_plat_clock.c
> deleted file mode 100644
> index f96789a31819..
> diff --git a/drivers/staging/media/atomisp/platform/intel-
> mid/atomisp_gmin_platform.c
> b/drivers/staging/media/atomisp/platform/intel-
> mid/atomisp_gmin_platform.c
> index edaae93af8f9..17b4cfae5abf 100644
> --- a/drivers/staging/media/atomisp/platform/intel-
> mid/atomisp_gmin_platform.c
> +++ b/drivers/staging/media/atomisp/platform/intel-
> mid/atomisp_gmin_platform.c
> @@ -4,10 +4,10 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> -#include "../../include/linux/vlv2_plat_clock.h"
>  #include 
>  #include 
>  #include 
> @@ -17,11 +17,7 @@
>  
>  #define MAX_SUBDEVS 8
>  
> -/* Should be defined in vlv2_plat_clock API, isn't: */
> -#define VLV2_CLK_PLL_19P2MHZ 1
> -#define VLV2_CLK_XTAL_19P2MHZ 0
> -#define VLV2_CLK_ON  1
> -#define VLV2_CLK_OFF 2
> +#define VLV2_CLK_PLL_19P2MHZ 1 /* XTAL on CHT */
>  #define ELDO1_SEL_REG0x19
>  #define ELDO1_1P8V   0x16
>  #define ELDO1_CTRL_SHIFT 0x00
> @@ -33,6 +29,7 @@ struct gmin_subdev {
>   struct v4l2_subdev *subdev;
>   int clock_num;
>   int clock_src;
> + struct clk *pmc_clk;
>   struct gpio_desc *gpio0;
>   struct gpio_desc *gpio1;
>   struct regulator *v1p8_reg;
> @@ -344,6 +341,9 @@ static int gmin_platform_deinit(void)
>   return 0;
>  }
>  
> +#define GMIN_PMC_CLK_NAME 14 /* "pmc_plt_clk_[0..5]" */
> +static char gmin_pmc_clk_name[GMIN_PMC_CLK_NAME];
> +
>  static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev
> *subdev)
>  {
>   int i, ret;
> @@ -377,6 +377,37 @@ stat

Re: [PATCH] android: binder: fix type mismatch warning

2017-09-20 Thread Martijn Coenen
On Mon, Sep 18, 2017 at 9:49 PM, Arnd Bergmann  wrote:
> The current Kconfig comment says that v7 of the ABI is also
> incompatible with Android 4.5 and later user space. Can someone
> confirm that?

That is not actually true - v7 does work with all versions of Android
(up to and including Oreo). In fact, we've polled some vendors, and
all vendors with a 32-bit SoC are using the v7 interface, even on
recent Android versions.

> The code looks like it's written under the assumption
> that user space would dynamically pick between v7 and v8 based
> on the return value of ioctl(..., BINDER_VERSION).

It's a build-time configuration option in Android userspace.

> b) Treat the fact that we implemented the v7 binder ABI as a bug,
> since real Android uses v8, removing all traces of the v7 code from
> the kernel, and requiring users of Android 4.4 and earlier to upgrade
> their binder to a version that runs on modern kernels.

This would be my proposal as well. In fact, we have already planned to
officially remove support for the v7 interface in Android P, and
require all devices using Android P to use the 64-bit v8 interface
(regardless of whether the machine is 32-bit or 64-bit). The one
caveat is that for stable/longterm, I think we want to leave the
config option, but perhaps flip the default (to v8). The main reason
is that some vendors may have existing devices on the v7 interface,
and maybe they're just pushing security updates. We don't want to
force them to switch to 64-bit just by pulling in the latest stable.
Does that sound reasonable?

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


[PATCH v3 2/2] staging: ion: create one device entry per heap

2017-09-20 Thread Benjamin Gaignard
Instead a getting one common device "/dev/ion" for
all the heaps this patch allow to create one device
entry ("/dev/ionX") per heap.
Getting an entry per heap could allow to set security rules
per heap and global ones for all heaps.

Allocation requests will be only allowed if the mask_id
match with device minor.
Query request could be done on any of the devices.
Deivce node major will also change and that may impact init scripts.

Signed-off-by: Benjamin Gaignard 
---
version 3:
- change ion_device_add_heap prototype to return a possible error

version 2:
- simplify ioctl check like propose by Dan
- make sure that we don't register more than ION_DEV_MAX heaps

 drivers/staging/android/TODO|  1 -
 drivers/staging/android/ion/ion-ioctl.c | 11 +--
 drivers/staging/android/ion/ion.c   | 27 ---
 drivers/staging/android/ion/ion.h   | 12 
 4 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/android/TODO b/drivers/staging/android/TODO
index 5f14247..d770ffa 100644
--- a/drivers/staging/android/TODO
+++ b/drivers/staging/android/TODO
@@ -9,7 +9,6 @@ TODO:
 ion/
  - Add dt-bindings for remaining heaps (chunk and carveout heaps). This would
involve putting appropriate bindings in a memory node for Ion to find.
- - Split /dev/ion up into multiple nodes (e.g. /dev/ion/heap0)
  - Better test framework (integration with VGEM was suggested)
 
 Please send patches to Greg Kroah-Hartman  and Cc:
diff --git a/drivers/staging/android/ion/ion-ioctl.c 
b/drivers/staging/android/ion/ion-ioctl.c
index e26b786..c8c906c 100644
--- a/drivers/staging/android/ion/ion-ioctl.c
+++ b/drivers/staging/android/ion/ion-ioctl.c
@@ -25,8 +25,11 @@ union ion_ioctl_arg {
struct ion_heap_query query;
 };
 
-static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
+static int validate_ioctl_arg(struct file *filp,
+ unsigned int cmd, union ion_ioctl_arg *arg)
 {
+   int mask = 1 << iminor(filp->f_inode);
+
switch (cmd) {
case ION_IOC_HEAP_QUERY:
if (arg->query.reserved0 ||
@@ -34,6 +37,10 @@ static int validate_ioctl_arg(unsigned int cmd, union 
ion_ioctl_arg *arg)
arg->query.reserved2 )
return -EINVAL;
break;
+   case ION_IOC_ALLOC:
+   if (!(arg->allocation.heap_id_mask & mask))
+   return -EINVAL;
+   break;
default:
break;
}
@@ -69,7 +76,7 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd)))
return -EFAULT;
 
-   ret = validate_ioctl_arg(cmd, &data);
+   ret = validate_ioctl_arg(filp, cmd, &data);
if (WARN_ON_ONCE(ret))
return ret;
 
diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index 93e2c90..cc2d381 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -40,6 +40,8 @@
 
 #include "ion.h"
 
+#define ION_DEV_MAX 32
+
 static struct ion_device *internal_dev;
 static int heap_id;
 
@@ -537,15 +539,28 @@ static int debug_shrink_get(void *data, u64 *val)
 DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get,
debug_shrink_set, "%llu\n");
 
-void ion_device_add_heap(struct ion_heap *heap)
+int ion_device_add_heap(struct ion_heap *heap)
 {
struct dentry *debug_file;
struct ion_device *dev = internal_dev;
+   int ret;
 
if (!heap->ops->allocate || !heap->ops->free)
pr_err("%s: can not add heap with invalid ops struct.\n",
   __func__);
 
+   if (heap_id >= ION_DEV_MAX)
+   return -EBUSY;
+
+   heap->ddev.devt = MKDEV(MAJOR(dev->devt), heap_id);
+   dev_set_name(&heap->ddev, "ion%d", heap_id);
+   device_initialize(&heap->ddev);
+   cdev_init(&heap->chrdev, &ion_fops);
+   heap->chrdev.owner = THIS_MODULE;
+   ret = cdev_device_add(&heap->chrdev, &heap->ddev);
+   if (ret < 0)
+   return ret;
+
spin_lock_init(&heap->free_lock);
heap->free_list_size = 0;
 
@@ -583,6 +598,8 @@ void ion_device_add_heap(struct ion_heap *heap)
 
dev->heap_cnt++;
up_write(&dev->lock);
+
+   return 0;
 }
 EXPORT_SYMBOL(ion_device_add_heap);
 
@@ -595,13 +612,9 @@ static int ion_device_create(void)
if (!idev)
return -ENOMEM;
 
-   idev->dev.minor = MISC_DYNAMIC_MINOR;
-   idev->dev.name = "ion";
-   idev->dev.fops = &ion_fops;
-   idev->dev.parent = NULL;
-   ret = misc_register(&idev->dev);
+   ret = alloc_chrdev_region(&idev->devt, 0, ION_DEV_MAX, "ion");
if (ret) {
-   pr_err("ion: failed to register misc device.\n");
+   pr_err("ion: unable to allocate major\n");
kf

[PATCH v3 0/2] staging: ion: get one device per heap

2017-09-20 Thread Benjamin Gaignard
version 3:
- change ion_device_add_heap prototype to return a possible error

version 2:
- simplify ioctl check like propose by Dan
- make sure that we don't register more than ION_DEV_MAX heaps

Until now all ion heaps are addressing using the same device "/dev/ion".
This way of working doesn't allow to give access rights (for example with
SElinux rules) per heap.
This series propose to have one device "/dev/ionX" per heap.
Query heaps informations will be possible on each device node but allocation
request will only be possible if heap_mask_id match with device minor number.

That really change ion ABI because:
- device name change
- allocation must be done on the correct device/heap.
- device major number will not be the same and that could impact init scripts.

Even if splitting ion device in multiple node was one of the item of the
de-staging TODO list this must be agreed by a larger audience because it is
(again) an ion ABI bing bang. Hopefully that could be discussed at next XDC
to get a decission on this particular point.

Benjamin Gaignard (2):
  staging: ion: simplify ioctl args checking function
  staging: ion: create one device entry per heap

 drivers/staging/android/TODO|  1 -
 drivers/staging/android/ion/ion-ioctl.c | 20 +---
 drivers/staging/android/ion/ion.c   | 27 ---
 drivers/staging/android/ion/ion.h   | 12 
 4 files changed, 41 insertions(+), 19 deletions(-)

-- 
2.7.4

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


[PATCH v3 1/2] staging: ion: simplify ioctl args checking function

2017-09-20 Thread Benjamin Gaignard
Make arguments checking more easy to read.

Signed-off-by: Benjamin Gaignard 
---
 drivers/staging/android/ion/ion-ioctl.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/android/ion/ion-ioctl.c 
b/drivers/staging/android/ion/ion-ioctl.c
index d9f8b14..e26b786 100644
--- a/drivers/staging/android/ion/ion-ioctl.c
+++ b/drivers/staging/android/ion/ion-ioctl.c
@@ -27,19 +27,18 @@ union ion_ioctl_arg {
 
 static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
 {
-   int ret = 0;
-
switch (cmd) {
case ION_IOC_HEAP_QUERY:
-   ret = arg->query.reserved0 != 0;
-   ret |= arg->query.reserved1 != 0;
-   ret |= arg->query.reserved2 != 0;
+   if (arg->query.reserved0 ||
+   arg->query.reserved1 ||
+   arg->query.reserved2 )
+   return -EINVAL;
break;
default:
break;
}
 
-   return ret ? -EINVAL : 0;
+   return 0;
 }
 
 /* fix up the cases where the ioctl direction bits are incorrect */
-- 
2.7.4

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


Re: [PATCH v2 2/2] staging: ion: create one device entry per heap

2017-09-20 Thread Benjamin Gaignard
2017-09-20 3:01 GMT+02:00 Laura Abbott :
> On 09/19/2017 04:55 AM, Benjamin Gaignard wrote:
>>
>> 2017-09-19 13:02 GMT+02:00 Greg KH :
>>>
>>> On Tue, Sep 19, 2017 at 12:25:38PM +0200, Benjamin Gaignard wrote:

 Instead a getting one common device "/dev/ion" for
 all the heaps this patch allow to create one device
 entry ("/dev/ionX") per heap.
 Getting an entry per heap could allow to set security rules
 per heap and global ones for all heaps.

 Allocation requests will be only allowed if the mask_id
 match with device minor.
 Query request could be done on any of the devices.

 Signed-off-by: Benjamin Gaignard 
 ---
   drivers/staging/android/ion/ion-ioctl.c | 11 +--
   drivers/staging/android/ion/ion.c   | 23 +--
   drivers/staging/android/ion/ion.h   | 10 +++---
   3 files changed, 33 insertions(+), 11 deletions(-)

 diff --git a/drivers/staging/android/ion/ion-ioctl.c
 b/drivers/staging/android/ion/ion-ioctl.c
 index e26b786..c8c906c 100644
 --- a/drivers/staging/android/ion/ion-ioctl.c
 +++ b/drivers/staging/android/ion/ion-ioctl.c
 @@ -25,8 +25,11 @@ union ion_ioctl_arg {
struct ion_heap_query query;
   };

 -static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg
 *arg)
 +static int validate_ioctl_arg(struct file *filp,
 +   unsigned int cmd, union ion_ioctl_arg *arg)
   {
 + int mask = 1 << iminor(filp->f_inode);
 +
switch (cmd) {
case ION_IOC_HEAP_QUERY:
if (arg->query.reserved0 ||
 @@ -34,6 +37,10 @@ static int validate_ioctl_arg(unsigned int cmd, union
 ion_ioctl_arg *arg)
arg->query.reserved2 )
return -EINVAL;
break;
 + case ION_IOC_ALLOC:
 + if (!(arg->allocation.heap_id_mask & mask))
 + return -EINVAL;
 + break;
default:
break;
}
 @@ -69,7 +76,7 @@ long ion_ioctl(struct file *filp, unsigned int cmd,
 unsigned long arg)
if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd)))
return -EFAULT;

 - ret = validate_ioctl_arg(cmd, &data);
 + ret = validate_ioctl_arg(filp, cmd, &data);
if (WARN_ON_ONCE(ret))
return ret;

 diff --git a/drivers/staging/android/ion/ion.c
 b/drivers/staging/android/ion/ion.c
 index 93e2c90..3f8b595 100644
 --- a/drivers/staging/android/ion/ion.c
 +++ b/drivers/staging/android/ion/ion.c
 @@ -40,6 +40,8 @@

   #include "ion.h"

 +#define ION_DEV_MAX 32
 +
   static struct ion_device *internal_dev;
   static int heap_id;

 @@ -541,11 +543,24 @@ void ion_device_add_heap(struct ion_heap *heap)
   {
struct dentry *debug_file;
struct ion_device *dev = internal_dev;
 + int ret;

if (!heap->ops->allocate || !heap->ops->free)
pr_err("%s: can not add heap with invalid ops struct.\n",
   __func__);

 + if (heap_id >= ION_DEV_MAX)
 + return -EBUSY;
 +
 + heap->ddev.devt = MKDEV(MAJOR(dev->devt), heap_id);
 + dev_set_name(&heap->ddev, "ion%d", heap_id);
 + device_initialize(&heap->ddev);
 + cdev_init(&heap->chrdev, &ion_fops);
 + heap->chrdev.owner = THIS_MODULE;
 + ret = cdev_device_add(&heap->chrdev, &heap->ddev);
 + if (ret < 0)
 + return;
>>>
>>>
>>> No cleanup needed?  No reporting an error happened back up the chain?
>>> Not nice :(
>>
>>
>> I will change that
>>
 +
spin_lock_init(&heap->free_lock);
heap->free_list_size = 0;

 @@ -595,13 +610,9 @@ static int ion_device_create(void)
if (!idev)
return -ENOMEM;

 - idev->dev.minor = MISC_DYNAMIC_MINOR;
 - idev->dev.name = "ion";
 - idev->dev.fops = &ion_fops;
 - idev->dev.parent = NULL;
 - ret = misc_register(&idev->dev);
 + ret = alloc_chrdev_region(&idev->devt, 0, ION_DEV_MAX, "ion");
>>>
>>>
>>> Did you just change the major number for the device node as well?
>>>
>> My understanding of alloc_chrdev_region() is that major number is chosen
>> dynamically but I don't understand the link with device node, sorry.
>>
>>> Wow, that's a lot of userspace breakage (both major number, and name),
>>> how did you test this?
>>
>>
>> I had to write a test by myself:
>>
>> https://git.linaro.org/people/benjamin.gaignard/ion_test_application.git/log/?h=one_device_per_heap
>>
>> Laura have tried to push a test VGEM but I believe it hasn't be
>> accepted yet (I will check)
>>
>>>
>>> Have you gotten "upstream" to agree to th