Skip to contentSkip to conversation

scsi: st: Small fixes

PATCH Applied Kai Mäkisara 3 participants 7 messages Mar 11, 2025 – Apr 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover scsi: st: Small fixes

Fix some small things in the st driver.

Applies to 6.15/scsi-staging

Kai Mäkisara (3):
scsi: st: Fix array overflow in st_setup()
scsi: st: ERASE does not change tape location
scsi: st: Tighten the page format heuristics with MODE SELECT

 drivers/scsi/st.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 scsi: st: Fix array overflow in st_setup()

Change the array size to follow parms size instead of a fixed value.

---
 drivers/scsi/st.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/st.c +1 -1
index 85867120c8a9..0d020cb1ffcd 100644
@@ -4157,7 +4157,7 @@ static void validate_options(void)
  */
 static int __init st_setup(char *str)
 {
-	int i, len, ints[5];
+	int i, len, ints[ARRAY_SIZE(parms)+1];
 	char *stp;
 
 	stp = get_options(str, ARRAY_SIZE(ints), ints);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 scsi: st: ERASE does not change tape location

In reply to Kai Mäkisara

The SCSI ERASE command erases from the current position onwards. Don't clear the position variables.

---
 drivers/scsi/st.c | 1 -
 1 file changed, 1 deletion(-)
drivers/scsi/st.c +0 -1
index 0d020cb1ffcd..55809f8a62d3 100644
@@ -2915,7 +2915,6 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
 			timeout = STp->long_timeout * 8;
 
 		DEBC_printk(STp, "Erasing tape.\n");
-		fileno = blkno = at_sm = 0;
 		break;
 	case MTSETBLK:		/* Set block length */
 	case MTSETDENSITY:	/* Set tape density */
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 scsi: st: Tighten the page format heuristics with MODE SELECT

In reply to Kai Mäkisara

In the days when SCSI-2 was emerging, some drives did claim SCSI-2 but did not correctly implement it. The st driver first tries MODE SELECT with the page format bit set to set the block descriptor. If not successful, the non-page format is tried.

The test only tests the sense code and this triggers also from illegal parameter in the parameter list. The test is limited to "old" devices and made more strict to remove false alarms.

---
 drivers/scsi/st.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/st.c +3 -1
index 55809f8a62d3..c33c0f2045b7 100644
@@ -3104,7 +3104,9 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
 			   cmd_in == MTSETDRVBUFFER ||
 			   cmd_in == SET_DENS_AND_BLK) {
 			if (cmdstatp->sense_hdr.sense_key == ILLEGAL_REQUEST &&
-			    !(STp->use_pf & PF_TESTED)) {
+				cmdstatp->sense_hdr.asc == 0x24 &&
+				(STp->device)->scsi_level <= SCSI_2 &&
+				!(STp->use_pf & PF_TESTED)) {
 				/* Try the other possible state of Page Format if not
 				   already tried */
 				STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED;
Signature · 1 line
2.43.0
Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] scsi: st: Tighten the page format heuristics with MODE SELECT

Quoted 31 lines · Kai Mäkisara

In the days when SCSI-2 was emerging, some drives did claim SCSI-2 but did not correctly implement it. The st driver first tries MODE SELECT with the page format bit set to set the block descriptor. If not successful, the non-page format is tried.

The test only tests the sense code and this triggers also from illegal parameter in the parameter list. The test is limited to "old" devices and made more strict to remove false alarms.

---
 drivers/scsi/st.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/st.c +3 -2
index 55809f8a62d3..c33c0f2045b7 100644
@@ -3104,7 +3104,9 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
                           cmd_in == MTSETDRVBUFFER ||
                           cmd_in == SET_DENS_AND_BLK) {
                        if (cmdstatp->sense_hdr.sense_key == ILLEGAL_REQUEST &&
-                           !(STp->use_pf & PF_TESTED)) {
+                               cmdstatp->sense_hdr.asc == 0x24 &&
+                               (STp->device)->scsi_level <= SCSI_2 &&
+                               !(STp->use_pf & PF_TESTED)) {
                                /* Try the other possible state of Page Format if not
                                   already tried */
                                STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED;
--
Quoted 3 lines

2.43.0

#6 lore raw
In reply to Kai Mäkisara
Quoted 10 lines · Kai Mäkisara

Fix some small things in the st driver.

Applies to 6.15/scsi-staging

Kai Mäkisara (3):
scsi: st: Fix array overflow in st_setup()
scsi: st: ERASE does not change tape location
scsi: st: Tighten the page format heuristics with MODE SELECT

[...]

Applied to 6.15/scsi-queue, thanks!

[1/3] scsi: st: Fix array overflow in st_setup()

      https://git.kernel.org/mkp/scsi/c/a018d1cf990d
[2/3] scsi: st: ERASE does not change tape location
      https://git.kernel.org/mkp/scsi/c/ad77cebf97bd
[3/3] scsi: st: Tighten the page format heuristics with MODE SELECT
      https://git.kernel.org/mkp/scsi/c/8db816c6f176
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering