Skip to content

Commit

Permalink
mtip32xx:Added appropriate timeout value for secure erase
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Selvan Mani authored and Jens Axboe committed Oct 30, 2012
1 parent 1f99957 commit 4453bc8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 15 additions & 4 deletions drivers/block/mtip32xx/mtip32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,16 +2035,20 @@ 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:
*timeout = 120000; /* 2 minutes */
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 */
Expand Down Expand Up @@ -2087,6 +2091,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;
Expand Down Expand Up @@ -2212,7 +2217,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)
Expand Down
3 changes: 3 additions & 0 deletions drivers/block/mtip32xx/mtip32xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4453bc8

Please sign in to comment.