Message ID | 20240626230411.3471543-7-ipylypiv@google.com |
---|---|
State | New |
Headers | show |
Series | ATA PASS-THROUGH sense data fixes | expand |
On 6/27/24 08:04, Igor Pylypiv wrote: > qc->result_tf contents are only valid when the ATA_QCFLAG_RTF_FILLED flag > is set. The ATA_QCFLAG_RTF_FILLED flag should be always set for commands > that failed or for commands that have the ATA_QCFLAG_RESULT_TF flag set. > > Signed-off-by: Igor Pylypiv <ipylypiv@google.com> Please change "RTF" to "result TF" in the messages below, to be clear (RTF is not). Feel free to split the ata_dev_dbg() lines after "dev," to avoid long lines. With that: Reviewed-by: Damien Le Moal <dlemoal@kernel.org> > --- > drivers/ata/libata-scsi.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c > index 02af4d5d5799..d5874d4b9253 100644 > --- a/drivers/ata/libata-scsi.c > +++ b/drivers/ata/libata-scsi.c > @@ -242,10 +242,16 @@ void ata_scsi_set_sense_information(struct ata_device *dev, > */ > static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) > { > + struct ata_device *dev = qc->dev; > struct scsi_cmnd *cmd = qc->scsicmd; > struct ata_taskfile *tf = &qc->result_tf; > unsigned char *sb = cmd->sense_buffer; > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > + ata_dev_dbg(dev, "Missing RTF: cannot set ATA PT sense fields.\n"); > + return; > + } > + > if ((sb[0] & 0x7f) >= 0x72) { > unsigned char *desc; > u8 len; > @@ -923,10 +929,16 @@ static void ata_to_sense_error(u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, > */ > static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) > { > + struct ata_device *dev = qc->dev; > struct scsi_cmnd *cmd = qc->scsicmd; > struct ata_taskfile *tf = &qc->result_tf; > u8 sense_key, asc, ascq; > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > + ata_dev_dbg(dev, "Missing RTF: cannot generate ATA PT sense data.\n"); > + return; > + } > + > /* > * Use ata_to_sense_error() to map status register bits > * onto sense key, asc & ascq. > @@ -970,6 +982,12 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) > ata_scsi_set_sense(dev, cmd, NOT_READY, 0x04, 0x21); > return; > } > + > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > + ata_dev_dbg(dev, "Missing RTF: cannot generate sense data.\n"); > + return; > + } > + > /* Use ata_to_sense_error() to map status register bits > * onto sense key, asc & ascq. > */
On 6/27/24 01:04, Igor Pylypiv wrote: > qc->result_tf contents are only valid when the ATA_QCFLAG_RTF_FILLED flag > is set. The ATA_QCFLAG_RTF_FILLED flag should be always set for commands > that failed or for commands that have the ATA_QCFLAG_RESULT_TF flag set. > > Signed-off-by: Igor Pylypiv <ipylypiv@google.com> > --- > drivers/ata/libata-scsi.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > Reviewed-by: Hannes Reinecke <hare@suse.de> Cheers, Hannes
On Thu, Jun 27, 2024 at 09:19:17AM +0900, Damien Le Moal wrote: > On 6/27/24 08:04, Igor Pylypiv wrote: > > qc->result_tf contents are only valid when the ATA_QCFLAG_RTF_FILLED flag > > is set. The ATA_QCFLAG_RTF_FILLED flag should be always set for commands > > that failed or for commands that have the ATA_QCFLAG_RESULT_TF flag set. > > > > Signed-off-by: Igor Pylypiv <ipylypiv@google.com> > > Please change "RTF" to "result TF" in the messages below, to be clear (RTF is > not). Feel free to split the ata_dev_dbg() lines after "dev," to avoid long lines. Thanks Damien! I wrote "result taskfile" first, then changed it to "result TF", and then to "RTF" to shorten the lines :) I'll change it to "result TF" with the line split in v3. > > With that: > > Reviewed-by: Damien Le Moal <dlemoal@kernel.org> > > > --- > > drivers/ata/libata-scsi.c | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c > > index 02af4d5d5799..d5874d4b9253 100644 > > --- a/drivers/ata/libata-scsi.c > > +++ b/drivers/ata/libata-scsi.c > > @@ -242,10 +242,16 @@ void ata_scsi_set_sense_information(struct ata_device *dev, > > */ > > static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) > > { > > + struct ata_device *dev = qc->dev; > > struct scsi_cmnd *cmd = qc->scsicmd; > > struct ata_taskfile *tf = &qc->result_tf; > > unsigned char *sb = cmd->sense_buffer; > > > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > > + ata_dev_dbg(dev, "Missing RTF: cannot set ATA PT sense fields.\n"); > > + return; > > + } > > + > > if ((sb[0] & 0x7f) >= 0x72) { > > unsigned char *desc; > > u8 len; > > @@ -923,10 +929,16 @@ static void ata_to_sense_error(u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, > > */ > > static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) > > { > > + struct ata_device *dev = qc->dev; > > struct scsi_cmnd *cmd = qc->scsicmd; > > struct ata_taskfile *tf = &qc->result_tf; > > u8 sense_key, asc, ascq; > > > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > > + ata_dev_dbg(dev, "Missing RTF: cannot generate ATA PT sense data.\n"); > > + return; > > + } > > + > > /* > > * Use ata_to_sense_error() to map status register bits > > * onto sense key, asc & ascq. > > @@ -970,6 +982,12 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) > > ata_scsi_set_sense(dev, cmd, NOT_READY, 0x04, 0x21); > > return; > > } > > + > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > > + ata_dev_dbg(dev, "Missing RTF: cannot generate sense data.\n"); > > + return; > > + } > > + > > /* Use ata_to_sense_error() to map status register bits > > * onto sense key, asc & ascq. > > */ > > -- > Damien Le Moal > Western Digital Research > Thanks, Igor
On Wed, Jun 26, 2024 at 11:04:11PM +0000, Igor Pylypiv wrote: > qc->result_tf contents are only valid when the ATA_QCFLAG_RTF_FILLED flag > is set. The ATA_QCFLAG_RTF_FILLED flag should be always set for commands > that failed or for commands that have the ATA_QCFLAG_RESULT_TF flag set. > > Signed-off-by: Igor Pylypiv <ipylypiv@google.com> > --- > drivers/ata/libata-scsi.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c > index 02af4d5d5799..d5874d4b9253 100644 > --- a/drivers/ata/libata-scsi.c > +++ b/drivers/ata/libata-scsi.c > @@ -242,10 +242,16 @@ void ata_scsi_set_sense_information(struct ata_device *dev, > */ > static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) > { > + struct ata_device *dev = qc->dev; > struct scsi_cmnd *cmd = qc->scsicmd; > struct ata_taskfile *tf = &qc->result_tf; > unsigned char *sb = cmd->sense_buffer; > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > + ata_dev_dbg(dev, "Missing RTF: cannot set ATA PT sense fields.\n"); > + return; > + } > + > if ((sb[0] & 0x7f) >= 0x72) { > unsigned char *desc; > u8 len; > @@ -923,10 +929,16 @@ static void ata_to_sense_error(u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, > */ > static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) > { > + struct ata_device *dev = qc->dev; > struct scsi_cmnd *cmd = qc->scsicmd; > struct ata_taskfile *tf = &qc->result_tf; > u8 sense_key, asc, ascq; > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > + ata_dev_dbg(dev, "Missing RTF: cannot generate ATA PT sense data.\n"); > + return; > + } > + > /* > * Use ata_to_sense_error() to map status register bits > * onto sense key, asc & ascq. > @@ -970,6 +982,12 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) > ata_scsi_set_sense(dev, cmd, NOT_READY, 0x04, 0x21); > return; > } > + > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > + ata_dev_dbg(dev, "Missing RTF: cannot generate sense data.\n"); > + return; > + } > + > /* Use ata_to_sense_error() to map status register bits > * onto sense key, asc & ascq. > */ > -- > 2.45.2.803.g4e1b14247a-goog > In order to be more consistent with existing prints in this file, please do not capitalize the first letter, and remove the punctuation. Kind regards, Niklas
On Fri, Jun 28, 2024 at 09:42:53PM +0200, Niklas Cassel wrote: > On Wed, Jun 26, 2024 at 11:04:11PM +0000, Igor Pylypiv wrote: > > qc->result_tf contents are only valid when the ATA_QCFLAG_RTF_FILLED flag > > is set. The ATA_QCFLAG_RTF_FILLED flag should be always set for commands > > that failed or for commands that have the ATA_QCFLAG_RESULT_TF flag set. > > > > Signed-off-by: Igor Pylypiv <ipylypiv@google.com> > > --- > > drivers/ata/libata-scsi.c | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c > > index 02af4d5d5799..d5874d4b9253 100644 > > --- a/drivers/ata/libata-scsi.c > > +++ b/drivers/ata/libata-scsi.c > > @@ -242,10 +242,16 @@ void ata_scsi_set_sense_information(struct ata_device *dev, > > */ > > static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) > > { > > + struct ata_device *dev = qc->dev; > > struct scsi_cmnd *cmd = qc->scsicmd; > > struct ata_taskfile *tf = &qc->result_tf; > > unsigned char *sb = cmd->sense_buffer; > > > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > > + ata_dev_dbg(dev, "Missing RTF: cannot set ATA PT sense fields.\n"); > > + return; > > + } > > + > > if ((sb[0] & 0x7f) >= 0x72) { > > unsigned char *desc; > > u8 len; > > @@ -923,10 +929,16 @@ static void ata_to_sense_error(u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, > > */ > > static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) > > { > > + struct ata_device *dev = qc->dev; > > struct scsi_cmnd *cmd = qc->scsicmd; > > struct ata_taskfile *tf = &qc->result_tf; > > u8 sense_key, asc, ascq; > > > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > > + ata_dev_dbg(dev, "Missing RTF: cannot generate ATA PT sense data.\n"); > > + return; > > + } > > + > > /* > > * Use ata_to_sense_error() to map status register bits > > * onto sense key, asc & ascq. > > @@ -970,6 +982,12 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) > > ata_scsi_set_sense(dev, cmd, NOT_READY, 0x04, 0x21); > > return; > > } > > + > > + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { > > + ata_dev_dbg(dev, "Missing RTF: cannot generate sense data.\n"); > > + return; > > + } > > + > > /* Use ata_to_sense_error() to map status register bits > > * onto sense key, asc & ascq. > > */ > > -- > > 2.45.2.803.g4e1b14247a-goog > > > > In order to be more consistent with existing prints in this file, > please do not capitalize the first letter, and remove the punctuation. Thanks! I'll remove periods and will keep the colons. > > > Kind regards, > Niklas
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 02af4d5d5799..d5874d4b9253 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -242,10 +242,16 @@ void ata_scsi_set_sense_information(struct ata_device *dev, */ static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) { + struct ata_device *dev = qc->dev; struct scsi_cmnd *cmd = qc->scsicmd; struct ata_taskfile *tf = &qc->result_tf; unsigned char *sb = cmd->sense_buffer; + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { + ata_dev_dbg(dev, "Missing RTF: cannot set ATA PT sense fields.\n"); + return; + } + if ((sb[0] & 0x7f) >= 0x72) { unsigned char *desc; u8 len; @@ -923,10 +929,16 @@ static void ata_to_sense_error(u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, */ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) { + struct ata_device *dev = qc->dev; struct scsi_cmnd *cmd = qc->scsicmd; struct ata_taskfile *tf = &qc->result_tf; u8 sense_key, asc, ascq; + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { + ata_dev_dbg(dev, "Missing RTF: cannot generate ATA PT sense data.\n"); + return; + } + /* * Use ata_to_sense_error() to map status register bits * onto sense key, asc & ascq. @@ -970,6 +982,12 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) ata_scsi_set_sense(dev, cmd, NOT_READY, 0x04, 0x21); return; } + + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { + ata_dev_dbg(dev, "Missing RTF: cannot generate sense data.\n"); + return; + } + /* Use ata_to_sense_error() to map status register bits * onto sense key, asc & ascq. */
qc->result_tf contents are only valid when the ATA_QCFLAG_RTF_FILLED flag is set. The ATA_QCFLAG_RTF_FILLED flag should be always set for commands that failed or for commands that have the ATA_QCFLAG_RESULT_TF flag set. Signed-off-by: Igor Pylypiv <ipylypiv@google.com> --- drivers/ata/libata-scsi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)