public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: mtip32xx:Added appropriate timeout value for secure erase
  2012-09-27 12:57 mtip32xx:Added appropriate timeout value for secure erase Selvan Mani
@ 2012-09-27 12:37 ` Jens Axboe
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2012-09-27 12:37 UTC (permalink / raw)
  To: Selvan Mani; +Cc: linux-kernel, sbradshaw, asamymuthupa

On 09/27/2012 02:57 PM, Selvan Mani wrote:
> Hi Jens,
> 
> Please queue this patch for 3.7.
> 
> Added appropriate timeout value for secure erase based on identify device data

Queued up!

-- 
Jens Axboe


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

* mtip32xx:Added appropriate timeout value for secure erase
@ 2012-09-27 12:57 Selvan Mani
  2012-09-27 12:37 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Selvan Mani @ 2012-09-27 12:57 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel, sbradshaw, asamymuthupa

Hi Jens,

Please queue this patch for 3.7.

Added appropriate timeout value for secure erase based on identify device data

Signed-off-by: Asai Thambi S P <asamymuthupa@micron.com>
Signed-off-by: Selvan Mani <smani@micron.com>
---
 drivers/block/mtip32xx/mtip32xx.c |   19 +++++++++++++++----
 drivers/block/mtip32xx/mtip32xx.h |    3 +++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index f56205f..cbaacd7 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2038,8 +2038,9 @@ static unsigned int implicit_sector(unsigned char command,
 	}
 	return rv;
 }
-
-static void mtip_set_timeout(struct host_to_dev_fis *fis, unsigned int *timeout)
+static void mtip_set_timeout(struct driver_data *dd,
+					struct host_to_dev_fis *fis,
+					unsigned int *timeout, u8 erasemode)
 {
 	switch (fis->command) {
 	case ATA_CMD_DOWNLOAD_MICRO:
@@ -2047,7 +2048,10 @@ static void mtip_set_timeout(struct host_to_dev_fis *fis, unsigned int *timeout)
 		break;
 	case ATA_CMD_SEC_ERASE_UNIT:
 	case 0xFC:
-		*timeout = 240000; /* 4 minutes */
+		if (erasemode)
+			*timeout = ((*(dd->port->identify + 90) * 2) * 60000);
+		else
+			*timeout = ((*(dd->port->identify + 89) * 2) * 60000);
 		break;
 	case ATA_CMD_STANDBYNOW1:
 		*timeout = 120000;  /* 2 minutes */
@@ -2090,6 +2094,7 @@ static int exec_drive_taskfile(struct driver_data *dd,
 	unsigned int transfer_size;
 	unsigned long task_file_data;
 	int intotal = outtotal + req_task->out_size;
+	int erasemode = 0;
 
 	taskout = req_task->out_size;
 	taskin = req_task->in_size;
@@ -2215,7 +2220,13 @@ static int exec_drive_taskfile(struct driver_data *dd,
 		fis.lba_hi,
 		fis.device);
 
-	mtip_set_timeout(&fis, &timeout);
+	/* check for erase mode support during secure erase.*/
+	if ((fis.command == ATA_CMD_SEC_ERASE_UNIT)
+					&& (outbuf[0] & MTIP_SEC_ERASE_MODE)) {
+		erasemode = 1;
+	}
+
+	mtip_set_timeout(dd, &fis, &timeout, erasemode);
 
 	/* Determine the correct transfer size.*/
 	if (force_single_sector)
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index 18627a1..8498e99 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -33,6 +33,9 @@
 /* offset of Device Control register in PCIe extended capabilites space */
 #define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET	0x48
 
+/* check for erase mode support during secure erase */
+#define MTIP_SEC_ERASE_MODE     0x3
+
 /* # of times to retry timed out/failed IOs */
 #define MTIP_MAX_RETRIES	2
 
-- 
1.7.1



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

* re: mtip32xx:Added appropriate timeout value for secure erase
@ 2012-09-28 12:25 Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2012-09-28 12:25 UTC (permalink / raw)
  To: smani; +Cc: Jens Axboe, linux-kernel

Hello Selvan Mani,

The patch 75e152877069: "mtip32xx:Added appropriate timeout value for 
secure erase" from Sep 27, 2012, leads to the following warning:
drivers/block/mtip32xx/mtip32xx.c:2222 exec_drive_taskfile()
	 error: potential NULL dereference 'outbuf'.

  2220          /* check for erase mode support during secure erase.*/
  2221          if ((fis.command == ATA_CMD_SEC_ERASE_UNIT)
  2222                                          && (outbuf[0] & MTIP_SEC_ERASE_MODE)) {
                                                    ^^^^^^
Smatch complains that if taskout is zero this is a NULL dereference.
Obviously that's not normal, but it looks like it might be possible.

  2223                  erasemode = 1;
  2224          }

regards,
dan carpenter


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

end of thread, other threads:[~2012-09-28 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27 12:57 mtip32xx:Added appropriate timeout value for secure erase Selvan Mani
2012-09-27 12:37 ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2012-09-28 12:25 Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox