Re: ipu3-imgu 0000:00:05.0: required queues are disabled

2019-01-28 Thread Kieran Bingham
Hi Kai-Heng,

On 27/01/2019 05:56, Kai-Heng Feng wrote:
> Hi,
> 
> We have a bug report [1] that the ipu3 doesn’t work.
> Does ipu3 need special userspace to work?

Yes, it will need further userspace support to configure the pipeline,
and to provide 3A algorithms for white balance, focus, and exposure
times to the sensor.

We are developing a stack called libcamera [0] to support this, but it's
still in active development and not yet ready for use. Fortunately
however, IPU3 is one of our primary initial targets.

[0] https://www.libcamera.org/

> [1] https://bugs.launchpad.net/bugs/1812114

I have reported similar information to the launchpad bug entry.

It might help if we can get hold of a Dell 7275 sometime although I
think Mauro at least has one ?

If this is a priority for Canonical, please contact us directly.

> Kai-Heng
--
Regards

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


[PATCH 1/6] staging: rtl8188eu: cleanup comments in mlme_linux.c

2019-01-28 Thread Michael Straube
Cleanup comments to avoid lines over 80 characters
and follow kernel style for block comments.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index 2bc49d074ce4..0321f1d45809 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -41,17 +41,21 @@ void rtw_reset_securitypriv(struct adapter *adapter)
u32 backup_time = 0;
 
if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
-   /* 802.1x */
-   /*  We have to backup the PMK information for WiFi PMK Caching 
test item. */
-   /*  Backup the btkip_countermeasure information. */
-   /*  When the countermeasure is trigger, the driver have to 
disconnect with AP for 60 seconds. */
+   /* 802.1x
+* We have to backup the PMK information for WiFi PMK Caching
+* test item. Backup the btkip_countermeasure information. When
+* the countermeasure is trigger, the driver have to disconnect
+* with AP for 60 seconds.
+*/
memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], 
sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
backup_index = adapter->securitypriv.PMKIDIndex;
backup_counter = adapter->securitypriv.btkip_countermeasure;
backup_time = adapter->securitypriv.btkip_countermeasure_time;
memset((unsigned char *)&adapter->securitypriv, 0, 
sizeof(struct security_priv));
 
-   /*  Restore the PMK information to securitypriv structure for 
the following connection. */
+   /* Restore the PMK information to securitypriv structure
+* for the following connection.
+*/
memcpy(&adapter->securitypriv.PMKIDList[0], &backup_pmkid[0],
   sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
adapter->securitypriv.PMKIDIndex = backup_index;
@@ -75,7 +79,8 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 
 void rtw_os_indicate_disconnect(struct adapter *adapter)
 {
-   netif_carrier_off(adapter->pnetdev); /*  Do it first for tx broadcast 
pkt after disconnection issue! */
+   /* Do it first for tx broadcast pkt after disconnection issue! */
+   netif_carrier_off(adapter->pnetdev);
rtw_indicate_wx_disassoc_event(adapter);
rtw_reset_securitypriv(adapter);
 }
-- 
2.20.1

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


[PATCH 4/6] staging: rtl8188eu: remove unncessary asignment to cleanup long line

2019-01-28 Thread Michael Straube
Instead of first asign 'wrqu.data.length = p - buff' use 'p - buff'
directly in min_t() in the subsequent asignment. Clears a line over
80 characters checkpatch warning.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index 142f8f9f6b1a..03d4cfefc9bc 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -109,8 +109,7 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 
authmode, u8 *sec_ie)
p += sprintf(p, "%02x", sec_ie[i]);
p += sprintf(p, ")");
memset(&wrqu, 0, sizeof(wrqu));
-   wrqu.data.length = p - buff;
-   wrqu.data.length = min_t(__u16, wrqu.data.length, 
IW_CUSTOM_MAX);
+   wrqu.data.length = min_t(__u16, p - buff, IW_CUSTOM_MAX);
wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
kfree(buff);
}
-- 
2.20.1

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


[PATCH 3/6] staging: rtl8188eu: cleanup declarations in mlme_linux.c

