Messages in this thread Patch in this message | | | Subject | Re: [RFC PATCH 2/5] scsi: ufs: Add UFS-feature layer | From | Bart Van Assche <> | Date | Tue, 9 Jun 2020 21:15:58 -0700 |
| |
On 2020-06-04 18:30, Daejun Park wrote: > +inline void ufsf_slave_configure(struct ufs_hba *hba, > + struct scsi_device *sdev) > +{ > + /* skip well-known LU */ > + if (sdev->lun >= UFS_UPIU_MAX_UNIT_NUM_ID) > + return; > + > + if (!(hba->dev_info.b_ufs_feature_sup & UFS_FEATURE_SUPPORT_HPB_BIT)) > + return; > + > + atomic_inc(&hba->ufsf.slave_conf_cnt); > + smp_mb__after_atomic(); /* for slave_conf_cnt */ > + > + /* waiting sdev init.*/ > + if (waitqueue_active(&hba->ufsf.sdev_wait)) > + wake_up(&hba->ufsf.sdev_wait); > +}
Guarding a wake_up() call with a waitqueue_active() check is an anti-pattern. Please don't do that and call wake_up() directly. Additionally, wake_up() includes a barrier if it wakes up a kernel thread so the smp_mb__after_atomic() can be left out if the waitqueue_active() call is removed.
> +/** > + * struct ufsf_operation - UFS feature specific callbacks > + * @prep_fn: called after construct upiu structure > + * @reset: called after proving hba ^^^^^^^ Is this a typo? Should "proving" perhaps be changed into "probing"?
> +struct ufshpb_driver { > + struct device_driver drv; > + struct list_head lh_hpb_lu; > + > + struct ufsf_operation ufshpb_ops; > + > + /* memory management */ > + struct kmem_cache *ufshpb_mctx_cache; > + mempool_t *ufshpb_mctx_pool; > + mempool_t *ufshpb_page_pool; > + > + struct workqueue_struct *ufshpb_wq; > +};
Why is a dedicated workqueue needed? Why are the standard workqueues not good enough?
> @@ -2525,6 +2525,8 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) > > ufshcd_comp_scsi_upiu(hba, lrbp); > > + ufsf_ops_prep_fn(hba, lrbp); > + > err = ufshcd_map_sg(hba, lrbp); > if (err) { > lrbp->cmd = NULL;
What happens if a SCSI command is retried and hence ufsf_ops_prep_fn() is called multiple times for the same SCSI command?
Thanks,
Bart.
| |