Re: [PATCH v16 1/3] scsi: ufs: Introduce HPB feature

From: Greg KH
Date: Sat Dec 19 2020 - 05:38:53 EST


On Sat, Dec 19, 2020 at 06:18:47PM +0900, Daejun Park wrote:
> +static int ufshpb_get_state(struct ufshpb_lu *hpb)
> +{
> + return atomic_read(&hpb->hpb_state);
> +}
> +
> +static void ufshpb_set_state(struct ufshpb_lu *hpb, int state)
> +{
> + atomic_set(&hpb->hpb_state, state);
> +}

You have a lock for the state, and yet the state is an atomic variable
and you do not use the lock here at all. You don't use the lock at all
infact...

So either the lock needs to be dropped, or you need to use the lock and
make the state a normal variable please.

> +static void ufshpb_hpb_lu_prepared(struct ufs_hba *hba)
> +{
> + struct ufshpb_lu *hpb;
> + struct scsi_device *sdev;
> + bool init_success;
> +
> + init_success = !ufshpb_check_hpb_reset_query(hba);
> +
> + shost_for_each_device(sdev, hba->host) {
> + hpb = sdev->hostdata;
> + if (!hpb)
> + continue;
> +
> + if (init_success) {
> + dev_info(hba->dev, "set state to present\n");

Why be noisy? Why does userspace need to see this all the time,
shouldn't only errors be printing something?

thanks,

greg k-h