mbox series

[0/4] simplify ufshcd with the guard() macro

Message ID 20240416102348.614-1-avri.altman@wdc.com
Headers show
Series simplify ufshcd with the guard() macro | expand

Message

Avri Altman April 16, 2024, 10:23 a.m. UTC
We can simplify the code with the guard() macro and co for  automatic
cleanup of locks. For making changes easier, this series is divided to
per-lock type patches and only address the ufshcd module. There are
still a few remaining explicit lock/unlock calls, and those are for the
places where we do temporary unlock/relock, which doesn't fit well with
the guard(), so far.

Only code refactoring, and no functional changes.


Avri Altman (4):
  scsi: ufs: core: Make use of guard(spinlock_irqsave)
  scsi: ufs: core: Make use of guard(spinlock)
  scsi: ufs: core: Make use of guard(spinlock_irq)
  scsi: ufs: core: Make use of guard(mutex)

 drivers/ufs/core/ufshcd.c | 623 +++++++++++++++++---------------------
 1 file changed, 270 insertions(+), 353 deletions(-)

Comments

Bart Van Assche April 16, 2024, 7:18 p.m. UTC | #1
On 4/16/24 03:23, Avri Altman wrote:
> +#define SERIALIZE_HOST_IRQSAVE(hba) guard(spinlock_irqsave)(hba->host->host_lock)

Something I have brought up before: what does the host lock protect in
the UFS driver? Rather than reworking the code that acquires and
releases the host lock, all uses of the host lock should be eliminated
from the UFS driver. The host lock should be replaced with new locks of
which it is clearly documented what member variables these new locks
protect.

Thanks,

Bart.
Avri Altman April 17, 2024, 6:39 a.m. UTC | #2
> Something I have brought up before: what does the host lock protect in the UFS
> driver? Rather than reworking the code that acquires and releases the host lock,
> all uses of the host lock should be eliminated from the UFS driver. The host lock
> should be replaced with new locks of which it is clearly documented what
> member variables these new locks protect.
Then either this series is pre-mature and needs to be dropped for now,
Or the changes you are planning can take place regardless?

Thanks,
Avri
> 
> Thanks,
> 
> Bart.