2019-01-28 Thread Michael Straube
Replace tabs with spaces in declarations to cleanup whitespace.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index cd6298e4920d..142f8f9f6b1a 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -13,7 +13,7 @@
 
 void rtw_init_mlme_timer(struct adapter *padapter)
 {
-   struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
+   struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
timer_setup(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler, 0);
timer_setup(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler, 0);
@@ -87,8 +87,8 @@ void rtw_os_indicate_disconnect(struct adapter *adapter)
 
 void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
 {
-   uintlen;
-   u8  *buff, *p, i;
+   uint len;
+   u8 *buff, *p, i;
union iwreq_data wrqu;
 
RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
@@ -123,7 +123,7 @@ void init_addba_retry_timer(struct adapter *padapter, 
struct sta_info *psta)
 
 void init_mlme_ext_timer(struct adapter *padapter)
 {
-   struct  mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
+   struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
timer_setup(&pmlmeext->survey_timer, survey_timer_hdl, 0);
timer_setup(&pmlmeext->link_timer, link_timer_hdl, 0);
-- 
2.20.1

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


[PATCH 6/6] staging: rtl8188eu: refactor rtw_reset_securitypriv()

2019-01-28 Thread Michael Straube
Move the declaration of 'psec_priv' out of the else path and use it
in the if path as well to improve readability. Also clears line over
80 characters checkpatch warnings.

Suggested-by: Joe Perches 
Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 29 ++-
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index caba3fe0250c..9db11b16cb93 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -39,34 +39,35 @@ void rtw_reset_securitypriv(struct adapter *adapter)
u8 backup_index;
u8 backup_counter;
u32 backup_time;
+   struct security_priv *psec_priv = &adapter->securitypriv;
 
-   if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
+   if (psec_priv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
/* 802.1x
 * We have to backup the PMK information for WiFi PMK Caching
 * test item. Backup the btkip_countermeasure information. When
 * the countermeasure is trigger, the driver have to disconnect
 * with AP for 60 seconds.
 */
-   memcpy(backup_pmkid, adapter->securitypriv.PMKIDList, 
sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-   backup_index = adapter->securitypriv.PMKIDIndex;
-   backup_counter = adapter->securitypriv.btkip_countermeasure;
-   backup_time = adapter->securitypriv.btkip_countermeasure_time;
-   memset((unsigned char *)&adapter->securitypriv, 0, 
sizeof(struct security_priv));
+   memcpy(backup_pmkid, psec_priv->PMKIDList,
+  sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+   backup_index = psec_priv->PMKIDIndex;
+   backup_counter = psec_priv->btkip_countermeasure;
+   backup_time = psec_priv->btkip_countermeasure_time;
+
+   memset(psec_priv, 0, sizeof(*psec_priv));
 
/* Restore the PMK information to securitypriv structure
 * for the following connection.
 */
-   memcpy(adapter->securitypriv.PMKIDList, backup_pmkid,
+   memcpy(psec_priv->PMKIDList, backup_pmkid,
   sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
-   adapter->securitypriv.PMKIDIndex = backup_index;
-   adapter->securitypriv.btkip_countermeasure = backup_counter;
-   adapter->securitypriv.btkip_countermeasure_time = backup_time;
-   adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
-   adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
+   psec_priv->PMKIDIndex = backup_index;
+   psec_priv->btkip_countermeasure = backup_counter;
+   psec_priv->btkip_countermeasure_time = backup_time;
+   psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
+   psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
} else {
/* reset values in securitypriv */
-   struct security_priv *psec_priv = &adapter->securitypriv;
-
psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
psec_priv->dot11PrivacyKeyIndex = 0;
-- 
2.20.1

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


[PATCH 5/6] staging: rtl8188eu: &array[0] -> array

2019-01-28 Thread Michael Straube
Change '&array[0]' to just 'array' in rtw_reset_securitypriv().

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index 03d4cfefc9bc..caba3fe0250c 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -47,7 +47,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 * the countermeasure is trigger, the driver have to disconnect
 * with AP for 60 seconds.
 */
-   memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], 
sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
+   memcpy(backup_pmkid, adapter->securitypriv.PMKIDList, 
sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
backup_index = adapter->securitypriv.PMKIDIndex;
backup_counter = adapter->securitypriv.btkip_countermeasure;
backup_time = adapter->securitypriv.btkip_countermeasure_time;
@@ -56,7 +56,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
/* Restore the PMK information to securitypriv structure
 * for the following connection.
 */
-   memcpy(&adapter->securitypriv.PMKIDList[0], &backup_pmkid[0],
+   memcpy(adapter->securitypriv.PMKIDList, backup_pmkid,
   sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
adapter->securitypriv.PMKIDIndex = backup_index;
adapter->securitypriv.btkip_countermeasure = backup_counter;
-- 
2.20.1

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


[PATCH 2/6] staging: rtl8188eu: remove unnecessary initializations

2019-01-28 Thread Michael Straube
The local variables backup_index, backup_counter and backup_time
in rtw_reset_securitypriv() are all asigned before their uses, so
initialization to zero is not necessary.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index 0321f1d45809..cd6298e4920d 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -36,9 +36,9 @@ static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE];
 
 void rtw_reset_securitypriv(struct adapter *adapter)
 {
-   u8  backup_index = 0;
-   u8  backup_counter = 0x00;
-   u32 backup_time = 0;
+   u8 backup_index;
+   u8 backup_counter;
+   u32 backup_time;
 
if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
/* 802.1x
-- 
2.20.1

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


Re: [PATCH] binder: fix CONFIG_ANDROID_BINDER_DEVICES

2019-01-28 Thread Dan Carpenter
On Sat, Jan 26, 2019 at 11:23:20AM +0100, Christian Brauner wrote:
> Several users have tried to only rely on binderfs to provide binder devices
> and set CONFIG_ANDROID_BINDER_DEVICES="" empty. This is a great use-case of
> binderfs and one that was always intended to work. However, this is
> currently not possible since setting CONFIG_ANDROID_BINDER_DEVICES="" emtpy
> will simply panic the kernel:
  

It should just do a WARN() and not panic the kernel.

regards,
dan carpenter

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


Re: [PATCH] binder: fix CONFIG_ANDROID_BINDER_DEVICES

2019-01-28 Thread Dan Carpenter
On Mon, Jan 28, 2019 at 02:47:29PM +0300, Dan Carpenter wrote:
> On Sat, Jan 26, 2019 at 11:23:20AM +0100, Christian Brauner wrote:
> > Several users have tried to only rely on binderfs to provide binder devices
> > and set CONFIG_ANDROID_BINDER_DEVICES="" empty. This is a great use-case of
> > binderfs and one that was always intended to work. However, this is
> > currently not possible since setting CONFIG_ANDROID_BINDER_DEVICES="" emtpy
> > will simply panic the kernel:
>   
> 
> It should just do a WARN() and not panic the kernel.
> 

Oh...  They have panic on warn set up probably.  Never mind.

regards,
dan carpenter

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


Re: [PATCH 3/3] Staging: media: ipu3: fixed max charecter style issue

2019-01-28 Thread Dan Carpenter
On Sun, Jan 27, 2019 at 10:24:16PM +0530, Prashantha SP wrote:
> fixed coding style issue.
> 
> Signed-off-by: Prashantha SP 
^^

Please use your full name that you would use to sign legal documents.

> ---
>  drivers/staging/media/ipu3/ipu3-css.c | 178 ++
>  1 file changed, 94 insertions(+), 84 deletions(-)
> 
> diff --git a/drivers/staging/media/ipu3/ipu3-css.c 
> b/drivers/staging/media/ipu3/ipu3-css.c
> index 44c55639389a..466a1a8cc422 100644
> --- a/drivers/staging/media/ipu3/ipu3-css.c
> +++ b/drivers/staging/media/ipu3/ipu3-css.c
> @@ -186,7 +186,8 @@ static bool ipu3_css_queue_enabled(struct ipu3_css_queue 
> *q)
>  /*** css hw ***/
>  
>  /* In the style of writesl() defined in include/asm-generic/io.h */
> -static inline void writes(const void *mem, ssize_t count, void __iomem *addr)
> +static inline void writes(const void *mem, ssize_t count,
> +   void __iomem *addr)
>  {
>   if (count >= 4) {
>   const u32 *buf = mem;
> @@ -671,8 +672,9 @@ static void ipu3_css_pipeline_cleanup(struct ipu3_css 
> *css, unsigned int pipe)
>   ipu3_css_pool_cleanup(imgu, &css->pipes[pipe].pool.obgrid);
>  
>   for (i = 0; i < IMGU_ABI_NUM_MEMORIES; i++)
> - ipu3_css_pool_cleanup(imgu,
> -   
> &css->pipes[pipe].pool.binary_params_p[i]);
> + ipu3_css_pool_cleanup
> + (imgu,
> + &css->pipes[pipe].pool.binary_params_p[i]);

The original is better.

regards,
dan carpenter

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


Re: [PATCH v2 2/2] staging: iio: ad7780: moving ad7780 out of staging

2019-01-28 Thread Dan Carpenter
On Sun, Jan 27, 2019 at 06:33:52PM -0200, Renato Lui Geh wrote:
> + st->reg = devm_regulator_get(&spi->dev, "avdd");
> + if (IS_ERR(st->reg))
> + return PTR_ERR(st->reg);
> +
> + ret = regulator_enable(st->reg);
> + if (ret) {
> + dev_err(&spi->dev, "Failed to enable specified AVdd supply\n");
> + goto error_disable_reg;
> + }

We don't need to disable the regulator if enabling it failed (probably,
I haven't looked at the code).


> +
> + ret = ad_sd_setup_buffer_and_trigger(indio_dev);
> + if (ret)
> + goto error_disable_reg;
> +
> + ret = iio_device_register(indio_dev);
> + if (ret)
> + goto error_cleanup_buffer_and_trigger;
> +
> + return 0;
> +
> +error_cleanup_buffer_and_trigger:
> + ad_sd_cleanup_buffer_and_trigger(indio_dev);
> +error_disable_reg:
> + regulator_disable(st->reg);
> +

Well chosen label names, btw.  Very easy to review.

> + return ret;
> +}
> +

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


Re: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support

2019-01-28 Thread Dan Carpenter
On Sat, Jan 26, 2019 at 10:48:53AM +0800, Chao Yu wrote:
> On 2019/1/26 0:10, Gao Xiang wrote:
> > Let's add .get_acl() to read the file's acl from its xattrs
> > to make POSIX ACL usable.
> > 
> > Here is the on-disk detail,
> > fullname: system.posix_acl_access
> > struct erofs_xattr_entry:
> > .e_name_len = 0
> > .e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS (2)
> > 
> > fullname: system.posix_acl_default
> > struct erofs_xattr_entry:
> > .e_name_len = 0
> > .e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT (3)
> > 
> > Signed-off-by: Gao Xiang 
> > ---
> > change log v2:
> >  - add the missing SB_POSIXACL flag;
> >  - fix the on-disk detail, use .e_name_len == 0 and proper prefix value;
> >  - tested ok with xattr enabled erofs_mkfs;
> 
> >  .../erofs/Documentation/filesystems/erofs.txt  |  2 ++
> >  drivers/staging/erofs/inode.c  |  3 ++
> >  drivers/staging/erofs/namei.c  |  1 +
> >  drivers/staging/erofs/super.c  |  8 +
> >  drivers/staging/erofs/xattr.c  | 37 
> > ++
> >  drivers/staging/erofs/xattr.h  |  6 
> >  6 files changed, 57 insertions(+)
> > 
> > diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt 
> > b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > index 803988d74c21..961ec4da7705 100644
> > --- a/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > +++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > @@ -36,6 +36,8 @@ Here is the main features of EROFS:
> >  
> >   - Support xattr inline and tail-end data inline for all files;
> >  
> > + - Support POSIX.1e ACLs by using xattrs;
> > +
> >   - Support transparent file compression as an option:
> > LZ4 algorithm with 4 KB fixed-output compression for high performance;
> >  
> > diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
> > index 4f04f7c38cf2..924b8dfc7a8f 100644
> > --- a/drivers/staging/erofs/inode.c
> > +++ b/drivers/staging/erofs/inode.c
> > @@ -287,6 +287,7 @@ const struct inode_operations erofs_generic_iops = {
> >  #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> >  #endif
> > +   .get_acl = erofs_get_acl,
> >  };
> >  
> >  const struct inode_operations erofs_symlink_iops = {
> > @@ -294,6 +295,7 @@ const struct inode_operations erofs_symlink_iops = {
> >  #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> >  #endif
> > +   .get_acl = erofs_get_acl,
> >  };
> >  
> >  const struct inode_operations erofs_fast_symlink_iops = {
> > @@ -301,5 +303,6 @@ const struct inode_operations erofs_fast_symlink_iops = 
> > {
> >  #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> >  #endif
> > +   .get_acl = erofs_get_acl,
> >  };
> >  
> > diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c
> > index 7fed1f996ab0..b1752adc5934 100644
> > --- a/drivers/staging/erofs/namei.c
> > +++ b/drivers/staging/erofs/namei.c
> > @@ -238,5 +238,6 @@ const struct inode_operations erofs_dir_iops = {
> >  #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> >  #endif
> > +   .get_acl = erofs_get_acl,
> >  };
> >  
> > diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
> > index 176fca2af379..54cd7dac0a1f 100644
> > --- a/drivers/staging/erofs/super.c
> > +++ b/drivers/staging/erofs/super.c
> > @@ -398,6 +398,14 @@ static int erofs_read_super(struct super_block *sb,
> > if (!silent)
> > infoln("root inode @ nid %llu", ROOT_NID(sbi));
> >  
> > +#ifdef CONFIG_EROFS_FS_POSIX_ACL
> > +   /* Update the POSIXACL Flag */
> > +   if (test_opt(sbi, POSIX_ACL))
> > +   sb->s_flags |= SB_POSIXACL;
> > +   else
> > +   sb->s_flags &= ~SB_POSIXACL;
> > +#endif
> > +
> >  #ifdef CONFIG_EROFS_FS_ZIP
> > INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
> >  #endif
> > diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
> > index 7de46690d972..6759485ae862 100644
> > --- a/drivers/staging/erofs/xattr.c
> > +++ b/drivers/staging/erofs/xattr.c
> > @@ -643,3 +643,40 @@ ssize_t erofs_listxattr(struct dentry *dentry,
> > return shared_listxattr(&it);
> >  }
> >  
> > +#ifdef CONFIG_EROFS_FS_POSIX_ACL
> > +struct posix_acl *erofs_get_acl(struct inode *inode, int type)
> > +{
> > +   struct posix_acl *acl;
> > +   int ea_prefix, rc;
> > +   char *value = NULL;
> > +
> > +   switch(type) {
> > +   case ACL_TYPE_ACCESS:
> > +   ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS;
> > +   break;
> > +   case ACL_TYPE_DEFAULT:
> > +   ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT;
> > +   break;
> > +   default:
> > +   return ERR_PTR(-EINVAL);
> > +   }
> > +
> > +   rc = erofs_getxattr(inode, ea_prefix, "", NULL, 0);
> > +   if (rc > 0) {
> > +   value = kvmalloc(rc, GFP_KERNEL);
> 
> erofs_kmalloc() is enough?

Re: [PATCH v2 2/2] staging: iio: ad7780: moving ad7780 out of staging

2019-01-28 Thread Renato Lui Geh

On 01/28, Dan Carpenter wrote:

On Sun, Jan 27, 2019 at 06:33:52PM -0200, Renato Lui Geh wrote:

+   st->reg = devm_regulator_get(&spi->dev, "avdd");
+   if (IS_ERR(st->reg))
+   return PTR_ERR(st->reg);
+
+   ret = regulator_enable(st->reg);
+   if (ret) {
+   dev_err(&spi->dev, "Failed to enable specified AVdd supply\n");
+   goto error_disable_reg;
+   }


We don't need to disable the regulator if enabling it failed (probably,
I haven't looked at the code).


I wasn't sure if ret would need to be cleaned up on failure, so I kept
it as it was before. I'll change it to a simple return if needed though.




+
+   ret = ad_sd_setup_buffer_and_trigger(indio_dev);
+   if (ret)
+   goto error_disable_reg;
+
+   ret = iio_device_register(indio_dev);
+   if (ret)
+   goto error_cleanup_buffer_and_trigger;
+
+   return 0;
+
+error_cleanup_buffer_and_trigger:
+   ad_sd_cleanup_buffer_and_trigger(indio_dev);
+error_disable_reg:
+   regulator_disable(st->reg);
+


Well chosen label names, btw.  Very easy to review.


That was already there before I came. But yes, very nice choice of
names. :)



+   return ret;
+}
+


regards,
dan carpenter

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


Re: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support

2019-01-28 Thread Gao Xiang
Hi Dan,

On 2019/1/28 21:33, Dan Carpenter wrote:
> Hopefully, regular kmalloc() is enough.
> 
> Do really need the erofs_kmalloc() function?  Regular kmalloc() has
> fault injection already.  Have you tried to use it?

The fault injection subsystem was introduced in the initial upstreamed
EROFS version, which is taken from f2fs by Chao Yu.

Fault injection is important to test fs.. However, I have no more idea
about the future plan of this feature...Follow f2fs or use the general
fault injection...

There already exists erofs_kmalloc, thus I think it's both ok to use
erofs_kmalloc or kmalloc for this patch at least.

Chao, any idea about this?

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


Re: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support

2019-01-28 Thread Dan Carpenter
The point is, that people shouldn't recreate core code that already
exists.  At least try it out and have an explanation why the other code
doesn't work.

In other projects, the default is to keep code around once it has been
written but in staging the default choice is to delete the code unless
there is an explanation.

regards,
dan carpenter

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


Re: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support

2019-01-28 Thread Gao Xiang



On 2019/1/28 22:28, Dan Carpenter wrote:
> The point is, that people shouldn't recreate core code that already
> exists.  At least try it out and have an explanation why the other code
> doesn't work.
> 
> In other projects, the default is to keep code around once it has been
> written but in staging the default choice is to delete the code unless
> there is an explanation.

That is why I need Chao's idea about the future of EROFS fault injection.

As far as I know, the fault injection of f2fs also introduces after
the general fault injection, and the original reason is to test separated
partitions with different fault injection rate/type simultaneously, as follows:

commit 1ecc0c5c50ce8834f7e35b63be7480bf1aaa4155
Author: Chao Yu 
Date:   Fri Sep 23 21:30:09 2016 +0800

f2fs: support configuring fault injection per superblock

Previously, we only support global fault injection configuration, so that
when we configure type/rate of fault injection through sysfs, mount
option, it will influence all f2fs partition which is being used.

It is not make sence, since it will be not convenient if developer want
to test separated partitions with different fault injection rate/type
simultaneously, also it's not possible to enable fault injection in one
partition and disable fault injection in other one.

>From now on, we move global configuration of fault injection in module
into per-superblock, hence injection testing can be more flexible.

Signed-off-by: Chao Yu 
Signed-off-by: Jaegeuk Kim 

For this patch, I could resend v4 to change erofs_kmalloc->kmalloc
if you like, it isn't an important stuff for this patch. However,
I'd like to get more ideas about the fault injection.

Thanks,
Gao Xiang

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


[PATCH AUTOSEL 4.20 044/304] Tools: hv: kvp: Fix a warning of buffer overflow with gcc 8.0.1

2019-01-28 Thread Sasha Levin
From: Dexuan Cui 

[ Upstream commit 4fcba7802c3e15a6e56e255871d6c72f829b9dd8 ]

The patch fixes:

hv_kvp_daemon.c: In function 'kvp_set_ip_info':
hv_kvp_daemon.c:1305:2: note: 'snprintf' output between 41 and 4136 bytes
into a destination of size 4096

The "(unsigned int)str_len" is to avoid:

hv_kvp_daemon.c:1309:30: warning: comparison of integer expressions of
different signedness: 'int' and 'long unsigned int' [-Wsign-compare]

Signed-off-by: Dexuan Cui 
Cc: K. Y. Srinivasan 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 tools/hv/hv_kvp_daemon.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index bbb2a8ef367c..d7e06fe0270e 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -1178,6 +1178,7 @@ static int kvp_set_ip_info(char *if_name, struct 
hv_kvp_ipaddr_value *new_val)
FILE *file;
char cmd[PATH_MAX];
char *mac_addr;
+   int str_len;
 
/*
 * Set the configuration for the specified interface with
@@ -1301,8 +1302,18 @@ static int kvp_set_ip_info(char *if_name, struct 
hv_kvp_ipaddr_value *new_val)
 * invoke the external script to do its magic.
 */
 
-   snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
-"hv_set_ifconfig", if_file);
+   str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
+  "hv_set_ifconfig", if_file);
+   /*
+* This is a little overcautious, but it's necessary to suppress some
+* false warnings from gcc 8.0.1.
+*/
+   if (str_len <= 0 || (unsigned int)str_len >= sizeof(cmd)) {
+   syslog(LOG_ERR, "Cmd '%s' (len=%d) may be too long",
+  cmd, str_len);
+   return HV_E_FAIL;
+   }
+
if (system(cmd)) {
syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s",
cmd, errno, strerror(errno));
-- 
2.19.1

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


[PATCH AUTOSEL 4.20 042/304] staging:iio:ad2s90: Make probe handle spi_setup failure

2019-01-28 Thread Sasha Levin
From: Matheus Tavares 

[ Upstream commit b3a3eafeef769c6982e15f83631dcbf8d1794efb ]

Previously, ad2s90_probe ignored the return code from spi_setup, not
handling its possible failure. This patch makes ad2s90_probe check if
the code is an error code and, if so, do the following:

- Call dev_err with an appropriate error message.
- Return the spi_setup's error code.

Note: The 'return ret' statement could be out of the 'if' block, but
this whole block will be moved up in the function in the patch:
'staging:iio:ad2s90: Move device registration to the end of probe'.

Signed-off-by: Matheus Tavares 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/resolver/ad2s90.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c 
b/drivers/staging/iio/resolver/ad2s90.c
index 59586947a936..51cda9151412 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -85,7 +85,12 @@ static int ad2s90_probe(struct spi_device *spi)
/* need 600ns between CS and the first falling edge of SCLK */
spi->max_speed_hz = 83;
spi->mode = SPI_MODE_3;
-   spi_setup(spi);
+   ret = spi_setup(spi);
+
+   if (ret < 0) {
+   dev_err(&spi->dev, "spi_setup failed!\n");
+   return ret;
+   }
 
return 0;
 }
-- 
2.19.1

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


Re: ipu3-imgu 0000:00:05.0: required queues are disabled

2019-01-28 Thread Kai Heng Feng
Hi Kieran,

> On Jan 28, 2019, at 4:48 PM, Kieran Bingham  
> wrote:
> 
> Hi Kai-Heng,
> 
> On 27/01/2019 05:56, Kai-Heng Feng wrote:
>> Hi,
>> 
>> We have a bug report [1] that the ipu3 doesn’t work.
>> Does ipu3 need special userspace to work?
> 
> Yes, it will need further userspace support to configure the pipeline,
> and to provide 3A algorithms for white balance, focus, and exposure
> times to the sensor.
> 
> We are developing a stack called libcamera [0] to support this, but it's
> still in active development and not yet ready for use. Fortunately
> however, IPU3 is one of our primary initial targets.

Thanks for the info.

> 
> [0] https://www.libcamera.org/
> 
>> [1] https://bugs.launchpad.net/bugs/1812114
> 
> I have reported similar information to the launchpad bug entry.
> 
> It might help if we can get hold of a Dell 7275 sometime although I
> think Mauro at least has one ?
> 
> If this is a priority for Canonical, please contact us directly.

Not really, just raise issues from Launchpad to appropriate mailing list.

Kai-Heng

> 
>> Kai-Heng
> --
> Regards
> 
> Kieran

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


[PATCH AUTOSEL 4.20 051/304] staging: iio: ad7780: update voltage on read

2019-01-28 Thread Sasha Levin
From: Renato Lui Geh 

[ Upstream commit 336650c785b62c3bea7c8cf6061c933a90241f67 ]

The ad7780 driver previously did not read the correct device output, as
it read an outdated value set at initialization. It now updates its
voltage on read.

Signed-off-by: Renato Lui Geh 
Acked-by: Alexandru Ardelean 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7780.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index b67412db0318..c7cb05cedbbc 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
   long m)
 {
struct ad7780_state *st = iio_priv(indio_dev);
+   int voltage_uv;
 
switch (m) {
case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE:
-   *val = st->int_vref_mv * st->gain;
+   voltage_uv = regulator_get_voltage(st->reg);
+   if (voltage_uv < 0)
+   return voltage_uv;
+   *val = (voltage_uv / 1000) * st->gain;
*val2 = chan->scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
-- 
2.19.1

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


[PATCH AUTOSEL 4.20 067/304] staging: erofs: fix race when the managed cache is enabled

2019-01-28 Thread Sasha Levin
From: Gao Xiang 

[ Upstream commit 51232df5e4b268936beccde5248f312a316800be ]

When the managed cache is enabled, the last reference count
of a workgroup must be used for its workstation.

Otherwise, it could lead to incorrect (un)freezes in
the reclaim path, and it would be harmful.

A typical race as follows:

Thread 1 (In the reclaim path)  Thread 2
workgroup_freeze(grp, 1)refcnt = 1
...
workgroup_unfreeze(grp, 1)  refcnt = 1
workgroup_get(grp)  refcnt = 2 (x)
workgroup_put(grp)  refcnt = 1 (x)
...unexpected behaviors

* grp is detached but still used, which violates cache-managed
  freeze constraint.

Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/erofs/internal.h |   1 +
 drivers/staging/erofs/utils.c| 134 ++-
 2 files changed, 96 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 048fb034b5aa..3ac4599bbe01 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -250,6 +250,7 @@ repeat:
 }
 
 #define __erofs_workgroup_get(grp) atomic_inc(&(grp)->refcount)
+#define __erofs_workgroup_put(grp) atomic_dec(&(grp)->refcount)
 
 extern int erofs_workgroup_put(struct erofs_workgroup *grp);
 
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index ea8a962e5c95..d2e3ace91046 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -83,12 +83,21 @@ int erofs_register_workgroup(struct super_block *sb,
 
grp = xa_tag_pointer(grp, tag);
 
-   err = radix_tree_insert(&sbi->workstn_tree,
-   grp->index, grp);
+   /*
+* Bump up reference count before making this workgroup
+* visible to other users in order to avoid potential UAF
+* without serialized by erofs_workstn_lock.
+*/
+   __erofs_workgroup_get(grp);
 
-   if (!err) {
-   __erofs_workgroup_get(grp);
-   }
+   err = radix_tree_insert(&sbi->workstn_tree,
+   grp->index, grp);
+   if (unlikely(err))
+   /*
+* it's safe to decrease since the workgroup isn't visible
+* and refcount >= 2 (cannot be freezed).
+*/
+   __erofs_workgroup_put(grp);
 
erofs_workstn_unlock(sbi);
radix_tree_preload_end();
@@ -97,19 +106,94 @@ int erofs_register_workgroup(struct super_block *sb,
 
 extern void erofs_workgroup_free_rcu(struct erofs_workgroup *grp);
 
+static void  __erofs_workgroup_free(struct erofs_workgroup *grp)
+{
+   atomic_long_dec(&erofs_global_shrink_cnt);
+   erofs_workgroup_free_rcu(grp);
+}
+
 int erofs_workgroup_put(struct erofs_workgroup *grp)
 {
int count = atomic_dec_return(&grp->refcount);
 
if (count == 1)
atomic_long_inc(&erofs_global_shrink_cnt);
-   else if (!count) {
-   atomic_long_dec(&erofs_global_shrink_cnt);
-   erofs_workgroup_free_rcu(grp);
-   }
+   else if (!count)
+   __erofs_workgroup_free(grp);
return count;
 }
 
+#ifdef EROFS_FS_HAS_MANAGED_CACHE
+/* for cache-managed case, customized reclaim paths exist */
+static void erofs_workgroup_unfreeze_final(struct erofs_workgroup *grp)
+{
+   erofs_workgroup_unfreeze(grp, 0);
+   __erofs_workgroup_free(grp);
+}
+
+bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
+   struct erofs_workgroup *grp,
+   bool cleanup)
+{
+   /*
+* for managed cache enabled, the refcount of workgroups
+* themselves could be < 0 (freezed). So there is no guarantee
+* that all refcount > 0 if managed cache is enabled.
+*/
+   if (!erofs_workgroup_try_to_freeze(grp, 1))
+   return false;
+
+   /*
+* note that all cached pages should be unlinked
+* before delete it from the radix tree.
+* Otherwise some cached pages of an orphan old workgroup
+* could be still linked after the new one is available.
+*/
+   if (erofs_try_to_free_all_cached_pages(sbi, grp)) {
+   erofs_workgroup_unfreeze(grp, 1);
+   return false;
+   }
+
+   /*
+* it is impossible to fail after the workgroup is freezed,
+* however in order to avoid some race conditions, add a
+* DBG_BUGON to observe this in advance.
+*/
+   DBG_BUGON(xa_untag_pointer(radix_tree_delete(&sbi->workstn_tree,
+grp->index)) != grp);
+
+   /*
+* if managed cache is enable, the last refcount
+* should indicate the related workstation.
+

[PATCH AUTOSEL 4.20 066/304] staging: erofs: fix the definition of DBG_BUGON

2019-01-28 Thread Sasha Levin
From: Gao Xiang 

[ Upstream commit eef168789866514e5d4316f030131c9fe65b643f ]

It's better not to positively BUG_ON the kernel, however developers
need a way to locate issues as soon as possible.

DBG_BUGON is introduced and it could only crash when EROFS_FS_DEBUG
(EROFS developping feature) is on. It is helpful for developers
to find and solve bugs quickly by eng builds.

Previously, DBG_BUGON is defined as ((void)0) if EROFS_FS_DEBUG is off,
but some unused variable warnings as follows could occur:

drivers/staging/erofs/unzip_vle.c: In function `init_alway:':
drivers/staging/erofs/unzip_vle.c:61:33: warning: unused variable `work' 
[-Wunused-variable]
  struct z_erofs_vle_work *const work =
 ^~~~

Fix it to #define DBG_BUGON(x) ((void)(x)).

Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/erofs/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 57575c7f5635..048fb034b5aa 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -39,7 +39,7 @@
 #define debugln(x, ...) ((void)0)
 
 #define dbg_might_sleep()   ((void)0)
-#define DBG_BUGON(...)  ((void)0)
+#define DBG_BUGON(x)((void)(x))
 #endif
 
 enum {
-- 
2.19.1

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


[PATCH AUTOSEL 4.20 084/304] staging: pi433: fix potential null dereference

2019-01-28 Thread Sasha Levin
From: Michael Straube 

[ Upstream commit 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 ]

Add a test for successful call to cdev_alloc() to avoid
potential null dereference. Issue reported by smatch.

Signed-off-by: Michael Straube 
Fixes: 874bcba65f9a ("staging: pi433: New driver")
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/pi433/pi433_if.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index c85a805a1243..a497ec197872 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1255,6 +1255,10 @@ static int pi433_probe(struct spi_device *spi)
 
/* create cdev */
device->cdev = cdev_alloc();
+   if (!device->cdev) {
+   dev_dbg(device->dev, "allocation of cdev failed");
+   goto cdev_failed;
+   }
device->cdev->owner = THIS_MODULE;
cdev_init(device->cdev, &pi433_fops);
retval = cdev_add(device->cdev, device->devt, 1);
-- 
2.19.1

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


[PATCH AUTOSEL 4.19 002/258] staging: iio: adc: ad7280a: handle error from __ad7280_read32()

2019-01-28 Thread Sasha Levin
From: Slawomir Stepien 

[ Upstream commit 0559ef7fde67bc6c83c6eb6329dbd6649528263e ]

Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative
error code. This change will ensure that this error is being passed up
in the call stack, so it can be handled.

Signed-off-by: Slawomir Stepien 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7280a.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index b736275c10f5..6a48ad067a8b 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -256,7 +256,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned 
int devaddr,
if (ret)
return ret;
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -294,7 +296,9 @@ static int ad7280_read_channel(struct ad7280_state *st, 
unsigned int devaddr,
 
ad7280_delay(st);
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -327,7 +331,9 @@ static int ad7280_read_all_channels(struct ad7280_state 
*st, unsigned int cnt,
ad7280_delay(st);
 
for (i = 0; i < cnt; i++) {
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -370,7 +376,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
return ret;
 
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
-   __ad7280_read32(st, &val);
+   ret = __ad7280_read32(st, &val);
+   if (ret)
+   return ret;
+
if (val == 0)
return n - 1;
 
-- 
2.19.1

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


[PATCH AUTOSEL 4.19 032/258] dpaa2-ptp: defer probe when portal allocation failed

2019-01-28 Thread Sasha Levin
From: Ioana Ciornei 

[ Upstream commit 5500598abbfb5b46201b9768bd9ea873a5eeaece ]

The fsl_mc_portal_allocate can fail when the requested MC portals are
not yet probed by the fsl_mc_allocator. In this situation, the driver
should defer the probe.

Signed-off-by: Ioana Ciornei 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/staging/fsl-dpaa2/rtc/rtc.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/rtc/rtc.c 
b/drivers/staging/fsl-dpaa2/rtc/rtc.c
index 0d52cb85441f..318a33c2f7a7 100644
--- a/drivers/staging/fsl-dpaa2/rtc/rtc.c
+++ b/drivers/staging/fsl-dpaa2/rtc/rtc.c
@@ -142,7 +142,10 @@ static int rtc_probe(struct fsl_mc_device *mc_dev)
 
err = fsl_mc_portal_allocate(mc_dev, 0, &mc_dev->mc_io);
if (err) {
-   dev_err(dev, "fsl_mc_portal_allocate err %d\n", err);
+   if (err == -ENXIO)
+   err = -EPROBE_DEFER;
+   else
+   dev_err(dev, "fsl_mc_portal_allocate err %d\n", err);
goto err_exit;
}
 
-- 
2.19.1

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


[PATCH AUTOSEL 4.19 036/258] staging:iio:ad2s90: Make probe handle spi_setup failure

2019-01-28 Thread Sasha Levin
From: Matheus Tavares 

[ Upstream commit b3a3eafeef769c6982e15f83631dcbf8d1794efb ]

Previously, ad2s90_probe ignored the return code from spi_setup, not
handling its possible failure. This patch makes ad2s90_probe check if
the code is an error code and, if so, do the following:

- Call dev_err with an appropriate error message.
- Return the spi_setup's error code.

Note: The 'return ret' statement could be out of the 'if' block, but
this whole block will be moved up in the function in the patch:
'staging:iio:ad2s90: Move device registration to the end of probe'.

Signed-off-by: Matheus Tavares 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/resolver/ad2s90.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c 
b/drivers/staging/iio/resolver/ad2s90.c
index 59586947a936..51cda9151412 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -85,7 +85,12 @@ static int ad2s90_probe(struct spi_device *spi)
/* need 600ns between CS and the first falling edge of SCLK */
spi->max_speed_hz = 83;
spi->mode = SPI_MODE_3;
-   spi_setup(spi);
+   ret = spi_setup(spi);
+
+   if (ret < 0) {
+   dev_err(&spi->dev, "spi_setup failed!\n");
+   return ret;
+   }
 
return 0;
 }
-- 
2.19.1

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


[PATCH AUTOSEL 4.19 038/258] Tools: hv: kvp: Fix a warning of buffer overflow with gcc 8.0.1

2019-01-28 Thread Sasha Levin
From: Dexuan Cui 

[ Upstream commit 4fcba7802c3e15a6e56e255871d6c72f829b9dd8 ]

The patch fixes:

hv_kvp_daemon.c: In function 'kvp_set_ip_info':
hv_kvp_daemon.c:1305:2: note: 'snprintf' output between 41 and 4136 bytes
into a destination of size 4096

The "(unsigned int)str_len" is to avoid:

hv_kvp_daemon.c:1309:30: warning: comparison of integer expressions of
different signedness: 'int' and 'long unsigned int' [-Wsign-compare]

Signed-off-by: Dexuan Cui 
Cc: K. Y. Srinivasan 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 tools/hv/hv_kvp_daemon.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index bbb2a8ef367c..d7e06fe0270e 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -1178,6 +1178,7 @@ static int kvp_set_ip_info(char *if_name, struct 
hv_kvp_ipaddr_value *new_val)
FILE *file;
char cmd[PATH_MAX];
char *mac_addr;
+   int str_len;
 
/*
 * Set the configuration for the specified interface with
@@ -1301,8 +1302,18 @@ static int kvp_set_ip_info(char *if_name, struct 
hv_kvp_ipaddr_value *new_val)
 * invoke the external script to do its magic.
 */
 
-   snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
-"hv_set_ifconfig", if_file);
+   str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
+  "hv_set_ifconfig", if_file);
+   /*
+* This is a little overcautious, but it's necessary to suppress some
+* false warnings from gcc 8.0.1.
+*/
+   if (str_len <= 0 || (unsigned int)str_len >= sizeof(cmd)) {
+   syslog(LOG_ERR, "Cmd '%s' (len=%d) may be too long",
+  cmd, str_len);
+   return HV_E_FAIL;
+   }
+
if (system(cmd)) {
syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s",
cmd, errno, strerror(errno));
-- 
2.19.1

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


[PATCH AUTOSEL 4.19 044/258] staging: iio: ad7780: update voltage on read

2019-01-28 Thread Sasha Levin
From: Renato Lui Geh 

[ Upstream commit 336650c785b62c3bea7c8cf6061c933a90241f67 ]

The ad7780 driver previously did not read the correct device output, as
it read an outdated value set at initialization. It now updates its
voltage on read.

Signed-off-by: Renato Lui Geh 
Acked-by: Alexandru Ardelean 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7780.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index 16d72072c076..8bcb5d5de749 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
   long m)
 {
struct ad7780_state *st = iio_priv(indio_dev);
+   int voltage_uv;
 
switch (m) {
case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE:
-   *val = st->int_vref_mv * st->gain;
+   voltage_uv = regulator_get_voltage(st->reg);
+   if (voltage_uv < 0)
+   return voltage_uv;
+   *val = (voltage_uv / 1000) * st->gain;
*val2 = chan->scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
-- 
2.19.1

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


[PATCH AUTOSEL 4.19 058/258] staging: erofs: fix the definition of DBG_BUGON

2019-01-28 Thread Sasha Levin
From: Gao Xiang 

[ Upstream commit eef168789866514e5d4316f030131c9fe65b643f ]

It's better not to positively BUG_ON the kernel, however developers
need a way to locate issues as soon as possible.

DBG_BUGON is introduced and it could only crash when EROFS_FS_DEBUG
(EROFS developping feature) is on. It is helpful for developers
to find and solve bugs quickly by eng builds.

Previously, DBG_BUGON is defined as ((void)0) if EROFS_FS_DEBUG is off,
but some unused variable warnings as follows could occur:

drivers/staging/erofs/unzip_vle.c: In function `init_alway:':
drivers/staging/erofs/unzip_vle.c:61:33: warning: unused variable `work' 
[-Wunused-variable]
  struct z_erofs_vle_work *const work =
 ^~~~

Fix it to #define DBG_BUGON(x) ((void)(x)).

Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/erofs/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 367b39fe46e5..e6313c54e3ad 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -39,7 +39,7 @@
 #define debugln(x, ...) ((void)0)
 
 #define dbg_might_sleep()   ((void)0)
-#define DBG_BUGON(...)  ((void)0)
+#define DBG_BUGON(x)((void)(x))
 #endif
 
 #ifdef CONFIG_EROFS_FAULT_INJECTION
-- 
2.19.1

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


[PATCH AUTOSEL 4.19 071/258] staging: pi433: fix potential null dereference

2019-01-28 Thread Sasha Levin
From: Michael Straube 

[ Upstream commit 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 ]

Add a test for successful call to cdev_alloc() to avoid
potential null dereference. Issue reported by smatch.

Signed-off-by: Michael Straube 
Fixes: 874bcba65f9a ("staging: pi433: New driver")
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/pi433/pi433_if.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index c85a805a1243..a497ec197872 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1255,6 +1255,10 @@ static int pi433_probe(struct spi_device *spi)
 
/* create cdev */
device->cdev = cdev_alloc();
+   if (!device->cdev) {
+   dev_dbg(device->dev, "allocation of cdev failed");
+   goto cdev_failed;
+   }
device->cdev->owner = THIS_MODULE;
cdev_init(device->cdev, &pi433_fops);
retval = cdev_add(device->cdev, device->devt, 1);
-- 
2.19.1

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


[PATCH AUTOSEL 4.14 002/170] staging: iio: adc: ad7280a: handle error from __ad7280_read32()

2019-01-28 Thread Sasha Levin
From: Slawomir Stepien 

[ Upstream commit 0559ef7fde67bc6c83c6eb6329dbd6649528263e ]

Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative
error code. This change will ensure that this error is being passed up
in the call stack, so it can be handled.

Signed-off-by: Slawomir Stepien 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7280a.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index f85dde9805e0..f17f700ea04f 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -256,7 +256,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned 
int devaddr,
if (ret)
return ret;
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -294,7 +296,9 @@ static int ad7280_read_channel(struct ad7280_state *st, 
unsigned int devaddr,
 
ad7280_delay(st);
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -327,7 +331,9 @@ static int ad7280_read_all_channels(struct ad7280_state 
*st, unsigned int cnt,
ad7280_delay(st);
 
for (i = 0; i < cnt; i++) {
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -370,7 +376,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
return ret;
 
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
-   __ad7280_read32(st, &val);
+   ret = __ad7280_read32(st, &val);
+   if (ret)
+   return ret;
+
if (val == 0)
return n - 1;
 
-- 
2.19.1

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


[PATCH AUTOSEL 4.14 024/170] staging:iio:ad2s90: Make probe handle spi_setup failure

2019-01-28 Thread Sasha Levin
From: Matheus Tavares 

[ Upstream commit b3a3eafeef769c6982e15f83631dcbf8d1794efb ]

Previously, ad2s90_probe ignored the return code from spi_setup, not
handling its possible failure. This patch makes ad2s90_probe check if
the code is an error code and, if so, do the following:

- Call dev_err with an appropriate error message.
- Return the spi_setup's error code.

Note: The 'return ret' statement could be out of the 'if' block, but
this whole block will be moved up in the function in the patch:
'staging:iio:ad2s90: Move device registration to the end of probe'.

Signed-off-by: Matheus Tavares 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/resolver/ad2s90.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c 
b/drivers/staging/iio/resolver/ad2s90.c
index b2270908f26f..cbee9ad00f0d 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -86,7 +86,12 @@ static int ad2s90_probe(struct spi_device *spi)
/* need 600ns between CS and the first falling edge of SCLK */
spi->max_speed_hz = 83;
spi->mode = SPI_MODE_3;
-   spi_setup(spi);
+   ret = spi_setup(spi);
+
+   if (ret < 0) {
+   dev_err(&spi->dev, "spi_setup failed!\n");
+   return ret;
+   }
 
return 0;
 }
-- 
2.19.1

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


[PATCH AUTOSEL 4.14 026/170] Tools: hv: kvp: Fix a warning of buffer overflow with gcc 8.0.1

2019-01-28 Thread Sasha Levin
From: Dexuan Cui 

[ Upstream commit 4fcba7802c3e15a6e56e255871d6c72f829b9dd8 ]

The patch fixes:

hv_kvp_daemon.c: In function 'kvp_set_ip_info':
hv_kvp_daemon.c:1305:2: note: 'snprintf' output between 41 and 4136 bytes
into a destination of size 4096

The "(unsigned int)str_len" is to avoid:

hv_kvp_daemon.c:1309:30: warning: comparison of integer expressions of
different signedness: 'int' and 'long unsigned int' [-Wsign-compare]

Signed-off-by: Dexuan Cui 
Cc: K. Y. Srinivasan 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 tools/hv/hv_kvp_daemon.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 3965186b375a..62c9a503ae05 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -1172,6 +1172,7 @@ static int kvp_set_ip_info(char *if_name, struct 
hv_kvp_ipaddr_value *new_val)
FILE *file;
char cmd[PATH_MAX];
char *mac_addr;
+   int str_len;
 
/*
 * Set the configuration for the specified interface with
@@ -1295,8 +1296,18 @@ static int kvp_set_ip_info(char *if_name, struct 
hv_kvp_ipaddr_value *new_val)
 * invoke the external script to do its magic.
 */
 
-   snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
-"hv_set_ifconfig", if_file);
+   str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
+  "hv_set_ifconfig", if_file);
+   /*
+* This is a little overcautious, but it's necessary to suppress some
+* false warnings from gcc 8.0.1.
+*/
+   if (str_len <= 0 || (unsigned int)str_len >= sizeof(cmd)) {
+   syslog(LOG_ERR, "Cmd '%s' (len=%d) may be too long",
+  cmd, str_len);
+   return HV_E_FAIL;
+   }
+
if (system(cmd)) {
syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s",
cmd, errno, strerror(errno));
-- 
2.19.1

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


[PATCH AUTOSEL 4.14 028/170] staging: iio: ad7780: update voltage on read

2019-01-28 Thread Sasha Levin
From: Renato Lui Geh 

[ Upstream commit 336650c785b62c3bea7c8cf6061c933a90241f67 ]

The ad7780 driver previously did not read the correct device output, as
it read an outdated value set at initialization. It now updates its
voltage on read.

Signed-off-by: Renato Lui Geh 
Acked-by: Alexandru Ardelean 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7780.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index dec3ba6eba8a..52613f6a9dd8 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
   long m)
 {
struct ad7780_state *st = iio_priv(indio_dev);
+   int voltage_uv;
 
switch (m) {
case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE:
-   *val = st->int_vref_mv * st->gain;
+   voltage_uv = regulator_get_voltage(st->reg);
+   if (voltage_uv < 0)
+   return voltage_uv;
+   *val = (voltage_uv / 1000) * st->gain;
*val2 = chan->scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
-- 
2.19.1

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


[PATCH AUTOSEL 4.14 044/170] staging: pi433: fix potential null dereference

2019-01-28 Thread Sasha Levin
From: Michael Straube 

[ Upstream commit 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 ]

Add a test for successful call to cdev_alloc() to avoid
potential null dereference. Issue reported by smatch.

Signed-off-by: Michael Straube 
Fixes: 874bcba65f9a ("staging: pi433: New driver")
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/pi433/pi433_if.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 93c01680f016..5be40bdc191b 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1210,6 +1210,10 @@ static int pi433_probe(struct spi_device *spi)
 
/* create cdev */
device->cdev = cdev_alloc();
+   if (!device->cdev) {
+   dev_dbg(device->dev, "allocation of cdev failed");
+   goto cdev_failed;
+   }
device->cdev->owner = THIS_MODULE;
cdev_init(device->cdev, &pi433_fops);
retval = cdev_add(device->cdev, device->devt, 1);
-- 
2.19.1

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


[PATCH AUTOSEL 4.9 002/107] staging: iio: adc: ad7280a: handle error from __ad7280_read32()

2019-01-28 Thread Sasha Levin
From: Slawomir Stepien 

[ Upstream commit 0559ef7fde67bc6c83c6eb6329dbd6649528263e ]

Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative
error code. This change will ensure that this error is being passed up
in the call stack, so it can be handled.

Signed-off-by: Slawomir Stepien 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7280a.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index b460dda7eb65..dec25fadba8c 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -250,7 +250,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned 
int devaddr,
if (ret)
return ret;
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -288,7 +290,9 @@ static int ad7280_read_channel(struct ad7280_state *st, 
unsigned int devaddr,
 
ad7280_delay(st);
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -321,7 +325,9 @@ static int ad7280_read_all_channels(struct ad7280_state 
*st, unsigned int cnt,
ad7280_delay(st);
 
for (i = 0; i < cnt; i++) {
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -364,7 +370,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
return ret;
 
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
-   __ad7280_read32(st, &val);
+   ret = __ad7280_read32(st, &val);
+   if (ret)
+   return ret;
+
if (val == 0)
return n - 1;
 
-- 
2.19.1

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


[PATCH AUTOSEL 4.9 016/107] staging:iio:ad2s90: Make probe handle spi_setup failure

2019-01-28 Thread Sasha Levin
From: Matheus Tavares 

[ Upstream commit b3a3eafeef769c6982e15f83631dcbf8d1794efb ]

Previously, ad2s90_probe ignored the return code from spi_setup, not
handling its possible failure. This patch makes ad2s90_probe check if
the code is an error code and, if so, do the following:

- Call dev_err with an appropriate error message.
- Return the spi_setup's error code.

Note: The 'return ret' statement could be out of the 'if' block, but
this whole block will be moved up in the function in the patch:
'staging:iio:ad2s90: Move device registration to the end of probe'.

Signed-off-by: Matheus Tavares 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/resolver/ad2s90.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c 
b/drivers/staging/iio/resolver/ad2s90.c
index 5b1c0db33e7f..b44253eb62ec 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -86,7 +86,12 @@ static int ad2s90_probe(struct spi_device *spi)
/* need 600ns between CS and the first falling edge of SCLK */
spi->max_speed_hz = 83;
spi->mode = SPI_MODE_3;
-   spi_setup(spi);
+   ret = spi_setup(spi);
+
+   if (ret < 0) {
+   dev_err(&spi->dev, "spi_setup failed!\n");
+   return ret;
+   }
 
return 0;
 }
-- 
2.19.1

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


[PATCH AUTOSEL 4.9 017/107] staging: iio: ad7780: update voltage on read

2019-01-28 Thread Sasha Levin
From: Renato Lui Geh 

[ Upstream commit 336650c785b62c3bea7c8cf6061c933a90241f67 ]

The ad7780 driver previously did not read the correct device output, as
it read an outdated value set at initialization. It now updates its
voltage on read.

Signed-off-by: Renato Lui Geh 
Acked-by: Alexandru Ardelean 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7780.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index c9a0c2aa602f..5d163386ab6e 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
   long m)
 {
struct ad7780_state *st = iio_priv(indio_dev);
+   int voltage_uv;
 
switch (m) {
case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE:
-   *val = st->int_vref_mv * st->gain;
+   voltage_uv = regulator_get_voltage(st->reg);
+   if (voltage_uv < 0)
+   return voltage_uv;
+   *val = (voltage_uv / 1000) * st->gain;
*val2 = chan->scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
-- 
2.19.1

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


[PATCH AUTOSEL 4.4 02/80] staging: iio: adc: ad7280a: handle error from __ad7280_read32()

2019-01-28 Thread Sasha Levin
From: Slawomir Stepien 

[ Upstream commit 0559ef7fde67bc6c83c6eb6329dbd6649528263e ]

Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative
error code. This change will ensure that this error is being passed up
in the call stack, so it can be handled.

Signed-off-by: Slawomir Stepien 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7280a.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index 35acb1a4669b..db8390022732 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -250,7 +250,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned 
devaddr,
if (ret)
return ret;
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -288,7 +290,9 @@ static int ad7280_read_channel(struct ad7280_state *st, 
unsigned devaddr,
 
ad7280_delay(st);
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -321,7 +325,9 @@ static int ad7280_read_all_channels(struct ad7280_state 
*st, unsigned cnt,
ad7280_delay(st);
 
for (i = 0; i < cnt; i++) {
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -364,7 +370,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
return ret;
 
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
-   __ad7280_read32(st, &val);
+   ret = __ad7280_read32(st, &val);
+   if (ret)
+   return ret;
+
if (val == 0)
return n - 1;
 
-- 
2.19.1

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


[PATCH AUTOSEL 4.4 15/80] staging: iio: ad7780: update voltage on read

2019-01-28 Thread Sasha Levin
From: Renato Lui Geh 

[ Upstream commit 336650c785b62c3bea7c8cf6061c933a90241f67 ]

The ad7780 driver previously did not read the correct device output, as
it read an outdated value set at initialization. It now updates its
voltage on read.

Signed-off-by: Renato Lui Geh 
Acked-by: Alexandru Ardelean 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7780.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index 3abc7789237f..531338ea5eb4 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -90,12 +90,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
   long m)
 {
struct ad7780_state *st = iio_priv(indio_dev);
+   int voltage_uv;
 
switch (m) {
case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE:
-   *val = st->int_vref_mv * st->gain;
+   voltage_uv = regulator_get_voltage(st->reg);
+   if (voltage_uv < 0)
+   return voltage_uv;
+   *val = (voltage_uv / 1000) * st->gain;
*val2 = chan->scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
-- 
2.19.1

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


[PATCH AUTOSEL 4.4 14/80] staging:iio:ad2s90: Make probe handle spi_setup failure

2019-01-28 Thread Sasha Levin
From: Matheus Tavares 

[ Upstream commit b3a3eafeef769c6982e15f83631dcbf8d1794efb ]

Previously, ad2s90_probe ignored the return code from spi_setup, not
handling its possible failure. This patch makes ad2s90_probe check if
the code is an error code and, if so, do the following:

- Call dev_err with an appropriate error message.
- Return the spi_setup's error code.

Note: The 'return ret' statement could be out of the 'if' block, but
this whole block will be moved up in the function in the patch:
'staging:iio:ad2s90: Move device registration to the end of probe'.

Signed-off-by: Matheus Tavares 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/resolver/ad2s90.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c 
b/drivers/staging/iio/resolver/ad2s90.c
index 5b1c0db33e7f..b44253eb62ec 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -86,7 +86,12 @@ static int ad2s90_probe(struct spi_device *spi)
/* need 600ns between CS and the first falling edge of SCLK */
spi->max_speed_hz = 83;
spi->mode = SPI_MODE_3;
-   spi_setup(spi);
+   ret = spi_setup(spi);
+
+   if (ret < 0) {
+   dev_err(&spi->dev, "spi_setup failed!\n");
+   return ret;
+   }
 
return 0;
 }
-- 
2.19.1

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


[PATCH AUTOSEL 3.18 01/61] staging: iio: adc: ad7280a: handle error from __ad7280_read32()

2019-01-28 Thread Sasha Levin
From: Slawomir Stepien 

[ Upstream commit 0559ef7fde67bc6c83c6eb6329dbd6649528263e ]

Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative
error code. This change will ensure that this error is being passed up
in the call stack, so it can be handled.

Signed-off-by: Slawomir Stepien 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7280a.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index d215edf66af2..0ad4af5d0ae4 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -250,7 +250,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned 
devaddr,
if (ret)
return ret;
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -288,7 +290,9 @@ static int ad7280_read_channel(struct ad7280_state *st, 
unsigned devaddr,
 
ad7280_delay(st);
 
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -321,7 +325,9 @@ static int ad7280_read_all_channels(struct ad7280_state 
*st, unsigned cnt,
ad7280_delay(st);
 
for (i = 0; i < cnt; i++) {
-   __ad7280_read32(st, &tmp);
+   ret = __ad7280_read32(st, &tmp);
+   if (ret)
+   return ret;
 
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -364,7 +370,10 @@ static int ad7280_chain_setup(struct ad7280_state *st)
return ret;
 
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
-   __ad7280_read32(st, &val);
+   ret = __ad7280_read32(st, &val);
+   if (ret)
+   return ret;
+
if (val == 0)
return n - 1;
 
-- 
2.19.1

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


[PATCH AUTOSEL 3.18 10/61] staging:iio:ad2s90: Make probe handle spi_setup failure

2019-01-28 Thread Sasha Levin
From: Matheus Tavares 

[ Upstream commit b3a3eafeef769c6982e15f83631dcbf8d1794efb ]

Previously, ad2s90_probe ignored the return code from spi_setup, not
handling its possible failure. This patch makes ad2s90_probe check if
the code is an error code and, if so, do the following:

- Call dev_err with an appropriate error message.
- Return the spi_setup's error code.

Note: The 'return ret' statement could be out of the 'if' block, but
this whole block will be moved up in the function in the patch:
'staging:iio:ad2s90: Move device registration to the end of probe'.

Signed-off-by: Matheus Tavares 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/resolver/ad2s90.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c 
b/drivers/staging/iio/resolver/ad2s90.c
index e24c5890652f..c0cee97bd0f1 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -86,7 +86,12 @@ static int ad2s90_probe(struct spi_device *spi)
/* need 600ns between CS and the first falling edge of SCLK */
spi->max_speed_hz = 83;
spi->mode = SPI_MODE_3;
-   spi_setup(spi);
+   ret = spi_setup(spi);
+
+   if (ret < 0) {
+   dev_err(&spi->dev, "spi_setup failed!\n");
+   return ret;
+   }
 
return 0;
 }
-- 
2.19.1

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


[PATCH AUTOSEL 3.18 11/61] staging: iio: ad7780: update voltage on read

2019-01-28 Thread Sasha Levin
From: Renato Lui Geh 

[ Upstream commit 336650c785b62c3bea7c8cf6061c933a90241f67 ]

The ad7780 driver previously did not read the correct device output, as
it read an outdated value set at initialization. It now updates its
voltage on read.

Signed-off-by: Renato Lui Geh 
Acked-by: Alexandru Ardelean 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/staging/iio/adc/ad7780.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index 273add3ed63f..5a3072740326 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -90,12 +90,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
   long m)
 {
struct ad7780_state *st = iio_priv(indio_dev);
+   int voltage_uv;
 
switch (m) {
case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE:
-   *val = st->int_vref_mv * st->gain;
+   voltage_uv = regulator_get_voltage(st->reg);
+   if (voltage_uv < 0)
+   return voltage_uv;
+   *val = (voltage_uv / 1000) * st->gain;
*val2 = chan->scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
-- 
2.19.1

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


Re: [PATCH 4/6] staging: rtl8188eu: remove unncessary asignment to cleanup long line

2019-01-28 Thread Joe Perches
On Mon, 2019-01-28 at 10:51 +0100, Michael Straube wrote:
> Instead of first asign 'wrqu.data.length = p - buff' use 'p - buff'
> directly in min_t() in the subsequent asignment. Clears a line over
> 80 characters checkpatch warning.

Thank you.  I believe you should include Larry Finger
in the cc list for this driver

Using scripts/get_maintainer.pl should tell you that.

And while this is true, another way to reduce line length
is to reduce indentation.

In this function, it is reasonable to change the

if (authmode == _WPA_IE_ID_) {
...
}
}

to

if (authmode != _WPA_IE_ID_)
return;
...
}

Another issue with this code is the sprintf.

It expands a u8 buffer of a maximum of IW_CUSTOM_MAX size
into an allocated buffer of IW_CUSTOM_MAX size with %02x;

That could overflow the allocated buffer.

> diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c 
> b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
[]
> @@ -109,8 +109,7 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 
> authmode, u8 *sec_ie)
>   p += sprintf(p, "%02x", sec_ie[i]);
>   p += sprintf(p, ")");
>   memset(&wrqu, 0, sizeof(wrqu));
> - wrqu.data.length = p - buff;
> - wrqu.data.length = min_t(__u16, wrqu.data.length, 
> IW_CUSTOM_MAX);
> + wrqu.data.length = min_t(__u16, p - buff, IW_CUSTOM_MAX);
>   wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
>   kfree(buff);
>   }


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


Re: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support

2019-01-28 Thread Chao Yu
Hi Dan and Xiang,

On 2019-1-28 21:48, Gao Xiang wrote:
> Hi Dan,
> 
> On 2019/1/28 21:33, Dan Carpenter wrote:
>> Hopefully, regular kmalloc() is enough.
>>
>> Do really need the erofs_kmalloc() function?  Regular kmalloc() has
>> fault injection already.  Have you tried to use it?

Yes, I think we'd better to use erofs_kmalloc(). :)

Actually, fault injection in erofs_kmalloc only affect erofs module, we can
expect that the range of fault can be limited in erofs code, rather than whole
kernel, so the test point can be aimed at more accurately.

> 
> The fault injection subsystem was introduced in the initial upstreamed
> EROFS version, which is taken from f2fs by Chao Yu.
> 
> Fault injection is important to test fs.. However, I have no more idea
> about the future plan of this feature...Follow f2fs or use the general
> fault injection...

I guess following f2fs is not bad.

Thanks,

> 
> There already exists erofs_kmalloc, thus I think it's both ok to use
> erofs_kmalloc or kmalloc for this patch at least.
> 
> Chao, any idea about this?
> 
> Thanks,
> Gao Xiang
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] binder: fix CONFIG_ANDROID_BINDER_DEVICES

2019-01-28 Thread Todd Kjos
On Sat, Jan 26, 2019 at 2:23 AM Christian Brauner  wrote:
>
> Several users have tried to only rely on binderfs to provide binder devices
> and set CONFIG_ANDROID_BINDER_DEVICES="" empty. This is a great use-case of
> binderfs and one that was always intended to work. However, this is
> currently not possible since setting CONFIG_ANDROID_BINDER_DEVICES="" emtpy
> will simply panic the kernel:
>
> kobject: (028c2f79): attempted to be registered with empty name!
> WARNING: CPU: 7 PID: 1703 at lib/kobject.c:228 
> kobject_add_internal+0x288/0x2b0
> Modules linked in: binder_linux(+) bridge stp llc ipmi_ssif gpio_ich dcdbas 
> coretemp kvm_intel kvm irqbypass serio_raw input_leds lpc_ich i5100_edac 
> mac_hid ipmi_si ipmi_devintf ipmi_msghandler sch_fq_codel ib_i
> CPU: 7 PID: 1703 Comm: modprobe Not tainted 5.0.0-rc2-brauner-binderfs #263
> Hardware name: Dell  DCS XS24-SC2  /XS24-SC2  , BIOS 
> S59_3C20 04/07/2011
> RIP: 0010:kobject_add_internal+0x288/0x2b0
> Code: 12 95 48 c7 c7 78 63 3b 95 e8 77 35 71 ff e9 91 fe ff ff 0f 0b eb a7 0f 
> 0b eb 9a 48 89 de 48 c7 c7 00 63 3b 95 e8 f8 95 6a ff <0f> 0b 41 bc ea ff ff 
> ff e9 6d fe ff ff 41 bc fe ff ff ff e9 62 fe
> RSP: 0018:973f84237a30 EFLAGS: 00010282
> RAX:  RBX: 8b53e2472010 RCX: 0006
> RDX: 0007 RSI: 0086 RDI: 8b53edbd63a0
> RBP: 973f84237a60 R08: 0342 R09: 0004
> R10: 973f84237af0 R11: 0001 R12: 
> R13: 8b53e9f1a1e0 R14: e9f1a1e0 R15: 00a00037
> FS:  7fbac36f7540() GS:8b53edbc() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 7fbac364cfa7 CR3: 0004a6d48000 CR4: 000406e0
> Call Trace:
>  kobject_add+0x71/0xd0
>  ? _cond_resched+0x19/0x40
>  ? mutex_lock+0x12/0x40
>  device_add+0x12e/0x6b0
>  device_create_groups_vargs+0xe4/0xf0
>  device_create_with_groups+0x3f/0x60
>  ? _cond_resched+0x19/0x40
>  misc_register+0x140/0x180
>  binder_init+0x1ed/0x2d4 [binder_linux]
>  ? trace_event_define_fields_binder_transaction_fd_send+0x8e/0x8e 
> [binder_linux]
>  do_one_initcall+0x4a/0x1c9
>  ? _cond_resched+0x19/0x40
>  ? kmem_cache_alloc_trace+0x151/0x1c0
>  do_init_module+0x5f/0x216
>  load_module+0x223d/0x2b20
>  __do_sys_finit_module+0xfc/0x120
>  ? __do_sys_finit_module+0xfc/0x120
>  __x64_sys_finit_module+0x1a/0x20
>  do_syscall_64+0x5a/0x120
>  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> RIP: 0033:0x7fbac3202839
> Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 
> 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 
> 01 c3 48 8b 0d 1f f6 2c 00 f7 d8 64 89 01 48
> RSP: 002b:7ffd1494a908 EFLAGS: 0246 ORIG_RAX: 0139
> RAX: ffda RBX: 55b629ebec60 RCX: 7fbac3202839
> RDX:  RSI: 55b629c20d2e RDI: 0003
> RBP: 55b629c20d2e R08:  R09: 55b629ec2310
> R10: 0003 R11: 0246 R12: 
> R13: 55b629ebed70 R14: 0004 R15: 55b629ebec60
>
> So check for the empty string since strsep() will otherwise return the
> emtpy string which will cause kobject_add_internal() to panic when trying
> to add a kobject with an emtpy name.
>
> Fixes: ac4812c5ffbb ("binder: Support multiple /dev instances")
> Cc: Martijn Coenen 
> Signed-off-by: Christian Brauner 

Acked-by: Todd Kjos 

> ---
>  drivers/android/binder.c | 30 --
>  1 file changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 751d76173f81..5f7d6fe06eec 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5898,21 +5898,23 @@ static int __init binder_init(void)
> &transaction_log_fops);
> }
>
> -   /*
> -* Copy the module_parameter string, because we don't want to
> -* tokenize it in-place.
> -*/
> -   device_names = kstrdup(binder_devices_param, GFP_KERNEL);
> -   if (!device_names) {
> -   ret = -ENOMEM;
> -   goto err_alloc_device_names_failed;
> -   }
> +   if (strcmp(binder_devices_param, "") != 0) {
> +   /*
> +   * Copy the module_parameter string, because we don't want to
> +   * tokenize it in-place.
> +*/
> +   device_names = kstrdup(binder_devices_param, GFP_KERNEL);
> +   if (!device_names) {
> +   ret = -ENOMEM;
> +   goto err_alloc_device_names_failed;
> +   }
>
> -   device_tmp = device_names;
> -   while ((device_name = strsep(&device_tmp, ","))) {
> -   ret = init_binder_device(device_name);
> -   if (ret)
> -   goto err_init_binder_device_failed;
> +   d

Re: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support

2019-01-28 Thread Dan Carpenter
On Tue, Jan 29, 2019 at 12:41:55AM +0800, Chao Yu wrote:
> Hi Dan and Xiang,
> 
> On 2019-1-28 21:48, Gao Xiang wrote:
> > Hi Dan,
> > 
> > On 2019/1/28 21:33, Dan Carpenter wrote:
> >> Hopefully, regular kmalloc() is enough.
> >>
> >> Do really need the erofs_kmalloc() function?  Regular kmalloc() has
> >> fault injection already.  Have you tried to use it?
> 
> Yes, I think we'd better to use erofs_kmalloc(). :)
> 
> Actually, fault injection in erofs_kmalloc only affect erofs module, we can
> expect that the range of fault can be limited in erofs code, rather than whole
> kernel, so the test point can be aimed at more accurately.
> 

Are you serious?  The standard fault injection doesn't do that???

Please fix it instead of creating a duplicate better implementation
which only your filesystem can use.  I would have thought that obviously
any fault injection framework could at least be configured to test
specific code...

regards,
dan carpenter

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


Re: [PATCH] Drivers: hv: vmbus: Add mutex lock to channel show functions

2019-01-28 Thread Kimberly Brown
On Tue, Jan 22, 2019 at 06:40:30PM +, Dexuan Cui wrote:
> > From: Kimberly Brown 
> > Sent: Monday, January 21, 2019 10:43 PM
> > > > @@ -1421,7 +1422,10 @@ static ssize_t vmbus_chan_attr_show(struct
> > > > kobject *kobj,
> > > > if (chan->state != CHANNEL_OPENED_STATE)
> > > > return -EINVAL;
> > > >
> > > > -   return attribute->show(chan, buf);
> > > > +   mutex_lock(&vmbus_connection.channel_mutex);
> > > > +   ret = attribute->show(chan, buf);
> > > > +   mutex_unlock(&vmbus_connection.channel_mutex);
> > > > +   return ret;
> > > >  }
> > >
> > > It looks this patch is already able to fix the original issue:
> > > 6712cc9c2211 ("vmbus: don't return values for uninitalized channels"),
> > > as chan->state can't be CHANNEL_OPENED_STATE when
> > > channel->ringbuffer_page is not set up yet, or has been freed.
> > > -- Dexuan
> > 
> > I think that patch 6712cc9c2211 fixes the problem when the channel is
> > not set up yet, but it doesn't fix the problem when the channel is being
> > closed
> Yeah, now I see your point.
> 
> > The channel could be freed after the check that "chan->state" is
> > CHANNEL_OPENED_STATE, while the "attribute->show()" function is running.
> 
> IMO the channel struct itself can't be freed while the "attribute->show()"
> function is running, because I suppose the sysfs interface should have an 
> extra
> reference to channel->kobj (see vmbus_add_channel_kobj()), so before the sysfs
> files are removed, the channel struct itself can't disappear.
> (I didn't check the related code very carefully, so I could be wrong. :-) )
> 

I think that you're correct that the channel struct can't be freed while
the "attribute->show()" function is running. I tested this by calling
msleep() in chan_attr_show(), opening a subchannel sysfs file, and
unloading hv_netvsc. Unloading hv_netvsc should result in calls to
vmbus_chan_release() for each subchannel. I confirmed that
vmbus_chan_release() isn't called until the "attribute->show()" function
returns.


> But as you pointed, at least for sub-channels, channel->ringbuffer_page
> can indeed disappear in vmbus_close() -> ... -> vmbus_free_ring(), and
> the "attribute->show()" could crash when the race happens.
> Adding channel_mutex here seems to be able to fix the race for
> sub-channels, as the same channel_mutex is used in vmbus_disconnect_ring().
>
> For a primary channel, vmbus_close() -> vmbus_free_ring() can still
> free channel->ringbuffer_page without notifying the "attribute->show()".
> We may also need to acquire/release the channel_mutex in vmbus_close()?
>  
> > Actually, there should be checks that "chan" is not null and that
> > "chan->state" is CHANNEL_OPENED_STATE within the locked section. I'll
> > need to fix that.
> I suppose "chan" can not be NULL here (see the above).
> 
> Checking "chan->state" may not help to completely fix the race, because
> there is no locking/synchronization code in
> vmbus_close_internal() when we test and change "channel->state".
>

The calls to vmbus_close_internal() for the subchannels and the primary
channel are protected with channel_mutex in vmbus_disconnect_ring().
This prevents "channel->state" from changing while "attribute->show()" is
running.


> I guess we may need to check if channel->ringbuffer_page is NULL in
> the "attribute->show()". 
> 

For the primary channel, vmbus_free_ring() is called after the
return from vmbus_disconnect_ring(). Therefore, the primary channel's
state is changed before "channel->ringbuffer_page" is set to NULL.
Checking the channel state should be sufficient to prevent the ring
buffers from being freed while "attribute->show()" is running. The
ring buffers can't be freed until the channel's state is changed, and
the channel state change is protected by the mutex.

I think checking that "channel->ringbuffer_page" is not NULL would
also work, but, as you stated, we would need to aquire/release
channel_mutex in vmbus_close().


> PS, to prove that a race condition does exist and can really cause a panic or
> something, I usually add some msleep() delays in different paths so that I
> can reproduce the crash every time I take a special action, e.g. when I read
> the sysfs files of a NIC, I try to remove hv_netvsc driver. This way, I can 
> prove
> a patch can indeed help, at least it can fix the crash which would happen
> without the patch. :-)
> 

Thanks! I was able to free the ring buffers while "attribute->show()"
was running, which caused a null pointer dereference bug. As expected,
the mutex lock fixed it.


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


Re: [PATCH] nfit: add Hyper-V NVDIMM DSM command set to white list

2019-01-28 Thread Dan Williams
Hi Dexuan,

Looks good. Just one update request and a note below...

On Wed, Jan 23, 2019 at 12:51 PM Dexuan Cui  wrote:
>
>
> Add the Hyper-V _DSM command set to the white list of NVDIMM command
> sets.
>
> This command set is documented at http://www.uefi.org/RFIC_LIST
> (see the link to "Virtual NVDIMM 0x1901" on the page).
>
> Signed-off-by: Dexuan Cui 
> ---
>
> I'm going to change the user-space utility "ndctl" to support Hyper-V Virtual 
> NVDIMM.
> This kernel patch is required first.
>
>  drivers/acpi/nfit/core.c   | 5 -
>  drivers/acpi/nfit/nfit.h   | 6 +-
>  include/uapi/linux/ndctl.h | 1 +
>  3 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 011d3db19c80..fb48cb17a519 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1840,7 +1840,7 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
> *acpi_desc,
> dev_set_drvdata(&adev_dimm->dev, nfit_mem);
>
> /*
> -* Until standardization materializes we need to consider 4
> +* Until standardization materializes we need to consider 5
>  * different command sets.  Note, that checking for function0 (bit0)
>  * tells us if any commands are reachable through this GUID.
>  */

This comment is stale. This "HYPERV" family is the first example of
the "right" way to define a new NVDIMM command set. Lets update it to
mention the process and considerations for submitting new command sets
to UEFI (http://www.uefi.org/RFIC_LIST). The fact that there's now a
defined process is a step forward from when this comment was initially
written. Also, the fact that the process encourages "adopt" vs
"supersede" addresses the main concern about vendor-specific
command-set proliferation.

> @@ -1865,6 +1865,8 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
> *acpi_desc,
> dsm_mask &= ~(1 << 8);
> } else if (nfit_mem->family == NVDIMM_FAMILY_MSFT) {
> dsm_mask = 0x;
> +   } else if (nfit_mem->family == NVDIMM_FAMILY_HYPERV) {
> +   dsm_mask = 0x1f;

Just a note that starting with commit 5e9e38d0db1d "acpi/nfit: Block
function zero DSMs", bit0 in this mask will be cleared to ensure that
only the kernel has the ability to probe for supported DSM functions.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] tty: Fix WARNING in tty_set_termios

2019-01-28 Thread shuah

On 1/25/19 9:14 PM, Al Viro wrote:

On Fri, Jan 25, 2019 at 04:29:05PM -0700, Shuah Khan wrote:

tty_set_termios() has the following WARMN_ON which can be triggered with a
syscall to invoke TIOCGETD __NR_ioctl.

WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY &&
 tty->driver->subtype == PTY_TYPE_MASTER);
Reference: 
https://syzkaller.appspot.com/bug?id=2410d22f1d8e5984217329dd0884b01d99e3e48d

A simple change would have been to print error message instead of WARN_ON.
However, the callers assume that tty_set_termios() always returns 0 and
don't check return value. The complete solution is fixing all the callers
to check error and bail out to fix the WARN_ON.

This fix changes tty_set_termios() to return error and all the callers
to check error and bail out. The reproducer is used to reproduce the
problem and verify the fix.



--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -321,6 +321,8 @@ void hci_uart_set_flow_control(struct hci_uart *hu, bool 
enable)
status = tty_set_termios(tty, &ktermios);
BT_DBG("Disabling hardware flow control: %s",
   status ? "failed" : "success");
+   if (status)
+   return;


Can that ldisc end up set on pty master?  And does it make any sense there?


The initial objective of the patch is to prevent the WARN_ON by making
the change to return error instead of WARN_ON. However, without changes
to places that don't check the return and keep making progress, there
will be secondary problems.

Without this change to return here, instead of WARN_ON, it will fail
with the following NULL pointer dereference at the next thing 
hci_uart_set_flow_control() attempts.


status = tty->driver->ops->tiocmget(tty);

kernel: [10140.649783] BUG: unable to handle kernel NULL pointer 
dereference at 

kernel: [10140.649786] #PF error: [INSTR]
kernel: [10140.649787] PGD 0 P4D 0
kernel: [10140.649790] Oops: 0010 [#1] SMP PTI
Jan 24 15:33:35 deneb kernel: [10140.649793] CPU: 2 PID: 55 Comm: 
kworker/u33:0 Tainted: GW 5.0.0-rc3+ #5
kernel: [10140.649794] Hardware name: Dell Inc. OptiPlex 790/0HY9JP, 
BIOS A18 09/24/2013

Workqueue: hci0 hci_power_on [bluetooth]
kernel: [10140.649805] RIP: 0010:  (null)
kernel: [10140.649809] Code: Bad RIP value.
kernel: [10140.649810] RSP: 0018:a01a8153fd28 EFLAGS: 00010282
kernel: [10140.649812] RAX:  RBX: 8958d6bc4800 RCX: 
35ad8b03
kernel: [10140.649814] RDX: 0001 RSI:  RDI: 
8958d6bc4800
kernel: [10140.649816] RBP: a01a8153fd78 R08: 91773f09 R09: 
0003
kernel: [10140.649817] R10: 8958d6bc4a98 R11: 0720 R12: 
895814500c00
kernel: [10140.649819] R13: 8958a858e000 R14:  R15: 
8958af1af440
kernel: [10140.649821] FS:  () 
GS:89592588() knlGS:

kernel: [10140.649823] CS:  0010 DS:  ES:  CR0: 80050033
kernel: [10140.649824] CR2: ffd6 CR3: 83f46002 CR4: 
000606e0

kernel: [10140.649826] Call Trace:
kernel: [10140.649830]  ? hci_uart_set_flow_control+0x20e/0x2c0 [hci_uart]
kernel: [10140.649836]  mrvl_setup+0x17/0x80 [hci_uart]
kernel: [10140.649840]  hci_uart_setup+0x56/0x160 [hci_uart]
kernel: [10140.649850]  hci_dev_do_open+0xe6/0x630 [bluetooth]
kernel: [10140.649860]  hci_power_on+0x52/0x220 [bluetooth]



IOW, I don't believe that this patch makes any sense.  If anything,
we need to prevent unconditional tty_set_termios() on the path
that *does* lead to calling it for pty.



I don't think preventing unconditional tty_set_termios() is enough to
prevent secondary problems such as the one above.

For example, the following call chain leads to the WARN_ON that was
reported. Even if void hci_uart_set_baudrate() prevents the very first
tty_set_termios() call, its caller hci_uart_setup() continues with
more tty setup. It goes ahead to call driver setup callback. The
driver callback goes on to do more setup calling tty_set_termios().

WARN_ON call path:
 hci_uart_set_baudrate+0x1cc/0x250 drivers/bluetooth/hci_ldisc.c:378
 hci_uart_setup+0xa2/0x490 drivers/bluetooth/hci_ldisc.c:401
 hci_dev_do_open+0x6b1/0x1920 net/bluetooth/hci_core.c:1423

Once this WARN_ON is changed to return error, the following
happens, when hci_uart_setup() does driver setup callback.

kernel: [10140.649836]  mrvl_setup+0x17/0x80 [hci_uart]
kernel: [10140.649840]  hci_uart_setup+0x56/0x160 [hci_uart]
kernel: [10140.649850]  hci_dev_do_open+0xe6/0x630 [bluetooth]
kernel: [10140.649860]  hci_power_on+0x52/0x220 [bluetooth]

I think continuing to catch the invalid condition in tty_set_termios()
and preventing progress by checking return value is a straight forward
change to avoid secondary problems, and it might be difficult to catch
all the cases where it could fail. Here is the reproducer for reference:


#define _GN

RE: [PATCH] nfit: add Hyper-V NVDIMM DSM command set to white list

2019-01-28 Thread Dexuan Cui
> From: Dan Williams 
> Sent: Monday, January 28, 2019 1:01 PM
> 
> Hi Dexuan,
> Looks good. Just one update request and a note below...
> 
> On Wed, Jan 23, 2019 at 12:51 PM Dexuan Cui  wrote:
> > ...
> > --- a/drivers/acpi/nfit/core.c
> > +++ b/drivers/acpi/nfit/core.c
> > @@ -1840,7 +1840,7 @@ static int acpi_nfit_add_dimm(struct
> acpi_nfit_desc *acpi_desc,
> > dev_set_drvdata(&adev_dimm->dev, nfit_mem);
> >
> > /*
> > -* Until standardization materializes we need to consider 4
> > +* Until standardization materializes we need to consider 5
> >  * different command sets.  Note, that checking for function0
> (bit0)
> >  * tells us if any commands are reachable through this GUID.
> >  */
> 
> This comment is stale. This "HYPERV" family is the first example of
> the "right" way to define a new NVDIMM command set. Lets update it to
> mention the process and considerations for submitting new command sets
> to UEFI (http://www.uefi.org/RFIC_LIST). The fact that there's now a
> defined process is a step forward from when this comment was initially
> written. Also, the fact that the process encourages "adopt" vs
> "supersede" addresses the main concern about vendor-specific
> command-set proliferation.

I made the below simple change. Is this enough? Please suggest the proper
wording/sentence, as I'm relatively new to NVDIMM, and I don't really know the
history of the standardization process.

--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1732,8 +1732,10 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
*acpi_desc,
dev_set_drvdata(&adev_dimm->dev, nfit_mem);

/*
-* Until standardization materializes we need to consider 4
-* different command sets.  Note, that checking for function0 (bit0)
+* New command sets should be submitted to UEFI
+* http://www.uefi.org/RFIC_LIST.
+*
+* Note, that checking for function0 (bit0)
 * tells us if any commands are reachable through this GUID.
 */
for (i = 0; i <= NVDIMM_FAMILY_MAX; i++)

 
> > @@ -1865,6 +1865,8 @@ static int acpi_nfit_add_dimm(struct
> acpi_nfit_desc *acpi_desc,
> > dsm_mask &= ~(1 << 8);
> > } else if (nfit_mem->family == NVDIMM_FAMILY_MSFT) {
> > dsm_mask = 0x;
> > +   } else if (nfit_mem->family == NVDIMM_FAMILY_HYPERV) {
> > +   dsm_mask = 0x1f;
> 
> Just a note that starting with commit 5e9e38d0db1d "acpi/nfit: Block
> function zero DSMs", bit0 in this mask will be cleared to ensure that
> only the kernel has the ability to probe for supported DSM functions.

Thanks for the note!

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


[PATCH v2] staging: android: ion: Allocate from heap ID directly without mask

2019-01-28 Thread Andrew F. Davis
Previously the heap to allocate from was selected by a mask of allowed
heap types. This may have been done as a primitive form of constraint
solving, the first heap type that matched any set bit of the heap mask
was allocated from, unless that heap was excluded by having its heap
ID bit not set in the separate passed in heap ID mask.

The heap type does not really represent constraints that should be
matched against to begin with. So the patch [0] removed the the heap type
mask matching but unfortunately left the heap ID mask check (possibly by
mistake or to preserve API). Therefor we now only have a mask of heap
IDs, but heap IDs are unique identifiers and have nothing to do with the
underlying heap, so mask matching is not useful here. This also limits us
to 32 heaps total in a system.

With the heap query API users can find the right heap based on type or
name themselves then just supply the ID for that heap. Remove heap ID
mask and allow users to specify heap ID directly by its number.

I know this is an ABI break, but we are in staging so lets get this over
with now rather than limit ourselves later.

[0] commit 2bb9f5034ec7 ("gpu: ion: Remove heapmask from client")

Signed-off-by: Andrew F. Davis 
---

This also means we don't need to store the available heaps in a plist,
we only operation we care about is lookup, so a better data structure
should be chosen at some point, regular list or xarray maybe?

This is base on -next as to be on top of the other taken Ion patches.

Changes from v1:
 - Fix spelling in commit message
 - Cleanup logic per Brian's suggestion

 drivers/staging/android/ion/ion.c  | 28 +---
 drivers/staging/android/uapi/ion.h |  6 ++
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index 92c2914239e3..b0b0d0b587c2 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -387,7 +387,7 @@ static const struct dma_buf_ops dma_buf_ops = {
.unmap = ion_dma_buf_kunmap,
 };
 
-static int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags)
+static int ion_alloc(size_t len, unsigned int heap_id, unsigned int flags)
 {
struct ion_device *dev = internal_dev;
struct ion_buffer *buffer = NULL;
@@ -396,27 +396,25 @@ static int ion_alloc(size_t len, unsigned int 
heap_id_mask, unsigned int flags)
int fd;
struct dma_buf *dmabuf;
 
-   pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__,
-len, heap_id_mask, flags);
-   /*
-* traverse the list of heaps available in this system in priority
-* order.  If the heap type is supported by the client, and matches the
-* request of the caller allocate from it.  Repeat until allocate has
-* succeeded or all heaps have been tried
-*/
+   pr_debug("%s: len %zu heap_id %u flags %x\n", __func__,
+len, heap_id, flags);
+
len = PAGE_ALIGN(len);
 
if (!len)
return -EINVAL;
 
+   /*
+* Traverse the list of heaps available in this system.  If the
+* heap id matches the request of the caller allocate from it.
+*/
down_read(&dev->lock);
plist_for_each_entry(heap, &dev->heaps, node) {
-   /* if the caller didn't specify this heap id */
-   if (!((1 << heap->id) & heap_id_mask))
-   continue;
-   buffer = ion_buffer_create(heap, dev, len, flags);
-   if (!IS_ERR(buffer))
+   /* if the caller specified this heap id */
+   if (heap->id == heap_id) {
+   buffer = ion_buffer_create(heap, dev, len, flags);
break;
+   }
}
up_read(&dev->lock);
 
@@ -541,7 +539,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, 
unsigned long arg)
int fd;
 
fd = ion_alloc(data.allocation.len,
-  data.allocation.heap_id_mask,
+  data.allocation.heap_id,
   data.allocation.flags);
if (fd < 0)
return fd;
diff --git a/drivers/staging/android/uapi/ion.h 
b/drivers/staging/android/uapi/ion.h
index 5d7009884c13..6a78a1e23251 100644
--- a/drivers/staging/android/uapi/ion.h
+++ b/drivers/staging/android/uapi/ion.h
@@ -35,8 +35,6 @@ enum ion_heap_type {
   */
 };
 
-#define ION_NUM_HEAP_IDS   (sizeof(unsigned int) * 8)
-
 /**
  * allocation flags - the lower 16 bits are used by core ion, the upper 16
  * bits are reserved for use by the heaps themselves.
@@ -59,7 +57,7 @@ enum ion_heap_type {
 /**
  * struct ion_allocation_data - metadata passed from userspace for allocations
  * @len:   size of the allocation
- * @heap_id_mask:  mask of heap ids to allocate fr

Re: [PATCH] nfit: add Hyper-V NVDIMM DSM command set to white list

2019-01-28 Thread Dan Williams
On Mon, Jan 28, 2019 at 1:40 PM Dexuan Cui  wrote:
>
> > From: Dan Williams 
> > Sent: Monday, January 28, 2019 1:01 PM
> >
> > Hi Dexuan,
> > Looks good. Just one update request and a note below...
> >
> > On Wed, Jan 23, 2019 at 12:51 PM Dexuan Cui  wrote:
> > > ...
> > > --- a/drivers/acpi/nfit/core.c
> > > +++ b/drivers/acpi/nfit/core.c
> > > @@ -1840,7 +1840,7 @@ static int acpi_nfit_add_dimm(struct
> > acpi_nfit_desc *acpi_desc,
> > > dev_set_drvdata(&adev_dimm->dev, nfit_mem);
> > >
> > > /*
> > > -* Until standardization materializes we need to consider 4
> > > +* Until standardization materializes we need to consider 5
> > >  * different command sets.  Note, that checking for function0
> > (bit0)
> > >  * tells us if any commands are reachable through this GUID.
> > >  */
> >
> > This comment is stale. This "HYPERV" family is the first example of
> > the "right" way to define a new NVDIMM command set. Lets update it to
> > mention the process and considerations for submitting new command sets
> > to UEFI (http://www.uefi.org/RFIC_LIST). The fact that there's now a
> > defined process is a step forward from when this comment was initially
> > written. Also, the fact that the process encourages "adopt" vs
> > "supersede" addresses the main concern about vendor-specific
> > command-set proliferation.
>
> I made the below simple change. Is this enough? Please suggest the proper
> wording/sentence, as I'm relatively new to NVDIMM, and I don't really know the
> history of the standardization process.
>
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1732,8 +1732,10 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
> *acpi_desc,
> dev_set_drvdata(&adev_dimm->dev, nfit_mem);
>
> /*
> -* Until standardization materializes we need to consider 4
> -* different command sets.  Note, that checking for function0 (bit0)
> +* New command sets should be submitted to UEFI
> +* http://www.uefi.org/RFIC_LIST.
> +*

How about something a bit more relevant for the code in question:

---

There are 4 "legacy" NVDIMM command sets
(NVDIMM_FAMILY_{INTEL,MSFT,HPE1,HPE2}) that were created before an EFI
working group was established to constrain this proliferation. The
nfit driver probes for the supported command set by GUID. Note, If
you're a platform developer looking to add a new command set to this
probe consider using an existing set, or otherwise seek approval to
publish the command set at http://www.uefi.org/RFIC_LIST.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/1] staging: wilc1000: remove redundant reset of station statistics

2019-01-28 Thread Adham.Abozaeid
From: Adham Abozaeid 

Driver sends configuration wids to reset connection statistics in the
device, but the device already resets it when starting a new connection

Signed-off-by: Adham Abozaeid 
---
 drivers/staging/wilc1000/host_interface.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index fbb61de20304..286685e426c1 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -342,29 +342,11 @@ static int wilc_send_connect_wid(struct wilc_vif *vif)
 {
int result = 0;
struct wid wid_list[8];
-   u32 wid_cnt = 0, dummyval = 0;
+   u32 wid_cnt = 0;
struct host_if_drv *hif_drv = vif->hif_drv;
struct wilc_conn_info *conn_attr = &hif_drv->conn_info;
struct wilc_join_bss_param *bss_param = conn_attr->param;
 
-   wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT;
-   wid_list[wid_cnt].type = WID_INT;
-   wid_list[wid_cnt].size = sizeof(u32);
-   wid_list[wid_cnt].val = (s8 *)(&(dummyval));
-   wid_cnt++;
-
-   wid_list[wid_cnt].id = WID_RECEIVED_FRAGMENT_COUNT;
-   wid_list[wid_cnt].type = WID_INT;
-   wid_list[wid_cnt].size = sizeof(u32);
-   wid_list[wid_cnt].val = (s8 *)(&(dummyval));
-   wid_cnt++;
-
-   wid_list[wid_cnt].id = WID_FAILED_COUNT;
-   wid_list[wid_cnt].type = WID_INT;
-   wid_list[wid_cnt].size = sizeof(u32);
-   wid_list[wid_cnt].val = (s8 *)(&(dummyval));
-   wid_cnt++;
-
wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE;
wid_list[wid_cnt].type = WID_BIN_DATA;
wid_list[wid_cnt].val = conn_attr->req_ies;
-- 
2.17.1

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


RE: [PATCH] nfit: add Hyper-V NVDIMM DSM command set to white list

2019-01-28 Thread Dexuan Cui
> From: Dan Williams 
> Sent: Monday, January 28, 2019 1:55 PM
> 
> On Mon, Jan 28, 2019 at 1:40 PM Dexuan Cui  wrote:
> 
> > I made the below simple change. Is this enough? Please suggest the proper
> > wording/sentence, as I'm relatively new to NVDIMM, and I don't really know
> the history of the standardization process.
> 
> How about something a bit more relevant for the code in question:
> 
 
> There are 4 "legacy" NVDIMM command sets
> (NVDIMM_FAMILY_{INTEL,MSFT,HPE1,HPE2}) that were created before an EFI
> working group was established to constrain this proliferation. The
> nfit driver probes for the supported command set by GUID. Note, If
> you're a platform developer looking to add a new command set to this
> probe consider using an existing set, or otherwise seek approval to
> publish the command set at
> http://www.uefi.org/RFIC_LIST

Looks perfect! Let me use this, rebase the patch to 
https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/tag/?h=libnvdimm-fixes-5.0-rc4
and post a v2 later today.

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


[PATCH 1/7] binder: create userspace-to-binder-buffer copy function

2019-01-28 Thread Todd Kjos
The binder driver uses a vm_area to map the per-process
binder buffer space. For 32-bit android devices, this is
now taking too much vmalloc space. This patch removes
the use of vm_area when copying the transaction data
from the sender to the buffer space. Instead of using
copy_from_user() for multi-page copies, it now uses
binder_alloc_copy_user_to_buffer() which uses kmap()
and kunmap() to map each page, and uses copy_from_user()
for copying to that page.

Signed-off-by: Todd Kjos 
---
 drivers/android/binder.c   |  29 +++--
 drivers/android/binder_alloc.c | 114 +
 drivers/android/binder_alloc.h |   8 +++
 3 files changed, 144 insertions(+), 7 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 5f6ef5e63b91e..ab0b3eec363bc 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -3078,8 +3078,12 @@ static void binder_transaction(struct binder_proc *proc,
  ALIGN(tr->data_size, sizeof(void *)));
offp = off_start;
 
-   if (copy_from_user(t->buffer->data, (const void __user *)(uintptr_t)
-  tr->data.ptr.buffer, tr->data_size)) {
+   if (binder_alloc_copy_user_to_buffer(
+   &target_proc->alloc,
+   t->buffer, 0,
+   (const void __user *)
+   (uintptr_t)tr->data.ptr.buffer,
+   tr->data_size)) {
binder_user_error("%d:%d got transaction with invalid data 
ptr\n",
proc->pid, thread->pid);
return_error = BR_FAILED_REPLY;
@@ -3087,8 +3091,13 @@ static void binder_transaction(struct binder_proc *proc,
return_error_line = __LINE__;
goto err_copy_data_failed;
}
-   if (copy_from_user(offp, (const void __user *)(uintptr_t)
-  tr->data.ptr.offsets, tr->offsets_size)) {
+   if (binder_alloc_copy_user_to_buffer(
+   &target_proc->alloc,
+   t->buffer,
+   ALIGN(tr->data_size, sizeof(void *)),
+   (const void __user *)
+   (uintptr_t)tr->data.ptr.offsets,
+   tr->offsets_size)) {
binder_user_error("%d:%d got transaction with invalid offsets 
ptr\n",
proc->pid, thread->pid);
return_error = BR_FAILED_REPLY;
@@ -3217,6 +3226,8 @@ static void binder_transaction(struct binder_proc *proc,
struct binder_buffer_object *bp =
to_binder_buffer_object(hdr);
size_t buf_left = sg_buf_end - sg_bufp;
+   binder_size_t sg_buf_offset = (uintptr_t)sg_bufp -
+   (uintptr_t)t->buffer->data;
 
if (bp->length > buf_left) {
binder_user_error("%d:%d got transaction with 
too large buffer\n",
@@ -3226,9 +3237,13 @@ static void binder_transaction(struct binder_proc *proc,
return_error_line = __LINE__;
goto err_bad_offset;
}
-   if (copy_from_user(sg_bufp,
-  (const void __user *)(uintptr_t)
-  bp->buffer, bp->length)) {
+   if (binder_alloc_copy_user_to_buffer(
+   &target_proc->alloc,
+   t->buffer,
+   sg_buf_offset,
+   (const void __user *)
+   (uintptr_t)bp->buffer,
+   bp->length)) {
binder_user_error("%d:%d got transaction with 
invalid offsets ptr\n",
  proc->pid, thread->pid);
return_error_param = -EFAULT;
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 022cd80e80cc3..255fa71911e5e 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -29,6 +29,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "binder_alloc.h"
 #include "binder_trace.h"
 
@@ -1053,3 +1055,115 @@ int binder_alloc_shrinker_init(void)
}
return ret;
 }
+
+/**
+ * check_buffer() - verify that buffer/offset is safe to access
+ * @alloc: binder_alloc for this proc
+ * @buffer: binder buffer to be accessed
+ * @offset: offset into @buffer data
+ * @bytes: bytes to access from offset
+ *
+ * Check that the @offset/@bytes are within the size of 

[PATCH 7/7] binder: use userspace pointer as base of buffer space

2019-01-28 Thread Todd Kjos
Now that alloc->buffer points to the userspace vm_area
rename buffer->data to buffer->user_data and rename
local pointers that hold user addresses. Also use the
"__user" tag to annotate all user pointers so sparse
can flag cases where user pointer vaues  are copied to
kernel pointers. Refactor code to use offsets instead
of user pointers.

Signed-off-by: Todd Kjos 
---
 drivers/android/binder.c   | 120 +++--
 drivers/android/binder_alloc.c |  89 
 drivers/android/binder_alloc.h |   6 +-
 drivers/android/binder_trace.h |   2 +-
 4 files changed, 119 insertions(+), 98 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 07b92bbb7360e..ec5b98699de4d 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2278,33 +2278,30 @@ static void binder_deferred_fd_close(int fd)
 
 static void binder_transaction_buffer_release(struct binder_proc *proc,
  struct binder_buffer *buffer,
- binder_size_t *failed_at)
+ binder_size_t failed_at,
+ bool is_failure)
 {
-   binder_size_t *offp, *off_start, *off_end;
int debug_id = buffer->debug_id;
-   binder_size_t off_start_offset;
+   binder_size_t off_start_offset, buffer_offset, off_end_offset;
 
binder_debug(BINDER_DEBUG_TRANSACTION,
-"%d buffer release %d, size %zd-%zd, failed at %pK\n",
+"%d buffer release %d, size %zd-%zd, failed at %llx\n",
 proc->pid, buffer->debug_id,
-buffer->data_size, buffer->offsets_size, failed_at);
+buffer->data_size, buffer->offsets_size,
+(unsigned long long)failed_at);
 
if (buffer->target_node)
binder_dec_node(buffer->target_node, 1, 0);
 
off_start_offset = ALIGN(buffer->data_size, sizeof(void *));
-   off_start = (binder_size_t *)(buffer->data + off_start_offset);
-   if (failed_at)
-   off_end = failed_at;
-   else
-   off_end = (void *)off_start + buffer->offsets_size;
-   for (offp = off_start; offp < off_end; offp++) {
+   off_end_offset = is_failure ? failed_at :
+   off_start_offset + buffer->offsets_size;
+   for (buffer_offset = off_start_offset; buffer_offset < off_end_offset;
+buffer_offset += sizeof(binder_size_t)) {
struct binder_object_header *hdr;
size_t object_size;
struct binder_object object;
binder_size_t object_offset;
-   binder_size_t buffer_offset = (uintptr_t)offp -
-   (uintptr_t)buffer->data;
 
binder_alloc_copy_from_buffer(&proc->alloc, &object_offset,
  buffer, buffer_offset,
@@ -2380,9 +2377,10 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
struct binder_fd_array_object *fda;
struct binder_buffer_object *parent;
struct binder_object ptr_object;
-   u32 *fd_array;
+   binder_size_t fda_offset;
size_t fd_index;
binder_size_t fd_buf_size;
+   binder_size_t num_valid;
 
if (proc->tsk != current->group_leader) {
/*
@@ -2393,12 +2391,14 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
continue;
}
 
+   num_valid = (buffer_offset - off_start_offset) /
+   sizeof(binder_size_t);
fda = to_binder_fd_array_object(hdr);
parent = binder_validate_ptr(proc, buffer, &ptr_object,
 fda->parent,
 off_start_offset,
 NULL,
-offp - off_start);
+num_valid);
if (!parent) {
pr_err("transaction release %d bad parent 
offset\n",
   debug_id);
@@ -2417,14 +2417,21 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
   debug_id, (u64)fda->num_fds);
continue;
}
-   fd_array = (u32 *)(uintptr_t)
-   (parent->buffer + fda->parent_offset);
+   /*
+* the 

[PATCH 0/7] binder: eliminate use of vmalloc space for binder buffers

2019-01-28 Thread Todd Kjos
Binder buffers have always been mapped into kernel space
via map_kernel_range_noflush() to allow the binder driver
to modify the buffer before posting to userspace for
processing.

In recent Android releases, the number of long-running
binder processes has increased to the point that for
32-bit systems, there is a risk of running out of
vmalloc space.

This patch set removes the persistent mapping of the
binder buffers into kernel space. Instead, the binder
driver creates temporary mappings with kmap() or
kmap_atomic() to copy to or from the buffer only when
necessary.

Todd Kjos (7):
binder: create userspace-to-binder-buffer copy function
binder: add functions to copy to/from binder buffers
binder: add function to copy binder object from buffer
binder: avoid kernel vm_area for buffer fixups
binder: remove kernel vm_area for buffer space
binder: remove user_buffer_offset
binder: use userspace pointer as base of buffer space

 drivers/android/Kconfig|   2 +-
 drivers/android/binder.c   | 461 
-
 drivers/android/binder_alloc.c | 302 
+--
 drivers/android/binder_alloc.h |  47 +-
 drivers/android/binder_trace.h |   2 +-
 5 files changed, 538 insertions(+), 276 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/7] binder: add functions to copy to/from binder buffers

2019-01-28 Thread Todd Kjos
Avoid vm_area when copying to or from binder buffers.
Instead, new copy functions are added that copy from
kernel space to binder buffer space. These use
kmap_atomic() and kunmap_atomic() to create temporary
mappings and then memcpy() is used to copy within
that page.

Also, kmap_atomic() / kunmap_atomic() use the appropriate
cache flushing to support VIVT cache architectures.
Allow binder to build if CPU_CACHE_VIVT is defined.

Several uses of the new functions are added here. More
to follow in subsequent patches.

Signed-off-by: Todd Kjos 
---
 drivers/android/Kconfig|   2 +-
 drivers/android/binder.c   | 119 +
 drivers/android/binder_alloc.c |  59 
 drivers/android/binder_alloc.h |  12 
 4 files changed, 147 insertions(+), 45 deletions(-)

diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig
index 4c190f8d1f4c6..6fdf2abe4598a 100644
--- a/drivers/android/Kconfig
+++ b/drivers/android/Kconfig
@@ -10,7 +10,7 @@ if ANDROID
 
 config ANDROID_BINDER_IPC
bool "Android Binder IPC Driver"
-   depends on MMU && !CPU_CACHE_VIVT
+   depends on MMU
default n
---help---
  Binder is used in Android for both communication between processes,
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index ab0b3eec363bc..74d0c1ff874e2 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2244,14 +2244,22 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
off_end = (void *)off_start + buffer->offsets_size;
for (offp = off_start; offp < off_end; offp++) {
struct binder_object_header *hdr;
-   size_t object_size = binder_validate_object(buffer, *offp);
-
+   size_t object_size;
+   binder_size_t object_offset;
+   binder_size_t buffer_offset = (uintptr_t)offp -
+   (uintptr_t)buffer->data;
+
+   binder_alloc_copy_from_buffer(&proc->alloc, &object_offset,
+ buffer, buffer_offset,
+ sizeof(object_offset));
+   object_size = binder_validate_object(buffer, object_offset);
if (object_size == 0) {
pr_err("transaction release %d bad object at offset 
%lld, size %zd\n",
-  debug_id, (u64)*offp, buffer->data_size);
+  debug_id, (u64)object_offset, buffer->data_size);
continue;
}
-   hdr = (struct binder_object_header *)(buffer->data + *offp);
+   hdr = (struct binder_object_header *)
+   (buffer->data + object_offset);
switch (hdr->type) {
case BINDER_TYPE_BINDER:
case BINDER_TYPE_WEAK_BINDER: {
@@ -2359,8 +2367,20 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
continue;
}
fd_array = (u32 *)(parent_buffer + 
(uintptr_t)fda->parent_offset);
-   for (fd_index = 0; fd_index < fda->num_fds; fd_index++)
-   binder_deferred_fd_close(fd_array[fd_index]);
+   for (fd_index = 0; fd_index < fda->num_fds;
+fd_index++) {
+   u32 fd;
+   binder_size_t offset =
+   (uintptr_t)&fd_array[fd_index] -
+   (uintptr_t)buffer->data;
+
+   binder_alloc_copy_from_buffer(&proc->alloc,
+ &fd,
+ buffer,
+ offset,
+ sizeof(fd));
+   binder_deferred_fd_close(fd);
+   }
} break;
default:
pr_err("transaction release %d bad object type %x\n",
@@ -2496,7 +2516,7 @@ static int binder_translate_handle(struct 
flat_binder_object *fp,
return ret;
 }
 
-static int binder_translate_fd(u32 *fdp,
+static int binder_translate_fd(u32 fd, binder_size_t fd_offset,
   struct binder_transaction *t,
   struct binder_thread *thread,
   struct binder_transaction *in_reply_to)
@@ -2507,7 +2527,6 @@ static int binder_translate_fd(u32 *fdp,
struct file *file;
int ret = 0;
bool target_allows_fd;
-   int fd = *fdp;
 
if (in_reply_to)
target_allows_fd = !!(in_reply_to->flags & TF_ACCEPT_FDS);
@@ -2546,7 +2565,7 @@ static int binder_translate_fd(u32 *fdp

[PATCH 3/7] binder: add function to copy binder object from buffer

2019-01-28 Thread Todd Kjos
When creating or tearing down a transaction, the binder driver
examines objects in the buffer and takes appropriate action.
To do this without needing to dereference pointers into the
buffer, the local copies of the objects are needed. This patch
introduces a function to validate and copy binder objects
from the buffer to a local structure.

Signed-off-by: Todd Kjos 
---
 drivers/android/binder.c | 75 +++-
 1 file changed, 58 insertions(+), 17 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 74d0c1ff874e2..1563b9b60a0a3 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -628,6 +628,26 @@ struct binder_transaction {
spinlock_t lock;
 };
 
+/**
+ * struct binder_object - union of flat binder object types
+ * @hdr:   generic object header
+ * @fbo:   binder object (nodes and refs)
+ * @fdo:   file descriptor object
+ * @bbo:   binder buffer pointer
+ * @fdao:  file descriptor array
+ *
+ * Used for type-independent object copies
+ */
+struct binder_object {
+   union {
+   struct binder_object_header hdr;
+   struct flat_binder_object fbo;
+   struct binder_fd_object fdo;
+   struct binder_buffer_object bbo;
+   struct binder_fd_array_object fdao;
+   };
+};
+
 /**
  * binder_proc_lock() - Acquire outer lock for given binder_proc
  * @proc: struct binder_proc to acquire
@@ -2017,26 +2037,33 @@ static void binder_cleanup_transaction(struct 
binder_transaction *t,
 }
 
 /**
- * binder_validate_object() - checks for a valid metadata object in a buffer.
+ * binder_get_object() - gets object and checks for valid metadata
+ * @proc:  binder_proc owning the buffer
  * @buffer:binder_buffer that we're parsing.
- * @offset:offset in the buffer at which to validate an object.
+ * @offset:offset in the @buffer at which to validate an object.
+ * @object:struct binder_object to read into
  *
  * Return: If there's a valid metadata object at @offset in @buffer, the
- * size of that object. Otherwise, it returns zero.
+ * size of that object. Otherwise, it returns zero. The object
+ * is read into the struct binder_object pointed to by @object.
  */
-static size_t binder_validate_object(struct binder_buffer *buffer, u64 offset)
+static size_t binder_get_object(struct binder_proc *proc,
+   struct binder_buffer *buffer,
+   unsigned long offset,
+   struct binder_object *object)
 {
-   /* Check if we can read a header first */
+   size_t read_size;
struct binder_object_header *hdr;
size_t object_size = 0;
 
-   if (buffer->data_size < sizeof(*hdr) ||
-   offset > buffer->data_size - sizeof(*hdr) ||
-   !IS_ALIGNED(offset, sizeof(u32)))
+   read_size = min(sizeof(*object), (size_t)(buffer->data_size - offset));
+   if (read_size < sizeof(*hdr))
return 0;
+   binder_alloc_copy_from_buffer(&proc->alloc, object, buffer,
+ offset, read_size);
 
-   /* Ok, now see if we can read a complete object. */
-   hdr = (struct binder_object_header *)(buffer->data + offset);
+   /* Ok, now see if we read a complete object. */
+   hdr = &object->hdr;
switch (hdr->type) {
case BINDER_TYPE_BINDER:
case BINDER_TYPE_WEAK_BINDER:
@@ -2245,6 +2272,7 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
for (offp = off_start; offp < off_end; offp++) {
struct binder_object_header *hdr;
size_t object_size;
+   struct binder_object object;
binder_size_t object_offset;
binder_size_t buffer_offset = (uintptr_t)offp -
(uintptr_t)buffer->data;
@@ -2252,14 +2280,14 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
binder_alloc_copy_from_buffer(&proc->alloc, &object_offset,
  buffer, buffer_offset,
  sizeof(object_offset));
-   object_size = binder_validate_object(buffer, object_offset);
+   object_size = binder_get_object(proc, buffer,
+   object_offset, &object);
if (object_size == 0) {
pr_err("transaction release %d bad object at offset 
%lld, size %zd\n",
   debug_id, (u64)object_offset, buffer->data_size);
continue;
}
-   hdr = (struct binder_object_header *)
-   (buffer->data + object_offset);
+   hdr = &object.hdr;
switch (hdr->type) {
case BINDER_TYPE_BINDER:
case BINDER

[PATCH 6/7] binder: remove user_buffer_offset

2019-01-28 Thread Todd Kjos
Remove user_buffer_offset since there is no kernel
buffer pointer anymore.

Signed-off-by: Todd Kjos 
---
 drivers/android/binder.c   | 38 +++---
 drivers/android/binder_alloc.c | 16 ++
 drivers/android/binder_alloc.h | 23 
 3 files changed, 13 insertions(+), 64 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 197b7bdc38eef..07b92bbb7360e 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2380,7 +2380,6 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
struct binder_fd_array_object *fda;
struct binder_buffer_object *parent;
struct binder_object ptr_object;
-   uintptr_t parent_buffer;
u32 *fd_array;
size_t fd_index;
binder_size_t fd_buf_size;
@@ -2405,14 +2404,6 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
   debug_id);
continue;
}
-   /*
-* Since the parent was already fixed up, convert it
-* back to kernel address space to access it
-*/
-   parent_buffer = parent->buffer -
-   binder_alloc_get_user_buffer_offset(
-   &proc->alloc);
-
fd_buf_size = sizeof(u32) * fda->num_fds;
if (fda->num_fds >= SIZE_MAX / sizeof(u32)) {
pr_err("transaction release %d invalid number 
of fds (%lld)\n",
@@ -2426,7 +2417,8 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
   debug_id, (u64)fda->num_fds);
continue;
}
-   fd_array = (u32 *)(parent_buffer + 
(uintptr_t)fda->parent_offset);
+   fd_array = (u32 *)(uintptr_t)
+   (parent->buffer + fda->parent_offset);
for (fd_index = 0; fd_index < fda->num_fds;
 fd_index++) {
u32 fd;
@@ -2646,7 +2638,6 @@ static int binder_translate_fd_array(struct 
binder_fd_array_object *fda,
 struct binder_transaction *in_reply_to)
 {
binder_size_t fdi, fd_buf_size;
-   uintptr_t parent_buffer;
u32 *fd_array;
struct binder_proc *proc = thread->proc;
struct binder_proc *target_proc = t->to_proc;
@@ -2664,13 +2655,7 @@ static int binder_translate_fd_array(struct 
binder_fd_array_object *fda,
  proc->pid, thread->pid, (u64)fda->num_fds);
return -EINVAL;
}
-   /*
-* Since the parent was already fixed up, convert it
-* back to the kernel address space to access it
-*/
-   parent_buffer = parent->buffer -
-   binder_alloc_get_user_buffer_offset(&target_proc->alloc);
-   fd_array = (u32 *)(parent_buffer + (uintptr_t)fda->parent_offset);
+   fd_array = (u32 *)(uintptr_t)(parent->buffer + fda->parent_offset);
if (!IS_ALIGNED((unsigned long)fd_array, sizeof(u32))) {
binder_user_error("%d:%d parent offset not aligned 
correctly.\n",
  proc->pid, thread->pid);
@@ -2703,7 +2688,6 @@ static int binder_fixup_parent(struct binder_transaction 
*t,
   binder_size_t last_fixup_min_off)
 {
struct binder_buffer_object *parent;
-   u8 *parent_buffer;
struct binder_buffer *b = t->buffer;
struct binder_proc *proc = thread->proc;
struct binder_proc *target_proc = t->to_proc;
@@ -2739,11 +2723,8 @@ static int binder_fixup_parent(struct binder_transaction 
*t,
  proc->pid, thread->pid);
return -EINVAL;
}
-   parent_buffer = (u8 *)((uintptr_t)parent->buffer -
-   binder_alloc_get_user_buffer_offset(
-   &target_proc->alloc));
buffer_offset = bp->parent_offset +
-   (uintptr_t)parent_buffer - (uintptr_t)b->data;
+   (uintptr_t)parent->buffer - (uintptr_t)b->data;
binder_alloc_copy_to_buffer(&target_proc->alloc, b, buffer_offset,
&bp->buffer, sizeof(bp->buffer));
 
@@ -3159,10 +3140,8 @@ static void binder_transaction(struct binder_proc *proc,
ALIGN(tr->offsets_size, sizeof(void *)) +
ALIGN(extra_buffers_size, sizeof(void *)) -
ALIGN(secctx_sz, sizeof(u64));
-   cha

[PATCH 4/7] binder: avoid kernel vm_area for buffer fixups

2019-01-28 Thread Todd Kjos
Refactor the functions to validate and fixup struct
binder_buffer pointer objects to avoid using vm_area
pointers. Instead copy to/from kernel space using
binder_alloc_copy_to_buffer() and
binder_alloc_copy_from_buffer(). The following
functions were refactored:

binder_validate_ptr()
binder_validate_fixup()
binder_fixup_parent()

Signed-off-by: Todd Kjos 
---
 drivers/android/binder.c | 146 ++-
 1 file changed, 97 insertions(+), 49 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 1563b9b60a0a3..197b7bdc38eef 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2092,10 +2092,13 @@ static size_t binder_get_object(struct binder_proc 
*proc,
 
 /**
  * binder_validate_ptr() - validates binder_buffer_object in a binder_buffer.
+ * @proc:  binder_proc owning the buffer
  * @b: binder_buffer containing the object
+ * @object:struct binder_object to read into
  * @index: index in offset array at which the binder_buffer_object is
  * located
- * @start: points to the start of the offset array
+ * @start_offset: points to the start of the offset array
+ * @object_offsetp: offset of @object read from @b
  * @num_valid: the number of valid offsets in the offset array
  *
  * Return: If @index is within the valid range of the offset array
@@ -2106,34 +2109,46 @@ static size_t binder_get_object(struct binder_proc 
*proc,
  * Note that the offset found in index @index itself is not
  * verified; this function assumes that @num_valid elements
  * from @start were previously verified to have valid offsets.
+ * If @object_offsetp is non-NULL, then the offset within
+ * @b is written to it.
  */
-static struct binder_buffer_object *binder_validate_ptr(struct binder_buffer 
*b,
-   binder_size_t index,
-   binder_size_t *start,
-   binder_size_t num_valid)
+static struct binder_buffer_object *binder_validate_ptr(
+   struct binder_proc *proc,
+   struct binder_buffer *b,
+   struct binder_object *object,
+   binder_size_t index,
+   binder_size_t start_offset,
+   binder_size_t *object_offsetp,
+   binder_size_t num_valid)
 {
-   struct binder_buffer_object *buffer_obj;
-   binder_size_t *offp;
+   size_t object_size;
+   binder_size_t object_offset;
+   unsigned long buffer_offset;
 
if (index >= num_valid)
return NULL;
 
-   offp = start + index;
-   buffer_obj = (struct binder_buffer_object *)(b->data + *offp);
-   if (buffer_obj->hdr.type != BINDER_TYPE_PTR)
+   buffer_offset = start_offset + sizeof(binder_size_t) * index;
+   binder_alloc_copy_from_buffer(&proc->alloc, &object_offset,
+ b, buffer_offset, sizeof(object_offset));
+   object_size = binder_get_object(proc, b, object_offset, object);
+   if (!object_size || object->hdr.type != BINDER_TYPE_PTR)
return NULL;
+   if (object_offsetp)
+   *object_offsetp = object_offset;
 
-   return buffer_obj;
+   return &object->bbo;
 }
 
 /**
  * binder_validate_fixup() - validates pointer/fd fixups happen in order.
+ * @proc:  binder_proc owning the buffer
  * @b: transaction buffer
- * @objects_start  start of objects buffer
- * @buffer:binder_buffer_object in which to fix up
- * @offset:start offset in @buffer to fix up
- * @last_obj:  last binder_buffer_object that we fixed up in
- * @last_min_offset:   minimum fixup offset in @last_obj
+ * @objects_start_offset: offset to start of objects buffer
+ * @buffer_obj_offset: offset to binder_buffer_object in which to fix up
+ * @fixup_offset:  start offset in @buffer to fix up
+ * @last_obj_offset:   offset to last binder_buffer_object that we fixed
+ * @last_min_offset:   minimum fixup offset in object at @last_obj_offset
  *
  * Return: %true if a fixup in buffer @buffer at offset @offset is
  * allowed.
@@ -2164,28 +2179,41 @@ static struct binder_buffer_object 
*binder_validate_ptr(struct binder_buffer *b,
  *   C (parent = A, offset = 16)
  * D (parent = B, offset = 0) // B is not A or any of A's parents
  */
-static bool binder_validate_fixup(struct binder_buffer *b,
- binder_size_t *objects_start,
- struct binder_buffer_object *buffer,
+static

[PATCH 5/7] binder: remove kernel vm_area for buffer space

2019-01-28 Thread Todd Kjos
Remove the kernel's vm_area and the code that maps
buffer pages into it.

Signed-off-by: Todd Kjos 
---
 drivers/android/binder_alloc.c | 40 ++
 1 file changed, 2 insertions(+), 38 deletions(-)

diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index be2a6077e6c5c..dde8977c49ea0 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -265,16 +265,6 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
page->alloc = alloc;
INIT_LIST_HEAD(&page->lru);
 
-   ret = map_kernel_range_noflush((unsigned long)page_addr,
-  PAGE_SIZE, PAGE_KERNEL,
-  &page->page_ptr);
-   flush_cache_vmap((unsigned long)page_addr,
-   (unsigned long)page_addr + PAGE_SIZE);
-   if (ret != 1) {
-   pr_err("%d: binder_alloc_buf failed to map page at %pK 
in kernel\n",
-  alloc->pid, page_addr);
-   goto err_map_kernel_failed;
-   }
user_page_addr =
(uintptr_t)page_addr + alloc->user_buffer_offset;
ret = vm_insert_page(vma, user_page_addr, page[0].page_ptr);
@@ -314,8 +304,6 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
continue;
 
 err_vm_insert_page_failed:
-   unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
-err_map_kernel_failed:
__free_page(page->page_ptr);
page->page_ptr = NULL;
 err_alloc_page_failed:
@@ -695,7 +683,6 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
  struct vm_area_struct *vma)
 {
int ret;
-   struct vm_struct *area;
const char *failure_string;
struct binder_buffer *buffer;
 
@@ -706,28 +693,10 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
goto err_already_mapped;
}
 
-   area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC);
-   if (area == NULL) {
-   ret = -ENOMEM;
-   failure_string = "get_vm_area";
-   goto err_get_vm_area_failed;
-   }
-   alloc->buffer = area->addr;
-   alloc->user_buffer_offset =
-   vma->vm_start - (uintptr_t)alloc->buffer;
+   alloc->buffer = (void *)vma->vm_start;
+   alloc->user_buffer_offset = 0;
mutex_unlock(&binder_alloc_mmap_lock);
 
-#ifdef CONFIG_CPU_CACHE_VIPT
-   if (cache_is_vipt_aliasing()) {
-   while (CACHE_COLOUR(
-   (vma->vm_start ^ (uint32_t)alloc->buffer))) {
-   pr_info("%s: %d %lx-%lx maps %pK bad alignment\n",
-   __func__, alloc->pid, vma->vm_start,
-   vma->vm_end, alloc->buffer);
-   vma->vm_start += PAGE_SIZE;
-   }
-   }
-#endif
alloc->pages = kcalloc((vma->vm_end - vma->vm_start) / PAGE_SIZE,
   sizeof(alloc->pages[0]),
   GFP_KERNEL);
@@ -760,9 +729,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
alloc->pages = NULL;
 err_alloc_pages_failed:
mutex_lock(&binder_alloc_mmap_lock);
-   vfree(alloc->buffer);
alloc->buffer = NULL;
-err_get_vm_area_failed:
 err_already_mapped:
mutex_unlock(&binder_alloc_mmap_lock);
binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
@@ -821,12 +788,10 @@ void binder_alloc_deferred_release(struct binder_alloc 
*alloc)
 "%s: %d: page %d at %pK %s\n",
 __func__, alloc->pid, i, page_addr,
 on_lru ? "on lru" : "active");
-   unmap_kernel_range((unsigned long)page_addr, PAGE_SIZE);
__free_page(alloc->pages[i].page_ptr);
page_count++;
}
kfree(alloc->pages);
-   vfree(alloc->buffer);
}
mutex_unlock(&alloc->mutex);
if (alloc->vma_vm_mm)
@@ -988,7 +953,6 @@ enum lru_status binder_alloc_free_page(struct list_head 
*item,
 
trace_binder_unmap_kernel_start(alloc, index);
 
-   unmap_kernel_range(page_addr, PAGE_SIZE);
__free_page(page->page_ptr);
page->page_ptr = NULL;
 
-- 
2.20.1.495.gaa96b0ce6b-goog

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


[PATCH v2] nfit: add Hyper-V NVDIMM DSM command set to white list

2019-01-28 Thread Dexuan Cui


Add the Hyper-V _DSM command set to the white list of NVDIMM command
sets.

This command set is documented at http://www.uefi.org/RFIC_LIST
(see "Virtual NVDIMM 0x1901").

Thanks Dan Williams  for writing the
comment change.

Signed-off-by: Dexuan Cui 
Reviewed-by: Michael Kelley 
---

Changes in v2:
Updated the comment and changelog (Thanks, Dan!)
Rebased to the tag libnvdimm-fixes-5.0-rc4 of the nvdimm tree.

 drivers/acpi/nfit/core.c   | 17 ++---
 drivers/acpi/nfit/nfit.h   |  6 +-
 include/uapi/linux/ndctl.h |  1 +
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index e18ade5d74e9..a9270c99be72 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1861,9 +1861,17 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
*acpi_desc,
dev_set_drvdata(&adev_dimm->dev, nfit_mem);
 
/*
-* Until standardization materializes we need to consider 4
-* different command sets.  Note, that checking for function0 (bit0)
-* tells us if any commands are reachable through this GUID.
+* There are 4 "legacy" NVDIMM command sets
+* (NVDIMM_FAMILY_{INTEL,MSFT,HPE1,HPE2}) that were created before
+* an EFI working group was established to constrain this
+* proliferation. The nfit driver probes for the supported command
+* set by GUID. Note, if you're a platform developer looking to add
+* a new command set to this probe, consider using an existing set,
+* or otherwise seek approval to publish the command set at
+* http://www.uefi.org/RFIC_LIST.
+*
+* Note, that checking for function0 (bit0) tells us if any commands
+* are reachable through this GUID.
 */
for (i = 0; i <= NVDIMM_FAMILY_MAX; i++)
if (acpi_check_dsm(adev_dimm->handle, to_nfit_uuid(i), 1, 1))
@@ -1886,6 +1894,8 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc 
*acpi_desc,
dsm_mask &= ~(1 << 8);
} else if (nfit_mem->family == NVDIMM_FAMILY_MSFT) {
dsm_mask = 0x;
+   } else if (nfit_mem->family == NVDIMM_FAMILY_HYPERV) {
+   dsm_mask = 0x1f;
} else {
dev_dbg(dev, "unknown dimm command family\n");
nfit_mem->family = -1;
@@ -3729,6 +3739,7 @@ static __init int nfit_init(void)
guid_parse(UUID_NFIT_DIMM_N_HPE1, &nfit_uuid[NFIT_DEV_DIMM_N_HPE1]);
guid_parse(UUID_NFIT_DIMM_N_HPE2, &nfit_uuid[NFIT_DEV_DIMM_N_HPE2]);
guid_parse(UUID_NFIT_DIMM_N_MSFT, &nfit_uuid[NFIT_DEV_DIMM_N_MSFT]);
+   guid_parse(UUID_NFIT_DIMM_N_HYPERV, &nfit_uuid[NFIT_DEV_DIMM_N_HYPERV]);
 
nfit_wq = create_singlethread_workqueue("nfit");
if (!nfit_wq)
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index 33691aecfcee..4de167b4f76f 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -34,11 +34,14 @@
 /* https://msdn.microsoft.com/library/windows/hardware/mt604741 */
 #define UUID_NFIT_DIMM_N_MSFT "1ee68b36-d4bd-4a1a-9a16-4f8e53d46e05"
 
+/* http://www.uefi.org/RFIC_LIST (see "Virtual NVDIMM 0x1901") */
+#define UUID_NFIT_DIMM_N_HYPERV "5746c5f2-a9a2-4264-ad0e-e4ddc9e09e80"
+
 #define ACPI_NFIT_MEM_FAILED_MASK (ACPI_NFIT_MEM_SAVE_FAILED \
| ACPI_NFIT_MEM_RESTORE_FAILED | ACPI_NFIT_MEM_FLUSH_FAILED \
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
 
-#define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_MSFT
+#define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
 
 #define NVDIMM_STANDARD_CMDMASK \
 (1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \
@@ -94,6 +97,7 @@ enum nfit_uuids {
NFIT_DEV_DIMM_N_HPE1 = NVDIMM_FAMILY_HPE1,
NFIT_DEV_DIMM_N_HPE2 = NVDIMM_FAMILY_HPE2,
NFIT_DEV_DIMM_N_MSFT = NVDIMM_FAMILY_MSFT,
+   NFIT_DEV_DIMM_N_HYPERV = NVDIMM_FAMILY_HYPERV,
NFIT_SPA_VOLATILE,
NFIT_SPA_PM,
NFIT_SPA_DCR,
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index f57c9e434d2d..de5d90212409 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -243,6 +243,7 @@ struct nd_cmd_pkg {
 #define NVDIMM_FAMILY_HPE1 1
 #define NVDIMM_FAMILY_HPE2 2
 #define NVDIMM_FAMILY_MSFT 3
+#define NVDIMM_FAMILY_HYPERV 4
 
 #define ND_IOCTL_CALL  _IOWR(ND_IOCTL, ND_CMD_CALL,\
struct nd_cmd_pkg)
-- 
2.19.1

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


Re: [PATCH v2 1/2] PCI: hv: Replace hv_vp_set with hv_vpset

2019-01-28 Thread Maya Nakamura
On Sun, Jan 27, 2019 at 05:11:48AM +, Michael Kelley wrote:
> From: Maya Nakamura   Sent: Saturday, January 26, 
> 2019 12:52 AM
> > 
> > Remove a duplicate definition of VP set (hv_vp_set) and use the common
> > definition (hv_vpset) that is used in other places.
> > 
> > Change the order of the members in struct hv_pcibus_device so that the
> > declaration of retarget_msi_interrupt_params is the last member. Struct
> > hv_vpset, which contains a flexible array, is nested two levels deep in
> > struct hv_pcibus_device via retarget_msi_interrupt_params.
> > 
> > Add a comment that retarget_msi_interrupt_params should be the last member
> > of struct hv_pcibus_device.
> > 
> > Signed-off-by: Maya Nakamura 
> > ---
> > Change in v2:
> > - None
> > 
> 
> Right -- there was no code change.  But it's customary to note that
> you updated the commit message.
> 
Thank you for your feedback. I will edit the change log in v3.

> Reviewed-by:  Michael Kelley 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/2] PCI: hv: Refactor hv_irq_unmask() to use cpumask_to_vpset()

2019-01-28 Thread Maya Nakamura
On Sun, Jan 27, 2019 at 05:22:06AM +, Michael Kelley wrote:
> From: Maya Nakamura   Sent: Saturday, January 26, 
> 2019 12:55 AM
> >
> > @@ -953,29 +951,27 @@ static void hv_irq_unmask(struct irq_data *data)
> >  */
> > params->int_target.flags |=
> > HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;
> > -   params->int_target.vp_set.valid_bank_mask =
> > -   (1ull << HV_VP_SET_BANK_COUNT_MAX) - 1;
> > +
> > +   if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) {
> > +   res = 1;
> > +   goto exit_unlock;
> > +   }
> > +
> > +   cpumask_and(tmp, dest, cpu_online_mask);
> > +   nr_bank = cpumask_to_vpset(¶ms->int_target.vp_set, tmp);
> > +   free_cpumask_var(tmp);
> > +
> > +   if (!nr_bank) {
> 
> There are two failures cases in cpumask_to_vpset().  One case returns
> 0, and the other case returns -1.  The above test only catches the 0
> failure case.  Need to modify the test to catch both cases.
> 
> Michael
> 
Thank you for your feedback. I will correct it in v3.

Maya

> > +   res = 1;
> > +   goto exit_unlock;
> > +   }
> > 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 0/2] PCI: hv: Refactor hv_irq_unmask() to use hv_vpset and cpumask_to_vpset()

2019-01-28 Thread Maya Nakamura
This patchset removes a duplicate definition of VP set (hv_vp_set) and
uses the common definition (hv_vpset) that is used in other places. It
changes the order of the members in struct hv_pcibus_device due to
flexible array in hv_vpset.

It also removes the duplicate implementation of cpumask_to_vpset(), uses
the shared implementation, and exports hv_max_vp_index, which is
required by cpumask_to_vpset().

Maya Nakamura (2):
  PCI: hv: Replace hv_vp_set with hv_vpset
  PCI: hv: Refactor hv_irq_unmask() to use cpumask_to_vpset()

 arch/x86/hyperv/hv_init.c   |  1 +
 drivers/pci/controller/pci-hyperv.c | 59 +
 2 files changed, 28 insertions(+), 32 deletions(-)

-- 
2.17.1

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


[PATCH v3 1/2] PCI: hv: Replace hv_vp_set with hv_vpset

2019-01-28 Thread Maya Nakamura
Remove a duplicate definition of VP set (hv_vp_set) and use the common
definition (hv_vpset) that is used in other places.

Change the order of the members in struct hv_pcibus_device so that the
declaration of retarget_msi_interrupt_params is the last member. Struct
hv_vpset, which contains a flexible array, is nested two levels deep in
struct hv_pcibus_device via retarget_msi_interrupt_params.

Add a comment that retarget_msi_interrupt_params should be the last member
of struct hv_pcibus_device.

Signed-off-by: Maya Nakamura 
---
Change in v3:
- Correct the v2 change log.

Change in v2:
- Update the commit message.

 drivers/pci/controller/pci-hyperv.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/controller/pci-hyperv.c 
b/drivers/pci/controller/pci-hyperv.c
index 9ba4d12c179c..da8b58d8630d 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -393,12 +393,6 @@ struct hv_interrupt_entry {
 
 #define HV_VP_SET_BANK_COUNT_MAX   5 /* current implementation limit */
 
-struct hv_vp_set {
-   u64 format; /* 0 (HvGenericSetSparse4k) */
-   u64 valid_banks;
-   u64 masks[HV_VP_SET_BANK_COUNT_MAX];
-};
-
 /*
  * flags for hv_device_interrupt_target.flags
  */
@@ -410,7 +404,7 @@ struct hv_device_interrupt_target {
u32 flags;
union {
u64  vp_mask;
-   struct hv_vp_set vp_set;
+   struct hv_vpset vp_set;
};
 };
 
@@ -460,12 +454,16 @@ struct hv_pcibus_device {
struct msi_controller msi_chip;
struct irq_domain *irq_domain;
 
-   /* hypercall arg, must not cross page boundary */
-   struct retarget_msi_interrupt retarget_msi_interrupt_params;
-
spinlock_t retarget_msi_interrupt_lock;
 
struct workqueue_struct *wq;
+
+   /* hypercall arg, must not cross page boundary */
+   struct retarget_msi_interrupt retarget_msi_interrupt_params;
+
+   /*
+* Don't put anything here: retarget_msi_interrupt_params must be last
+*/
 };
 
 /*
@@ -955,12 +953,13 @@ static void hv_irq_unmask(struct irq_data *data)
 */
params->int_target.flags |=
HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;
-   params->int_target.vp_set.valid_banks =
+   params->int_target.vp_set.valid_bank_mask =
(1ull << HV_VP_SET_BANK_COUNT_MAX) - 1;
 
/*
 * var-sized hypercall, var-size starts after vp_mask (thus
-* vp_set.format does not count, but vp_set.valid_banks does).
+* vp_set.format does not count, but vp_set.valid_bank_mask
+* does).
 */
var_size = 1 + HV_VP_SET_BANK_COUNT_MAX;
 
@@ -974,7 +973,7 @@ static void hv_irq_unmask(struct irq_data *data)
goto exit_unlock;
}
 
-   params->int_target.vp_set.masks[cpu_vmbus / 64] |=
+   params->int_target.vp_set.bank_contents[cpu_vmbus / 64] 
|=
(1ULL << (cpu_vmbus & 63));
}
} else {
-- 
2.17.1

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


[PATCH v3 2/2] PCI: hv: Refactor hv_irq_unmask() to use cpumask_to_vpset()

2019-01-28 Thread Maya Nakamura
Remove the duplicate implementation of cpumask_to_vpset() and use the
shared implementation. Export hv_max_vp_index, which is required by
cpumask_to_vpset().

Apply changes to hv_irq_unmask() based on feedback.

Signed-off-by: Maya Nakamura 
---
Changes in v3:
 - Modify to catch all failures from cpumask_to_vpset().
 - Correct the v2 change log about the commit message.

Changes in v2:
 - Remove unnecessary nr_bank initialization.
 - Delete two unnecessary dev_err()'s.
 - Unlock before returning.
 - Update the commit message.

 arch/x86/hyperv/hv_init.c   |  1 +
 drivers/pci/controller/pci-hyperv.c | 38 +
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 7abb09e2eeb8..7f2eed1fc81b 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -96,6 +96,7 @@ void  __percpu **hyperv_pcpu_input_arg;
 EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg);
 
 u32 hv_max_vp_index;
+EXPORT_SYMBOL_GPL(hv_max_vp_index);
 
 static int hv_cpu_init(unsigned int cpu)
 {
diff --git a/drivers/pci/controller/pci-hyperv.c 
b/drivers/pci/controller/pci-hyperv.c
index da8b58d8630d..a78def332bbc 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -391,8 +391,6 @@ struct hv_interrupt_entry {
u32 data;
 };
 
-#define HV_VP_SET_BANK_COUNT_MAX   5 /* current implementation limit */
-
 /*
  * flags for hv_device_interrupt_target.flags
  */
@@ -908,12 +906,12 @@ static void hv_irq_unmask(struct irq_data *data)
struct retarget_msi_interrupt *params;
struct hv_pcibus_device *hbus;
struct cpumask *dest;
+   cpumask_var_t tmp;
struct pci_bus *pbus;
struct pci_dev *pdev;
unsigned long flags;
u32 var_size = 0;
-   int cpu_vmbus;
-   int cpu;
+   int cpu, nr_bank;
u64 res;
 
dest = irq_data_get_effective_affinity_mask(data);
@@ -953,29 +951,27 @@ static void hv_irq_unmask(struct irq_data *data)
 */
params->int_target.flags |=
HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET;
-   params->int_target.vp_set.valid_bank_mask =
-   (1ull << HV_VP_SET_BANK_COUNT_MAX) - 1;
+
+   if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) {
+   res = 1;
+   goto exit_unlock;
+   }
+
+   cpumask_and(tmp, dest, cpu_online_mask);
+   nr_bank = cpumask_to_vpset(¶ms->int_target.vp_set, tmp);
+   free_cpumask_var(tmp);
+
+   if (nr_bank <= 0) {
+   res = 1;
+   goto exit_unlock;
+   }
 
/*
 * var-sized hypercall, var-size starts after vp_mask (thus
 * vp_set.format does not count, but vp_set.valid_bank_mask
 * does).
 */
-   var_size = 1 + HV_VP_SET_BANK_COUNT_MAX;
-
-   for_each_cpu_and(cpu, dest, cpu_online_mask) {
-   cpu_vmbus = hv_cpu_number_to_vp_number(cpu);
-
-   if (cpu_vmbus >= HV_VP_SET_BANK_COUNT_MAX * 64) {
-   dev_err(&hbus->hdev->device,
-   "too high CPU %d", cpu_vmbus);
-   res = 1;
-   goto exit_unlock;
-   }
-
-   params->int_target.vp_set.bank_contents[cpu_vmbus / 64] 
|=
-   (1ULL << (cpu_vmbus & 63));
-   }
+   var_size = 1 + nr_bank;
} else {
for_each_cpu_and(cpu, dest, cpu_online_mask) {
params->int_target.vp_mask |=
-- 
2.17.1

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


Re: [linux-sunxi] [PATCH v2 1/2] media: v4l: Add definitions for the HEVC slice format and controls

2019-01-28 Thread Alexandre Courbot
On Fri, Jan 25, 2019 at 10:04 PM Paul Kocialkowski
 wrote:
>
> Hi,
>
> On Thu, 2019-01-24 at 20:23 +0800, Ayaka wrote:
> >
> > Sent from my iPad
> >
> > > On Jan 24, 2019, at 6:27 PM, Paul Kocialkowski 
> > >  wrote:
> > >
> > > Hi,
> > >
> > > > On Thu, 2019-01-10 at 21:32 +0800, ayaka wrote:
> > > > I forget a important thing, for the rkvdec and rk hevc decoder, it would
> > > > requests cabac table, scaling list, picture parameter set and reference
> > > > picture storing in one or various of DMA buffers. I am not talking about
> > > > the data been parsed, the decoder would requests a raw data.
> > > >
> > > > For the pps and rps, it is possible to reuse the slice header, just let
> > > > the decoder know the offset from the bitstream bufer, I would suggest to
> > > > add three properties(with sps) for them. But I think we need a method to
> > > > mark a OUTPUT side buffer for those aux data.
> > >
> > > I'm quite confused about the hardware implementation then. From what
> > > you're saying, it seems that it takes the raw bitstream elements rather
> > > than parsed elements. Is it really a stateless implementation?
> > >
> > > The stateless implementation was designed with the idea that only the
> > > raw slice data should be passed in bitstream form to the decoder. For
> > > H.264, it seems that some decoders also need the slice header in raw
> > > bitstream form (because they take the full slice NAL unit), see the
> > > discussions in this thread:
> > > media: docs-rst: Document m2m stateless video decoder interface
> >
> > Stateless just mean it won’t track the previous result, but I don’t
> > think you can define what a date the hardware would need. Even you
> > just build a dpb for the decoder, it is still stateless, but parsing
> > less or more data from the bitstream doesn’t stop a decoder become a
> > stateless decoder.
>
> Yes fair enough, the format in which the hardware decoder takes the
> bitstream parameters does not make it stateless or stateful per-se.
> It's just that stateless decoders should have no particular reason for
> parsing the bitstream on their own since the hardware can be designed
> with registers for each relevant bitstream element to configure the
> decoding pipeline. That's how GPU-based decoder implementations are
> implemented (VAAPI/VDPAU/NVDEC, etc).
>
> So the format we have agreed on so far for the stateless interface is
> to pass parsed elements via v4l2 control structures.
>
> If the hardware can only work by parsing the bitstream itself, I'm not
> sure what the best solution would be. Reconstructing the bitstream in
> the kernel is a pretty bad option, but so is parsing in the kernel or
> having the data both in parsed and raw forms. Do you see another
> possibility?

Is reconstructing the bitstream so bad? The v4l2 controls provide a
generic interface to an encoded format which the driver needs to
convert into a sequence that the hardware can understand. Typically
this is done by populating hardware-specific structures. Can't we
consider that in this specific instance, the hardware-specific
structure just happens to be identical to the original bitstream
format?

I agree that this is not strictly optimal for that particular
hardware, but such is the cost of abstractions, and in this specific
case I don't believe the cost would be particularly high?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel