[PATCH V2 08/15] staging: unisys: visorhba: use sg helper to operate sgl
The current way isn't safe for chained sgl, so use sg helper to operate sgl. Cc: de...@driverdev.osuosl.org Cc: Greg Kroah-Hartman Signed-off-by: Ming Lei --- drivers/staging/unisys/visorhba/visorhba_main.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 2dad36a05518..dd979ee4dcf1 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -871,12 +871,11 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, return; } - sg = scsi_sglist(scsicmd); - for (i = 0; i < scsi_sg_count(scsicmd); i++) { - this_page_orig = kmap_atomic(sg_page(sg + i)); + scsi_for_each_sg(scsicmd, sg, scsi_sg_count(scsicmd), i) { + this_page_orig = kmap_atomic(sg_page(sg)); this_page = (void *)((unsigned long)this_page_orig | -sg[i].offset); - memcpy(this_page, buf + bufind, sg[i].length); +sg->offset); + memcpy(this_page, buf + bufind, sg->length); kunmap_atomic(this_page_orig); } kfree(buf); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/11] staging: rtl8723bs: core: Remove function eeprom_read_sz()
On 13/06/19 12:15 PM, Dan Carpenter wrote: On Wed, Jun 12, 2019 at 11:34:29PM +0530, Nishka Dasgupta wrote: Remove unused function eeprom_read_sz. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta This is great but you need to remove the declaration from the .h file as well. I noticed some of the other patches have this problem as well so please check them and resend the whole set. I'm sorry, I couldn't find the declaration in any .h file for any of these patches, even after fetch origin, rebase, and grep. Going to individual .h files and searching for declarations does not seem to work either. Is there any other way I can look for the declarations? Thanking you, Nishka regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/2] staging: erofs: add requirements field in superblock
There are some backward incompatible features pending for months, mainly due to on-disk format expensions. However, we should ensure that it cannot be mounted with old kernels. Otherwise, it will causes unexpected behaviors. Fixes: ba2b77a82022 ("staging: erofs: add super block operations") Cc: # 4.19+ Reviewed-by: Chao Yu Signed-off-by: Gao Xiang --- change log v3: - record requirements in erofs_sb_info for runtime use as well; change log v2: - update printed message drivers/staging/erofs/erofs_fs.h | 13 ++--- drivers/staging/erofs/internal.h | 2 ++ drivers/staging/erofs/super.c| 19 +++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h index fa52898df006..8ddb2b3e7d39 100644 --- a/drivers/staging/erofs/erofs_fs.h +++ b/drivers/staging/erofs/erofs_fs.h @@ -17,10 +17,16 @@ #define EROFS_SUPER_MAGIC_V10xE0F5E1E2 #define EROFS_SUPER_OFFSET 1024 +/* + * Any bits that aren't in EROFS_ALL_REQUIREMENTS should be + * incompatible with this kernel version. + */ +#define EROFS_ALL_REQUIREMENTS 0 + struct erofs_super_block { /* 0 */__le32 magic; /* in the little endian */ /* 4 */__le32 checksum;/* crc32c(super_block) */ -/* 8 */__le32 features; +/* 8 */__le32 features;/* (aka. feature_compat) */ /* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */ /* 13 */__u8 reserved; @@ -34,9 +40,10 @@ struct erofs_super_block { /* 44 */__le32 xattr_blkaddr; /* 48 */__u8 uuid[16]; /* 128-bit uuid for volume */ /* 64 */__u8 volume_name[16]; /* volume name */ +/* 80 */__le32 requirements;/* (aka. feature_incompat) */ -/* 80 */__u8 reserved2[48]; /* 128 bytes */ -} __packed; +/* 84 */__u8 reserved2[44]; +} __packed; /* 128 bytes */ /* * erofs inode data mapping: diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 911333cdeef4..fc732c86ecd8 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -115,6 +115,8 @@ struct erofs_sb_info { u8 uuid[16];/* 128-bit uuid for volume */ u8 volume_name[16]; /* volume name */ + u32 requirements; + char *dev_name; unsigned int mount_opt; diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index f580d4ef77a1..cadbcc11702a 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -71,6 +71,22 @@ static void free_inode(struct inode *inode) kmem_cache_free(erofs_inode_cachep, vi); } +static bool check_layout_compatibility(struct super_block *sb, + struct erofs_super_block *layout) +{ + const unsigned int requirements = le32_to_cpu(layout->requirements); + + EROFS_SB(sb)->requirements = requirements; + + /* check if current kernel meets all mandatory requirements */ + if (requirements & (~EROFS_ALL_REQUIREMENTS)) { + errln("unidentified requirements %x, please upgrade kernel version", + requirements & ~EROFS_ALL_REQUIREMENTS); + return false; + } + return true; +} + static int superblock_read(struct super_block *sb) { struct erofs_sb_info *sbi; @@ -104,6 +120,9 @@ static int superblock_read(struct super_block *sb) goto out; } + if (!check_layout_compatibility(sb, layout)) + goto out; + sbi->blocks = le32_to_cpu(layout->blocks); sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr); #ifdef CONFIG_EROFS_FS_XATTR -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/11] staging: rtl8723bs: core: Remove function eeprom_read_sz()
On Thu, Jun 13, 2019 at 01:53:20PM +0530, Nishka Dasgupta wrote: > On 13/06/19 12:15 PM, Dan Carpenter wrote: > > On Wed, Jun 12, 2019 at 11:34:29PM +0530, Nishka Dasgupta wrote: > > > Remove unused function eeprom_read_sz. > > > Issue found with Coccinelle. > > > > > > Signed-off-by: Nishka Dasgupta > > > > This is great but you need to remove the declaration from the .h file > > as well. I noticed some of the other patches have this problem as well > > so please check them and resend the whole set. > > I'm sorry, I couldn't find the declaration in any .h file for any of these > patches, even after fetch origin, rebase, and grep. Going to individual .h > files and searching for declarations does not seem to work either. Is there > any other way I can look for the declarations? > Oh... Heh. Sorry for the noise. My bad. I was looking at the wrong driver. It's declared but not implemented in rtl8188eu in drivers/staging/rtl8188eu/include/rtw_eeprom.h. We should delete those too, but it's unrelated to your patchset so don't worry about it. regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 01/11] staging: rtl8723bs: core: Remove function eeprom_read_sz()
On 13/06/19 2:05 PM, Dan Carpenter wrote: On Thu, Jun 13, 2019 at 01:53:20PM +0530, Nishka Dasgupta wrote: On 13/06/19 12:15 PM, Dan Carpenter wrote: On Wed, Jun 12, 2019 at 11:34:29PM +0530, Nishka Dasgupta wrote: Remove unused function eeprom_read_sz. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta This is great but you need to remove the declaration from the .h file as well. I noticed some of the other patches have this problem as well so please check them and resend the whole set. I'm sorry, I couldn't find the declaration in any .h file for any of these patches, even after fetch origin, rebase, and grep. Going to individual .h files and searching for declarations does not seem to work either. Is there any other way I can look for the declarations? Oh... Heh. Sorry for the noise. My bad. I was looking at the wrong driver. It's declared but not implemented in rtl8188eu in drivers/staging/rtl8188eu/include/rtw_eeprom.h. We should delete those too, but it's unrelated to your patchset so don't worry about it. Oh, okay. I was actually going to do rtl8188eu anyway so I'll keep this in mind when I get round to it. Thanking you, Nishka regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/6] staging: kpc2000_dma: added Kconfig to enable asynchronous I/O.
On Tue, Jun 11, 2019 at 08:50:59PM +0100, Jeremy Sowden wrote: > The DMA driver has call-backs for doing asynchronous I/O which are > protected by a CONFIG_ macro which is not defined. Added a Kconfig > stanza to define it. > > Cc: Matt Sickler > Signed-off-by: Jeremy Sowden > --- > drivers/staging/kpc2000/Kconfig | 8 > drivers/staging/kpc2000/kpc_dma/fileops.c | 6 +++--- > 2 files changed, 11 insertions(+), 3 deletions(-) This patch breaks the build if you enable the new build option. So it probably should go _after_ you have fixed up the code. Please fix this series up and resend it. Also, is aio even wanted/needed for this driver? If it's been disabled for so long, can't we just delete it if no one is using it? thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/6] staging: kpc2000_dma: added Kconfig to enable asynchronous I/O.
On 2019-06-13, at 10:45:31 +0200, Greg KH wrote: > On Tue, Jun 11, 2019 at 08:50:59PM +0100, Jeremy Sowden wrote: > > The DMA driver has call-backs for doing asynchronous I/O which are > > protected by a CONFIG_ macro which is not defined. Added a Kconfig > > stanza to define it. > > > > Cc: Matt Sickler > > Signed-off-by: Jeremy Sowden > > --- > > drivers/staging/kpc2000/Kconfig | 8 > > drivers/staging/kpc2000/kpc_dma/fileops.c | 6 +++--- > > 2 files changed, 11 insertions(+), 3 deletions(-) > > This patch breaks the build if you enable the new build option. So it > probably should go _after_ you have fixed up the code. > > Please fix this series up and resend it. > Also, is aio even wanted/needed for this driver? If it's been > disabled for so long, can't we just delete it if no one is using it? Matt's recommendation was also to delete it, so I have sent a later patch to do so. J. signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH][next] staging: media: meson: remove redundant initialization of mpeg12
Hi Colin, On Wed, Jun 12, 2019 at 4:42 PM Colin King wrote: > > From: Colin Ian King > > The pointer mpeg12 is being initialized however that value is never > read and mpeg12 is being re-assigned almost immediately afterwards. > Remove the redundant initialization. > > Addresses-Coverity: ("Unused value") > Signed-off-by: Colin Ian King > --- > drivers/staging/media/meson/vdec/codec_mpeg12.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/media/meson/vdec/codec_mpeg12.c > b/drivers/staging/media/meson/vdec/codec_mpeg12.c > index 5398fbf7ce20..48869cc3d973 100644 > --- a/drivers/staging/media/meson/vdec/codec_mpeg12.c > +++ b/drivers/staging/media/meson/vdec/codec_mpeg12.c > @@ -63,7 +63,7 @@ static void codec_mpeg12_recycle(struct amvdec_core *core, > u32 buf_idx) > static int codec_mpeg12_start(struct amvdec_session *sess) > { > struct amvdec_core *core = sess->core; > - struct codec_mpeg12 *mpeg12 = sess->priv; > + struct codec_mpeg12 *mpeg12; > int ret; > > mpeg12 = kzalloc(sizeof(*mpeg12), GFP_KERNEL); > -- > 2.20.1 > Thank you for the patch. Acked-by: Maxime Jourdan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/6] staging: kpc2000_dma: added Kconfig to enable asynchronous I/O.
On Thu, Jun 13, 2019 at 10:13:06AM +0100, Jeremy Sowden wrote: > On 2019-06-13, at 10:45:31 +0200, Greg KH wrote: > > On Tue, Jun 11, 2019 at 08:50:59PM +0100, Jeremy Sowden wrote: > > > The DMA driver has call-backs for doing asynchronous I/O which are > > > protected by a CONFIG_ macro which is not defined. Added a Kconfig > > > stanza to define it. > > > > > > Cc: Matt Sickler > > > Signed-off-by: Jeremy Sowden > > > --- > > > drivers/staging/kpc2000/Kconfig | 8 > > > drivers/staging/kpc2000/kpc_dma/fileops.c | 6 +++--- > > > 2 files changed, 11 insertions(+), 3 deletions(-) > > > > This patch breaks the build if you enable the new build option. So it > > probably should go _after_ you have fixed up the code. > > > > Please fix this series up and resend it. > > Also, is aio even wanted/needed for this driver? If it's been > > disabled for so long, can't we just delete it if no one is using it? > > Matt's recommendation was also to delete it, so I have sent a later > patch to do so. I somehow missed that, can you resend it please as a stand-alone patch or series or whatever is needed? thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH RESEND] staging: kpc2000: removed DMA AIO implementation.
The existing implementation for doing DMA via asynchronous IO didn't work and there was no longer a use-case for it. Removed it. Fixed a few checkpatch warnings about too-long lines and extraneous braces in the process. Reported-by: Matt Sickler Signed-off-by: Jeremy Sowden --- drivers/staging/kpc2000/TODO | 3 - drivers/staging/kpc2000/kpc_dma/fileops.c | 102 -- .../staging/kpc2000/kpc_dma/kpc_dma_driver.h | 2 - 3 files changed, 21 insertions(+), 86 deletions(-) diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO index 47530e23e940..9b5ab37fb3a0 100644 --- a/drivers/staging/kpc2000/TODO +++ b/drivers/staging/kpc2000/TODO @@ -1,5 +1,2 @@ - the kpc_spi driver doesn't seem to let multiple transactions (to different instances of the core) happen in parallel... - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton. It functions against current hardware though. -- would be nice if the AIO fileops in kpc_dma could be made to work -- probably want to add a CONFIG_ option to control compilation of the AIO functions -- if the AIO fileops in kpc_dma start working, next would be making iov_count > 1 work too diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index f80b01715d93..7feb2fde0db2 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -9,7 +9,6 @@ #include /* size_t */ #include #include /* copy_*_user */ -#include /* aio stuff */ #include #include #include "kpc_dma_driver.h" @@ -32,8 +31,8 @@ unsigned int count_parts_for_sge(struct scatterlist *sg) } /** Transfer Helpers **/ -static -int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned long iov_base, size_t iov_len) +static int kpc_dma_transfer(struct dev_private_data *priv, + unsigned long iov_base, size_t iov_len) { unsigned int i = 0; long rv = 0; @@ -65,7 +64,6 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned acd->ldev = priv->ldev; acd->cpl = &done; acd->flags = 0; - acd->kcb = kcb; acd->len = iov_len; acd->page_count = count_pages(iov_base, iov_len); @@ -173,21 +171,18 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned unlock_engine(ldev); - // If this is a synchronous kiocb, we need to put the calling process to sleep until the transfer is complete - if (kcb == NULL || is_sync_kiocb(kcb)) { - rv = wait_for_completion_interruptible(&done); - // If the user aborted (rv == -ERESTARTSYS), we're no longer responsible for cleaning up the acd - if (rv == -ERESTARTSYS) { - acd->cpl = NULL; - } - if (rv == 0) { - rv = acd->len; - kfree(acd); - } - return rv; + rv = wait_for_completion_interruptible(&done); + /* +* If the user aborted (rv == -ERESTARTSYS), we're no longer responsible +* for cleaning up the acd +*/ + if (rv == -ERESTARTSYS) + acd->cpl = NULL; + if (rv == 0) { + rv = acd->len; + kfree(acd); } - - return -EIOCBQUEUED; + return rv; err_descr_too_many: unlock_engine(ldev); @@ -234,17 +229,13 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) acd->flags = flags; - if (acd->kcb == NULL || is_sync_kiocb(acd->kcb)) { - if (acd->cpl) { - complete(acd->cpl); - } else { - // There's no completion, so we're responsible for cleaning up the acd - kfree(acd); - } + if (acd->cpl) { + complete(acd->cpl); } else { -#ifdef CONFIG_KPC_DMA_AIO - aio_complete(acd->kcb, acd->len, acd->flags); -#endif + /* +* There's no completion, so we're responsible for cleaning up +* the acd +*/ kfree(acd); } } @@ -308,53 +299,6 @@ int kpc_dma_close(struct inode *inode, struct file *filp) return 0; } -#ifdef CONFIG_KPC_DMA_AIO -static -int kpc_dma_aio_cancel(struct kiocb *kcb) -{ - struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - - dev_dbg(&priv->ldev->pldev->dev, "%s(kcb = [%p]) priv = [%p], ldev = [%p]\n", __func__, kcb, priv, priv->ldev); - return 0; -} - -static -ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned long iov_count, loff_t pos) -{ - struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - - if (priv
Re: [PATCH 1/2] staging: rtl8723bs: hal: sdio_halinit: fix comparison to true/false is error prone
On Wed, Jun 12, 2019 at 07:59:57AM +0530, Hariprasad Kelam wrote: > CHECK: Using comparison to false is error prone > CHECK: Using comparison to true is error prone > > Signed-off-by: Hariprasad Kelam > --- > drivers/staging/rtl8723bs/hal/sdio_halinit.c | 16 > 1 file changed, 8 insertions(+), 8 deletions(-) > Patch seems to be corrupt, please rebase and resend. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/2] staging: rtl8723bs: hal: sdio_halinit: fix spaces preferred around that unary operator
On Wed, Jun 12, 2019 at 08:00:19AM +0530, Hariprasad Kelam wrote: > CHECK: spaces preferred around that '+' (ctx:VxV) > CHECK: spaces preferred around that '<<' (ctx:VxV) > CHECK: spaces preferred around that '|' (ctx:VxV) > > Signed-off-by: Hariprasad Kelam > --- > drivers/staging/rtl8723bs/hal/sdio_halinit.c | 92 > ++-- > 1 file changed, 46 insertions(+), 46 deletions(-) > Also corrupted, please fix up and resend. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V2 08/15] staging: unisys: visorhba: use sg helper to operate sgl
On Thu, Jun 13, 2019 at 03:13:28PM +0800, Ming Lei wrote: > The current way isn't safe for chained sgl, so use sg helper to > operate sgl. I can not make any sense out of this changelog. What "isn't safe"? What is a "sgl"? Can this be applied "out of order"? confused, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 31/34] staging: media: soc_camera: imx074: simplify getting the adapter of a client
On Sat, Jun 08, 2019 at 12:56:10PM +0200, Wolfram Sang wrote: > We have a dedicated pointer for that, so use it. Much easier to read and > less computation involved. > > Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman > --- > > Please apply to your subsystem tree. > > drivers/staging/media/soc_camera/imx074.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/media/soc_camera/imx074.c > b/drivers/staging/media/soc_camera/imx074.c > index d907aa62f898..14240b74cdd0 100644 > --- a/drivers/staging/media/soc_camera/imx074.c > +++ b/drivers/staging/media/soc_camera/imx074.c > @@ -409,7 +409,7 @@ static int imx074_probe(struct i2c_client *client, > const struct i2c_device_id *did) > { > struct imx074 *priv; > - struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); > + struct i2c_adapter *adapter = client->adapter; > struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); > int ret; > > -- > 2.19.1 > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 33/34] staging: media: soc_camera: soc_mt9v022: simplify getting the adapter of a client
On Sat, Jun 08, 2019 at 12:56:12PM +0200, Wolfram Sang wrote: > We have a dedicated pointer for that, so use it. Much easier to read and > less computation involved. > > Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman > --- > > Please apply to your subsystem tree. > > drivers/staging/media/soc_camera/soc_mt9v022.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/media/soc_camera/soc_mt9v022.c > b/drivers/staging/media/soc_camera/soc_mt9v022.c > index e7e0d3d29499..1739a618846d 100644 > --- a/drivers/staging/media/soc_camera/soc_mt9v022.c > +++ b/drivers/staging/media/soc_camera/soc_mt9v022.c > @@ -883,7 +883,7 @@ static int mt9v022_probe(struct i2c_client *client, > { > struct mt9v022 *mt9v022; > struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); > - struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); > + struct i2c_adapter *adapter = client->adapter; > struct mt9v022_platform_data *pdata; > int ret; > > -- > 2.19.1 > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 32/34] staging: media: soc_camera: mt9t031: simplify getting the adapter of a client
On Sat, Jun 08, 2019 at 12:56:11PM +0200, Wolfram Sang wrote: > We have a dedicated pointer for that, so use it. Much easier to read and > less computation involved. > > Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman > --- > > Please apply to your subsystem tree. > > drivers/staging/media/soc_camera/mt9t031.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/media/soc_camera/mt9t031.c > b/drivers/staging/media/soc_camera/mt9t031.c > index 615ae9df2c57..c14f23221544 100644 > --- a/drivers/staging/media/soc_camera/mt9t031.c > +++ b/drivers/staging/media/soc_camera/mt9t031.c > @@ -751,7 +751,7 @@ static int mt9t031_probe(struct i2c_client *client, > { > struct mt9t031 *mt9t031; > struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); > - struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); > + struct i2c_adapter *adapter = client->adapter; > int ret; > > if (!ssdd) { > -- > 2.19.1 > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V2 08/15] staging: unisys: visorhba: use sg helper to operate sgl
On Thu, Jun 13, 2019 at 11:52:14AM +0200, Greg Kroah-Hartman wrote: > On Thu, Jun 13, 2019 at 03:13:28PM +0800, Ming Lei wrote: > > The current way isn't safe for chained sgl, so use sg helper to > > operate sgl. > > I can not make any sense out of this changelog. > > What "isn't safe"? What is a "sgl"? sgl is 'scatterlist' in kernel, and several linear sgl can be chained together, so accessing the sgl in linear way may see a chained sg, which is like a link pointer, then may cause trouble for driver. > > Can this be applied "out of order"? Yes, there isn't any dependency among the 15 patches. Thanks, Ming ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V2 08/15] staging: unisys: visorhba: use sg helper to operate sgl
On Thu, Jun 13, 2019 at 06:04:11PM +0800, Ming Lei wrote: > On Thu, Jun 13, 2019 at 11:52:14AM +0200, Greg Kroah-Hartman wrote: > > On Thu, Jun 13, 2019 at 03:13:28PM +0800, Ming Lei wrote: > > > The current way isn't safe for chained sgl, so use sg helper to > > > operate sgl. > > > > I can not make any sense out of this changelog. > > > > What "isn't safe"? What is a "sgl"? > > sgl is 'scatterlist' in kernel, and several linear sgl can be chained > together, so accessing the sgl in linear way may see a chained sg, which > is like a link pointer, then may cause trouble for driver. What kind of "trouble"? Is this a bug fix that needs to be backported to stable kernels? How can this be triggered? > > Can this be applied "out of order"? > > Yes, there isn't any dependency among the 15 patches. Then perhaps you shouldn't send a numbered patch series with different patches sent to different maintainers, it just causes confusion :) thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V2 08/15] staging: unisys: visorhba: use sg helper to operate sgl
On Thu, Jun 13, 2019 at 06:04:11PM +0800, Ming Lei wrote: > On Thu, Jun 13, 2019 at 11:52:14AM +0200, Greg Kroah-Hartman wrote: > > On Thu, Jun 13, 2019 at 03:13:28PM +0800, Ming Lei wrote: > > > The current way isn't safe for chained sgl, so use sg helper to > > > operate sgl. > > > > I can not make any sense out of this changelog. > > > > What "isn't safe"? What is a "sgl"? > > sgl is 'scatterlist' in kernel, and several linear sgl can be chained > together, so accessing the sgl in linear way may see a chained sg, which > is like a link pointer, then may cause trouble for driver. > So from a user perspective it results in an Oops? It would be really cool if you had the copy of the Oops btw so people could grep the git history for it. (You need to resend with the improved commit message). regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: kpc2000: remove dead code in core.c
Fixes checkpatch warning: "Consider removing the code enclosed by this #if 0 and its #endif". Signed-off-by: Simon Sandström --- drivers/staging/kpc2000/kpc2000/core.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 6a5999e8ff4e..610ea549d240 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -223,15 +223,9 @@ static void wait_and_read_ssid(struct kp2000_device *pcard) dev_notice(&pcard->pdev->dev, "SSID didn't show up!\n"); -#if 0 - // Timed out waiting for the SSID to show up, just use the DDNA instead? - read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); - pcard->ssid = read_val; -#else // Timed out waiting for the SSID to show up, stick all zeros in the // value pcard->ssid = 0; -#endif } static int read_system_regs(struct kp2000_device *pcard) -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Hello,
Hello, I am Mr. Abdulahi Issa, from Burkina Faso in West African region. I work with the Bank of Africa here Which i am the audit manager . Can you safe Guard these amount( $13.5 Million USD) for me in your Country?? Further Details will be given to you if you show Interest. Regards Mr. Abdulahi Issa. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: most: deregister net and video config subsystems with configFS
This patch makes the modules net and video deregister its config subsystems when the modules are removed from the kernel. Signed-off-by: Christian Gromm --- drivers/staging/most/net/net.c | 1 + drivers/staging/most/video/video.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c index 3fc80ad..aababdf 100644 --- a/drivers/staging/most/net/net.c +++ b/drivers/staging/most/net/net.c @@ -524,6 +524,7 @@ static int __init most_net_init(void) static void __exit most_net_exit(void) { + most_deregister_configfs_subsys(&comp); most_deregister_component(&comp); } diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index 72622eb..19ae7c4 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -576,6 +576,7 @@ static void __exit comp_exit(void) } spin_unlock_irq(&list_lock); + most_deregister_configfs_subsys(&comp); most_deregister_component(&comp); BUG_ON(!list_empty(&video_devices)); } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V2 08/15] staging: unisys: visorhba: use sg helper to operate sgl
On Thu, 2019-06-13 at 12:16 +0200, Greg Kroah-Hartman wrote: > On Thu, Jun 13, 2019 at 06:04:11PM +0800, Ming Lei wrote: > > On Thu, Jun 13, 2019 at 11:52:14AM +0200, Greg Kroah-Hartman wrote: > > > On Thu, Jun 13, 2019 at 03:13:28PM +0800, Ming Lei wrote: > > > > The current way isn't safe for chained sgl, so use sg helper to > > > > operate sgl. > > > > > > I can not make any sense out of this changelog. > > > > > > What "isn't safe"? What is a "sgl"? > > > > sgl is 'scatterlist' in kernel, and several linear sgl can be > > chained together, so accessing the sgl in linear way may see a > > chained sg, which is like a link pointer, then may cause trouble > > for driver. > > What kind of "trouble"? Is this a bug fix that needs to be > backported to stable kernels? How can this be triggered? OK, stop. I haven't seen the commit log since the original hasn't appeared on the list yet, but the changelog needs to say something like this to prevent questions like the above, as I asked in the last review. Please make it something like this: --- Scsi MQ makes a large static allocation for the first scatter gather list chunk for the driver to use. This is a performance headache we'd like to fix by reducing the size of the allocation to a 2 element array. Doing this will break the current guarantee that any driver using SG_ALL doesn't need to use the scatterlist iterators and can get away with directly dereferencing the array. Thus we need to update all drivers to use the scatterlist iterators and remove direct indexing of the scatterlist array before reducing the initial scatterlist allocation size in SCSI. --- James ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[driver-core:debugfs_cleanup 129/129] drivers/gpu//drm/sti/sti_compositor.c:55:9: warning: 'return' with a value, in function returning void
tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git debugfs_cleanup head: 9831e93ace88fcb51c013ceca0b097133c8efb5f commit: 9831e93ace88fcb51c013ceca0b097133c8efb5f [129/129] drm: huge cleanup... config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 9831e93ace88fcb51c013ceca0b097133c8efb5f # save the attached .config to linux build tree GCC_VERSION=7.4.0 make.cross ARCH=arm If you fix the issue, kindly add following tag Reported-by: kbuild test robot All warnings (new ones prefixed by >>): drivers/gpu//drm/sti/sti_compositor.c: In function 'sti_compositor_debugfs_init': >> drivers/gpu//drm/sti/sti_compositor.c:55:9: warning: 'return' with a value, >> in function returning void return 0; ^ drivers/gpu//drm/sti/sti_compositor.c:42:6: note: declared here void sti_compositor_debugfs_init(struct sti_compositor *compo, ^~~ vim +/return +55 drivers/gpu//drm/sti/sti_compositor.c d219673d Benjamin Gaignard 2014-07-30 41 9831e93a Greg Kroah-Hartman 2019-06-13 42 void sti_compositor_debugfs_init(struct sti_compositor *compo, 83af0a48 Benjamin Gaignard 2016-06-21 43 struct drm_minor *minor) 83af0a48 Benjamin Gaignard 2016-06-21 44 { 38fdb8d9 Vincent Abriou 2016-09-15 45 unsigned int i; 83af0a48 Benjamin Gaignard 2016-06-21 46 38fdb8d9 Vincent Abriou 2016-09-15 47 for (i = 0; i < STI_MAX_VID; i++) 38fdb8d9 Vincent Abriou 2016-09-15 48 if (compo->vid[i]) 38fdb8d9 Vincent Abriou 2016-09-15 49 vid_debugfs_init(compo->vid[i], minor); 83af0a48 Benjamin Gaignard 2016-06-21 50 38fdb8d9 Vincent Abriou 2016-09-15 51 for (i = 0; i < STI_MAX_MIXER; i++) 38fdb8d9 Vincent Abriou 2016-09-15 52 if (compo->mixer[i]) 38fdb8d9 Vincent Abriou 2016-09-15 53 sti_mixer_debugfs_init(compo->mixer[i], minor); 83af0a48 Benjamin Gaignard 2016-06-21 54 83af0a48 Benjamin Gaignard 2016-06-21 @55 return 0; 83af0a48 Benjamin Gaignard 2016-06-21 56 } 83af0a48 Benjamin Gaignard 2016-06-21 57 :: The code at line 55 was first introduced by commit :: 83af0a483ac44594620ecae10a4d708b284972e1 drm: sti: use late_register and early_unregister callbacks :: TO: Benjamin Gaignard :: CC: Daniel Vetter --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] x86/hyperv: Disable preemption while setting reenlightenment vector
On Wed, 12 Jun 2019, Vitaly Kuznetsov wrote: > Dmitry Safonov writes: > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > > index 1608050e9df9..0bdd79ecbff8 100644 > > --- a/arch/x86/hyperv/hv_init.c > > +++ b/arch/x86/hyperv/hv_init.c > > @@ -91,7 +91,7 @@ EXPORT_SYMBOL_GPL(hv_max_vp_index); > > static int hv_cpu_init(unsigned int cpu) > > { > > u64 msr_vp_index; > > - struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()]; > > + struct hv_vp_assist_page **hvp = &hv_vp_assist_page[cpu]; > > void **input_arg; > > struct page *pg; > > > > @@ -103,7 +103,7 @@ static int hv_cpu_init(unsigned int cpu) > > > > hv_get_vp_index(msr_vp_index); > > > > - hv_vp_index[smp_processor_id()] = msr_vp_index; > > + hv_vp_index[cpu] = msr_vp_index; > > > > if (msr_vp_index > hv_max_vp_index) > > hv_max_vp_index = msr_vp_index; > > The above is unrelated cleanup (as cpu == smp_processor_id() for > CPUHP_AP_ONLINE_DYN callbacks), right? As I'm pretty sure these can'd be > preempted. They can be preempted, but they are guaranteed to run on the upcoming CPU, i.e. smp_processor_id() is allowed even in preemptible context as the task cannot migrate. Thanks, tglx ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
memory leak in binder_transaction
Hello, syzbot found the following crash on: HEAD commit:d1fdb6d8 Linux 5.2-rc4 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=15e5ce1ea0 kernel config: https://syzkaller.appspot.com/x/.config?x=cb38d33cd06d8d48 dashboard link: https://syzkaller.appspot.com/bug?extid=182ce46596c3f2e1eb24 compiler: gcc (GCC) 9.0.0 20181231 (experimental) syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1181703ea0 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14e14392a0 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+182ce46596c3f2e1e...@syzkaller.appspotmail.com -executor774" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=binder permissive=1 BUG: memory leak unreferenced object 0x888123934800 (size 32): comm "syz-executor774", pid 7083, jiffies 4294941834 (age 7.970s) hex dump (first 32 bytes): 00 48 93 23 81 88 ff ff 00 48 93 23 81 88 ff ff .H.#.H.# 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 backtrace: [<38ba7202>] kmemleak_alloc_recursive include/linux/kmemleak.h:43 [inline] [<38ba7202>] slab_post_alloc_hook mm/slab.h:439 [inline] [<38ba7202>] slab_alloc mm/slab.c:3326 [inline] [<38ba7202>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553 [<04e63839>] kmalloc include/linux/slab.h:547 [inline] [<04e63839>] kzalloc include/linux/slab.h:742 [inline] [<04e63839>] binder_transaction+0x28b/0x2eb0 drivers/android/binder.c:3072 [<50997ec4>] binder_thread_write+0x357/0x1430 drivers/android/binder.c:3794 [] binder_ioctl_write_read drivers/android/binder.c:4827 [inline] [ ] binder_ioctl+0x8bc/0xbb4 drivers/android/binder.c:5004 [<2eec2b63>] vfs_ioctl fs/ioctl.c:46 [inline] [<2eec2b63>] file_ioctl fs/ioctl.c:509 [inline] [<2eec2b63>] do_vfs_ioctl+0x62a/0x810 fs/ioctl.c:696 [<48cfc9e6>] ksys_ioctl+0x86/0xb0 fs/ioctl.c:713 [<30bf392d>] __do_sys_ioctl fs/ioctl.c:720 [inline] [<30bf392d>] __se_sys_ioctl fs/ioctl.c:718 [inline] [<30bf392d>] __x64_sys_ioctl+0x1e/0x30 fs/ioctl.c:718 [<7dec438c>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301 [ ] entry_SYSCALL_64_after_hwframe+0x44/0xa9 --- This bug is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkal...@googlegroups.com. syzbot will keep track of this bug report. See: https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this bug, for details see: https://goo.gl/tpsmEJ#testing-patches ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8723bs: Resolve checkpatch error "that open brace { should be on the previous line" in the rtl8723bs driver
Cleaned up the code from the following files to get rid of check patch error "that open brace { should be on the previous line" drivers/staging/rtl8723bs/os_dep/mlme_linux.c drivers/staging/rtl8723bs/os_dep/recv_linux.c drivers/staging/rtl8723bs/os_dep/rtw_proc.c drivers/staging/rtl8723bs/os_dep/sdio_intf.c drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c Signed-off-by: Shobhit Kukreti --- drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 14 ++--- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 76 --- drivers/staging/rtl8723bs/os_dep/rtw_proc.c | 6 +- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 15 ++--- drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 24 +++ 5 files changed, 47 insertions(+), 88 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index aa2499f..6799ed4 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -46,8 +46,7 @@ void rtw_os_indicate_connect(struct adapter *adapter) struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) - { + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { rtw_cfg80211_ibss_indicate_connect(adapter); } else @@ -77,8 +76,8 @@ void rtw_reset_securitypriv(struct adapter *adapter) spin_lock_bh(&adapter->security_key_mutex); - if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)/* 802.1x */ - { + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802.1x */ + /* Added by Albert 2009/02/18 */ /* We have to backup the PMK information for WiFi PMK Caching test item. */ /* */ @@ -106,8 +105,8 @@ void rtw_reset_securitypriv(struct adapter *adapter) adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; } - else /* reset values in securitypriv */ - { + else { /* reset values in securitypriv */ + /* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */ /* */ struct security_priv *psec_priv = &adapter->securitypriv; @@ -150,8 +149,7 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode =%d\n", authmode)); buff = NULL; - if (authmode == _WPA_IE_ID_) - { + if (authmode == _WPA_IE_ID_) { RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("rtw_report_sec_ie, authmode =%d\n", authmode)); buff = rtw_zmalloc(IW_CUSTOM_MAX); diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 3fe9c22..44a8920 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -12,8 +12,7 @@ void rtw_os_free_recvframe(union recv_frame *precvframe) { - if (precvframe->u.hdr.pkt) - { + if (precvframe->u.hdr.pkt) { dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */ precvframe->u.hdr.pkt = NULL; @@ -34,10 +33,8 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) precvframe = (union recv_frame*) precvpriv->precv_frame_buf; - for (i = 0; i < NR_RECVFRAME; i++) - { - if (precvframe->u.hdr.pkt) - { + for (i = 0; i < NR_RECVFRAME; i++) { + if (precvframe->u.hdr.pkt) { dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */ precvframe->u.hdr.pkt = NULL; } @@ -48,8 +45,7 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) /* free os related resource in struct recv_buf */ void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf) { - if (precvbuf->pskb) - { + if (precvbuf->pskb) { dev_kfree_skb_any(precvbuf->pskb); } } @@ -63,22 +59,18 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 pattrib = &prframe->u.hdr.attrib; sub_skb = rtw_skb_alloc(nSubframe_Length + 12); - if (sub_skb) - { + if (sub_skb) { skb_reserve(sub_skb, 12); skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length); } - else - { + else { sub_skb = rtw_skb_clone(prframe->u.hdr.pkt); - if (sub_skb) - { + if (sub_skb) { sub_skb->data = pdata + ETH_HLEN; sub_skb->len = nSubframe_Length; skb_set_ta
[PATCH V3 03/15] scsi: lpfc: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Reviewed by: Ewan D. Milne Signed-off-by: Ming Lei --- drivers/scsi/lpfc/lpfc_nvmet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index f3d9a5545164..3f803982bd1e 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -2887,8 +2887,7 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba, nvmewqe->drvrTimeout = (phba->fc_ratov * 3) + LPFC_DRVR_TIMEOUT; nvmewqe->context1 = ndlp; - for (i = 0; i < rsp->sg_cnt; i++) { - sgel = &rsp->sg[i]; + for_each_sg(rsp->sg, sgel, rsp->sg_cnt, i) { physaddr = sg_dma_address(sgel); cnt = sg_dma_len(sgel); sgl->addr_hi = putPaddrHigh(physaddr); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 02/15] scsi: advansys: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Reviewed-by: Ewan D. Milne Signed-off-by: Ming Lei --- drivers/scsi/advansys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index d37584403c33..b87de8d3d844 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -7714,7 +7714,7 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */ return ADV_SUCCESS; } - slp++; + slp = sg_next(slp); } sg_block->sg_cnt = NO_OF_SG_PER_BLOCK; prev_sg_block = sg_block; -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 04/15] scsi: mvumi: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Reviewed-by: Ewan D. Milne Signed-off-by: Ming Lei --- drivers/scsi/mvumi.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index a5410615edac..0022cd31500a 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -211,8 +211,7 @@ static int mvumi_make_sgl(struct mvumi_hba *mhba, struct scsi_cmnd *scmd, unsigned int sgnum = scsi_sg_count(scmd); dma_addr_t busaddr; - sg = scsi_sglist(scmd); - *sg_count = dma_map_sg(&mhba->pdev->dev, sg, sgnum, + *sg_count = dma_map_sg(&mhba->pdev->dev, scsi_sglist(scmd), sgnum, scmd->sc_data_direction); if (*sg_count > mhba->max_sge) { dev_err(&mhba->pdev->dev, @@ -222,12 +221,12 @@ static int mvumi_make_sgl(struct mvumi_hba *mhba, struct scsi_cmnd *scmd, scmd->sc_data_direction); return -1; } - for (i = 0; i < *sg_count; i++) { - busaddr = sg_dma_address(&sg[i]); + scsi_for_each_sg(scmd, sg, *sg_count, i) { + busaddr = sg_dma_address(sg); m_sg->baseaddr_l = cpu_to_le32(lower_32_bits(busaddr)); m_sg->baseaddr_h = cpu_to_le32(upper_32_bits(busaddr)); m_sg->flags = 0; - sgd_setsz(mhba, m_sg, cpu_to_le32(sg_dma_len(&sg[i]))); + sgd_setsz(mhba, m_sg, cpu_to_le32(sg_dma_len(sg))); if ((i + 1) == *sg_count) m_sg->flags |= 1U << mhba->eot_flag; -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 05/15] scsi: ipr: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Signed-off-by: Ming Lei --- drivers/scsi/ipr.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 6d053e220153..383603973937 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -3915,22 +3915,22 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist, u8 *buffer, u32 len) { int bsize_elem, i, result = 0; - struct scatterlist *scatterlist; + struct scatterlist *sg; void *kaddr; /* Determine the actual number of bytes per element */ bsize_elem = PAGE_SIZE * (1 << sglist->order); - scatterlist = sglist->scatterlist; + sg = sglist->scatterlist; - for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) { - struct page *page = sg_page(&scatterlist[i]); + for (i = 0; i < (len / bsize_elem); i++, sg = sg_next(sg), buffer += bsize_elem) { + struct page *page = sg_page(sg); kaddr = kmap(page); memcpy(kaddr, buffer, bsize_elem); kunmap(page); - scatterlist[i].length = bsize_elem; + sg->length = bsize_elem; if (result != 0) { ipr_trace; @@ -3939,13 +3939,13 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist, } if (len % bsize_elem) { - struct page *page = sg_page(&scatterlist[i]); + struct page *page = sg_page(sg); kaddr = kmap(page); memcpy(kaddr, buffer, len % bsize_elem); kunmap(page); - scatterlist[i].length = len % bsize_elem; + sg->length = len % bsize_elem; } sglist->buffer_len = len; @@ -3966,6 +3966,7 @@ static void ipr_build_ucode_ioadl64(struct ipr_cmnd *ipr_cmd, struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64; struct scatterlist *scatterlist = sglist->scatterlist; + struct scatterlist *sg; int i; ipr_cmd->dma_use_sg = sglist->num_dma_sg; @@ -3974,10 +3975,10 @@ static void ipr_build_ucode_ioadl64(struct ipr_cmnd *ipr_cmd, ioarcb->ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl64_desc) * ipr_cmd->dma_use_sg); - for (i = 0; i < ipr_cmd->dma_use_sg; i++) { + for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) { ioadl64[i].flags = cpu_to_be32(IPR_IOADL_FLAGS_WRITE); - ioadl64[i].data_len = cpu_to_be32(sg_dma_len(&scatterlist[i])); - ioadl64[i].address = cpu_to_be64(sg_dma_address(&scatterlist[i])); + ioadl64[i].data_len = cpu_to_be32(sg_dma_len(sg)); + ioadl64[i].address = cpu_to_be64(sg_dma_address(sg)); } ioadl64[i-1].flags |= cpu_to_be32(IPR_IOADL_FLAGS_LAST); @@ -3997,6 +3998,7 @@ static void ipr_build_ucode_ioadl(struct ipr_cmnd *ipr_cmd, struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl; struct scatterlist *scatterlist = sglist->scatterlist; + struct scatterlist *sg; int i; ipr_cmd->dma_use_sg = sglist->num_dma_sg; @@ -4006,11 +4008,11 @@ static void ipr_build_ucode_ioadl(struct ipr_cmnd *ipr_cmd, ioarcb->ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); - for (i = 0; i < ipr_cmd->dma_use_sg; i++) { + for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) { ioadl[i].flags_and_data_len = - cpu_to_be32(IPR_IOADL_FLAGS_WRITE | sg_dma_len(&scatterlist[i])); + cpu_to_be32(IPR_IOADL_FLAGS_WRITE | sg_dma_len(sg)); ioadl[i].address = - cpu_to_be32(sg_dma_address(&scatterlist[i])); + cpu_to_be32(sg_dma_address(sg)); } ioadl[i-1].flags_and_data_len |= -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 00/15] use sg helper to operate scatterlist
Hi, Scsi MQ makes a large static allocation for the first scatter gather list chunk for the driver to use. This is a performance headache we'd like to fix by reducing the size of the allocation to a 2 element array. Doing this will break the current guarantee that any driver using SG_ALL doesn't need to use the scatterlist iterators and can get away with directly dereferencing the array. Thus we need to update all drivers to use the scatterlist iterators and remove direct indexing of the scatterlist array before reducing the initial scatterlist allocation size in SCSI. So convert drivers to use scatterlist helper. There are two types of scsi SGL uses: 1) operate on scsi_sglist(scmd) directly, then one local variable of 'struct scatterlist *' is involved, so the following coccinelle semantic patch is developed for finding this type of direct sgl uses: https://marc.info/?l=linux-scsi&m=156031374809852&w=2 2) scsi_sglist(scmd) is stored to cmd->SCp.buffer and the SGL is used via cmd->SCp.buffer. Simple 'grep SCp.buffer' is used for finding SGL direct uses, fortunately only the following drivers uses SCp.buffer to store SGL: NCR5380, aha152x, arm/, imm, pcmcia, ppa and wd33c93 And arm/ is already ready to handle chained SGL. The 1st 9 patches are for handling type #1, and the other 6 patches for handling type #2. V3: - update commit log and cover letter, most of words are from James Bottomley V2: - use coccinelle semantic patch for finding direct sgl uses from scsi command(9 drivers found) - run 'git grep -E "SCp.buffer"' to find direct sgl uses from SCp.buffer(6 drivers are found) Finn Thain (1): NCR5380: Support chained sg lists Ming Lei (14): scsi: vmw_pscsi: use sg helper to operate scatterlist scsi: advansys: use sg helper to operate scatterlist scsi: lpfc: use sg helper to operate scatterlist scsi: mvumi: use sg helper to operate scatterlist scsi: ipr: use sg helper to operate scatterlist scsi: pmcraid: use sg helper to operate scatterlist usb: image: microtek: use sg helper to operate scatterlist staging: unisys: visorhba: use sg helper to operate scatterlist s390: zfcp_fc: use sg helper to operate scatterlist scsi: aha152x: use sg helper to operate scatterlist scsi: imm: use sg helper to operate scatterlist scsi: pcmcia: nsp_cs: use sg helper to operate scatterlist scsi: ppa: use sg helper to operate scatterlist scsi: wd33c93: use sg helper to operate scatterlist drivers/s390/scsi/zfcp_fc.c | 4 +- drivers/scsi/NCR5380.c| 41 --- drivers/scsi/advansys.c | 2 +- drivers/scsi/aha152x.c| 29 - drivers/scsi/imm.c| 2 +- drivers/scsi/ipr.c| 28 +++-- drivers/scsi/lpfc/lpfc_nvmet.c| 3 +- drivers/scsi/mvumi.c | 9 ++-- drivers/scsi/pcmcia/nsp_cs.c | 4 +- drivers/scsi/pmcraid.c| 12 +++--- drivers/scsi/ppa.c| 2 +- drivers/scsi/vmw_pvscsi.c | 2 +- drivers/scsi/wd33c93.c| 2 +- .../staging/unisys/visorhba/visorhba_main.c | 9 ++-- drivers/usb/image/microtek.c | 20 - drivers/usb/image/microtek.h | 2 +- 16 files changed, 85 insertions(+), 86 deletions(-) -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 01/15] scsi: vmw_pscsi: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Reviewed-by: Ewan D. Milne Signed-off-by: Ming Lei --- drivers/scsi/vmw_pvscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index ecee4b3ff073..d71abd416eb4 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -335,7 +335,7 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx, BUG_ON(count > PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT); sge = &ctx->sgl->sge[0]; - for (i = 0; i < count; i++, sg++) { + for (i = 0; i < count; i++, sg = sg_next(sg)) { sge[i].addr = sg_dma_address(sg); sge[i].length = sg_dma_len(sg); sge[i].flags = 0; -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Patch v2 1/3] staging: rtl8723bs: hal: sdio_halinit: fix comparison to true/false is error prone
fix below issues reported by checkpatch CHECK: Using comparison to false is error prone CHECK: Using comparison to true is error prone Signed-off-by: Hariprasad Kelam changes in v2: send proper patch without corruption --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 3c65a9c..4db3211 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -26,7 +26,7 @@ static u8 CardEnable(struct adapter *padapter) rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); - if (bMacPwrCtrlOn == false) { + if (!bMacPwrCtrlOn) { /* RSV_CTRL 0x1C[7:0] = 0x00 */ /* unlock ISO/CLK/Power control register */ rtw_write8(padapter, REG_RSV_CTRL, 0x0); @@ -127,7 +127,7 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter) /* only cmd52 can be used before power on(card enable) */ ret = CardEnable(padapter); - if (ret == false) { + if (!ret) { RT_TRACE( _module_hci_hal_init_c_, _drv_emerg_, @@ -838,7 +838,7 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) /* SIC_Init(padapter); */ - if (pwrctrlpriv->reg_rfoff == true) + if (pwrctrlpriv->reg_rfoff) pwrctrlpriv->rf_pwrstate = rf_off; /* 2010/08/09 MH We need to check if we need to turnon or off RF after detecting */ @@ -1081,7 +1081,7 @@ static void CardDisableRTL8723BSdio(struct adapter *padapter) ret = false; rtw_hal_set_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); ret = HalPwrSeqCmdParsing(padapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, rtl8723B_card_disable_flow); - if (ret == false) { + if (!ret) { DBG_8192C(KERN_ERR "%s: run CARD DISABLE flow fail!\n", __func__); } } @@ -1091,9 +1091,9 @@ static u32 rtl8723bs_hal_deinit(struct adapter *padapter) struct dvobj_priv *psdpriv = padapter->dvobj; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; - if (padapter->hw_init_completed == true) { - if (adapter_to_pwrctl(padapter)->bips_processing == true) { - if (padapter->netif_up == true) { + if (padapter->hw_init_completed) { + if (adapter_to_pwrctl(padapter)->bips_processing) { + if (padapter->netif_up) { int cnt = 0; u8 val8 = 0; @@ -1387,7 +1387,7 @@ static s32 _ReadAdapterInfo8723BS(struct adapter *padapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+_ReadAdapterInfo8723BS\n")); /* before access eFuse, make sure card enable has been called */ - if (padapter->hw_init_completed == false) + if (!padapter->hw_init_completed) _InitPowerOn_8723BS(padapter); @@ -1404,7 +1404,7 @@ static s32 _ReadAdapterInfo8723BS(struct adapter *padapter) _ReadPROMContent(padapter); _InitOtherVariable(padapter); - if (padapter->hw_init_completed == false) { + if (!padapter->hw_init_completed) { rtw_write8(padapter, 0x67, 0x00); /* for BT, Switch Ant control to BT */ CardDisableRTL8723BSdio(padapter);/* for the power consumption issue, wifi ko module is loaded during booting, but wifi GUI is off */ } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 10/15] scsi: aha152x: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Signed-off-by: Ming Lei --- drivers/scsi/aha152x.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 97872838b983..bc9d12aa7880 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -2033,7 +2033,7 @@ static void datai_run(struct Scsi_Host *shpnt) CURRENT_SC->SCp.buffers_residual > 0) { /* advance to next buffer */ CURRENT_SC->SCp.buffers_residual--; - CURRENT_SC->SCp.buffer++; + CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer); CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; } @@ -2139,7 +2139,7 @@ static void datao_run(struct Scsi_Host *shpnt) if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { /* advance to next buffer */ CURRENT_SC->SCp.buffers_residual--; - CURRENT_SC->SCp.buffer++; + CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer); CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; } @@ -2160,20 +2160,29 @@ static void datao_end(struct Scsi_Host *shpnt) if(TESTLO(DMASTAT, DFIFOEMP)) { int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - GETSTCNT(); + struct scatterlist *sg = scsi_sglist(CURRENT_SC); + int left, i = 0; CMD_INC_RESID(CURRENT_SC, data_count); data_count -= CURRENT_SC->SCp.ptr - SG_ADDRESS(CURRENT_SC->SCp.buffer); - while(data_count>0) { - CURRENT_SC->SCp.buffer--; - CURRENT_SC->SCp.buffers_residual++; - data_count -= CURRENT_SC->SCp.buffer->length; + + left = CURRENT_SC->transfersize - data_count; + for (i = 0; left > 0 && !sg_is_last(sg); i++, sg = sg_next(sg)) { + if (left < sg->length) + break; + left -= sg->length; + } + + if (data_count > 0) { + CURRENT_SC->SCp.buffers_residual += i; + CURRENT_SC->SCp.buffer = sg; + + CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) + left; + CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length - + left; } - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - - data_count; - CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + - data_count; } SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 08/15] staging: unisys: visorhba: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Cc: de...@driverdev.osuosl.org Cc: Greg Kroah-Hartman Signed-off-by: Ming Lei --- drivers/staging/unisys/visorhba/visorhba_main.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 2dad36a05518..dd979ee4dcf1 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -871,12 +871,11 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, return; } - sg = scsi_sglist(scsicmd); - for (i = 0; i < scsi_sg_count(scsicmd); i++) { - this_page_orig = kmap_atomic(sg_page(sg + i)); + scsi_for_each_sg(scsicmd, sg, scsi_sg_count(scsicmd), i) { + this_page_orig = kmap_atomic(sg_page(sg)); this_page = (void *)((unsigned long)this_page_orig | -sg[i].offset); - memcpy(this_page, buf + bufind, sg[i].length); +sg->offset); + memcpy(this_page, buf + bufind, sg->length); kunmap_atomic(this_page_orig); } kfree(buf); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 07/15] usb: image: microtek: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Cc: Oliver Neukum Cc: Greg Kroah-Hartman Cc: linux-...@vger.kernel.org Signed-off-by: Ming Lei --- drivers/usb/image/microtek.c | 20 drivers/usb/image/microtek.h | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 607be1f4fe27..0a57c2cc8e5a 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -488,7 +488,6 @@ static void mts_command_done( struct urb *transfer ) static void mts_do_sg (struct urb* transfer) { - struct scatterlist * sg; int status = transfer->status; MTS_INT_INIT(); @@ -500,13 +499,12 @@ static void mts_do_sg (struct urb* transfer) mts_transfer_cleanup(transfer); } - sg = scsi_sglist(context->srb); - context->fragment++; + context->curr_sg = sg_next(context->curr_sg); mts_int_submit_urb(transfer, context->data_pipe, - sg_virt(&sg[context->fragment]), - sg[context->fragment].length, - context->fragment + 1 == scsi_sg_count(context->srb) ? + sg_virt(context->curr_sg), + context->curr_sg->length, + sg_is_last(context->curr_sg) ? mts_data_done : mts_do_sg); } @@ -526,22 +524,20 @@ static void mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc) { int pipe; - struct scatterlist * sg; - + MTS_DEBUG_GOT_HERE(); desc->context.instance = desc; desc->context.srb = srb; - desc->context.fragment = 0; if (!scsi_bufflen(srb)) { desc->context.data = NULL; desc->context.data_length = 0; return; } else { - sg = scsi_sglist(srb); - desc->context.data = sg_virt(&sg[0]); - desc->context.data_length = sg[0].length; + desc->context.curr_sg = scsi_sglist(srb); + desc->context.data = sg_virt(desc->context.curr_sg); + desc->context.data_length = desc->context.curr_sg->length; } diff --git a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h index 66685e59241a..7bd5f4639c4a 100644 --- a/drivers/usb/image/microtek.h +++ b/drivers/usb/image/microtek.h @@ -21,7 +21,7 @@ struct mts_transfer_context void *data; unsigned data_length; int data_pipe; - int fragment; + struct scatterlist *curr_sg; u8 *scsi_status; /* status returned from ep_response after command completion */ }; -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 12/15] scsi: pcmcia: nsp_cs: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Signed-off-by: Ming Lei --- drivers/scsi/pcmcia/nsp_cs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index a81748e6e8fb..97416e1dcc5b 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -789,7 +789,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt) SCpnt->SCp.buffers_residual != 0 ) { //nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next timeout=%d", time_out); SCpnt->SCp.buffers_residual--; - SCpnt->SCp.buffer++; + SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); SCpnt->SCp.ptr = BUFFER_ADDR; SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; time_out = 1000; @@ -887,7 +887,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt) SCpnt->SCp.buffers_residual != 0 ) { //nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next"); SCpnt->SCp.buffers_residual--; - SCpnt->SCp.buffer++; + SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); SCpnt->SCp.ptr = BUFFER_ADDR; SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; time_out = 1000; -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 06/15] scsi: pmcraid: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Signed-off-by: Ming Lei --- drivers/scsi/pmcraid.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index e338d7a4f571..922c6e4b7eb3 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3270,7 +3270,7 @@ static int pmcraid_copy_sglist( int direction ) { - struct scatterlist *scatterlist; + struct scatterlist *sg; void *kaddr; int bsize_elem; int i; @@ -3281,8 +3281,8 @@ static int pmcraid_copy_sglist( scatterlist = sglist->scatterlist; - for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) { - struct page *page = sg_page(&scatterlist[i]); + for (i = 0; i < (len / bsize_elem); i++, sg = sg_next(sg), buffer += bsize_elem) { + struct page *page = sg_page(sg); kaddr = kmap(page); if (direction == DMA_TO_DEVICE) @@ -3297,11 +3297,11 @@ static int pmcraid_copy_sglist( return -EFAULT; } - scatterlist[i].length = bsize_elem; + sg->length = bsize_elem; } if (len % bsize_elem) { - struct page *page = sg_page(&scatterlist[i]); + struct page *page = sg_page(sg); kaddr = kmap(page); @@ -3312,7 +3312,7 @@ static int pmcraid_copy_sglist( kunmap(page); - scatterlist[i].length = len % bsize_elem; + sg->length = len % bsize_elem; } if (rc) { -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 13/15] scsi: ppa: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Signed-off-by: Ming Lei --- drivers/scsi/ppa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index 35213082e933..a406cc825426 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c @@ -590,7 +590,7 @@ static int ppa_completion(struct scsi_cmnd *cmd) if (cmd->SCp.buffer && !cmd->SCp.this_residual) { /* if scatter/gather, advance to the next segment */ if (cmd->SCp.buffers_residual--) { - cmd->SCp.buffer++; + cmd->SCp.buffer = sg_next(cmd->SCp.buffer); cmd->SCp.this_residual = cmd->SCp.buffer->length; cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 09/15] s390: zfcp_fc: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Cc: Steffen Maier Cc: Benjamin Block Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: linux-s...@vger.kernel.org Signed-off-by: Ming Lei --- drivers/s390/scsi/zfcp_fc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index 33eddb02ee30..b018b61bd168 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c @@ -620,7 +620,7 @@ static void zfcp_fc_sg_free_table(struct scatterlist *sg, int count) { int i; - for (i = 0; i < count; i++, sg++) + for (i = 0; i < count; i++, sg = sg_next(sg)) if (sg) free_page((unsigned long) sg_virt(sg)); else @@ -641,7 +641,7 @@ static int zfcp_fc_sg_setup_table(struct scatterlist *sg, int count) int i; sg_init_table(sg, count); - for (i = 0; i < count; i++, sg++) { + for (i = 0; i < count; i++, sg = sg_next(sg)) { addr = (void *) get_zeroed_page(GFP_KERNEL); if (!addr) { zfcp_fc_sg_free_table(sg, i); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 15/15] NCR5380: Support chained sg lists
From: Finn Thain My understanding is that support for chained scatterlists is to become mandatory for LLDs. Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Cc: Michael Schmitz Reviewed-by: Michael Schmitz Signed-off-by: Finn Thain --- drivers/scsi/NCR5380.c | 41 ++--- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index fe0535affc14..4ef44fafe6ca 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -149,12 +149,10 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd) if (scsi_bufflen(cmd)) { cmd->SCp.buffer = scsi_sglist(cmd); - cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); cmd->SCp.this_residual = cmd->SCp.buffer->length; } else { cmd->SCp.buffer = NULL; - cmd->SCp.buffers_residual = 0; cmd->SCp.ptr = NULL; cmd->SCp.this_residual = 0; } @@ -163,6 +161,17 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd) cmd->SCp.Message = 0; } +static inline void advance_sg_buffer(struct scsi_cmnd *cmd) +{ + struct scatterlist *s = cmd->SCp.buffer; + + if (!cmd->SCp.this_residual && s && !sg_is_last(s)) { + cmd->SCp.buffer = sg_next(s); + cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); + cmd->SCp.this_residual = cmd->SCp.buffer->length; + } +} + /** * NCR5380_poll_politely2 - wait for two chip register values * @hostdata: host private data @@ -1672,12 +1681,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) sun3_dma_setup_done != cmd) { int count; - if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { - ++cmd->SCp.buffer; - --cmd->SCp.buffers_residual; - cmd->SCp.this_residual = cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); - } + advance_sg_buffer(cmd); count = sun3scsi_dma_xfer_len(hostdata, cmd); @@ -1727,15 +1731,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) * scatter-gather list, move onto the next one. */ - if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { - ++cmd->SCp.buffer; - --cmd->SCp.buffers_residual; - cmd->SCp.this_residual = cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); - dsprintk(NDEBUG_INFORMATION, instance, "%d bytes and %d buffers left\n", -cmd->SCp.this_residual, -cmd->SCp.buffers_residual); - } + advance_sg_buffer(cmd); + dsprintk(NDEBUG_INFORMATION, instance, + "this residual %d, sg ents %d\n", + cmd->SCp.this_residual, + sg_nents(cmd->SCp.buffer)); /* * The preferred transfer method is going to be @@ -2136,12 +2136,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) if (sun3_dma_setup_done != tmp) { int count; - if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) { - ++tmp->SCp.buffer; - --tmp->SCp.buffers_residual; - tmp->SCp.this_residual = tmp->SCp.buffer->length; - tmp->SCp.ptr = sg_virt(tmp->SCp.buffer); - } + advance_sg_buffer(tmp); count = sun3scsi_dma_xfer_len(hostdata, tmp); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 11/15] scsi: imm: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Signed-off-by: Ming Lei --- drivers/scsi/imm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c index 64ae418d29f3..56d29f157749 100644 --- a/drivers/scsi/imm.c +++ b/drivers/scsi/imm.c @@ -686,7 +686,7 @@ static int imm_completion(struct scsi_cmnd *cmd) if (cmd->SCp.buffer && !cmd->SCp.this_residual) { /* if scatter/gather, advance to the next segment */ if (cmd->SCp.buffers_residual--) { - cmd->SCp.buffer++; + cmd->SCp.buffer = sg_next(cmd->SCp.buffer); cmd->SCp.this_residual = cmd->SCp.buffer->length; cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH V3 14/15] scsi: wd33c93: use sg helper to operate scatterlist
Use the scatterlist iterators and remove direct indexing of the scatterlist array. This way allows us to pre-allocate one small scatterlist, which can be chained with one runtime allocated scatterlist if the pre-allocated one isn't enough for the whole request. Signed-off-by: Ming Lei --- drivers/scsi/wd33c93.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index 74be04f2357c..ae5935c0a149 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c @@ -744,7 +744,7 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, * source or destination for THIS transfer. */ if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { - ++cmd->SCp.buffer; + cmd->SCp.buffer = sg_next(cmd->SCp.buffer); --cmd->SCp.buffers_residual; cmd->SCp.this_residual = cmd->SCp.buffer->length; cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Patch v2 2/3] staging: rtl8723bs: hal: sdio_halinit: fix spaces preferred around that unary operator
This patch fixes below issues reported by checkpatch CHECK: spaces preferred around that '+' (ctx:VxV) CHECK: spaces preferred around that '<<' (ctx:VxV) CHECK: spaces preferred around that '|' (ctx:VxV) Signed-off-by: Hariprasad Kelam -- changes in v2: Send proper patch without corruption --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 90 ++-- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 4db3211..5c7cff0 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -112,17 +112,17 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter) /* all of these MUST be configured before power on */ #ifdef CONFIG_EXT_CLK /* Use external crystal(XTAL) */ - value8 = rtw_read8(padapter, REG_PAD_CTRL1_8723B+2); + value8 = rtw_read8(padapter, REG_PAD_CTRL1_8723B + 2); value8 |= BIT(7); - rtw_write8(padapter, REG_PAD_CTRL1_8723B+2, value8); + rtw_write8(padapter, REG_PAD_CTRL1_8723B + 2, value8); /* CLK_REQ High active or Low Active */ /* Request GPIO polarity: */ /* 0: low active */ /* 1: high active */ - value8 = rtw_read8(padapter, REG_MULTI_FUNC_CTRL+1); + value8 = rtw_read8(padapter, REG_MULTI_FUNC_CTRL + 1); value8 |= BIT(5); - rtw_write8(padapter, REG_MULTI_FUNC_CTRL+1, value8); + rtw_write8(padapter, REG_MULTI_FUNC_CTRL + 1, value8); #endif /* CONFIG_EXT_CLK */ /* only cmd52 can be used before power on(card enable) */ @@ -137,12 +137,12 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter) } /* Radio-Off Pin Trigger */ - value8 = rtw_read8(padapter, REG_GPIO_INTM+1); + value8 = rtw_read8(padapter, REG_GPIO_INTM + 1); value8 |= BIT(1); /* Enable falling edge triggering interrupt */ - rtw_write8(padapter, REG_GPIO_INTM+1, value8); - value8 = rtw_read8(padapter, REG_GPIO_IO_SEL_2+1); + rtw_write8(padapter, REG_GPIO_INTM + 1, value8); + value8 = rtw_read8(padapter, REG_GPIO_IO_SEL_2 + 1); value8 |= BIT(1); - rtw_write8(padapter, REG_GPIO_IO_SEL_2+1, value8); + rtw_write8(padapter, REG_GPIO_IO_SEL_2 + 1, value8); /* Enable power down and GPIO interrupt */ value16 = rtw_read16(padapter, REG_APS_FSMCO); @@ -203,13 +203,13 @@ static void _init_available_page_threshold(struct adapter *padapter, u8 numHQ, u u16 HQ_threshold, NQ_threshold, LQ_threshold; HQ_threshold = (numPubQ + numHQ + 1) >> 1; - HQ_threshold |= (HQ_threshold<<8); + HQ_threshold |= (HQ_threshold << 8); NQ_threshold = (numPubQ + numNQ + 1) >> 1; - NQ_threshold |= (NQ_threshold<<8); + NQ_threshold |= (NQ_threshold << 8); LQ_threshold = (numPubQ + numLQ + 1) >> 1; - LQ_threshold |= (LQ_threshold<<8); + LQ_threshold |= (LQ_threshold << 8); rtw_write16(padapter, 0x218, HQ_threshold); rtw_write16(padapter, 0x21A, NQ_threshold); @@ -271,7 +271,7 @@ static void _InitTxBufferBoundary(struct adapter *padapter) rtw_write8(padapter, REG_TXPKTBUF_MGQ_BDNY_8723B, txpktbuf_bndy); rtw_write8(padapter, REG_TXPKTBUF_WMAC_LBK_BF_HD_8723B, txpktbuf_bndy); rtw_write8(padapter, REG_TRXFF_BNDY, txpktbuf_bndy); - rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + rtw_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); } static void _InitNormalChipRegPriority( @@ -569,7 +569,7 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) valueDMAPageCount = 0x06; } - rtw_write8(padapter, REG_RXDMA_AGG_PG_TH+1, valueDMATimeout); + rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); } @@ -588,8 +588,8 @@ static void sdio_AggSettingRxUpdate(struct adapter *padapter) rtw_write8(padapter, REG_TRXDMA_CTRL, valueDMA); valueRxAggCtrl |= RXDMA_AGG_MODE_EN; - valueRxAggCtrl |= ((aggBurstNum<<2) & 0x0C); - valueRxAggCtrl |= ((aggBurstSize<<4) & 0x30); + valueRxAggCtrl |= ((aggBurstNum << 2) & 0x0C); + valueRxAggCtrl |= ((aggBurstSize << 4) & 0x30); rtw_write8(padapter, REG_RXDMA_MODE_CTRL_8723B, valueRxAggCtrl);/* RxAggLowThresh = 4*1K */ } @@ -754,11 +754,11 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_orig); /* ser rpwm */ - val8 = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1); + val8 = rtw_read8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1); val8 &= 0x80; val8 += 0x80; val8 |= BIT(6); - rtw_write8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1, val8); + rt
[Patch v2 3/3] staging: rtl8723bs: hal: sdio_halinit: fix Comparison to NULL
This patch fixes below issue reported by checkpatch CHECK: Comparison to NULL could be written "psta" CHECK: Comparison to NULL could be written "psta" Signed-off-by: Hariprasad Kelam - changes in v2: Send proper patch with out corruption --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 5c7cff0..6f10349 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -1558,7 +1558,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) DBG_871X_LEVEL(_drv_always_, "WOWLAN_DISABLE\n"); psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv)); - if (psta != NULL) + if (psta) rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_DISCONNECT, psta->mac_id); else DBG_871X("psta is null\n"); @@ -1673,7 +1673,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) (pwrctl->wowlan_wake_reason != Rx_DeAuth) ) { rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); - if (psta != NULL) + if (psta) rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id); } #ifdef CONFIG_PNO_SUPPORT -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V3 10/15] scsi: aha152x: use sg helper to operate scatterlist
Hi Ming, On Fri, 14 Jun 2019, Ming Lei wrote: > Use the scatterlist iterators and remove direct indexing of the > scatterlist array. > > This way allows us to pre-allocate one small scatterlist, which can be > chained with one runtime allocated scatterlist if the pre-allocated one > isn't enough for the whole request. > > Signed-off-by: Ming Lei > --- > drivers/scsi/aha152x.c | 29 +++-- > 1 file changed, 19 insertions(+), 10 deletions(-) > > diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c > index 97872838b983..bc9d12aa7880 100644 > --- a/drivers/scsi/aha152x.c > +++ b/drivers/scsi/aha152x.c > @@ -2033,7 +2033,7 @@ static void datai_run(struct Scsi_Host *shpnt) > CURRENT_SC->SCp.buffers_residual > 0) { > /* advance to next buffer */ > CURRENT_SC->SCp.buffers_residual--; > - CURRENT_SC->SCp.buffer++; > + CURRENT_SC->SCp.buffer = > sg_next(CURRENT_SC->SCp.buffer); > CURRENT_SC->SCp.ptr = > SG_ADDRESS(CURRENT_SC->SCp.buffer); > CURRENT_SC->SCp.this_residual = > CURRENT_SC->SCp.buffer->length; > } > @@ -2139,7 +2139,7 @@ static void datao_run(struct Scsi_Host *shpnt) > if(CURRENT_SC->SCp.this_residual==0 && > CURRENT_SC->SCp.buffers_residual>0) { > /* advance to next buffer */ > CURRENT_SC->SCp.buffers_residual--; > - CURRENT_SC->SCp.buffer++; > + CURRENT_SC->SCp.buffer = > sg_next(CURRENT_SC->SCp.buffer); > CURRENT_SC->SCp.ptr = > SG_ADDRESS(CURRENT_SC->SCp.buffer); > CURRENT_SC->SCp.this_residual = > CURRENT_SC->SCp.buffer->length; > } > @@ -2160,20 +2160,29 @@ static void datao_end(struct Scsi_Host *shpnt) > if(TESTLO(DMASTAT, DFIFOEMP)) { > int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - > GETSTCNT(); data_count appears to be the number of bytes remaining in the FIFO. (I have to infer that much from the surrounding code. I don't have documentation for this controller.) Some comments would be nice. > + struct scatterlist *sg = scsi_sglist(CURRENT_SC); > + int left, i = 0; > > CMD_INC_RESID(CURRENT_SC, data_count); > Apparently the aim is to increase the residual by the number of bytes that will never leave the FIFO. Above we can see that increase performed by scsi_set_resid() and now the same has to be done to the SCp struct. > data_count -= CURRENT_SC->SCp.ptr - > SG_ADDRESS(CURRENT_SC->SCp.buffer); Here, data_count effectively has SCp.this_residual subtracted from it. > - while(data_count>0) { > - CURRENT_SC->SCp.buffer--; > - CURRENT_SC->SCp.buffers_residual++; > - data_count -= CURRENT_SC->SCp.buffer->length; > - } So far, so good. > - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - > - data_count; > - CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + > - data_count; This is like saying ptr = buffer + residual, which is bogus. This must be an old bug, but we never hit it because the FIFO is always empty when we get a DISCONNECT message. Probably because every SG segment has a length that is a multiple of 128 bytes. (Juergen?) > + > + left = CURRENT_SC->transfersize - data_count; Are you sure about that? Perhaps you meant to write, left = scsi_bufflen(CURRENT_SC) - scsi_get_resid(CURRENT_SC); Is there a better name for this variable? Maybe 'sent' or 'bytes_sent'? > + for (i = 0; left > 0 && !sg_is_last(sg); i++, sg = sg_next(sg)) > { > + if (left < sg->length) > + break; > + left -= sg->length; > + } > + > + if (data_count > 0) { > + CURRENT_SC->SCp.buffers_residual += i; Shouldn't that be, CURRENT_SC->SCp.buffers_residual = i; > + CURRENT_SC->SCp.buffer = sg; > + > + CURRENT_SC->SCp.ptr = > SG_ADDRESS(CURRENT_SC->SCp.buffer) + left; > + CURRENT_SC->SCp.this_residual = > CURRENT_SC->SCp.buffer->length - > + left; > + } > } > > SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); > BTW, datao_run() seems to guarantee that the FIFO will never contain more than min(128, SCp.this_residual) so I suspect that this code can be simplified. That's just BTW. I wouldn't attempt to optimize this branch as it w
Re: [PATCH V3 07/15] usb: image: microtek: use sg helper to operate scatterlist
On Fri, 14 Jun 2019, Ming Lei wrote: > Use the scatterlist iterators and remove direct indexing of the > scatterlist array. > > This way allows us to pre-allocate one small scatterlist, which can be > chained with one runtime allocated scatterlist if the pre-allocated one > isn't enough for the whole request. > > Cc: Oliver Neukum > Cc: Greg Kroah-Hartman > Cc: linux-...@vger.kernel.org > Signed-off-by: Ming Lei > --- > drivers/usb/image/microtek.c | 20 > drivers/usb/image/microtek.h | 2 +- > 2 files changed, 9 insertions(+), 13 deletions(-) > > diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c > index 607be1f4fe27..0a57c2cc8e5a 100644 > --- a/drivers/usb/image/microtek.c > +++ b/drivers/usb/image/microtek.c > @@ -488,7 +488,6 @@ static void mts_command_done( struct urb *transfer ) > > static void mts_do_sg (struct urb* transfer) > { > - struct scatterlist * sg; > int status = transfer->status; > MTS_INT_INIT(); > > @@ -500,13 +499,12 @@ static void mts_do_sg (struct urb* transfer) > mts_transfer_cleanup(transfer); > } > > - sg = scsi_sglist(context->srb); > - context->fragment++; > + context->curr_sg = sg_next(context->curr_sg); > mts_int_submit_urb(transfer, > context->data_pipe, > -sg_virt(&sg[context->fragment]), > -sg[context->fragment].length, > -context->fragment + 1 == scsi_sg_count(context->srb) > ? > +sg_virt(context->curr_sg), > +context->curr_sg->length, > +sg_is_last(context->curr_sg) ? > mts_data_done : mts_do_sg); > } > > @@ -526,22 +524,20 @@ static void > mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc) > { > int pipe; > - struct scatterlist * sg; > - > + > MTS_DEBUG_GOT_HERE(); > > desc->context.instance = desc; > desc->context.srb = srb; > - desc->context.fragment = 0; > > if (!scsi_bufflen(srb)) { > desc->context.data = NULL; > desc->context.data_length = 0; > return; > } else { > - sg = scsi_sglist(srb); > - desc->context.data = sg_virt(&sg[0]); > - desc->context.data_length = sg[0].length; > + desc->context.curr_sg = scsi_sglist(srb); > + desc->context.data = sg_virt(desc->context.curr_sg); > + desc->context.data_length = desc->context.curr_sg->length; > } > Would it not be better to initialize desc->context.curr_sg in both branches of this conditional? -- > > diff --git a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h > index 66685e59241a..7bd5f4639c4a 100644 > --- a/drivers/usb/image/microtek.h > +++ b/drivers/usb/image/microtek.h > @@ -21,7 +21,7 @@ struct mts_transfer_context > void *data; > unsigned data_length; > int data_pipe; > - int fragment; > + struct scatterlist *curr_sg; > > u8 *scsi_status; /* status returned from ep_response after command > completion */ > }; > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V3 08/15] staging: unisys: visorhba: use sg helper to operate scatterlist
On Fri, Jun 14, 2019 at 10:53:09AM +0800, Ming Lei wrote: > Use the scatterlist iterators and remove direct indexing of the > scatterlist array. > > This way allows us to pre-allocate one small scatterlist, which can be > chained with one runtime allocated scatterlist if the pre-allocated one > isn't enough for the whole request. > > Cc: de...@driverdev.osuosl.org > Cc: Greg Kroah-Hartman > Signed-off-by: Ming Lei > --- > drivers/staging/unisys/visorhba/visorhba_main.c | 9 - > 1 file changed, 4 insertions(+), 5 deletions(-) Acked-by: Greg Kroah-Hartman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH V3 07/15] usb: image: microtek: use sg helper to operate scatterlist
On Fri, Jun 14, 2019 at 03:39:10PM +1000, Finn Thain wrote: > On Fri, 14 Jun 2019, Ming Lei wrote: > > > Use the scatterlist iterators and remove direct indexing of the > > scatterlist array. > > > > This way allows us to pre-allocate one small scatterlist, which can be > > chained with one runtime allocated scatterlist if the pre-allocated one > > isn't enough for the whole request. > > > > Cc: Oliver Neukum > > Cc: Greg Kroah-Hartman > > Cc: linux-...@vger.kernel.org > > Signed-off-by: Ming Lei > > --- > > drivers/usb/image/microtek.c | 20 > > drivers/usb/image/microtek.h | 2 +- > > 2 files changed, 9 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c > > index 607be1f4fe27..0a57c2cc8e5a 100644 > > --- a/drivers/usb/image/microtek.c > > +++ b/drivers/usb/image/microtek.c > > @@ -488,7 +488,6 @@ static void mts_command_done( struct urb *transfer ) > > > > static void mts_do_sg (struct urb* transfer) > > { > > - struct scatterlist * sg; > > int status = transfer->status; > > MTS_INT_INIT(); > > > > @@ -500,13 +499,12 @@ static void mts_do_sg (struct urb* transfer) > > mts_transfer_cleanup(transfer); > > } > > > > - sg = scsi_sglist(context->srb); > > - context->fragment++; > > + context->curr_sg = sg_next(context->curr_sg); > > mts_int_submit_urb(transfer, > >context->data_pipe, > > - sg_virt(&sg[context->fragment]), > > - sg[context->fragment].length, > > - context->fragment + 1 == scsi_sg_count(context->srb) > > ? > > + sg_virt(context->curr_sg), > > + context->curr_sg->length, > > + sg_is_last(context->curr_sg) ? > >mts_data_done : mts_do_sg); > > } > > > > @@ -526,22 +524,20 @@ static void > > mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc) > > { > > int pipe; > > - struct scatterlist * sg; > > - > > + > > MTS_DEBUG_GOT_HERE(); > > > > desc->context.instance = desc; > > desc->context.srb = srb; > > - desc->context.fragment = 0; > > > > if (!scsi_bufflen(srb)) { > > desc->context.data = NULL; > > desc->context.data_length = 0; > > return; > > } else { > > - sg = scsi_sglist(srb); > > - desc->context.data = sg_virt(&sg[0]); > > - desc->context.data_length = sg[0].length; > > + desc->context.curr_sg = scsi_sglist(srb); > > + desc->context.data = sg_virt(desc->context.curr_sg); > > + desc->context.data_length = desc->context.curr_sg->length; > > } > > > > Would it not be better to initialize desc->context.curr_sg in both > branches of this conditional? I think either way is fine given desc->context.curr_sg is used only if 'context->data' isn't NULL, see mts_command_done(). So I'd keep the patch as it is. Thanks, Ming ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel