Re: [PATCH] [RFC] scsi: Convert from tasklet to BH workqueue

2024-05-03 Thread Allen Pais



> On May 2, 2024, at 7:03 PM, Michael Ellerman  wrote:
> 
> Allen Pais  writes:
>> The only generic interface to execute asynchronously in the BH context is
>> tasklet; however, it's marked deprecated and has some design flaws. To
>> replace tasklets, BH workqueue support was recently added. A BH workqueue
>> behaves similarly to regular workqueues except that the queued work items
>> are executed in the BH context.
>> 
>> This patch converts drivers/scsi/* from tasklet to BH workqueue.
>> 
>> Based on the work done by Tejun Heo 
>> Branch: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-6.10
>> 
>> Signed-off-by: Allen Pais 
>> ---
>> drivers/scsi/aic7xxx/aic7xxx_osm.c  |  2 +-
>> drivers/scsi/aic94xx/aic94xx_hwi.c  | 14 ++--
>> drivers/scsi/aic94xx/aic94xx_hwi.h  |  5 +-
>> drivers/scsi/aic94xx/aic94xx_scb.c  | 36 +-
>> drivers/scsi/aic94xx/aic94xx_task.c | 14 ++--
>> drivers/scsi/aic94xx/aic94xx_tmf.c  | 34 -
>> drivers/scsi/esas2r/esas2r.h| 12 ++--
>> drivers/scsi/esas2r/esas2r_init.c   | 14 ++--
>> drivers/scsi/esas2r/esas2r_int.c| 18 ++---
>> drivers/scsi/esas2r/esas2r_io.c |  2 +-
>> drivers/scsi/esas2r/esas2r_main.c   | 16 ++---
>> drivers/scsi/ibmvscsi/ibmvfc.c  | 16 ++---
>> drivers/scsi/ibmvscsi/ibmvfc.h  |  3 +-
>> drivers/scsi/ibmvscsi/ibmvscsi.c| 16 ++---
>> drivers/scsi/ibmvscsi/ibmvscsi.h|  3 +-
>> drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c| 15 ++--
>> drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h|  3 +-
> 
> Something there is giving me a build failure (ppc64le_guest_defconfig):
> 
>  + make -s 'CC=ccache powerpc64le-linux-gnu-gcc' -j 4
>  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c: In function 
> 'ibmvscsi_init_crq_queue':
>  Error: /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:370:331: error: 
> 'ibmvscsi_work' undeclared (first use in this function)
>  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:370:331: note: each undeclared 
> identifier is reported only once for each function it appears in
>  /linux/scripts/Makefile.build:244: recipe for target 
> 'drivers/scsi/ibmvscsi/ibmvscsi.o' failed
>  /linux/scripts/Makefile.build:485: recipe for target 'drivers/scsi/ibmvscsi' 
> failed
>  /linux/scripts/Makefile.build:485: recipe for target 'drivers/scsi' failed
>  /linux/scripts/Makefile.build:485: recipe for target 'drivers' failed
>  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c: In function 'ibmvscsi_probe':
>  Error: /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:2255:78: error: passing 
> argument 1 of 'kthread_create_on_node' from incompatible pointer type 
> [-Werror=incompatible-pointer-types]
>  In file included from /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:56:0:
>  /linux/include/linux/kthread.h:11:21: note: expected 'int (*)(void *)' but 
> argument is of type 'int (*)(struct work_struct *)'
>   struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
>   ^
>  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c: At top level:
>  Warning: /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:212:13: warning: 
> 'ibmvscsi_task' defined but not used [-Wunused-function]
>   static void ibmvscsi_task(void *data)
>   ^
>  Warning: cc1: warning: unrecognized command line option 
> '-Wno-shift-negative-value'
>  Warning: cc1: warning: unrecognized command line option 
> '-Wno-stringop-overflow'
>  cc1: some warnings being treated as errors
>  make[6]: *** [drivers/scsi/ibmvscsi/ibmvscsi.o] Error 1
>  make[5]: *** [drivers/scsi/ibmvscsi] Error 2
>  make[4]: *** [drivers/scsi] Error 2
>  make[3]: *** [drivers] Error 2
>  make[3]: *** Waiting for unfinished jobs
> 
> Full log here: 
> https://github.com/linuxppc/linux-snowpatch/actions/runs/8930174372/job/24529645923

 Thank you for testing it out. Unfortunately, I did not cross-compile it.
Will fix this in v2.

- Allen

> 
> Cross compile instructions if you're keen: 
> https://github.com/linuxppc/wiki/wiki/Building-powerpc-kernels
> 
> cheers



Re: [PATCH] [RFC] scsi: Convert from tasklet to BH workqueue

2024-05-02 Thread Michael Ellerman
Allen Pais  writes:
> The only generic interface to execute asynchronously in the BH context is
> tasklet; however, it's marked deprecated and has some design flaws. To
> replace tasklets, BH workqueue support was recently added. A BH workqueue
> behaves similarly to regular workqueues except that the queued work items
> are executed in the BH context.
>
> This patch converts drivers/scsi/* from tasklet to BH workqueue.
>
> Based on the work done by Tejun Heo 
> Branch: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-6.10
>
> Signed-off-by: Allen Pais 
> ---
>  drivers/scsi/aic7xxx/aic7xxx_osm.c  |  2 +-
>  drivers/scsi/aic94xx/aic94xx_hwi.c  | 14 ++--
>  drivers/scsi/aic94xx/aic94xx_hwi.h  |  5 +-
>  drivers/scsi/aic94xx/aic94xx_scb.c  | 36 +-
>  drivers/scsi/aic94xx/aic94xx_task.c | 14 ++--
>  drivers/scsi/aic94xx/aic94xx_tmf.c  | 34 -
>  drivers/scsi/esas2r/esas2r.h| 12 ++--
>  drivers/scsi/esas2r/esas2r_init.c   | 14 ++--
>  drivers/scsi/esas2r/esas2r_int.c| 18 ++---
>  drivers/scsi/esas2r/esas2r_io.c |  2 +-
>  drivers/scsi/esas2r/esas2r_main.c   | 16 ++---
>  drivers/scsi/ibmvscsi/ibmvfc.c  | 16 ++---
>  drivers/scsi/ibmvscsi/ibmvfc.h  |  3 +-
>  drivers/scsi/ibmvscsi/ibmvscsi.c| 16 ++---
>  drivers/scsi/ibmvscsi/ibmvscsi.h|  3 +-
>  drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c| 15 ++--
>  drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h|  3 +-

Something there is giving me a build failure (ppc64le_guest_defconfig):

  + make -s 'CC=ccache powerpc64le-linux-gnu-gcc' -j 4
  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c: In function 
'ibmvscsi_init_crq_queue':
  Error: /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:370:331: error: 
'ibmvscsi_work' undeclared (first use in this function)
  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:370:331: note: each undeclared 
identifier is reported only once for each function it appears in
  /linux/scripts/Makefile.build:244: recipe for target 
'drivers/scsi/ibmvscsi/ibmvscsi.o' failed
  /linux/scripts/Makefile.build:485: recipe for target 'drivers/scsi/ibmvscsi' 
failed
  /linux/scripts/Makefile.build:485: recipe for target 'drivers/scsi' failed
  /linux/scripts/Makefile.build:485: recipe for target 'drivers' failed
  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c: In function 'ibmvscsi_probe':
  Error: /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:2255:78: error: passing 
argument 1 of 'kthread_create_on_node' from incompatible pointer type 
[-Werror=incompatible-pointer-types]
  In file included from /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:56:0:
  /linux/include/linux/kthread.h:11:21: note: expected 'int (*)(void *)' but 
argument is of type 'int (*)(struct work_struct *)'
   struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
   ^
  /linux/drivers/scsi/ibmvscsi/ibmvscsi.c: At top level:
  Warning: /linux/drivers/scsi/ibmvscsi/ibmvscsi.c:212:13: warning: 
'ibmvscsi_task' defined but not used [-Wunused-function]
   static void ibmvscsi_task(void *data)
   ^
  Warning: cc1: warning: unrecognized command line option 
'-Wno-shift-negative-value'
  Warning: cc1: warning: unrecognized command line option 
'-Wno-stringop-overflow'
  cc1: some warnings being treated as errors
  make[6]: *** [drivers/scsi/ibmvscsi/ibmvscsi.o] Error 1
  make[5]: *** [drivers/scsi/ibmvscsi] Error 2
  make[4]: *** [drivers/scsi] Error 2
  make[3]: *** [drivers] Error 2
  make[3]: *** Waiting for unfinished jobs

Full log here: 
https://github.com/linuxppc/linux-snowpatch/actions/runs/8930174372/job/24529645923

Cross compile instructions if you're keen: 
https://github.com/linuxppc/wiki/wiki/Building-powerpc-kernels

cheers


[PATCH] [RFC] scsi: Convert from tasklet to BH workqueue

2024-05-02 Thread Allen Pais
The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws. To
replace tasklets, BH workqueue support was recently added. A BH workqueue
behaves similarly to regular workqueues except that the queued work items
are executed in the BH context.

This patch converts drivers/scsi/* from tasklet to BH workqueue.

Based on the work done by Tejun Heo 
Branch: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-6.10

Signed-off-by: Allen Pais 
---
 drivers/scsi/aic7xxx/aic7xxx_osm.c  |  2 +-
 drivers/scsi/aic94xx/aic94xx_hwi.c  | 14 ++--
 drivers/scsi/aic94xx/aic94xx_hwi.h  |  5 +-
 drivers/scsi/aic94xx/aic94xx_scb.c  | 36 +-
 drivers/scsi/aic94xx/aic94xx_task.c | 14 ++--
 drivers/scsi/aic94xx/aic94xx_tmf.c  | 34 -
 drivers/scsi/esas2r/esas2r.h| 12 ++--
 drivers/scsi/esas2r/esas2r_init.c   | 14 ++--
 drivers/scsi/esas2r/esas2r_int.c| 18 ++---
 drivers/scsi/esas2r/esas2r_io.c |  2 +-
 drivers/scsi/esas2r/esas2r_main.c   | 16 ++---
 drivers/scsi/ibmvscsi/ibmvfc.c  | 16 ++---
 drivers/scsi/ibmvscsi/ibmvfc.h  |  3 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c| 16 ++---
 drivers/scsi/ibmvscsi/ibmvscsi.h|  3 +-
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c| 15 ++--
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h|  3 +-
 drivers/scsi/isci/host.c| 12 ++--
 drivers/scsi/isci/host.h|  8 +--
 drivers/scsi/isci/init.c|  4 +-
 drivers/scsi/megaraid/mega_common.h |  5 +-
 drivers/scsi/megaraid/megaraid_mbox.c   | 21 +++---
 drivers/scsi/megaraid/megaraid_sas.h|  4 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   | 32 -
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 16 ++---
 drivers/scsi/mvsas/mv_init.c| 27 ---
 drivers/scsi/mvsas/mv_sas.h |  9 +--
 drivers/scsi/pm8001/pm8001_init.c   | 55 ---
 drivers/scsi/pm8001/pm8001_sas.h|  2 +-
 drivers/scsi/pmcraid.c  | 78 +++--
 drivers/scsi/pmcraid.h  |  5 +-
 31 files changed, 251 insertions(+), 250 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c 
b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index b0c4f2345321..42f76391f589 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -797,7 +797,7 @@ struct scsi_host_template aic7xxx_driver_template = {
.target_destroy = ahc_linux_target_destroy,
 };
 
-/ Tasklet Handler 
*/
+/ Work Handler */
 
 
 static inline unsigned int ahc_build_scsiid(struct ahc_softc *ahc,
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c 
b/drivers/scsi/aic94xx/aic94xx_hwi.c
index 9dda296c0152..b08f0231e562 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -246,7 +246,7 @@ static void asd_get_max_scb_ddb(struct asd_ha_struct 
*asd_ha)
 
 /* -- Done List initialization -- */
 
-static void asd_dl_tasklet_handler(unsigned long);
+static void asd_dl_work_handler(struct work_struct *);
 
 static int asd_init_dl(struct asd_ha_struct *asd_ha)
 {
@@ -259,8 +259,7 @@ static int asd_init_dl(struct asd_ha_struct *asd_ha)
asd_ha->seq.dl = asd_ha->seq.actual_dl->vaddr;
asd_ha->seq.dl_toggle = ASD_DEF_DL_TOGGLE;
asd_ha->seq.dl_next = 0;
-   tasklet_init(_ha->seq.dl_tasklet, asd_dl_tasklet_handler,
-(unsigned long) asd_ha);
+   INIT_WORK(_ha->seq.dl_work, asd_dl_work_handler);
 
return 0;
 }
@@ -709,10 +708,9 @@ static void asd_chip_reset(struct asd_ha_struct *asd_ha)
 
 /* -- Done List Routines -- */
 
-static void asd_dl_tasklet_handler(unsigned long data)
+static void asd_dl_work_handler(struct work_struct *t)
 {
-   struct asd_ha_struct *asd_ha = (struct asd_ha_struct *) data;
-   struct asd_seq_data *seq = _ha->seq;
+   struct asd_seq_data *seq = from_work(seq, t, dl_work);
unsigned long flags;
 
while (1) {
@@ -739,7 +737,7 @@ static void asd_dl_tasklet_handler(unsigned long data)
seq->pending--;
spin_unlock_irqrestore(>pend_q_lock, flags);
out:
-   ascb->tasklet_complete(ascb, dl);
+   ascb->work_complete(ascb, dl);
 
next_1:
seq->dl_next = (seq->dl_next + 1) & (ASD_DL_SIZE-1);
@@ -756,7 +754,7 @@ static void asd_dl_tasklet_handler(unsigned long data)
  */
 static void asd_process_donelist_isr(struct asd_ha_struct *asd_ha)
 {
-   tasklet_schedule(_ha->seq.dl_tasklet);
+   queue_work(system_bh_wq, _ha->seq.dl_work);
 }
 
 /**
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.h