All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure
@ 2022-11-07  0:47 Shin'ichiro Kawasaki
  2022-11-07  1:08 ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-11-07  0:47 UTC (permalink / raw)
  To: linux-ide, Damien Le Moal; +Cc: Dmitry Fomichev, Shin'ichiro Kawasaki

SAT SCSI/ATA Translation specification requires SCSI SYNCHRONIZE CACHE
(10) and (16) commands both shall be translated to ATA flush command.
However, libata translates only SYNCHRONIZE CACHE (10). This results in
SYNCHRONIZE CACHE (16) command failures. To avoid the failure, add
support for SYNCHRONIZE CACHE (16).

This patch conflicts with kernels version 5.4 and older. Conflict
resolution will be required to back port to them.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: stable@vger.kernel.org # v5.10+
---
 drivers/ata/libata-scsi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e2ebb0b065e2..61cd4e90e4e7 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3264,6 +3264,7 @@ static unsigned int ata_scsiop_maint_in(struct ata_scsi_args *args, u8 *rbuf)
 	case REPORT_LUNS:
 	case REQUEST_SENSE:
 	case SYNCHRONIZE_CACHE:
+	case SYNCHRONIZE_CACHE_16:
 	case REZERO_UNIT:
 	case SEEK_6:
 	case SEEK_10:
@@ -3922,6 +3923,7 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
 		return ata_scsi_write_same_xlat;
 
 	case SYNCHRONIZE_CACHE:
+	case SYNCHRONIZE_CACHE_16:
 		if (ata_try_flush_cache(dev))
 			return ata_scsi_flush_xlat;
 		break;
@@ -4145,6 +4147,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
 	 * turning this into a no-op.
 	 */
 	case SYNCHRONIZE_CACHE:
+	case SYNCHRONIZE_CACHE_16:
 		fallthrough;
 
 	/* no-op's, complete with success */
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure
  2022-11-07  0:47 [PATCH] ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure Shin'ichiro Kawasaki
@ 2022-11-07  1:08 ` Damien Le Moal
  2022-11-07  3:05   ` Shinichiro Kawasaki
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2022-11-07  1:08 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki, linux-ide; +Cc: Dmitry Fomichev

On 11/7/22 09:47, Shin'ichiro Kawasaki wrote:
> SAT SCSI/ATA Translation specification requires SCSI SYNCHRONIZE CACHE
> (10) and (16) commands both shall be translated to ATA flush command.
> However, libata translates only SYNCHRONIZE CACHE (10). This results in
> SYNCHRONIZE CACHE (16) command failures. To avoid the failure, add
> support for SYNCHRONIZE CACHE (16).

Also mention that SYNCHRONIZE CACHE 16 is mandatory for ZBC drives (see
below).

> 
> This patch conflicts with kernels version 5.4 and older. Conflict
> resolution will be required to back port to them.

The above is not needed.

> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Cc: stable@vger.kernel.org # v5.10+

Remove the version number.

> ---
>  drivers/ata/libata-scsi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index e2ebb0b065e2..61cd4e90e4e7 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3264,6 +3264,7 @@ static unsigned int ata_scsiop_maint_in(struct ata_scsi_args *args, u8 *rbuf)
>  	case REPORT_LUNS:
>  	case REQUEST_SENSE:
>  	case SYNCHRONIZE_CACHE:
> +	case SYNCHRONIZE_CACHE_16:
>  	case REZERO_UNIT:
>  	case SEEK_6:
>  	case SEEK_10:
> @@ -3922,6 +3923,7 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
>  		return ata_scsi_write_same_xlat;
>  
>  	case SYNCHRONIZE_CACHE:
> +	case SYNCHRONIZE_CACHE_16:
>  		if (ata_try_flush_cache(dev))
>  			return ata_scsi_flush_xlat;
>  		break;
> @@ -4145,6 +4147,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
>  	 * turning this into a no-op.
>  	 */
>  	case SYNCHRONIZE_CACHE:
> +	case SYNCHRONIZE_CACHE_16:
>  		fallthrough;
>  
>  	/* no-op's, complete with success */

This also needs a patch for sd.c to always use SYNCHRONIZE CACHE 16 for
ZBC drives.


-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure
  2022-11-07  1:08 ` Damien Le Moal
@ 2022-11-07  3:05   ` Shinichiro Kawasaki
  0 siblings, 0 replies; 3+ messages in thread
From: Shinichiro Kawasaki @ 2022-11-07  3:05 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: linux-ide, Dmitry Fomichev

On Nov 07, 2022 / 10:08, Damien Le Moal wrote:
> On 11/7/22 09:47, Shin'ichiro Kawasaki wrote:
> > SAT SCSI/ATA Translation specification requires SCSI SYNCHRONIZE CACHE
> > (10) and (16) commands both shall be translated to ATA flush command.
> > However, libata translates only SYNCHRONIZE CACHE (10). This results in
> > SYNCHRONIZE CACHE (16) command failures. To avoid the failure, add
> > support for SYNCHRONIZE CACHE (16).
> 
> Also mention that SYNCHRONIZE CACHE 16 is mandatory for ZBC drives (see
> below).
> 
> > 
> > This patch conflicts with kernels version 5.4 and older. Conflict
> > resolution will be required to back port to them.
> 
> The above is not needed.
> 
> > 
> > Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> > Cc: stable@vger.kernel.org # v5.10+
> 
> Remove the version number.

Thanks. Will reflect these comments to v2.

> 
> > ---
> >  drivers/ata/libata-scsi.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> > index e2ebb0b065e2..61cd4e90e4e7 100644
> > --- a/drivers/ata/libata-scsi.c
> > +++ b/drivers/ata/libata-scsi.c
> > @@ -3264,6 +3264,7 @@ static unsigned int ata_scsiop_maint_in(struct ata_scsi_args *args, u8 *rbuf)
> >  	case REPORT_LUNS:
> >  	case REQUEST_SENSE:
> >  	case SYNCHRONIZE_CACHE:
> > +	case SYNCHRONIZE_CACHE_16:
> >  	case REZERO_UNIT:
> >  	case SEEK_6:
> >  	case SEEK_10:
> > @@ -3922,6 +3923,7 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
> >  		return ata_scsi_write_same_xlat;
> >  
> >  	case SYNCHRONIZE_CACHE:
> > +	case SYNCHRONIZE_CACHE_16:
> >  		if (ata_try_flush_cache(dev))
> >  			return ata_scsi_flush_xlat;
> >  		break;
> > @@ -4145,6 +4147,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
> >  	 * turning this into a no-op.
> >  	 */
> >  	case SYNCHRONIZE_CACHE:
> > +	case SYNCHRONIZE_CACHE_16:
> >  		fallthrough;
> >  
> >  	/* no-op's, complete with success */
> 
> This also needs a patch for sd.c to always use SYNCHRONIZE CACHE 16 for
> ZBC drives.

I see. Will prepare another patch and post to linux-scsi.

-- 
Shin'ichiro Kawasaki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-07  3:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07  0:47 [PATCH] ata: libata-scsi: fix SYNCHRONIZE CACHE (16) command failure Shin'ichiro Kawasaki
2022-11-07  1:08 ` Damien Le Moal
2022-11-07  3:05   ` Shinichiro Kawasaki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.