[PATCH] mtip32xx: move error handling to service thread

2014-05-20 Thread Asai Thambi S P

Move error handling to service thread, and use mtip_set_timeout()
to set timeouts for HDIO_DRIVE_TASK and HDIO_DRIVE_CMD IOCTL commands.

Signed-off-by: Selvan Mani 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   71 +
 drivers/block/mtip32xx/mtip32xx.h |8 +++--
 2 files changed, 53 insertions(+), 26 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 4efc676..6124aa4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -620,7 +620,6 @@ static void mtip_handle_tfe(struct driver_data *dd)
 
port = dd->port;
 
-   /* Stop the timer to prevent command timeouts. */
set_bit(MTIP_PF_EH_ACTIVE_BIT, >flags);
 
if (test_bit(MTIP_PF_IC_ACTIVE_BIT, >flags) &&
@@ -855,8 +854,6 @@ static inline void mtip_process_legacy(struct driver_data 
*dd, u32 port_stat)
  */
 static inline void mtip_process_errors(struct driver_data *dd, u32 port_stat)
 {
-   if (likely(port_stat & (PORT_IRQ_TF_ERR | PORT_IRQ_IF_ERR)))
-   mtip_handle_tfe(dd);
 
if (unlikely(port_stat & PORT_IRQ_CONNECT)) {
dev_warn(>pdev->dev,
@@ -874,6 +871,12 @@ static inline void mtip_process_errors(struct driver_data 
*dd, u32 port_stat)
dev_warn(>pdev->dev,
"Port stat errors %x unhandled\n",
(port_stat & ~PORT_IRQ_HANDLED));
+   if (mtip_check_surprise_removal(dd->pdev))
+   return;
+   }
+   if (likely(port_stat & (PORT_IRQ_TF_ERR | PORT_IRQ_IF_ERR))) {
+   set_bit(MTIP_PF_EH_ACTIVE_BIT, >port->flags);
+   wake_up_interruptible(>port->svc_wait);
}
 }
 
@@ -1040,8 +1043,13 @@ static int mtip_quiesce_io(struct mtip_port *port, 
unsigned long timeout)
msleep(20);
continue; /* svc thd is actively issuing commands */
}
+
+   msleep(100);
+   if (mtip_check_surprise_removal(port->dd->pdev))
+   goto err_fault;
if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, >dd->dd_flag))
goto err_fault;
+
/*
 * Ignore s_active bit 0 of array element 0.
 * This bit will always be set
@@ -1052,8 +1060,6 @@ static int mtip_quiesce_io(struct mtip_port *port, 
unsigned long timeout)
 
if (!active)
break;
-
-   msleep(20);
} while (time_before(jiffies, to));
 
blk_mq_start_stopped_hw_queues(port->dd->queue, true);
@@ -1113,7 +1119,8 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
if (atomic == GFP_KERNEL) {
if (fis->command != ATA_CMD_STANDBYNOW1) {
/* wait for io to complete if non atomic */
-   if (mtip_quiesce_io(port, 5000) < 0) {
+   if (mtip_quiesce_io(port,
+   MTIP_QUIESCE_IO_TIMEOUT_MS) < 0) {
dev_warn(>pdev->dev,
"Failed to quiesce IO\n");
mtip_put_int_command(dd, int_cmd);
@@ -1161,9 +1168,9 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
 
if (atomic == GFP_KERNEL) {
/* Wait for the command to complete or timeout. */
-   if (wait_for_completion_interruptible_timeout(
+   if ((rv = wait_for_completion_interruptible_timeout(
,
-   msecs_to_jiffies(timeout)) <= 0) {
+   msecs_to_jiffies(timeout))) <= 0) {
if (rv == -ERESTARTSYS) { /* interrupted */
dev_err(>pdev->dev,
"Internal command [%02X] was 
interrupted after %lu ms\n",
@@ -1299,7 +1306,7 @@ static void mtip_set_timeout(struct driver_data *dd,
*timeout = 15000;  /* 15 seconds */
break;
default:
-   *timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
+   *timeout = MTIP_IOCTL_CMD_TIMEOUT_MS;
break;
}
 }
@@ -1351,7 +1358,7 @@ static int mtip_get_identify(struct mtip_port *port, void 
__user *user_buffer)
sizeof(u16) * ATA_ID_WORDS,
0,
GFP_KERNEL,
-   MTIP_INTERNAL_COMMAND_TIMEOUT_MS)
+   MTIP_INT_CMD_TIMEOUT_MS)
< 0) {
rv = -1;
goto out;
@@ -1483,7 +1490,7 @@ static int mtip_read_log_page(struct mtip_por

[PATCH] mtip32xx: move error handling to service thread

2014-05-20 Thread Asai Thambi S P

Move error handling to service thread, and use mtip_set_timeout()
to set timeouts for HDIO_DRIVE_TASK and HDIO_DRIVE_CMD IOCTL commands.

Signed-off-by: Selvan Mani sm...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   71 +
 drivers/block/mtip32xx/mtip32xx.h |8 +++--
 2 files changed, 53 insertions(+), 26 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 4efc676..6124aa4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -620,7 +620,6 @@ static void mtip_handle_tfe(struct driver_data *dd)
 
port = dd-port;
 
-   /* Stop the timer to prevent command timeouts. */
set_bit(MTIP_PF_EH_ACTIVE_BIT, port-flags);
 
if (test_bit(MTIP_PF_IC_ACTIVE_BIT, port-flags) 
@@ -855,8 +854,6 @@ static inline void mtip_process_legacy(struct driver_data 
*dd, u32 port_stat)
  */
 static inline void mtip_process_errors(struct driver_data *dd, u32 port_stat)
 {
-   if (likely(port_stat  (PORT_IRQ_TF_ERR | PORT_IRQ_IF_ERR)))
-   mtip_handle_tfe(dd);
 
if (unlikely(port_stat  PORT_IRQ_CONNECT)) {
dev_warn(dd-pdev-dev,
@@ -874,6 +871,12 @@ static inline void mtip_process_errors(struct driver_data 
*dd, u32 port_stat)
dev_warn(dd-pdev-dev,
Port stat errors %x unhandled\n,
(port_stat  ~PORT_IRQ_HANDLED));
+   if (mtip_check_surprise_removal(dd-pdev))
+   return;
+   }
+   if (likely(port_stat  (PORT_IRQ_TF_ERR | PORT_IRQ_IF_ERR))) {
+   set_bit(MTIP_PF_EH_ACTIVE_BIT, dd-port-flags);
+   wake_up_interruptible(dd-port-svc_wait);
}
 }
 
@@ -1040,8 +1043,13 @@ static int mtip_quiesce_io(struct mtip_port *port, 
unsigned long timeout)
msleep(20);
continue; /* svc thd is actively issuing commands */
}
+
+   msleep(100);
+   if (mtip_check_surprise_removal(port-dd-pdev))
+   goto err_fault;
if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, port-dd-dd_flag))
goto err_fault;
+
/*
 * Ignore s_active bit 0 of array element 0.
 * This bit will always be set
@@ -1052,8 +1060,6 @@ static int mtip_quiesce_io(struct mtip_port *port, 
unsigned long timeout)
 
if (!active)
break;
-
-   msleep(20);
} while (time_before(jiffies, to));
 
blk_mq_start_stopped_hw_queues(port-dd-queue, true);
@@ -1113,7 +1119,8 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
if (atomic == GFP_KERNEL) {
if (fis-command != ATA_CMD_STANDBYNOW1) {
/* wait for io to complete if non atomic */
-   if (mtip_quiesce_io(port, 5000)  0) {
+   if (mtip_quiesce_io(port,
+   MTIP_QUIESCE_IO_TIMEOUT_MS)  0) {
dev_warn(dd-pdev-dev,
Failed to quiesce IO\n);
mtip_put_int_command(dd, int_cmd);
@@ -1161,9 +1168,9 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
 
if (atomic == GFP_KERNEL) {
/* Wait for the command to complete or timeout. */
-   if (wait_for_completion_interruptible_timeout(
+   if ((rv = wait_for_completion_interruptible_timeout(
wait,
-   msecs_to_jiffies(timeout)) = 0) {
+   msecs_to_jiffies(timeout))) = 0) {
if (rv == -ERESTARTSYS) { /* interrupted */
dev_err(dd-pdev-dev,
Internal command [%02X] was 
interrupted after %lu ms\n,
@@ -1299,7 +1306,7 @@ static void mtip_set_timeout(struct driver_data *dd,
*timeout = 15000;  /* 15 seconds */
break;
default:
-   *timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
+   *timeout = MTIP_IOCTL_CMD_TIMEOUT_MS;
break;
}
 }
@@ -1351,7 +1358,7 @@ static int mtip_get_identify(struct mtip_port *port, void 
__user *user_buffer)
sizeof(u16) * ATA_ID_WORDS,
0,
GFP_KERNEL,
-   MTIP_INTERNAL_COMMAND_TIMEOUT_MS)
+   MTIP_INT_CMD_TIMEOUT_MS)
 0) {
rv = -1;
goto out;
@@ -1483,7 +1490,7 @@ static int mtip_read_log_page(struct mtip_port *port, u8 
page, u16 *buffer,
sectors * ATA_SECT_SIZE

mtip32xx: add open/close handlers in block device ops

2014-05-08 Thread Asai Thambi S P

Add open/close handlers to 'block_device_operations' instance.

Signed-off-by: Selvan Mani 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 7dc4fb4..bbbd83e 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4010,6 +4010,16 @@ static int mtip_block_getgeo(struct block_device *dev,
return 0;
 }
 
+int mtip_block_open(struct block_device *disk, fmode_t mode)
+{
+   return 0;
+}
+
+void mtip_block_release(struct gendisk *disk, fmode_t mode)
+{
+   return;
+}
+
 /*
  * Block device operation function.
  *
@@ -4017,6 +4027,8 @@ static int mtip_block_getgeo(struct block_device *dev,
  * layer.
  */
 static const struct block_device_operations mtip_block_ops = {
+   .open   = mtip_block_open,
+   .release= mtip_block_release,
.ioctl  = mtip_block_ioctl,
 #ifdef CONFIG_COMPAT
.compat_ioctl   = mtip_block_compat_ioctl,
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mtip32xx: fix incorrectly setting MTIP_DDF_SEC_LOCK_BIT

2014-05-08 Thread Asai Thambi S P

Fix incorrectly setting MTIP_DDF_SEC_LOCK_BIT

Signed-off-by: Selvan Mani 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |5 +
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index fb62446..7dc4fb4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1236,15 +1236,11 @@ static bool mtip_pause_ncq(struct mtip_port *port,
reply = port->rxfis + RX_FIS_D2H_REG;
task_file_data = readl(port->mmio+PORT_TFDATA);
 
-   if (fis->command == ATA_CMD_SEC_ERASE_UNIT)
-   clear_bit(MTIP_DDF_SEC_LOCK_BIT, >dd->dd_flag);
-
if ((task_file_data & 1))
return false;
 
if (fis->command == ATA_CMD_SEC_ERASE_PREP) {
set_bit(MTIP_PF_SE_ACTIVE_BIT, >flags);
-   set_bit(MTIP_DDF_SEC_LOCK_BIT, >dd->dd_flag);
port->ic_pause_timer = jiffies;
return true;
} else if ((fis->command == ATA_CMD_DOWNLOAD_MICRO) &&
@@ -1256,6 +1252,7 @@ static bool mtip_pause_ncq(struct mtip_port *port,
((fis->command == 0xFC) &&
(fis->features == 0x27 || fis->features == 0x72 ||
 fis->features == 0x62 || fis->features == 0x26))) {
+   clear_bit(MTIP_DDF_SEC_LOCK_BIT, >dd->dd_flag);
/* Com reset after secure erase or lowlevel format */
mtip_restart_port(port);
return false;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mtip32xx: fix incorrectly setting MTIP_DDF_SEC_LOCK_BIT

2014-05-08 Thread Asai Thambi S P

Fix incorrectly setting MTIP_DDF_SEC_LOCK_BIT

Signed-off-by: Selvan Mani sm...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |5 +
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index fb62446..7dc4fb4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1236,15 +1236,11 @@ static bool mtip_pause_ncq(struct mtip_port *port,
reply = port-rxfis + RX_FIS_D2H_REG;
task_file_data = readl(port-mmio+PORT_TFDATA);
 
-   if (fis-command == ATA_CMD_SEC_ERASE_UNIT)
-   clear_bit(MTIP_DDF_SEC_LOCK_BIT, port-dd-dd_flag);
-
if ((task_file_data  1))
return false;
 
if (fis-command == ATA_CMD_SEC_ERASE_PREP) {
set_bit(MTIP_PF_SE_ACTIVE_BIT, port-flags);
-   set_bit(MTIP_DDF_SEC_LOCK_BIT, port-dd-dd_flag);
port-ic_pause_timer = jiffies;
return true;
} else if ((fis-command == ATA_CMD_DOWNLOAD_MICRO) 
@@ -1256,6 +1252,7 @@ static bool mtip_pause_ncq(struct mtip_port *port,
((fis-command == 0xFC) 
(fis-features == 0x27 || fis-features == 0x72 ||
 fis-features == 0x62 || fis-features == 0x26))) {
+   clear_bit(MTIP_DDF_SEC_LOCK_BIT, port-dd-dd_flag);
/* Com reset after secure erase or lowlevel format */
mtip_restart_port(port);
return false;
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mtip32xx: add open/close handlers in block device ops

2014-05-08 Thread Asai Thambi S P

Add open/close handlers to 'block_device_operations' instance.

Signed-off-by: Selvan Mani sm...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 7dc4fb4..bbbd83e 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4010,6 +4010,16 @@ static int mtip_block_getgeo(struct block_device *dev,
return 0;
 }
 
+int mtip_block_open(struct block_device *disk, fmode_t mode)
+{
+   return 0;
+}
+
+void mtip_block_release(struct gendisk *disk, fmode_t mode)
+{
+   return;
+}
+
 /*
  * Block device operation function.
  *
@@ -4017,6 +4027,8 @@ static int mtip_block_getgeo(struct block_device *dev,
  * layer.
  */
 static const struct block_device_operations mtip_block_ops = {
+   .open   = mtip_block_open,
+   .release= mtip_block_release,
.ioctl  = mtip_block_ioctl,
 #ifdef CONFIG_COMPAT
.compat_ioctl   = mtip_block_compat_ioctl,
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


block: check for dying queue in generic_make_request()

2014-04-16 Thread Asai Thambi S P

Check for dying queue is in request queue interface, but not for direct use
of make_request().

When a mounted device is surprise removed, block drivers delete gendisk and
cleanup request queue. As the reference count is non-zero, these structures
continue to exist and any further I/O request is passed on to block drivers.
With respect to the block driver, the device is removed and cleaned up the
data structures. This check will stop I/O to a non-existent device at the
block layer.

Signed-off-by: Asai Thambi S P 
---
 block/blk-core.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index e45b321..cec6bf4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1713,7 +1713,7 @@ generic_make_request_checks(struct bio *bio)
goto end_io;
 
q = bdev_get_queue(bio->bi_bdev);
-   if (unlikely(!q)) {
+   if (unlikely(!q || blk_queue_dying(q))) {
printk(KERN_ERR
   "generic_make_request: Trying to access "
"nonexistent block-device %s (%Lu)\n",
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mtip32xx: Remove dfs_parent after pci unregister

2014-04-16 Thread Asai Thambi S P

In module exit, dfs_parent and it's subtree were removed before unregistering
with pci. When debugfs entry for each device is attempted to remove in
pci_remove() context, they don't exist, as dfs_parent and its children were
already ripped apart.

Modified to first unregister with pci and then remove dfs_parent.

Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 51628eb..27641bc 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4939,13 +4939,13 @@ static int __init mtip_init(void)
  */
 static void __exit mtip_exit(void)
 {
-   debugfs_remove_recursive(dfs_parent);
-
/* Release the allocated major block device number. */
unregister_blkdev(mtip_major, MTIP_DRV_NAME);
 
/* Unregister the PCI driver. */
pci_unregister_driver(_pci_driver);
+
+   debugfs_remove_recursive(dfs_parent);
 }
 
 MODULE_AUTHOR("Micron Technology, Inc");
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mtip32xx: Increase timeout for STANDBY IMMEDIATE command

2014-04-16 Thread Asai Thambi S P

Increased timeout for STANDBY IMMEDIATE command to 2 minutes.

Signed-off-by: Selvan Mani 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   66 +++-
 1 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 59c5abe..51628eb 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1529,6 +1529,37 @@ static inline void ata_swap_string(u16 *buf, unsigned 
int len)
be16_to_cpus([i]);
 }
 
+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 = 12; /* 2 minutes */
+   break;
+   case ATA_CMD_SEC_ERASE_UNIT:
+   case 0xFC:
+   if (erasemode)
+   *timeout = ((*(dd->port->identify + 90) * 2) * 6);
+   else
+   *timeout = ((*(dd->port->identify + 89) * 2) * 6);
+   break;
+   case ATA_CMD_STANDBYNOW1:
+   *timeout = 12;  /* 2 minutes */
+   break;
+   case 0xF7:
+   case 0xFA:
+   *timeout = 6;  /* 60 seconds */
+   break;
+   case ATA_CMD_SMART:
+   *timeout = 15000;  /* 15 seconds */
+   break;
+   default:
+   *timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
+   break;
+   }
+}
+
 /*
  * Request the device identity information.
  *
@@ -1644,6 +1675,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
int rv;
struct host_to_dev_fis  fis;
unsigned long start;
+   unsigned int timeout;
 
/* Build the FIS. */
memset(, 0, sizeof(struct host_to_dev_fis));
@@ -1651,6 +1683,8 @@ static int mtip_standby_immediate(struct mtip_port *port)
fis.opts= 1 << 7;
fis.command = ATA_CMD_STANDBYNOW1;
 
+   mtip_set_timeout(port->dd, , , 0);
+
start = jiffies;
rv = mtip_exec_internal_command(port,
,
@@ -1659,7 +1693,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
0,
0,
GFP_ATOMIC,
-   15000);
+   timeout);
dbg_printk(MTIP_DRV_NAME "Time taken to complete standby cmd: %d ms\n",
jiffies_to_msecs(jiffies - start));
if (rv)
@@ -2202,36 +2236,6 @@ static unsigned int implicit_sector(unsigned char 
command,
}
return rv;
 }
-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 = 12; /* 2 minutes */
-   break;
-   case ATA_CMD_SEC_ERASE_UNIT:
-   case 0xFC:
-   if (erasemode)
-   *timeout = ((*(dd->port->identify + 90) * 2) * 6);
-   else
-   *timeout = ((*(dd->port->identify + 89) * 2) * 6);
-   break;
-   case ATA_CMD_STANDBYNOW1:
-   *timeout = 12;  /* 2 minutes */
-   break;
-   case 0xF7:
-   case 0xFA:
-   *timeout = 6;  /* 60 seconds */
-   break;
-   case ATA_CMD_SMART:
-   *timeout = 15000;  /* 15 seconds */
-   break;
-   default:
-   *timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
-   break;
-   }
-}
 
 /*
  * Executes a taskfile
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mtip32xx: Increase timeout for STANDBY IMMEDIATE command

2014-04-16 Thread Asai Thambi S P

Increased timeout for STANDBY IMMEDIATE command to 2 minutes.

Signed-off-by: Selvan Mani sm...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   66 +++-
 1 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 59c5abe..51628eb 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1529,6 +1529,37 @@ static inline void ata_swap_string(u16 *buf, unsigned 
int len)
be16_to_cpus(buf[i]);
 }
 
+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 = 12; /* 2 minutes */
+   break;
+   case ATA_CMD_SEC_ERASE_UNIT:
+   case 0xFC:
+   if (erasemode)
+   *timeout = ((*(dd-port-identify + 90) * 2) * 6);
+   else
+   *timeout = ((*(dd-port-identify + 89) * 2) * 6);
+   break;
+   case ATA_CMD_STANDBYNOW1:
+   *timeout = 12;  /* 2 minutes */
+   break;
+   case 0xF7:
+   case 0xFA:
+   *timeout = 6;  /* 60 seconds */
+   break;
+   case ATA_CMD_SMART:
+   *timeout = 15000;  /* 15 seconds */
+   break;
+   default:
+   *timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
+   break;
+   }
+}
+
 /*
  * Request the device identity information.
  *
@@ -1644,6 +1675,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
int rv;
struct host_to_dev_fis  fis;
unsigned long start;
+   unsigned int timeout;
 
/* Build the FIS. */
memset(fis, 0, sizeof(struct host_to_dev_fis));
@@ -1651,6 +1683,8 @@ static int mtip_standby_immediate(struct mtip_port *port)
fis.opts= 1  7;
fis.command = ATA_CMD_STANDBYNOW1;
 
+   mtip_set_timeout(port-dd, fis, timeout, 0);
+
start = jiffies;
rv = mtip_exec_internal_command(port,
fis,
@@ -1659,7 +1693,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
0,
0,
GFP_ATOMIC,
-   15000);
+   timeout);
dbg_printk(MTIP_DRV_NAME Time taken to complete standby cmd: %d ms\n,
jiffies_to_msecs(jiffies - start));
if (rv)
@@ -2202,36 +2236,6 @@ static unsigned int implicit_sector(unsigned char 
command,
}
return rv;
 }
-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 = 12; /* 2 minutes */
-   break;
-   case ATA_CMD_SEC_ERASE_UNIT:
-   case 0xFC:
-   if (erasemode)
-   *timeout = ((*(dd-port-identify + 90) * 2) * 6);
-   else
-   *timeout = ((*(dd-port-identify + 89) * 2) * 6);
-   break;
-   case ATA_CMD_STANDBYNOW1:
-   *timeout = 12;  /* 2 minutes */
-   break;
-   case 0xF7:
-   case 0xFA:
-   *timeout = 6;  /* 60 seconds */
-   break;
-   case ATA_CMD_SMART:
-   *timeout = 15000;  /* 15 seconds */
-   break;
-   default:
-   *timeout = MTIP_IOCTL_COMMAND_TIMEOUT_MS;
-   break;
-   }
-}
 
 /*
  * Executes a taskfile
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mtip32xx: Remove dfs_parent after pci unregister

2014-04-16 Thread Asai Thambi S P

In module exit, dfs_parent and it's subtree were removed before unregistering
with pci. When debugfs entry for each device is attempted to remove in
pci_remove() context, they don't exist, as dfs_parent and its children were
already ripped apart.

Modified to first unregister with pci and then remove dfs_parent.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 51628eb..27641bc 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4939,13 +4939,13 @@ static int __init mtip_init(void)
  */
 static void __exit mtip_exit(void)
 {
-   debugfs_remove_recursive(dfs_parent);
-
/* Release the allocated major block device number. */
unregister_blkdev(mtip_major, MTIP_DRV_NAME);
 
/* Unregister the PCI driver. */
pci_unregister_driver(mtip_pci_driver);
+
+   debugfs_remove_recursive(dfs_parent);
 }
 
 MODULE_AUTHOR(Micron Technology, Inc);
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


block: check for dying queue in generic_make_request()

2014-04-16 Thread Asai Thambi S P

Check for dying queue is in request queue interface, but not for direct use
of make_request().

When a mounted device is surprise removed, block drivers delete gendisk and
cleanup request queue. As the reference count is non-zero, these structures
continue to exist and any further I/O request is passed on to block drivers.
With respect to the block driver, the device is removed and cleaned up the
data structures. This check will stop I/O to a non-existent device at the
block layer.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 block/blk-core.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index e45b321..cec6bf4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1713,7 +1713,7 @@ generic_make_request_checks(struct bio *bio)
goto end_io;
 
q = bdev_get_queue(bio-bi_bdev);
-   if (unlikely(!q)) {
+   if (unlikely(!q || blk_queue_dying(q))) {
printk(KERN_ERR
   generic_make_request: Trying to access 
nonexistent block-device %s (%Lu)\n,
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtip32xx: Fix incorrectly releasing a reference to pci_dev in pci_remove()

2014-03-14 Thread Asai Thambi S P

Fix incorrectly releasing a reference to pci_dev in pci_remove()

Signed-off-by: Rajesh Kumar S 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 624e9d9..54ad4df 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4737,8 +4737,6 @@ static void mtip_pci_remove(struct pci_dev *pdev)
 
pcim_iounmap_regions(pdev, 1 << MTIP_ABAR);
pci_set_drvdata(pdev, NULL);
-   pci_dev_put(pdev);
-
 }
 
 /*
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtip32xx: Fix incorrectly releasing a reference to pci_dev in pci_remove()

2014-03-14 Thread Asai Thambi S P

Fix incorrectly releasing a reference to pci_dev in pci_remove()

Signed-off-by: Rajesh Kumar S rsamban...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 624e9d9..54ad4df 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4737,8 +4737,6 @@ static void mtip_pci_remove(struct pci_dev *pdev)
 
pcim_iounmap_regions(pdev, 1  MTIP_ABAR);
pci_set_drvdata(pdev, NULL);
-   pci_dev_put(pdev);
-
 }
 
 /*
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems

2014-03-13 Thread Asai Thambi S P

A hardware quirk in P320h/P420m interfere with PCIe transactions on some
AMD chipsets, making P320h/P420m unusable. This workaround is to disable
ERO and NoSnoop bits in the parent and root complex for normal functioning
of these devices

NOTE: This workaround is specific to AMD chipset with a PCIe upstream
device with device id 0x5aXX

Signed-off-by: Asai Thambi S P 
Signed-off-by: Sam Bradshaw 
---
 drivers/block/mtip32xx/mtip32xx.c |   53 +
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 624e9d9..8c462d3 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4479,6 +4479,57 @@ static DEFINE_HANDLER(5);
 static DEFINE_HANDLER(6);
 static DEFINE_HANDLER(7);
 
+static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev 
*pdev)
+{
+   int pos;
+   unsigned short pcie_dev_ctrl;
+
+   pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+   if (pos) {
+   pci_read_config_word(pdev,
+   pos + PCI_EXP_DEVCTL,
+   _dev_ctrl);
+   if (pcie_dev_ctrl & (1 << 11) ||
+   pcie_dev_ctrl & (1 << 4)) {
+   dev_info(>pdev->dev,
+   "Disabling ERO/No-Snoop on bridge device 
%04x:%04x\n",
+   pdev->vendor, pdev->device);
+   pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
+   PCI_EXP_DEVCTL_RELAX_EN);
+   pci_write_config_word(pdev,
+   pos + PCI_EXP_DEVCTL,
+   pcie_dev_ctrl);
+   }
+   }
+}
+
+static void mtip_fix_ero_nosnoop(struct driver_data *dd, struct pci_dev *pdev)
+{
+   /*
+* This workaround is specific to AMD/ATI chipset with a PCI upstream
+* device with device id 0x5aXX
+*/
+   if (pdev->bus && pdev->bus->self) {
+   if (pdev->bus->self->vendor == PCI_VENDOR_ID_ATI &&
+   ((pdev->bus->self->device & 0xff00) == 0x5a00)) {
+   mtip_disable_link_opts(dd, pdev->bus->self);
+   } else {
+   /* Check further up the topology */
+   struct pci_dev *parent_dev = pdev->bus->self;
+   if (parent_dev->bus &&
+   parent_dev->bus->parent &&
+   parent_dev->bus->parent->self &&
+   parent_dev->bus->parent->self->vendor ==
+PCI_VENDOR_ID_ATI &&
+   (parent_dev->bus->parent->self->device &
+   0xff00) == 0x5a00) {
+   mtip_disable_link_opts(dd,
+   parent_dev->bus->parent->self);
+   }
+   }
+   }
+}
+
 /*
  * Called for each supported PCI device detected.
  *
@@ -4630,6 +4681,8 @@ static int mtip_pci_probe(struct pci_dev *pdev,
goto msi_initialize_err;
}
 
+   mtip_fix_ero_nosnoop(dd, pdev);
+
/* Initialize the block layer. */
rv = mtip_block_initialize(dd);
if (rv < 0) {
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtip32xx: Fix ERO and NoSnoop values in PCIe upstream on AMD systems

2014-03-13 Thread Asai Thambi S P

A hardware quirk in P320h/P420m interfere with PCIe transactions on some
AMD chipsets, making P320h/P420m unusable. This workaround is to disable
ERO and NoSnoop bits in the parent and root complex for normal functioning
of these devices

NOTE: This workaround is specific to AMD chipset with a PCIe upstream
device with device id 0x5aXX

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Sam Bradshaw sbrads...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   53 +
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 624e9d9..8c462d3 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4479,6 +4479,57 @@ static DEFINE_HANDLER(5);
 static DEFINE_HANDLER(6);
 static DEFINE_HANDLER(7);
 
+static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev 
*pdev)
+{
+   int pos;
+   unsigned short pcie_dev_ctrl;
+
+   pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+   if (pos) {
+   pci_read_config_word(pdev,
+   pos + PCI_EXP_DEVCTL,
+   pcie_dev_ctrl);
+   if (pcie_dev_ctrl  (1  11) ||
+   pcie_dev_ctrl  (1  4)) {
+   dev_info(dd-pdev-dev,
+   Disabling ERO/No-Snoop on bridge device 
%04x:%04x\n,
+   pdev-vendor, pdev-device);
+   pcie_dev_ctrl = ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
+   PCI_EXP_DEVCTL_RELAX_EN);
+   pci_write_config_word(pdev,
+   pos + PCI_EXP_DEVCTL,
+   pcie_dev_ctrl);
+   }
+   }
+}
+
+static void mtip_fix_ero_nosnoop(struct driver_data *dd, struct pci_dev *pdev)
+{
+   /*
+* This workaround is specific to AMD/ATI chipset with a PCI upstream
+* device with device id 0x5aXX
+*/
+   if (pdev-bus  pdev-bus-self) {
+   if (pdev-bus-self-vendor == PCI_VENDOR_ID_ATI 
+   ((pdev-bus-self-device  0xff00) == 0x5a00)) {
+   mtip_disable_link_opts(dd, pdev-bus-self);
+   } else {
+   /* Check further up the topology */
+   struct pci_dev *parent_dev = pdev-bus-self;
+   if (parent_dev-bus 
+   parent_dev-bus-parent 
+   parent_dev-bus-parent-self 
+   parent_dev-bus-parent-self-vendor ==
+PCI_VENDOR_ID_ATI 
+   (parent_dev-bus-parent-self-device 
+   0xff00) == 0x5a00) {
+   mtip_disable_link_opts(dd,
+   parent_dev-bus-parent-self);
+   }
+   }
+   }
+}
+
 /*
  * Called for each supported PCI device detected.
  *
@@ -4630,6 +4681,8 @@ static int mtip_pci_probe(struct pci_dev *pdev,
goto msi_initialize_err;
}
 
+   mtip_fix_ero_nosnoop(dd, pdev);
+
/* Initialize the block layer. */
rv = mtip_block_initialize(dd);
if (rv  0) {
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: mtip32xx blk-mq status?

2014-02-26 Thread Asai Thambi S P
On 2/26/2014 11:29 AM, Christoph Hellwig wrote:
> Hi all,
> 
> with blk-mq stabilizing in mainline and Jens using mtip32xx as tje major
> example drivers in the past is there any progress on getting the
> conversion finished and merged?

We are working on few changes in mtip32xx. After that, we will get to
blk-mq merge.

--
Regards,
Asai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: mtip32xx blk-mq status?

2014-02-26 Thread Asai Thambi S P
On 2/26/2014 11:29 AM, Christoph Hellwig wrote:
 Hi all,
 
 with blk-mq stabilizing in mainline and Jens using mtip32xx as tje major
 example drivers in the past is there any progress on getting the
 conversion finished and merged?

We are working on few changes in mtip32xx. After that, we will get to
blk-mq merge.

--
Regards,
Asai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtip32xx: Reduce the number of unaligned writes to 2

2014-02-18 Thread Asai Thambi S P
Hi Jens,

Please include this for 3.14. It is a trivial change, hope it should be ok.

--
Regards,
Asai


After several experiments, deduced the the optimal number of unaligned
writes to be 2. Changing the value accordingly.

Signed-off-by: Asai Thambi S P 
Signed-off-by: Sam Bradshaw 
---
 drivers/block/mtip32xx/mtip32xx.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.h
b/drivers/block/mtip32xx/mtip32xx.h
index b52e9a6..54174cb 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -53,7 +53,7 @@
 #define MTIP_FTL_REBUILD_TIMEOUT_MS240

 /* unaligned IO handling */
-#define MTIP_MAX_UNALIGNED_SLOTS   8
+#define MTIP_MAX_UNALIGNED_SLOTS   2

 /* Macro to extract the tag bit number from a tag value. */
 #define MTIP_TAG_BIT(tag)  (tag & 0x1F)
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtip32xx: Reduce the number of unaligned writes to 2

2014-02-18 Thread Asai Thambi S P
Hi Jens,

Please include this for 3.14. It is a trivial change, hope it should be ok.

--
Regards,
Asai


After several experiments, deduced the the optimal number of unaligned
writes to be 2. Changing the value accordingly.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Sam Bradshaw sbrads...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.h
b/drivers/block/mtip32xx/mtip32xx.h
index b52e9a6..54174cb 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -53,7 +53,7 @@
 #define MTIP_FTL_REBUILD_TIMEOUT_MS240

 /* unaligned IO handling */
-#define MTIP_MAX_UNALIGNED_SLOTS   8
+#define MTIP_MAX_UNALIGNED_SLOTS   2

 /* Macro to extract the tag bit number from a tag value. */
 #define MTIP_TAG_BIT(tag)  (tag  0x1F)
--
1.7.1
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions

2013-09-17 Thread Asai Thambi S P

On 07/12/2013 3:59 PM, Asai Thambi S P wrote:

On 5/23/2013 2:23 PM, David Milburn wrote:


Dynamically allocate buf to prevent warnings:

drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:
drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes 
is larger than 1024 bytes
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes 
is larger than 1024 bytes
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes 
is larger than 1024 bytes

Signed-off-by: David Milburn 


Acked-by: Asai Thambi S P 


Jens,

Please include this patch too for 3.12.

--
Regards,
Asai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions

2013-09-17 Thread Asai Thambi S P

On 07/12/2013 3:59 PM, Asai Thambi S P wrote:

On 5/23/2013 2:23 PM, David Milburn wrote:


Dynamically allocate buf to prevent warnings:

drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:
drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes 
is larger than 1024 bytes
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes 
is larger than 1024 bytes
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes 
is larger than 1024 bytes

Signed-off-by: David Milburn dmilb...@redhat.com


Acked-by: Asai Thambi S P asamymuth...@micron.com


Jens,

Please include this patch too for 3.12.

--
Regards,
Asai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: powerpc allmodconfig build broken due to commit 15863ff3b (powerpc: Make chip-id information available to userspace)

2013-09-09 Thread Asai Thambi S P

On 09/08/2013 5:28 PM, Guenter Roeck wrote:

Hi all,

powerpc allmodconfig build on the latest upstream kernel results in:

ERROR: ".cpu_to_chip_id" [drivers/block/mtip32xx/mtip32xx.ko] undefined!

This is due to commit 15863ff3b (powerpc: Make chip-id information 
available to userspace).

Not surprising, as cpu_to_chip_id() is not exported.


Apart from the above error, I have a concern on the patch, purely based on the 
commit message.
(to be honest, I am not familiar with the ppc architecture)

Commit message of 15863ff3b has the following text.

**
So far "/sys/devices/system/cpu/cpuX/topology/physical_package_id"
was always default (-1) on ppc64 architecture.

Now, some systems have an ibm,chip-id property in the cpu nodes in
the device tree. On these systems, we now use this information to
display physical_package_id
**

Shouldn't the new definition of "topology_physical_package_id" apply only to 
those systems supporting ibm,chip-id property?


Reverting this commit fixes the problem. Any good idea how to fix it 
for real ?


Guenter
--
To unsubscribe from this list: send the line "unsubscribe 
linux-kernel" in

the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: powerpc allmodconfig build broken due to commit 15863ff3b (powerpc: Make chip-id information available to userspace)

2013-09-09 Thread Asai Thambi S P

On 09/08/2013 5:28 PM, Guenter Roeck wrote:

Hi all,

powerpc allmodconfig build on the latest upstream kernel results in:

ERROR: .cpu_to_chip_id [drivers/block/mtip32xx/mtip32xx.ko] undefined!

This is due to commit 15863ff3b (powerpc: Make chip-id information 
available to userspace).

Not surprising, as cpu_to_chip_id() is not exported.


Apart from the above error, I have a concern on the patch, purely based on the 
commit message.
(to be honest, I am not familiar with the ppc architecture)

Commit message of 15863ff3b has the following text.

**
So far /sys/devices/system/cpu/cpuX/topology/physical_package_id
was always default (-1) on ppc64 architecture.

Now, some systems have an ibm,chip-id property in the cpu nodes in
the device tree. On these systems, we now use this information to
display physical_package_id
**

Shouldn't the new definition of topology_physical_package_id apply only to 
those systems supporting ibm,chip-id property?


Reverting this commit fixes the problem. Any good idea how to fix it 
for real ?


Guenter
--
To unsubscribe from this list: send the line unsubscribe 
linux-kernel in

the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions

2013-07-12 Thread Asai Thambi S P
On 5/23/2013 2:23 PM, David Milburn wrote:

> Dynamically allocate buf to prevent warnings:
> 
> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:
> drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes 
> is larger than 1024 bytes
> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
> drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes 
> is larger than 1024 bytes
> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
> drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes 
> is larger than 1024 bytes
> 
> Signed-off-by: David Milburn 


Acked-by: Asai Thambi S P 

> ---
>  drivers/block/mtip32xx/mtip32xx.c |   47 
> +
>  1 files changed, 37 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/block/mtip32xx/mtip32xx.c 
> b/drivers/block/mtip32xx/mtip32xx.c
> index 847107e..baa0996 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -2806,34 +2806,51 @@ static ssize_t show_device_status(struct 
> device_driver *drv, char *buf)
>  static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
>   size_t len, loff_t *offset)
>  {
> + struct driver_data *dd =  (struct driver_data *)f->private_data;
>   int size = *offset;
> - char buf[MTIP_DFS_MAX_BUF_SIZE];
> + char *buf;
> + int rv = 0;
>  
>   if (!len || *offset)
>   return 0;
>  
> + buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
> + if (!buf) {
> + dev_err(>pdev->dev,
> + "Memory allocation: status buffer\n");
> + return -ENOMEM;
> + }
> +
>   size += show_device_status(NULL, buf);
>  
>   *offset = size <= len ? size : len;
>   size = copy_to_user(ubuf, buf, *offset);
>   if (size)
> - return -EFAULT;
> + rv = -EFAULT;
>  
> - return *offset;
> + kfree(buf);
> + return rv ? rv : *offset;
>  }
>  
>  static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
> size_t len, loff_t *offset)
>  {
>   struct driver_data *dd =  (struct driver_data *)f->private_data;
> - char buf[MTIP_DFS_MAX_BUF_SIZE];
> + char *buf;
>   u32 group_allocated;
>   int size = *offset;
> - int n;
> + int n, rv = 0;
>  
>   if (!len || size)
>   return 0;
>  
> + buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
> + if (!buf) {
> + dev_err(>pdev->dev,
> + "Memory allocation: register buffer\n");
> + return -ENOMEM;
> + }
> +
>   size += sprintf([size], "H/ S ACTive  : [ 0x");
>  
>   for (n = dd->slot_groups-1; n >= 0; n--)
> @@ -2888,21 +2905,30 @@ static ssize_t mtip_hw_read_registers(struct file *f, 
> char __user *ubuf,
>   *offset = size <= len ? size : len;
>   size = copy_to_user(ubuf, buf, *offset);
>   if (size)
> - return -EFAULT;
> + rv = -EFAULT;
>  
> - return *offset;
> + kfree(buf);
> + return rv ? rv : *offset;
>  }
>  
>  static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
> size_t len, loff_t *offset)
>  {
>   struct driver_data *dd =  (struct driver_data *)f->private_data;
> - char buf[MTIP_DFS_MAX_BUF_SIZE];
> + char *buf;
>   int size = *offset;
> + int rv = 0;
>  
>   if (!len || size)
>   return 0;
>  
> + buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
> + if (!buf) {
> + dev_err(>pdev->dev,
> + "Memory allocation: flag buffer\n");
> + return -ENOMEM;
> + }
> +
>   size += sprintf([size], "Flag-port : [ %08lX ]\n",
>   dd->port->flags);
>   size += sprintf([size], "Flag-dd   : [ %08lX ]\n",
> @@ -2911,9 +2937,10 @@ static ssize_t mtip_hw_read_flags(struct file *f, char 
> __user *ubuf,
>   *offset = size <= len ? size : len;
>   size = copy_to_user(ubuf, buf, *offset);
>   if (size)
> - return -EFAULT;
> + rv = -EFAULT;
>  
> - return *offset;
> + kfree(buf);
> + return rv ? rv : *offset;
>  }
>  
>  static const struct file_operations mtip_device_status_fops = {
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions

2013-07-12 Thread Asai Thambi S P
On 5/23/2013 2:23 PM, David Milburn wrote:

 Dynamically allocate buf to prevent warnings:
 
 drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:
 drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes 
 is larger than 1024 bytes
 drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
 drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes 
 is larger than 1024 bytes
 drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
 drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes 
 is larger than 1024 bytes
 
 Signed-off-by: David Milburn dmilb...@redhat.com


Acked-by: Asai Thambi S P asamymuth...@micron.com

 ---
  drivers/block/mtip32xx/mtip32xx.c |   47 
 +
  1 files changed, 37 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/block/mtip32xx/mtip32xx.c 
 b/drivers/block/mtip32xx/mtip32xx.c
 index 847107e..baa0996 100644
 --- a/drivers/block/mtip32xx/mtip32xx.c
 +++ b/drivers/block/mtip32xx/mtip32xx.c
 @@ -2806,34 +2806,51 @@ static ssize_t show_device_status(struct 
 device_driver *drv, char *buf)
  static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
   size_t len, loff_t *offset)
  {
 + struct driver_data *dd =  (struct driver_data *)f-private_data;
   int size = *offset;
 - char buf[MTIP_DFS_MAX_BUF_SIZE];
 + char *buf;
 + int rv = 0;
  
   if (!len || *offset)
   return 0;
  
 + buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
 + if (!buf) {
 + dev_err(dd-pdev-dev,
 + Memory allocation: status buffer\n);
 + return -ENOMEM;
 + }
 +
   size += show_device_status(NULL, buf);
  
   *offset = size = len ? size : len;
   size = copy_to_user(ubuf, buf, *offset);
   if (size)
 - return -EFAULT;
 + rv = -EFAULT;
  
 - return *offset;
 + kfree(buf);
 + return rv ? rv : *offset;
  }
  
  static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
 size_t len, loff_t *offset)
  {
   struct driver_data *dd =  (struct driver_data *)f-private_data;
 - char buf[MTIP_DFS_MAX_BUF_SIZE];
 + char *buf;
   u32 group_allocated;
   int size = *offset;
 - int n;
 + int n, rv = 0;
  
   if (!len || size)
   return 0;
  
 + buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
 + if (!buf) {
 + dev_err(dd-pdev-dev,
 + Memory allocation: register buffer\n);
 + return -ENOMEM;
 + }
 +
   size += sprintf(buf[size], H/ S ACTive  : [ 0x);
  
   for (n = dd-slot_groups-1; n = 0; n--)
 @@ -2888,21 +2905,30 @@ static ssize_t mtip_hw_read_registers(struct file *f, 
 char __user *ubuf,
   *offset = size = len ? size : len;
   size = copy_to_user(ubuf, buf, *offset);
   if (size)
 - return -EFAULT;
 + rv = -EFAULT;
  
 - return *offset;
 + kfree(buf);
 + return rv ? rv : *offset;
  }
  
  static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
 size_t len, loff_t *offset)
  {
   struct driver_data *dd =  (struct driver_data *)f-private_data;
 - char buf[MTIP_DFS_MAX_BUF_SIZE];
 + char *buf;
   int size = *offset;
 + int rv = 0;
  
   if (!len || size)
   return 0;
  
 + buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
 + if (!buf) {
 + dev_err(dd-pdev-dev,
 + Memory allocation: flag buffer\n);
 + return -ENOMEM;
 + }
 +
   size += sprintf(buf[size], Flag-port : [ %08lX ]\n,
   dd-port-flags);
   size += sprintf(buf[size], Flag-dd   : [ %08lX ]\n,
 @@ -2911,9 +2937,10 @@ static ssize_t mtip_hw_read_flags(struct file *f, char 
 __user *ubuf,
   *offset = size = len ? size : len;
   size = copy_to_user(ubuf, buf, *offset);
   if (size)
 - return -EFAULT;
 + rv = -EFAULT;
  
 - return *offset;
 + kfree(buf);
 + return rv ? rv : *offset;
  }
  
  static const struct file_operations mtip_device_status_fops = {
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
 
 


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mtip32xx: Add SRSI support

2013-05-10 Thread Asai Thambi S P
On 5/9/2013 11:48 PM, Asai Thambi S P wrote:

> 
> This patch add support for SRSI(Surprise Removal Surprise Insertion).

Jens,

Forgot to include. This patch is for 3.10

> 
> Approach:
> -
> Surprise Removal:
> -
> On surprise removal of the device, gendisk, request queue, device index, sysfs
> entries, etc are retained as long as device is in use - mounted filesystem,
> device opened by an application, etc. The service thread breaks out of the 
> main
> while loop, waits for pci remove to exit, and then waits for device to become
> free. When there no holders of the device, service thread cleans up the block
> and device related stuff and returns.
> 
> Surprise Insertion:
> ---
> No change, this scenario follows the normal pci probe() function flow.
> 
> Signed-off-by: Asai Thambi S P 
> ---
>  drivers/block/mtip32xx/mtip32xx.c |  453 
> ++---
>  drivers/block/mtip32xx/mtip32xx.h |   18 +-
>  2 files changed, 289 insertions(+), 182 deletions(-)
> 
> diff --git a/drivers/block/mtip32xx/mtip32xx.c 
> b/drivers/block/mtip32xx/mtip32xx.c
> index 847107e..aab28a4 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -126,64 +126,30 @@ struct mtip_compat_ide_task_request_s {
>  static bool mtip_check_surprise_removal(struct pci_dev *pdev)
>  {
>   u16 vendor_id = 0;
> + struct driver_data *dd = pci_get_drvdata(pdev);
> +
> + if (dd->sr)
> + return true;
>  
> /* Read the vendorID from the configuration space */
>   pci_read_config_word(pdev, 0x00, _id);
> - if (vendor_id == 0x)
> + if (vendor_id == 0x) {
> + dd->sr = true;
> + if (dd->queue)
> + set_bit(QUEUE_FLAG_DEAD, >queue->queue_flags);
> + else
> + dev_warn(>pdev->dev,
> + "%s: dd->queue is NULL\n", __func__);
> + if (dd->port) {
> + set_bit(MTIP_PF_SR_CLEANUP_BIT, >port->flags);
> + wake_up_interruptible(>port->svc_wait);
> + } else
> + dev_warn(>pdev->dev,
> + "%s: dd->port is NULL\n", __func__);
>   return true; /* device removed */
> -
> - return false; /* device present */
> -}
> -
> -/*
> - * This function is called for clean the pending command in the
> - * command slot during the surprise removal of device and return
> - * error to the upper layer.
> - *
> - * @dd Pointer to the DRIVER_DATA structure.
> - *
> - * return value
> - *   None
> - */
> -static void mtip_command_cleanup(struct driver_data *dd)
> -{
> - int group = 0, commandslot = 0, commandindex = 0;
> - struct mtip_cmd *command;
> - struct mtip_port *port = dd->port;
> - static int in_progress;
> -
> - if (in_progress)
> - return;
> -
> - in_progress = 1;
> -
> - for (group = 0; group < 4; group++) {
> - for (commandslot = 0; commandslot < 32; commandslot++) {
> - if (!(port->allocated[group] & (1 << commandslot)))
> - continue;
> -
> - commandindex = group << 5 | commandslot;
> - command = >commands[commandindex];
> -
> - if (atomic_read(>active)
> - && (command->async_callback)) {
> - command->async_callback(command->async_data,
> - -ENODEV);
> - command->async_callback = NULL;
> - command->async_data = NULL;
> - }
> -
> - dma_unmap_sg(>dd->pdev->dev,
> - command->sg,
> - command->scatter_ents,
> - command->direction);
> - }
>   }
>  
> - up(>cmd_slot);
> -
> - set_bit(MTIP_DDF_CLEANUP_BIT, >dd_flag);
> - in_progress = 0;
> + return false; /* device present */
>  }
>  
>  /*
> @@ -222,10 +188,7 @@ static int get_slot(struct mtip_port *port)
>   }
>   dev_warn(>dd->pdev->dev, "Failed to get a tag.\n");
>  
> - if (mtip_check_surprise_removal(port->dd->pdev)) {
> - /* Device not present, clean outstanding commands */
> - mtip_command_cleanup(port->dd);
> - 

Re: [PATCH] mtip32xx: Add SRSI support

2013-05-10 Thread Asai Thambi S P
On 5/9/2013 11:48 PM, Asai Thambi S P wrote:

 
 This patch add support for SRSI(Surprise Removal Surprise Insertion).

Jens,

Forgot to include. This patch is for 3.10

 
 Approach:
 -
 Surprise Removal:
 -
 On surprise removal of the device, gendisk, request queue, device index, sysfs
 entries, etc are retained as long as device is in use - mounted filesystem,
 device opened by an application, etc. The service thread breaks out of the 
 main
 while loop, waits for pci remove to exit, and then waits for device to become
 free. When there no holders of the device, service thread cleans up the block
 and device related stuff and returns.
 
 Surprise Insertion:
 ---
 No change, this scenario follows the normal pci probe() function flow.
 
 Signed-off-by: Asai Thambi S P asamymuth...@micron.com
 ---
  drivers/block/mtip32xx/mtip32xx.c |  453 
 ++---
  drivers/block/mtip32xx/mtip32xx.h |   18 +-
  2 files changed, 289 insertions(+), 182 deletions(-)
 
 diff --git a/drivers/block/mtip32xx/mtip32xx.c 
 b/drivers/block/mtip32xx/mtip32xx.c
 index 847107e..aab28a4 100644
 --- a/drivers/block/mtip32xx/mtip32xx.c
 +++ b/drivers/block/mtip32xx/mtip32xx.c
 @@ -126,64 +126,30 @@ struct mtip_compat_ide_task_request_s {
  static bool mtip_check_surprise_removal(struct pci_dev *pdev)
  {
   u16 vendor_id = 0;
 + struct driver_data *dd = pci_get_drvdata(pdev);
 +
 + if (dd-sr)
 + return true;
  
 /* Read the vendorID from the configuration space */
   pci_read_config_word(pdev, 0x00, vendor_id);
 - if (vendor_id == 0x)
 + if (vendor_id == 0x) {
 + dd-sr = true;
 + if (dd-queue)
 + set_bit(QUEUE_FLAG_DEAD, dd-queue-queue_flags);
 + else
 + dev_warn(dd-pdev-dev,
 + %s: dd-queue is NULL\n, __func__);
 + if (dd-port) {
 + set_bit(MTIP_PF_SR_CLEANUP_BIT, dd-port-flags);
 + wake_up_interruptible(dd-port-svc_wait);
 + } else
 + dev_warn(dd-pdev-dev,
 + %s: dd-port is NULL\n, __func__);
   return true; /* device removed */
 -
 - return false; /* device present */
 -}
 -
 -/*
 - * This function is called for clean the pending command in the
 - * command slot during the surprise removal of device and return
 - * error to the upper layer.
 - *
 - * @dd Pointer to the DRIVER_DATA structure.
 - *
 - * return value
 - *   None
 - */
 -static void mtip_command_cleanup(struct driver_data *dd)
 -{
 - int group = 0, commandslot = 0, commandindex = 0;
 - struct mtip_cmd *command;
 - struct mtip_port *port = dd-port;
 - static int in_progress;
 -
 - if (in_progress)
 - return;
 -
 - in_progress = 1;
 -
 - for (group = 0; group  4; group++) {
 - for (commandslot = 0; commandslot  32; commandslot++) {
 - if (!(port-allocated[group]  (1  commandslot)))
 - continue;
 -
 - commandindex = group  5 | commandslot;
 - command = port-commands[commandindex];
 -
 - if (atomic_read(command-active)
 -  (command-async_callback)) {
 - command-async_callback(command-async_data,
 - -ENODEV);
 - command-async_callback = NULL;
 - command-async_data = NULL;
 - }
 -
 - dma_unmap_sg(port-dd-pdev-dev,
 - command-sg,
 - command-scatter_ents,
 - command-direction);
 - }
   }
  
 - up(port-cmd_slot);
 -
 - set_bit(MTIP_DDF_CLEANUP_BIT, dd-dd_flag);
 - in_progress = 0;
 + return false; /* device present */
  }
  
  /*
 @@ -222,10 +188,7 @@ static int get_slot(struct mtip_port *port)
   }
   dev_warn(port-dd-pdev-dev, Failed to get a tag.\n);
  
 - if (mtip_check_surprise_removal(port-dd-pdev)) {
 - /* Device not present, clean outstanding commands */
 - mtip_command_cleanup(port-dd);
 - }
 + mtip_check_surprise_removal(port-dd-pdev);
   return -1;
  }
  
 @@ -246,6 +209,107 @@ static inline void release_slot(struct mtip_port *port, 
 int tag)
  }
  
  /*
 + * IO completion function.
 + *
 + * This completion function is called by the driver ISR when a
 + * command that was issued by the kernel completes. It first calls the
 + * asynchronous completion function which normally calls back into the block
 + * layer passing the asynchronous callback data, then unmaps the
 + * scatter list associated with the completed command, and finally
 + * clears the allocated bit associated with the completed command.
 + *
 + * @port

[PATCH] mtip32xx: Add SRSI support

2013-05-09 Thread Asai Thambi S P

This patch add support for SRSI(Surprise Removal Surprise Insertion).

Approach:
-
Surprise Removal:
-
On surprise removal of the device, gendisk, request queue, device index, sysfs
entries, etc are retained as long as device is in use - mounted filesystem,
device opened by an application, etc. The service thread breaks out of the main
while loop, waits for pci remove to exit, and then waits for device to become
free. When there no holders of the device, service thread cleans up the block
and device related stuff and returns.

Surprise Insertion:
---
No change, this scenario follows the normal pci probe() function flow.

Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |  453 ++---
 drivers/block/mtip32xx/mtip32xx.h |   18 +-
 2 files changed, 289 insertions(+), 182 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 847107e..aab28a4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -126,64 +126,30 @@ struct mtip_compat_ide_task_request_s {
 static bool mtip_check_surprise_removal(struct pci_dev *pdev)
 {
u16 vendor_id = 0;
+   struct driver_data *dd = pci_get_drvdata(pdev);
+
+   if (dd->sr)
+   return true;
 
/* Read the vendorID from the configuration space */
pci_read_config_word(pdev, 0x00, _id);
-   if (vendor_id == 0x)
+   if (vendor_id == 0x) {
+   dd->sr = true;
+   if (dd->queue)
+   set_bit(QUEUE_FLAG_DEAD, >queue->queue_flags);
+   else
+   dev_warn(>pdev->dev,
+   "%s: dd->queue is NULL\n", __func__);
+   if (dd->port) {
+   set_bit(MTIP_PF_SR_CLEANUP_BIT, >port->flags);
+   wake_up_interruptible(>port->svc_wait);
+   } else
+   dev_warn(>pdev->dev,
+   "%s: dd->port is NULL\n", __func__);
return true; /* device removed */
-
-   return false; /* device present */
-}
-
-/*
- * This function is called for clean the pending command in the
- * command slot during the surprise removal of device and return
- * error to the upper layer.
- *
- * @dd Pointer to the DRIVER_DATA structure.
- *
- * return value
- * None
- */
-static void mtip_command_cleanup(struct driver_data *dd)
-{
-   int group = 0, commandslot = 0, commandindex = 0;
-   struct mtip_cmd *command;
-   struct mtip_port *port = dd->port;
-   static int in_progress;
-
-   if (in_progress)
-   return;
-
-   in_progress = 1;
-
-   for (group = 0; group < 4; group++) {
-   for (commandslot = 0; commandslot < 32; commandslot++) {
-   if (!(port->allocated[group] & (1 << commandslot)))
-   continue;
-
-   commandindex = group << 5 | commandslot;
-   command = >commands[commandindex];
-
-   if (atomic_read(>active)
-   && (command->async_callback)) {
-   command->async_callback(command->async_data,
-   -ENODEV);
-   command->async_callback = NULL;
-   command->async_data = NULL;
-   }
-
-   dma_unmap_sg(>dd->pdev->dev,
-   command->sg,
-   command->scatter_ents,
-   command->direction);
-   }
}
 
-   up(>cmd_slot);
-
-   set_bit(MTIP_DDF_CLEANUP_BIT, >dd_flag);
-   in_progress = 0;
+   return false; /* device present */
 }
 
 /*
@@ -222,10 +188,7 @@ static int get_slot(struct mtip_port *port)
}
dev_warn(>dd->pdev->dev, "Failed to get a tag.\n");
 
-   if (mtip_check_surprise_removal(port->dd->pdev)) {
-   /* Device not present, clean outstanding commands */
-   mtip_command_cleanup(port->dd);
-   }
+   mtip_check_surprise_removal(port->dd->pdev);
return -1;
 }
 
@@ -246,6 +209,107 @@ static inline void release_slot(struct mtip_port *port, 
int tag)
 }
 
 /*
+ * IO completion function.
+ *
+ * This completion function is called by the driver ISR when a
+ * command that was issued by the kernel completes. It first calls the
+ * asynchronous completion function which normally calls back into the block
+ * layer passing the asynchronous callback data, then unmaps the
+ * scatter list associated with the completed command, and finally
+ * clears the allocated bit assoc

[PATCH] mtip32xx: Add SRSI support

2013-05-09 Thread Asai Thambi S P

This patch add support for SRSI(Surprise Removal Surprise Insertion).

Approach:
-
Surprise Removal:
-
On surprise removal of the device, gendisk, request queue, device index, sysfs
entries, etc are retained as long as device is in use - mounted filesystem,
device opened by an application, etc. The service thread breaks out of the main
while loop, waits for pci remove to exit, and then waits for device to become
free. When there no holders of the device, service thread cleans up the block
and device related stuff and returns.

Surprise Insertion:
---
No change, this scenario follows the normal pci probe() function flow.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |  453 ++---
 drivers/block/mtip32xx/mtip32xx.h |   18 +-
 2 files changed, 289 insertions(+), 182 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 847107e..aab28a4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -126,64 +126,30 @@ struct mtip_compat_ide_task_request_s {
 static bool mtip_check_surprise_removal(struct pci_dev *pdev)
 {
u16 vendor_id = 0;
+   struct driver_data *dd = pci_get_drvdata(pdev);
+
+   if (dd-sr)
+   return true;
 
/* Read the vendorID from the configuration space */
pci_read_config_word(pdev, 0x00, vendor_id);
-   if (vendor_id == 0x)
+   if (vendor_id == 0x) {
+   dd-sr = true;
+   if (dd-queue)
+   set_bit(QUEUE_FLAG_DEAD, dd-queue-queue_flags);
+   else
+   dev_warn(dd-pdev-dev,
+   %s: dd-queue is NULL\n, __func__);
+   if (dd-port) {
+   set_bit(MTIP_PF_SR_CLEANUP_BIT, dd-port-flags);
+   wake_up_interruptible(dd-port-svc_wait);
+   } else
+   dev_warn(dd-pdev-dev,
+   %s: dd-port is NULL\n, __func__);
return true; /* device removed */
-
-   return false; /* device present */
-}
-
-/*
- * This function is called for clean the pending command in the
- * command slot during the surprise removal of device and return
- * error to the upper layer.
- *
- * @dd Pointer to the DRIVER_DATA structure.
- *
- * return value
- * None
- */
-static void mtip_command_cleanup(struct driver_data *dd)
-{
-   int group = 0, commandslot = 0, commandindex = 0;
-   struct mtip_cmd *command;
-   struct mtip_port *port = dd-port;
-   static int in_progress;
-
-   if (in_progress)
-   return;
-
-   in_progress = 1;
-
-   for (group = 0; group  4; group++) {
-   for (commandslot = 0; commandslot  32; commandslot++) {
-   if (!(port-allocated[group]  (1  commandslot)))
-   continue;
-
-   commandindex = group  5 | commandslot;
-   command = port-commands[commandindex];
-
-   if (atomic_read(command-active)
-(command-async_callback)) {
-   command-async_callback(command-async_data,
-   -ENODEV);
-   command-async_callback = NULL;
-   command-async_data = NULL;
-   }
-
-   dma_unmap_sg(port-dd-pdev-dev,
-   command-sg,
-   command-scatter_ents,
-   command-direction);
-   }
}
 
-   up(port-cmd_slot);
-
-   set_bit(MTIP_DDF_CLEANUP_BIT, dd-dd_flag);
-   in_progress = 0;
+   return false; /* device present */
 }
 
 /*
@@ -222,10 +188,7 @@ static int get_slot(struct mtip_port *port)
}
dev_warn(port-dd-pdev-dev, Failed to get a tag.\n);
 
-   if (mtip_check_surprise_removal(port-dd-pdev)) {
-   /* Device not present, clean outstanding commands */
-   mtip_command_cleanup(port-dd);
-   }
+   mtip_check_surprise_removal(port-dd-pdev);
return -1;
 }
 
@@ -246,6 +209,107 @@ static inline void release_slot(struct mtip_port *port, 
int tag)
 }
 
 /*
+ * IO completion function.
+ *
+ * This completion function is called by the driver ISR when a
+ * command that was issued by the kernel completes. It first calls the
+ * asynchronous completion function which normally calls back into the block
+ * layer passing the asynchronous callback data, then unmaps the
+ * scatter list associated with the completed command, and finally
+ * clears the allocated bit associated with the completed command.
+ *
+ * @port   Pointer to the port data structure.
+ * @tagTag of the command.
+ * @data   Pointer to driver_data.
+ * @status

[PATCH] mtip32xx: Workaround for unaligned writes

2013-04-23 Thread Asai Thambi S P
Workaround for handling unaligned writes: limit number of outstanding
unaligned writes

Signed-off-by: Sam Bradshaw 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   59 +---
 drivers/block/mtip32xx/mtip32xx.h |   11 +++
 2 files changed, 58 insertions(+), 12 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 30a03ab..c0d3873 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -712,7 +712,10 @@ static void mtip_async_complete(struct mtip_port *port,
atomic_set(>commands[tag].active, 0);
release_slot(port, tag);
 
-   up(>cmd_slot);
+   if (unlikely(command->unaligned))
+   up(>cmd_slot_unal);
+   else
+   up(>cmd_slot);
 }
 
 /*
@@ -2557,7 +2560,7 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned 
int cmd,
  */
 static void mtip_hw_submit_io(struct driver_data *dd, sector_t sector,
  int nsect, int nents, int tag, void *callback,
- void *data, int dir)
+ void *data, int dir, int unaligned)
 {
struct host_to_dev_fis  *fis;
struct mtip_port *port = dd->port;
@@ -2570,6 +2573,7 @@ static void mtip_hw_submit_io(struct driver_data *dd, 
sector_t sector,
 
command->scatter_ents = nents;
 
+   command->unaligned = unaligned;
/*
 * The number of retries for this command before it is
 * reported as a failure to the upper layers.
@@ -2598,6 +2602,9 @@ static void mtip_hw_submit_io(struct driver_data *dd, 
sector_t sector,
fis->res3= 0;
fill_command_sg(dd, command, nents);
 
+   if (unaligned)
+   fis->device |= 1 << 7;
+
/* Populate the command header */
command->command_header->opts =
__force_bit2int cpu_to_le32(
@@ -2644,9 +2651,13 @@ static void mtip_hw_submit_io(struct driver_data *dd, 
sector_t sector,
  * return value
  *  None
  */
-static void mtip_hw_release_scatterlist(struct driver_data *dd, int tag)
+static void mtip_hw_release_scatterlist(struct driver_data *dd, int tag,
+   int unaligned)
 {
+   struct semaphore *sem = unaligned ? >port->cmd_slot_unal :
+   >port->cmd_slot;
release_slot(dd->port, tag);
+   up(sem);
 }
 
 /*
@@ -2661,22 +2672,25 @@ static void mtip_hw_release_scatterlist(struct 
driver_data *dd, int tag)
  * or NULL if no command slots are available.
  */
 static struct scatterlist *mtip_hw_get_scatterlist(struct driver_data *dd,
-  int *tag)
+  int *tag, int unaligned)
 {
+   struct semaphore *sem = unaligned ? >port->cmd_slot_unal :
+   >port->cmd_slot;
+
/*
 * It is possible that, even with this semaphore, a thread
 * may think that no command slots are available. Therefore, we
 * need to make an attempt to get_slot().
 */
-   down(>port->cmd_slot);
+   down(sem);
*tag = get_slot(dd->port);
 
if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT, >dd_flag))) {
-   up(>port->cmd_slot);
+   up(sem);
return NULL;
}
if (unlikely(*tag < 0)) {
-   up(>port->cmd_slot);
+   up(sem);
return NULL;
}
 
@@ -2909,6 +2923,11 @@ static inline void hba_setup(struct driver_data *dd)
dd->mmio + HOST_HSORG);
 }
 
+static int mtip_device_unaligned_constrained(struct driver_data *dd)
+{
+   return (dd->pdev->device == P420M_DEVICE_ID ? 1 : 0);
+}
+
 /*
  * Detect the details of the product, and store anything needed
  * into the driver data structure.  This includes product type and
@@ -3131,8 +3150,15 @@ static int mtip_hw_init(struct driver_data *dd)
for (i = 0; i < MTIP_MAX_SLOT_GROUPS; i++)
dd->work[i].port = dd->port;
 
+   /* Enable unaligned IO constraints for some devices */
+   if (mtip_device_unaligned_constrained(dd))
+   dd->unal_qdepth = MTIP_MAX_UNALIGNED_SLOTS;
+   else
+   dd->unal_qdepth = 0;
+
/* Counting semaphore to track command slot usage */
-   sema_init(>port->cmd_slot, num_command_slots - 1);
+   sema_init(>port->cmd_slot, num_command_slots - 1 - dd->unal_qdepth);
+   sema_init(>port->cmd_slot_unal, dd->unal_qdepth);
 
/* Spinlock to prevent concurrent issue */
for (i = 0; i < MTIP_MAX_SLOT_GROUPS; i++)
@@ -3735,7 +3761,7 @@ static void mtip_make_request(

[PATCH] mtip32xx: Workaround for unaligned writes

2013-04-23 Thread Asai Thambi S P
Workaround for handling unaligned writes: limit number of outstanding
unaligned writes

Signed-off-by: Sam Bradshaw sbrads...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   59 +---
 drivers/block/mtip32xx/mtip32xx.h |   11 +++
 2 files changed, 58 insertions(+), 12 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 30a03ab..c0d3873 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -712,7 +712,10 @@ static void mtip_async_complete(struct mtip_port *port,
atomic_set(port-commands[tag].active, 0);
release_slot(port, tag);
 
-   up(port-cmd_slot);
+   if (unlikely(command-unaligned))
+   up(port-cmd_slot_unal);
+   else
+   up(port-cmd_slot);
 }
 
 /*
@@ -2557,7 +2560,7 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned 
int cmd,
  */
 static void mtip_hw_submit_io(struct driver_data *dd, sector_t sector,
  int nsect, int nents, int tag, void *callback,
- void *data, int dir)
+ void *data, int dir, int unaligned)
 {
struct host_to_dev_fis  *fis;
struct mtip_port *port = dd-port;
@@ -2570,6 +2573,7 @@ static void mtip_hw_submit_io(struct driver_data *dd, 
sector_t sector,
 
command-scatter_ents = nents;
 
+   command-unaligned = unaligned;
/*
 * The number of retries for this command before it is
 * reported as a failure to the upper layers.
@@ -2598,6 +2602,9 @@ static void mtip_hw_submit_io(struct driver_data *dd, 
sector_t sector,
fis-res3= 0;
fill_command_sg(dd, command, nents);
 
+   if (unaligned)
+   fis-device |= 1  7;
+
/* Populate the command header */
command-command_header-opts =
__force_bit2int cpu_to_le32(
@@ -2644,9 +2651,13 @@ static void mtip_hw_submit_io(struct driver_data *dd, 
sector_t sector,
  * return value
  *  None
  */
-static void mtip_hw_release_scatterlist(struct driver_data *dd, int tag)
+static void mtip_hw_release_scatterlist(struct driver_data *dd, int tag,
+   int unaligned)
 {
+   struct semaphore *sem = unaligned ? dd-port-cmd_slot_unal :
+   dd-port-cmd_slot;
release_slot(dd-port, tag);
+   up(sem);
 }
 
 /*
@@ -2661,22 +2672,25 @@ static void mtip_hw_release_scatterlist(struct 
driver_data *dd, int tag)
  * or NULL if no command slots are available.
  */
 static struct scatterlist *mtip_hw_get_scatterlist(struct driver_data *dd,
-  int *tag)
+  int *tag, int unaligned)
 {
+   struct semaphore *sem = unaligned ? dd-port-cmd_slot_unal :
+   dd-port-cmd_slot;
+
/*
 * It is possible that, even with this semaphore, a thread
 * may think that no command slots are available. Therefore, we
 * need to make an attempt to get_slot().
 */
-   down(dd-port-cmd_slot);
+   down(sem);
*tag = get_slot(dd-port);
 
if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT, dd-dd_flag))) {
-   up(dd-port-cmd_slot);
+   up(sem);
return NULL;
}
if (unlikely(*tag  0)) {
-   up(dd-port-cmd_slot);
+   up(sem);
return NULL;
}
 
@@ -2909,6 +2923,11 @@ static inline void hba_setup(struct driver_data *dd)
dd-mmio + HOST_HSORG);
 }
 
+static int mtip_device_unaligned_constrained(struct driver_data *dd)
+{
+   return (dd-pdev-device == P420M_DEVICE_ID ? 1 : 0);
+}
+
 /*
  * Detect the details of the product, and store anything needed
  * into the driver data structure.  This includes product type and
@@ -3131,8 +3150,15 @@ static int mtip_hw_init(struct driver_data *dd)
for (i = 0; i  MTIP_MAX_SLOT_GROUPS; i++)
dd-work[i].port = dd-port;
 
+   /* Enable unaligned IO constraints for some devices */
+   if (mtip_device_unaligned_constrained(dd))
+   dd-unal_qdepth = MTIP_MAX_UNALIGNED_SLOTS;
+   else
+   dd-unal_qdepth = 0;
+
/* Counting semaphore to track command slot usage */
-   sema_init(dd-port-cmd_slot, num_command_slots - 1);
+   sema_init(dd-port-cmd_slot, num_command_slots - 1 - dd-unal_qdepth);
+   sema_init(dd-port-cmd_slot_unal, dd-unal_qdepth);
 
/* Spinlock to prevent concurrent issue */
for (i = 0; i  MTIP_MAX_SLOT_GROUPS; i++)
@@ -3735,7 +3761,7 @@ static void mtip_make_request(struct request_queue 
*queue, struct bio *bio)
struct scatterlist *sg;
struct

Re: [PATCH 2/2] mtip32xx: mtip32xx: Disable TRIM support

2013-04-15 Thread Asai Thambi S P
On 4/14/2013 1:55 PM, Jens Axboe wrote:

> On Fri, Apr 12 2013, Asai Thambi S P wrote:
>>
>> Temporarily disabling TRIM support until TRIM related issues
>> are addressed in the firmware.
> 
> How serious is this? We do have released kernels out there with the
> driver, you might want to consider a stable backport too.
> 
> Anyway, applied for 3.10.
> 

Added TRIM support in 3.9 merge window. If this trivial change could be
pushed, it would be good. Otherwise, I can backport to stable 3.9 when released.

--
regards,
asai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] mtip32xx: mtip32xx: Disable TRIM support

2013-04-15 Thread Asai Thambi S P
On 4/14/2013 1:55 PM, Jens Axboe wrote:

 On Fri, Apr 12 2013, Asai Thambi S P wrote:

 Temporarily disabling TRIM support until TRIM related issues
 are addressed in the firmware.
 
 How serious is this? We do have released kernels out there with the
 driver, you might want to consider a stable backport too.
 
 Anyway, applied for 3.10.
 

Added TRIM support in 3.9 merge window. If this trivial change could be
pushed, it would be good. Otherwise, I can backport to stable 3.9 when released.

--
regards,
asai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] mtip32xx: mtip32xx: Disable TRIM support

2013-04-12 Thread Asai Thambi S P

Temporarily disabling TRIM support until TRIM related issues
are addressed in the firmware.

Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index d11ea92..53bad62 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1560,10 +1560,12 @@ static int mtip_get_identify(struct mtip_port *port, 
void __user *user_buffer)
}
 #endif
 
+#ifdef MTIP_TRIM /* Disabling TRIM support temporarily */
/* Demux ID.DRAT & ID.RZAT to determine trim support */
if (port->identify[69] & (1 << 14) && port->identify[69] & (1 << 5))
port->dd->trim_supp = true;
else
+#endif
port->dd->trim_supp = false;
 
/* Set the identify buffer as valid. */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] mtip32xx: fix a smatch warning

2013-04-12 Thread Asai Thambi S P

Reported smatch warning:
drivers/block/mtip32xx/mtip32xx.c:4163 mtip_block_shutdown() warn: variable 
dereferenced before check 'dd->disk' (see line 4159)

dd->disk->disk_name accessed before the check if dd->disk is NULL. Fixed this
and access of dd->queue/dd->disk->queue.

Reported-by: Dan Carpenter 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   18 --
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 32c6780..d11ea92 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4156,26 +4156,24 @@ static int mtip_block_remove(struct driver_data *dd)
  */
 static int mtip_block_shutdown(struct driver_data *dd)
 {
-   dev_info(>pdev->dev,
-   "Shutting down %s ...\n", dd->disk->disk_name);
-
/* Delete our gendisk structure, and cleanup the blk queue. */
if (dd->disk) {
-   if (dd->disk->queue)
+   dev_info(>pdev->dev,
+   "Shutting down %s ...\n", dd->disk->disk_name);
+
+   if (dd->disk->queue) {
del_gendisk(dd->disk);
-   else
+   blk_cleanup_queue(dd->queue);
+   } else
put_disk(dd->disk);
+   dd->disk  = NULL;
+   dd->queue = NULL;
}
 
-
spin_lock(_index_lock);
ida_remove(_index_ida, dd->index);
spin_unlock(_index_lock);
 
-   blk_cleanup_queue(dd->queue);
-   dd->disk  = NULL;
-   dd->queue = NULL;
-
mtip_hw_shutdown(dd);
return 0;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] mtip32xx: fix a smatch warning

2013-04-12 Thread Asai Thambi S P

Reported smatch warning:
drivers/block/mtip32xx/mtip32xx.c:4163 mtip_block_shutdown() warn: variable 
dereferenced before check 'dd-disk' (see line 4159)

dd-disk-disk_name accessed before the check if dd-disk is NULL. Fixed this
and access of dd-queue/dd-disk-queue.

Reported-by: Dan Carpenter dan.carpen...@oracle.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   18 --
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 32c6780..d11ea92 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4156,26 +4156,24 @@ static int mtip_block_remove(struct driver_data *dd)
  */
 static int mtip_block_shutdown(struct driver_data *dd)
 {
-   dev_info(dd-pdev-dev,
-   Shutting down %s ...\n, dd-disk-disk_name);
-
/* Delete our gendisk structure, and cleanup the blk queue. */
if (dd-disk) {
-   if (dd-disk-queue)
+   dev_info(dd-pdev-dev,
+   Shutting down %s ...\n, dd-disk-disk_name);
+
+   if (dd-disk-queue) {
del_gendisk(dd-disk);
-   else
+   blk_cleanup_queue(dd-queue);
+   } else
put_disk(dd-disk);
+   dd-disk  = NULL;
+   dd-queue = NULL;
}
 
-
spin_lock(rssd_index_lock);
ida_remove(rssd_index_ida, dd-index);
spin_unlock(rssd_index_lock);
 
-   blk_cleanup_queue(dd-queue);
-   dd-disk  = NULL;
-   dd-queue = NULL;
-
mtip_hw_shutdown(dd);
return 0;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] mtip32xx: mtip32xx: Disable TRIM support

2013-04-12 Thread Asai Thambi S P

Temporarily disabling TRIM support until TRIM related issues
are addressed in the firmware.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index d11ea92..53bad62 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1560,10 +1560,12 @@ static int mtip_get_identify(struct mtip_port *port, 
void __user *user_buffer)
}
 #endif
 
+#ifdef MTIP_TRIM /* Disabling TRIM support temporarily */
/* Demux ID.DRAT  ID.RZAT to determine trim support */
if (port-identify[69]  (1  14)  port-identify[69]  (1  5))
port-dd-trim_supp = true;
else
+#endif
port-dd-trim_supp = false;
 
/* Set the identify buffer as valid. */
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] mtip32xx: Add debugfs entry device_status

2013-04-03 Thread Asai Thambi S P
This patch adds a new debugfs entry 'device_status' in
/sys/kernel/debug/rssd. The value of this entry shows
devices online and those in the process of removing.

Signed-off-by: Sam Bradshaw 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |  148 +++-
 drivers/block/mtip32xx/mtip32xx.h |   18 +++--
 2 files changed, 154 insertions(+), 12 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 7e1aeb3..03555ec 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -81,12 +81,17 @@
 /* Device instance number, incremented each time a device is probed. */
 static int instance;
 
+struct list_head online_list;
+struct list_head removing_list;
+spinlock_t dev_lock;
+
 /*
  * Global variable used to hold the major block device number
  * allocated in mtip_init().
  */
 static int mtip_major;
 static struct dentry *dfs_parent;
+static struct dentry *dfs_device_status;
 
 static u32 cpu_use[NR_CPUS];
 
@@ -2707,6 +2712,100 @@ static ssize_t mtip_hw_show_status(struct device *dev,
 
 static DEVICE_ATTR(status, S_IRUGO, mtip_hw_show_status, NULL);
 
+/* debugsfs entries */
+
+static ssize_t show_device_status(struct device_driver *drv, char *buf)
+{
+   int size = 0;
+   struct driver_data *dd, *tmp;
+   unsigned long flags;
+   char id_buf[42];
+   u16 status = 0;
+
+   spin_lock_irqsave(_lock, flags);
+   size += sprintf([size], "Devices Present:\n");
+   list_for_each_entry_safe(dd, tmp, _list, online_list) {
+   if (dd && dd->pdev) {
+   if (dd->port &&
+   dd->port->identify &&
+   dd->port->identify_valid) {
+   strlcpy(id_buf,
+   (char *) (dd->port->identify + 10), 21);
+   status = *(dd->port->identify + 141);
+   } else {
+   memset(id_buf, 0, 42);
+   status = 0;
+   }
+
+   if (dd->port &&
+   test_bit(MTIP_PF_REBUILD_BIT, >port->flags)) {
+   size += sprintf([size],
+   " device %s %s (ftl rebuild %d %%)\n",
+   dev_name(>pdev->dev),
+   id_buf,
+   status);
+   } else {
+   size += sprintf([size],
+   " device %s %s\n",
+   dev_name(>pdev->dev),
+   id_buf);
+   }
+   }
+   }
+
+   size += sprintf([size], "Devices Being Removed:\n");
+   list_for_each_entry_safe(dd, tmp, _list, remove_list) {
+   if (dd && dd->pdev) {
+   if (dd->port &&
+   dd->port->identify &&
+   dd->port->identify_valid) {
+   strlcpy(id_buf,
+   (char *) (dd->port->identify+10), 21);
+   status = *(dd->port->identify + 141);
+   } else {
+   memset(id_buf, 0, 42);
+   status = 0;
+   }
+
+   if (dd->port &&
+   test_bit(MTIP_PF_REBUILD_BIT, >port->flags)) {
+   size += sprintf([size],
+   " device %s %s (ftl rebuild %d %%)\n",
+   dev_name(>pdev->dev),
+   id_buf,
+   status);
+   } else {
+   size += sprintf([size],
+   " device %s %s\n",
+   dev_name(>pdev->dev),
+   id_buf);
+   }
+   }
+   }
+   spin_unlock_irqrestore(_lock, flags);
+
+   return size;
+}
+
+static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
+   size_t len, loff_t *offset)
+{
+   int size = *offset;
+   char buf[MTIP_DFS_MAX_BUF_SIZE];
+
+   if (!len || *offset)
+   return 0;
+
+   size += show_device_status(NULL, buf);
+
+   *offset = size <= len ? size : len;
+   size = copy_to_user(ubuf, buf, *offset);
+   if

[PATCH 2/3] mtip32xx: return 0 from pci probe in case of rebuild

2013-04-03 Thread Asai Thambi S P

Fix to return 0 from pci probe in case of rebuild. If not, pci consider
probe has failed, and crash during rmmod.

Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 5becdaa..7e1aeb3 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4300,6 +4300,8 @@ static int mtip_pci_probe(struct pci_dev *pdev,
instance++;
if (rv != MTIP_FTL_REBUILD_MAGIC)
set_bit(MTIP_DDF_INIT_DONE_BIT, >dd_flag);
+   else
+   rv = 0; /* device in rebuild state, return 0 from probe */
goto done;
 
 block_initialize_err:
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] mtip32xx: recovery from command timeout

2013-04-03 Thread Asai Thambi S P

To recover from command timeouts, reset the device. In addition
to that improved timeout handling of PIO commands.

Signed-off-by: Sam Bradshaw 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |  177 ++---
 1 files changed, 87 insertions(+), 90 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 11cc952..5becdaa 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -243,40 +243,31 @@ static inline void release_slot(struct mtip_port *port, 
int tag)
 /*
  * Reset the HBA (without sleeping)
  *
- * Just like hba_reset, except does not call sleep, so can be
- * run from interrupt/tasklet context.
- *
  * @dd Pointer to the driver data structure.
  *
  * return value
  * 0   The reset was successful.
  * -1  The HBA Reset bit did not clear.
  */
-static int hba_reset_nosleep(struct driver_data *dd)
+static int mtip_hba_reset(struct driver_data *dd)
 {
unsigned long timeout;
 
-   /* Chip quirk: quiesce any chip function */
-   mdelay(10);
-
/* Set the reset bit */
writel(HOST_RESET, dd->mmio + HOST_CTL);
 
/* Flush */
readl(dd->mmio + HOST_CTL);
 
-   /*
-* Wait 10ms then spin for up to 1 second
-* waiting for reset acknowledgement
-*/
-   timeout = jiffies + msecs_to_jiffies(1000);
-   mdelay(10);
-   while ((readl(dd->mmio + HOST_CTL) & HOST_RESET)
-&& time_before(jiffies, timeout))
-   mdelay(1);
+   /* Spin for up to 2 seconds, waiting for reset acknowledgement */
+   timeout = jiffies + msecs_to_jiffies(2000);
+   do {
+   mdelay(10);
+   if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, >dd_flag))
+   return -1;
 
-   if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, >dd_flag))
-   return -1;
+   } while ((readl(dd->mmio + HOST_CTL) & HOST_RESET)
+&& time_before(jiffies, timeout));
 
if (readl(dd->mmio + HOST_CTL) & HOST_RESET)
return -1;
@@ -481,7 +472,7 @@ static void mtip_restart_port(struct mtip_port *port)
dev_warn(>dd->pdev->dev,
"PxCMD.CR not clear, escalating reset\n");
 
-   if (hba_reset_nosleep(port->dd))
+   if (mtip_hba_reset(port->dd))
dev_err(>dd->pdev->dev,
"HBA reset escalation failed.\n");
 
@@ -527,6 +518,26 @@ static void mtip_restart_port(struct mtip_port *port)
 
 }
 
+static int mtip_device_reset(struct driver_data *dd)
+{
+   int rv = 0;
+
+   if (mtip_check_surprise_removal(dd->pdev))
+   return 0;
+
+   if (mtip_hba_reset(dd) < 0)
+   rv = -EFAULT;
+
+   mdelay(1);
+   mtip_init_port(dd->port);
+   mtip_start_port(dd->port);
+
+   /* Enable interrupts on the HBA. */
+   writel(readl(dd->mmio + HOST_CTL) | HOST_IRQ_EN,
+   dd->mmio + HOST_CTL);
+   return rv;
+}
+
 /*
  * Helper function for tag logging
  */
@@ -632,7 +643,7 @@ static void mtip_timeout_function(unsigned long int data)
if (cmdto_cnt) {
print_tags(port->dd, "timed out", tagaccum, cmdto_cnt);
if (!test_bit(MTIP_PF_IC_ACTIVE_BIT, >flags)) {
-   mtip_restart_port(port);
+   mtip_device_reset(port->dd);
wake_up_interruptible(>svc_wait);
}
clear_bit(MTIP_PF_EH_ACTIVE_BIT, >flags);
@@ -1283,11 +1294,11 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
int rv = 0, ready2go = 1;
struct mtip_cmd *int_cmd = >commands[MTIP_TAG_INTERNAL];
unsigned long to;
+   struct driver_data *dd = port->dd;
 
/* Make sure the buffer is 8 byte aligned. This is asic specific. */
if (buffer & 0x0007) {
-   dev_err(>dd->pdev->dev,
-   "SG buffer is not 8 byte aligned\n");
+   dev_err(>pdev->dev, "SG buffer is not 8 byte aligned\n");
return -EFAULT;
}
 
@@ -1300,23 +1311,21 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
mdelay(100);
} while (time_before(jiffies, to));
if (!ready2go) {
-   dev_warn(>dd->pdev->dev,
+   dev_warn(>pdev->dev,
"Internal cmd active. new cmd [%02X]\n", fis->command);
return -EBUSY;
}
set_bit(MTIP_PF_IC_ACTIVE_BIT, >flags);
port->ic_pause_timer = 0;
 
-   if (fis->command == ATA_CMD_SEC_ERASE_UNIT)
-   clear_

[PATCH 0/3] mtip32xx: recovery improvement and fix for a crash

2013-04-03 Thread Asai Thambi S P
Hi Jens,

This patchset includes the following. It was generated against your 
for-3.9/drivers

* improved recovery for command timeout
* fix for a crash during rmmod
* add new debugfs entry 'device_status'


Asai Thambi S P (3):
  mtip32xx: recovery from command timeout
  mtip32xx: return 0 from pci probe in case of rebuild
  mtip32xx: Add debugfs entry device_status

 drivers/block/mtip32xx/mtip32xx.c |  327 ++---
 drivers/block/mtip32xx/mtip32xx.h |   18 ++-
 2 files changed, 243 insertions(+), 102 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] mtip32xx: recovery improvement and fix for a crash

2013-04-03 Thread Asai Thambi S P
Hi Jens,

This patchset includes the following. It was generated against your 
for-3.9/drivers

* improved recovery for command timeout
* fix for a crash during rmmod
* add new debugfs entry 'device_status'


Asai Thambi S P (3):
  mtip32xx: recovery from command timeout
  mtip32xx: return 0 from pci probe in case of rebuild
  mtip32xx: Add debugfs entry device_status

 drivers/block/mtip32xx/mtip32xx.c |  327 ++---
 drivers/block/mtip32xx/mtip32xx.h |   18 ++-
 2 files changed, 243 insertions(+), 102 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] mtip32xx: recovery from command timeout

2013-04-03 Thread Asai Thambi S P

To recover from command timeouts, reset the device. In addition
to that improved timeout handling of PIO commands.

Signed-off-by: Sam Bradshaw sbrads...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |  177 ++---
 1 files changed, 87 insertions(+), 90 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 11cc952..5becdaa 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -243,40 +243,31 @@ static inline void release_slot(struct mtip_port *port, 
int tag)
 /*
  * Reset the HBA (without sleeping)
  *
- * Just like hba_reset, except does not call sleep, so can be
- * run from interrupt/tasklet context.
- *
  * @dd Pointer to the driver data structure.
  *
  * return value
  * 0   The reset was successful.
  * -1  The HBA Reset bit did not clear.
  */
-static int hba_reset_nosleep(struct driver_data *dd)
+static int mtip_hba_reset(struct driver_data *dd)
 {
unsigned long timeout;
 
-   /* Chip quirk: quiesce any chip function */
-   mdelay(10);
-
/* Set the reset bit */
writel(HOST_RESET, dd-mmio + HOST_CTL);
 
/* Flush */
readl(dd-mmio + HOST_CTL);
 
-   /*
-* Wait 10ms then spin for up to 1 second
-* waiting for reset acknowledgement
-*/
-   timeout = jiffies + msecs_to_jiffies(1000);
-   mdelay(10);
-   while ((readl(dd-mmio + HOST_CTL)  HOST_RESET)
- time_before(jiffies, timeout))
-   mdelay(1);
+   /* Spin for up to 2 seconds, waiting for reset acknowledgement */
+   timeout = jiffies + msecs_to_jiffies(2000);
+   do {
+   mdelay(10);
+   if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, dd-dd_flag))
+   return -1;
 
-   if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, dd-dd_flag))
-   return -1;
+   } while ((readl(dd-mmio + HOST_CTL)  HOST_RESET)
+ time_before(jiffies, timeout));
 
if (readl(dd-mmio + HOST_CTL)  HOST_RESET)
return -1;
@@ -481,7 +472,7 @@ static void mtip_restart_port(struct mtip_port *port)
dev_warn(port-dd-pdev-dev,
PxCMD.CR not clear, escalating reset\n);
 
-   if (hba_reset_nosleep(port-dd))
+   if (mtip_hba_reset(port-dd))
dev_err(port-dd-pdev-dev,
HBA reset escalation failed.\n);
 
@@ -527,6 +518,26 @@ static void mtip_restart_port(struct mtip_port *port)
 
 }
 
+static int mtip_device_reset(struct driver_data *dd)
+{
+   int rv = 0;
+
+   if (mtip_check_surprise_removal(dd-pdev))
+   return 0;
+
+   if (mtip_hba_reset(dd)  0)
+   rv = -EFAULT;
+
+   mdelay(1);
+   mtip_init_port(dd-port);
+   mtip_start_port(dd-port);
+
+   /* Enable interrupts on the HBA. */
+   writel(readl(dd-mmio + HOST_CTL) | HOST_IRQ_EN,
+   dd-mmio + HOST_CTL);
+   return rv;
+}
+
 /*
  * Helper function for tag logging
  */
@@ -632,7 +643,7 @@ static void mtip_timeout_function(unsigned long int data)
if (cmdto_cnt) {
print_tags(port-dd, timed out, tagaccum, cmdto_cnt);
if (!test_bit(MTIP_PF_IC_ACTIVE_BIT, port-flags)) {
-   mtip_restart_port(port);
+   mtip_device_reset(port-dd);
wake_up_interruptible(port-svc_wait);
}
clear_bit(MTIP_PF_EH_ACTIVE_BIT, port-flags);
@@ -1283,11 +1294,11 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
int rv = 0, ready2go = 1;
struct mtip_cmd *int_cmd = port-commands[MTIP_TAG_INTERNAL];
unsigned long to;
+   struct driver_data *dd = port-dd;
 
/* Make sure the buffer is 8 byte aligned. This is asic specific. */
if (buffer  0x0007) {
-   dev_err(port-dd-pdev-dev,
-   SG buffer is not 8 byte aligned\n);
+   dev_err(dd-pdev-dev, SG buffer is not 8 byte aligned\n);
return -EFAULT;
}
 
@@ -1300,23 +1311,21 @@ static int mtip_exec_internal_command(struct mtip_port 
*port,
mdelay(100);
} while (time_before(jiffies, to));
if (!ready2go) {
-   dev_warn(port-dd-pdev-dev,
+   dev_warn(dd-pdev-dev,
Internal cmd active. new cmd [%02X]\n, fis-command);
return -EBUSY;
}
set_bit(MTIP_PF_IC_ACTIVE_BIT, port-flags);
port-ic_pause_timer = 0;
 
-   if (fis-command == ATA_CMD_SEC_ERASE_UNIT)
-   clear_bit(MTIP_PF_SE_ACTIVE_BIT, port-flags);
-   else if (fis-command == ATA_CMD_DOWNLOAD_MICRO)
-   clear_bit(MTIP_PF_DM_ACTIVE_BIT, port-flags);
+   clear_bit

[PATCH 2/3] mtip32xx: return 0 from pci probe in case of rebuild

2013-04-03 Thread Asai Thambi S P

Fix to return 0 from pci probe in case of rebuild. If not, pci consider
probe has failed, and crash during rmmod.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 5becdaa..7e1aeb3 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4300,6 +4300,8 @@ static int mtip_pci_probe(struct pci_dev *pdev,
instance++;
if (rv != MTIP_FTL_REBUILD_MAGIC)
set_bit(MTIP_DDF_INIT_DONE_BIT, dd-dd_flag);
+   else
+   rv = 0; /* device in rebuild state, return 0 from probe */
goto done;
 
 block_initialize_err:
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] mtip32xx: Add debugfs entry device_status

2013-04-03 Thread Asai Thambi S P
This patch adds a new debugfs entry 'device_status' in
/sys/kernel/debug/rssd. The value of this entry shows
devices online and those in the process of removing.

Signed-off-by: Sam Bradshaw sbrads...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |  148 +++-
 drivers/block/mtip32xx/mtip32xx.h |   18 +++--
 2 files changed, 154 insertions(+), 12 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 7e1aeb3..03555ec 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -81,12 +81,17 @@
 /* Device instance number, incremented each time a device is probed. */
 static int instance;
 
+struct list_head online_list;
+struct list_head removing_list;
+spinlock_t dev_lock;
+
 /*
  * Global variable used to hold the major block device number
  * allocated in mtip_init().
  */
 static int mtip_major;
 static struct dentry *dfs_parent;
+static struct dentry *dfs_device_status;
 
 static u32 cpu_use[NR_CPUS];
 
@@ -2707,6 +2712,100 @@ static ssize_t mtip_hw_show_status(struct device *dev,
 
 static DEVICE_ATTR(status, S_IRUGO, mtip_hw_show_status, NULL);
 
+/* debugsfs entries */
+
+static ssize_t show_device_status(struct device_driver *drv, char *buf)
+{
+   int size = 0;
+   struct driver_data *dd, *tmp;
+   unsigned long flags;
+   char id_buf[42];
+   u16 status = 0;
+
+   spin_lock_irqsave(dev_lock, flags);
+   size += sprintf(buf[size], Devices Present:\n);
+   list_for_each_entry_safe(dd, tmp, online_list, online_list) {
+   if (dd  dd-pdev) {
+   if (dd-port 
+   dd-port-identify 
+   dd-port-identify_valid) {
+   strlcpy(id_buf,
+   (char *) (dd-port-identify + 10), 21);
+   status = *(dd-port-identify + 141);
+   } else {
+   memset(id_buf, 0, 42);
+   status = 0;
+   }
+
+   if (dd-port 
+   test_bit(MTIP_PF_REBUILD_BIT, dd-port-flags)) {
+   size += sprintf(buf[size],
+device %s %s (ftl rebuild %d %%)\n,
+   dev_name(dd-pdev-dev),
+   id_buf,
+   status);
+   } else {
+   size += sprintf(buf[size],
+device %s %s\n,
+   dev_name(dd-pdev-dev),
+   id_buf);
+   }
+   }
+   }
+
+   size += sprintf(buf[size], Devices Being Removed:\n);
+   list_for_each_entry_safe(dd, tmp, removing_list, remove_list) {
+   if (dd  dd-pdev) {
+   if (dd-port 
+   dd-port-identify 
+   dd-port-identify_valid) {
+   strlcpy(id_buf,
+   (char *) (dd-port-identify+10), 21);
+   status = *(dd-port-identify + 141);
+   } else {
+   memset(id_buf, 0, 42);
+   status = 0;
+   }
+
+   if (dd-port 
+   test_bit(MTIP_PF_REBUILD_BIT, dd-port-flags)) {
+   size += sprintf(buf[size],
+device %s %s (ftl rebuild %d %%)\n,
+   dev_name(dd-pdev-dev),
+   id_buf,
+   status);
+   } else {
+   size += sprintf(buf[size],
+device %s %s\n,
+   dev_name(dd-pdev-dev),
+   id_buf);
+   }
+   }
+   }
+   spin_unlock_irqrestore(dev_lock, flags);
+
+   return size;
+}
+
+static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
+   size_t len, loff_t *offset)
+{
+   int size = *offset;
+   char buf[MTIP_DFS_MAX_BUF_SIZE];
+
+   if (!len || *offset)
+   return 0;
+
+   size += show_device_status(NULL, buf);
+
+   *offset = size = len ? size : len;
+   size = copy_to_user(ubuf, buf, *offset);
+   if (size)
+   return -EFAULT;
+
+   return *offset;
+}
+
 static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
  size_t len, loff_t

[PATCH] conversion to bio batch completion

2013-02-26 Thread Asai Thambi S P
Hi Jens,

This patch is for linux-next, applies cleanly on for-next branch.

This patch contains the following:
* changes for conversion to bio batch completion from Kent
* fix to apply the above changes cleanly on latest mtip32xx code
* batch bio completion changes in 
* mtip_command_cleanup()
* mtip_timeout_function()
* mtip_handle_tfe()

Signed-off-by: Kent Overstreet 
Signed-off-by: Andrew Morton 
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   86 
 drivers/block/mtip32xx/mtip32xx.h |8 +--
 2 files changed, 51 insertions(+), 43 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 11cc952..22d2b0f 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -146,6 +146,9 @@ static void mtip_command_cleanup(struct driver_data *dd)
struct mtip_cmd *command;
struct mtip_port *port = dd->port;
static int in_progress;
+   struct batch_complete batch;
+
+   batch_complete_init();
 
if (in_progress)
return;
@@ -161,11 +164,9 @@ static void mtip_command_cleanup(struct driver_data *dd)
command = >commands[commandindex];
 
if (atomic_read(>active)
-   && (command->async_callback)) {
-   command->async_callback(command->async_data,
-   -ENODEV);
-   command->async_callback = NULL;
-   command->async_data = NULL;
+   && (command->bio)) {
+   bio_endio_batch(command->bio, -ENODEV, );
+   command->bio = NULL;
}
 
dma_unmap_sg(>dd->pdev->dev,
@@ -173,9 +174,10 @@ static void mtip_command_cleanup(struct driver_data *dd)
command->scatter_ents,
command->direction);
}
+   up(>cmd_slot);
}
 
-   up(>cmd_slot);
+   batch_complete();
 
set_bit(MTIP_DDF_CLEANUP_BIT, >dd_flag);
in_progress = 0;
@@ -564,6 +566,9 @@ static void mtip_timeout_function(unsigned long int data)
unsigned int bit, group;
unsigned int num_command_slots;
unsigned long to, tagaccum[SLOTBITS_IN_LONGS];
+   struct batch_complete batch;
+
+   batch_complete_init();
 
if (unlikely(!port))
return;
@@ -606,11 +611,9 @@ static void mtip_timeout_function(unsigned long int data)
writel(1 << bit, port->completed[group]);
 
/* Call the async completion callback. */
-   if (likely(command->async_callback))
-   command->async_callback(command->async_data,
--EIO);
-   command->async_callback = NULL;
-   command->comp_func = NULL;
+   if (likely(command->bio))
+   bio_endio_batch(command->bio, -EIO, );
+   command->bio = NULL;
 
/* Unmap the DMA scatter list entries */
dma_unmap_sg(>dd->pdev->dev,
@@ -628,6 +631,8 @@ static void mtip_timeout_function(unsigned long int data)
up(>cmd_slot);
}
}
+
+   batch_complete();
 
if (cmdto_cnt) {
print_tags(port->dd, "timed out", tagaccum, cmdto_cnt);
@@ -679,7 +684,8 @@ static void mtip_timeout_function(unsigned long int data)
 static void mtip_async_complete(struct mtip_port *port,
int tag,
void *data,
-   int status)
+   int status,
+   struct batch_complete *batch)
 {
struct mtip_cmd *command;
struct driver_data *dd = data;
@@ -696,11 +702,10 @@ static void mtip_async_complete(struct mtip_port *port,
}
 
/* Upper layer callback */
-   if (likely(command->async_callback))
-   command->async_callback(command->async_data, cb_status);
+   if (likely(command->bio))
+   bio_endio_batch(command->bio, cb_status, batch);
 
-   command->async_callback = NULL;
-   command->comp_func = NULL;
+   command->bio = NULL;
 
/* Unmap the DMA scatter list entries */
dma_unmap_sg(>pdev->dev,
@@ -733,24 +738,22 @@ static void mtip_async_complete(struct mtip_port *port,
 static void mtip_completion(struct mtip_port *

[PATCH] conversion to bio batch completion

2013-02-26 Thread Asai Thambi S P
Hi Jens,

This patch is for linux-next, applies cleanly on for-next branch.

This patch contains the following:
* changes for conversion to bio batch completion from Kent
* fix to apply the above changes cleanly on latest mtip32xx code
* batch bio completion changes in 
* mtip_command_cleanup()
* mtip_timeout_function()
* mtip_handle_tfe()

Signed-off-by: Kent Overstreet koverstr...@google.com
Signed-off-by: Andrew Morton a...@linux-foundation.org
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   86 
 drivers/block/mtip32xx/mtip32xx.h |8 +--
 2 files changed, 51 insertions(+), 43 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 11cc952..22d2b0f 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -146,6 +146,9 @@ static void mtip_command_cleanup(struct driver_data *dd)
struct mtip_cmd *command;
struct mtip_port *port = dd-port;
static int in_progress;
+   struct batch_complete batch;
+
+   batch_complete_init(batch);
 
if (in_progress)
return;
@@ -161,11 +164,9 @@ static void mtip_command_cleanup(struct driver_data *dd)
command = port-commands[commandindex];
 
if (atomic_read(command-active)
-(command-async_callback)) {
-   command-async_callback(command-async_data,
-   -ENODEV);
-   command-async_callback = NULL;
-   command-async_data = NULL;
+(command-bio)) {
+   bio_endio_batch(command-bio, -ENODEV, batch);
+   command-bio = NULL;
}
 
dma_unmap_sg(port-dd-pdev-dev,
@@ -173,9 +174,10 @@ static void mtip_command_cleanup(struct driver_data *dd)
command-scatter_ents,
command-direction);
}
+   up(port-cmd_slot);
}
 
-   up(port-cmd_slot);
+   batch_complete(batch);
 
set_bit(MTIP_DDF_CLEANUP_BIT, dd-dd_flag);
in_progress = 0;
@@ -564,6 +566,9 @@ static void mtip_timeout_function(unsigned long int data)
unsigned int bit, group;
unsigned int num_command_slots;
unsigned long to, tagaccum[SLOTBITS_IN_LONGS];
+   struct batch_complete batch;
+
+   batch_complete_init(batch);
 
if (unlikely(!port))
return;
@@ -606,11 +611,9 @@ static void mtip_timeout_function(unsigned long int data)
writel(1  bit, port-completed[group]);
 
/* Call the async completion callback. */
-   if (likely(command-async_callback))
-   command-async_callback(command-async_data,
--EIO);
-   command-async_callback = NULL;
-   command-comp_func = NULL;
+   if (likely(command-bio))
+   bio_endio_batch(command-bio, -EIO, batch);
+   command-bio = NULL;
 
/* Unmap the DMA scatter list entries */
dma_unmap_sg(port-dd-pdev-dev,
@@ -628,6 +631,8 @@ static void mtip_timeout_function(unsigned long int data)
up(port-cmd_slot);
}
}
+
+   batch_complete(batch);
 
if (cmdto_cnt) {
print_tags(port-dd, timed out, tagaccum, cmdto_cnt);
@@ -679,7 +684,8 @@ static void mtip_timeout_function(unsigned long int data)
 static void mtip_async_complete(struct mtip_port *port,
int tag,
void *data,
-   int status)
+   int status,
+   struct batch_complete *batch)
 {
struct mtip_cmd *command;
struct driver_data *dd = data;
@@ -696,11 +702,10 @@ static void mtip_async_complete(struct mtip_port *port,
}
 
/* Upper layer callback */
-   if (likely(command-async_callback))
-   command-async_callback(command-async_data, cb_status);
+   if (likely(command-bio))
+   bio_endio_batch(command-bio, cb_status, batch);
 
-   command-async_callback = NULL;
-   command-comp_func = NULL;
+   command-bio = NULL;
 
/* Unmap the DMA scatter list entries */
dma_unmap_sg(dd-pdev-dev,
@@ -733,24 +738,22 @@ static void mtip_async_complete(struct mtip_port *port,
 static void mtip_completion(struct mtip_port *port,
int tag

Re: linux-next: manual merge of the akpm tree with the block tree

2013-01-15 Thread Asai Thambi S P
On 1/14/2013 9:28 AM, Stephen Rothwell wrote:

> Hi Andrew,
> 
> Today's linux-next merge of the akpm tree got a conflict in
> drivers/block/mtip32xx/mtip32xx.c between commit 16c906e51c6f ("mtip32xx:
> Add workqueue and NUMA support") from the  tree and commit "mtip32xx:
> convert to batch completion" from the akpm tree.
> 
> I couldn't see how to fix up the conflicts, so I just dropped the akpm
> tree patch.
> 

I will fix this and send out the patch.

--
Regards,
Asai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux-next: manual merge of the akpm tree with the block tree

2013-01-15 Thread Asai Thambi S P
On 1/14/2013 9:28 AM, Stephen Rothwell wrote:

 Hi Andrew,
 
 Today's linux-next merge of the akpm tree got a conflict in
 drivers/block/mtip32xx/mtip32xx.c between commit 16c906e51c6f (mtip32xx:
 Add workqueue and NUMA support) from the  tree and commit mtip32xx:
 convert to batch completion from the akpm tree.
 
 I couldn't see how to fix up the conflicts, so I just dropped the akpm
 tree patch.
 

I will fix this and send out the patch.

--
Regards,
Asai
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] mtip32xx: fix for crash when the device surprise removed during rebuild

2013-01-11 Thread Asai Thambi S P

When rebuild is in progress, disk->queue is yet to be created. Surprise
removing the device will call remove()-> del_gendisk(). del_gendisk()
expect disk->queue be not NULL. Fix is to call put_disk() when disk_queue
is NULL.

Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index a070a68..cfe65cf 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3967,7 +3967,12 @@ static int mtip_block_remove(struct driver_data *dd)
 * Delete our gendisk structure. This also removes the device
 * from /dev
 */
-   del_gendisk(dd->disk);
+   if (dd->disk) {
+   if (dd->disk->queue)
+   del_gendisk(dd->disk);
+   else
+   put_disk(dd->disk);
+   }
 
spin_lock(_index_lock);
ida_remove(_index_ida, dd->index);
@@ -4001,7 +4006,13 @@ static int mtip_block_shutdown(struct driver_data *dd)
"Shutting down %s ...\n", dd->disk->disk_name);
 
/* Delete our gendisk structure, and cleanup the blk queue. */
-   del_gendisk(dd->disk);
+   if (dd->disk) {
+   if (dd->disk->queue)
+   del_gendisk(dd->disk);
+   else
+   put_disk(dd->disk);
+   }
+
 
spin_lock(_index_lock);
ida_remove(_index_ida, dd->index);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] mtip32xx: fix for driver hang after a command timeout

2013-01-11 Thread Asai Thambi S P

If an I/O command times out when a PIO command is active,
MTIP_PF_EH_ACTIVE_BIT is not cleared. This results in I/O
hang in the driver. Fix is to clear this bit.

Signed-off-by: Asai Thambi S P 

---
 drivers/block/mtip32xx/mtip32xx.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index b7e6631..a070a68 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -625,12 +625,13 @@ static void mtip_timeout_function(unsigned long int data)
}
}
 
-   if (cmdto_cnt && !test_bit(MTIP_PF_IC_ACTIVE_BIT, >flags)) {
+   if (cmdto_cnt) {
print_tags(port->dd, "timed out", tagaccum, cmdto_cnt);
-
-   mtip_restart_port(port);
+   if (!test_bit(MTIP_PF_IC_ACTIVE_BIT, >flags)) {
+   mtip_restart_port(port);
+   wake_up_interruptible(>svc_wait);
+   }
clear_bit(MTIP_PF_EH_ACTIVE_BIT, >flags);
-   wake_up_interruptible(>svc_wait);
}
 
if (port->ic_pause_timer) {
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] mtip32xx: add trim support

2013-01-11 Thread Asai Thambi S P
TRIM support added through vendor unique command.

Signed-off-by: Sam Bradshaw < sbrads...@micron.com>
Signed-off-by: Asai Thambi S P 
---
 drivers/block/mtip32xx/mtip32xx.c |   96 +
 drivers/block/mtip32xx/mtip32xx.h |   18 +++
 2 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index f946d31..b7e6631 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1487,6 +1487,12 @@ static int mtip_get_identify(struct mtip_port *port, 
void __user *user_buffer)
}
 #endif
 
+   /* Demux ID.DRAT & ID.RZAT to determine trim support */
+   if (port->identify[69] & (1 << 14) && port->identify[69] & (1 << 5))
+   port->dd->trim_supp = true;
+   else
+   port->dd->trim_supp = false;
+
/* Set the identify buffer as valid. */
port->identify_valid = 1;
 
@@ -1674,6 +1680,81 @@ static int mtip_get_smart_attr(struct mtip_port *port, 
unsigned int id,
 }
 
 /*
+ * Trim unused sectors
+ *
+ * @dd pointer to driver_data structure
+ * @lbastarting lba
+ * @len# of 512b sectors to trim
+ *
+ * return value
+ *  -ENOMEMOut of dma memory
+ *  -EINVALInvalid parameters passed in, trim not supported
+ *  -EIO   Error submitting trim request to hw
+ */
+int mtip_send_trim(struct driver_data *dd, unsigned int lba, unsigned int len)
+{
+   int i, rv = 0;
+   u64 tlba, tlen, sect_left;
+   struct mtip_trim_entry *buf;
+   dma_addr_t dma_addr;
+   struct host_to_dev_fis fis;
+
+   if (!len || dd->trim_supp == false)
+   return -EINVAL;
+
+   /* Trim request too big */
+   WARN_ON(len > (MTIP_MAX_TRIM_ENTRY_LEN * MTIP_MAX_TRIM_ENTRIES));
+
+   /* Trim request not aligned on 4k boundary */
+   WARN_ON(len % 8 != 0);
+
+   /* Warn if vu_trim structure is too big */
+   WARN_ON(sizeof(struct mtip_trim) > ATA_SECT_SIZE);
+
+   /* Allocate a DMA buffer for the trim structure */
+   buf = dmam_alloc_coherent(>pdev->dev, ATA_SECT_SIZE, _addr,
+   GFP_KERNEL);
+   if (!buf)
+   return -ENOMEM;
+   memset(buf, 0, ATA_SECT_SIZE);
+
+   for (i = 0, sect_left = len, tlba = lba;
+   i < MTIP_MAX_TRIM_ENTRIES && sect_left;
+   i++) {
+   tlen = (sect_left >= MTIP_MAX_TRIM_ENTRY_LEN ?
+   MTIP_MAX_TRIM_ENTRY_LEN :
+   sect_left);
+   buf[i].lba = __force_bit2int cpu_to_le32(tlba);
+   buf[i].range = __force_bit2int cpu_to_le16(tlen);
+   tlba += tlen;
+   sect_left -= tlen;
+   }
+   WARN_ON(sect_left != 0);
+
+   /* Build the fis */
+   memset(, 0, sizeof(struct host_to_dev_fis));
+   fis.type   = 0x27;
+   fis.opts   = 1 << 7;
+   fis.command= 0xfb;
+   fis.features   = 0x60;
+   fis.sect_count = 1;
+   fis.device = ATA_DEVICE_OBS;
+
+   if (mtip_exec_internal_command(dd->port,
+   ,
+   5,
+   dma_addr,
+   ATA_SECT_SIZE,
+   0,
+   GFP_KERNEL,
+   MTIP_TRIM_TIMEOUT_MS) < 0)
+   rv = -EIO;
+
+   dmam_free_coherent(>pdev->dev, ATA_SECT_SIZE, buf, dma_addr);
+   return rv;
+}
+
+/*
  * Get the drive capacity.
  *
  * @dd  Pointer to the device data structure.
@@ -3623,6 +3704,12 @@ static void mtip_make_request(struct request_queue 
*queue, struct bio *bio)
}
}
 
+   if (unlikely(bio->bi_rw & REQ_DISCARD)) {
+   bio_endio(bio, mtip_send_trim(dd, bio->bi_sector,
+   bio_sectors(bio)));
+   return;
+   }
+
if (unlikely(!bio_has_data(bio))) {
blk_queue_flush(queue, 0);
bio_endio(bio, 0);
@@ -3765,6 +3852,15 @@ skip_create_disk:
 */
blk_queue_flush(dd->queue, 0);
 
+   /* Signal trim support */
+   if (dd->trim_supp == true) {
+   set_bit(QUEUE_FLAG_DISCARD, >queue->queue_flags);
+   dd->queue->limits.discard_granularity = 4096;
+   blk_queue_max_discard_sectors(dd->queue,
+   MTIP_MAX_TRIM_ENTRY_LEN * MTIP_MAX_TRIM_ENTRIES);
+   dd->queue->limits.discard_zeroes_data = 0;
+   }
+
/* Set the capacity of the device in 512 by

[PATCH 0/3] mtip32xx: add trim support and couple of fixes

2013-01-11 Thread Asai Thambi S P

This patch series contain changes for trim support and couple of fixes

Asai Thambi S P (3):
  mtip32xx: add trim support
  mtip32xx: fix for driver hang after a command timeout
  mtip32xx: fix for crash when the device surprise removed during
rebuild

 drivers/block/mtip32xx/mtip32xx.c |  120 +++--
 drivers/block/mtip32xx/mtip32xx.h |   18 ++
 2 files changed, 132 insertions(+), 6 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] mtip32xx: add trim support and couple of fixes

2013-01-11 Thread Asai Thambi S P

This patch series contain changes for trim support and couple of fixes

Asai Thambi S P (3):
  mtip32xx: add trim support
  mtip32xx: fix for driver hang after a command timeout
  mtip32xx: fix for crash when the device surprise removed during
rebuild

 drivers/block/mtip32xx/mtip32xx.c |  120 +++--
 drivers/block/mtip32xx/mtip32xx.h |   18 ++
 2 files changed, 132 insertions(+), 6 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] mtip32xx: add trim support

2013-01-11 Thread Asai Thambi S P
TRIM support added through vendor unique command.

Signed-off-by: Sam Bradshaw  sbrads...@micron.com
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   96 +
 drivers/block/mtip32xx/mtip32xx.h |   18 +++
 2 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index f946d31..b7e6631 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1487,6 +1487,12 @@ static int mtip_get_identify(struct mtip_port *port, 
void __user *user_buffer)
}
 #endif
 
+   /* Demux ID.DRAT  ID.RZAT to determine trim support */
+   if (port-identify[69]  (1  14)  port-identify[69]  (1  5))
+   port-dd-trim_supp = true;
+   else
+   port-dd-trim_supp = false;
+
/* Set the identify buffer as valid. */
port-identify_valid = 1;
 
@@ -1674,6 +1680,81 @@ static int mtip_get_smart_attr(struct mtip_port *port, 
unsigned int id,
 }
 
 /*
+ * Trim unused sectors
+ *
+ * @dd pointer to driver_data structure
+ * @lbastarting lba
+ * @len# of 512b sectors to trim
+ *
+ * return value
+ *  -ENOMEMOut of dma memory
+ *  -EINVALInvalid parameters passed in, trim not supported
+ *  -EIO   Error submitting trim request to hw
+ */
+int mtip_send_trim(struct driver_data *dd, unsigned int lba, unsigned int len)
+{
+   int i, rv = 0;
+   u64 tlba, tlen, sect_left;
+   struct mtip_trim_entry *buf;
+   dma_addr_t dma_addr;
+   struct host_to_dev_fis fis;
+
+   if (!len || dd-trim_supp == false)
+   return -EINVAL;
+
+   /* Trim request too big */
+   WARN_ON(len  (MTIP_MAX_TRIM_ENTRY_LEN * MTIP_MAX_TRIM_ENTRIES));
+
+   /* Trim request not aligned on 4k boundary */
+   WARN_ON(len % 8 != 0);
+
+   /* Warn if vu_trim structure is too big */
+   WARN_ON(sizeof(struct mtip_trim)  ATA_SECT_SIZE);
+
+   /* Allocate a DMA buffer for the trim structure */
+   buf = dmam_alloc_coherent(dd-pdev-dev, ATA_SECT_SIZE, dma_addr,
+   GFP_KERNEL);
+   if (!buf)
+   return -ENOMEM;
+   memset(buf, 0, ATA_SECT_SIZE);
+
+   for (i = 0, sect_left = len, tlba = lba;
+   i  MTIP_MAX_TRIM_ENTRIES  sect_left;
+   i++) {
+   tlen = (sect_left = MTIP_MAX_TRIM_ENTRY_LEN ?
+   MTIP_MAX_TRIM_ENTRY_LEN :
+   sect_left);
+   buf[i].lba = __force_bit2int cpu_to_le32(tlba);
+   buf[i].range = __force_bit2int cpu_to_le16(tlen);
+   tlba += tlen;
+   sect_left -= tlen;
+   }
+   WARN_ON(sect_left != 0);
+
+   /* Build the fis */
+   memset(fis, 0, sizeof(struct host_to_dev_fis));
+   fis.type   = 0x27;
+   fis.opts   = 1  7;
+   fis.command= 0xfb;
+   fis.features   = 0x60;
+   fis.sect_count = 1;
+   fis.device = ATA_DEVICE_OBS;
+
+   if (mtip_exec_internal_command(dd-port,
+   fis,
+   5,
+   dma_addr,
+   ATA_SECT_SIZE,
+   0,
+   GFP_KERNEL,
+   MTIP_TRIM_TIMEOUT_MS)  0)
+   rv = -EIO;
+
+   dmam_free_coherent(dd-pdev-dev, ATA_SECT_SIZE, buf, dma_addr);
+   return rv;
+}
+
+/*
  * Get the drive capacity.
  *
  * @dd  Pointer to the device data structure.
@@ -3623,6 +3704,12 @@ static void mtip_make_request(struct request_queue 
*queue, struct bio *bio)
}
}
 
+   if (unlikely(bio-bi_rw  REQ_DISCARD)) {
+   bio_endio(bio, mtip_send_trim(dd, bio-bi_sector,
+   bio_sectors(bio)));
+   return;
+   }
+
if (unlikely(!bio_has_data(bio))) {
blk_queue_flush(queue, 0);
bio_endio(bio, 0);
@@ -3765,6 +3852,15 @@ skip_create_disk:
 */
blk_queue_flush(dd-queue, 0);
 
+   /* Signal trim support */
+   if (dd-trim_supp == true) {
+   set_bit(QUEUE_FLAG_DISCARD, dd-queue-queue_flags);
+   dd-queue-limits.discard_granularity = 4096;
+   blk_queue_max_discard_sectors(dd-queue,
+   MTIP_MAX_TRIM_ENTRY_LEN * MTIP_MAX_TRIM_ENTRIES);
+   dd-queue-limits.discard_zeroes_data = 0;
+   }
+
/* Set the capacity of the device in 512 byte sectors. */
if (!(mtip_hw_get_capacity(dd, capacity))) {
dev_warn(dd-pdev-dev,
diff --git a/drivers/block/mtip32xx

[PATCH 2/3] mtip32xx: fix for driver hang after a command timeout

2013-01-11 Thread Asai Thambi S P

If an I/O command times out when a PIO command is active,
MTIP_PF_EH_ACTIVE_BIT is not cleared. This results in I/O
hang in the driver. Fix is to clear this bit.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com

---
 drivers/block/mtip32xx/mtip32xx.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index b7e6631..a070a68 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -625,12 +625,13 @@ static void mtip_timeout_function(unsigned long int data)
}
}
 
-   if (cmdto_cnt  !test_bit(MTIP_PF_IC_ACTIVE_BIT, port-flags)) {
+   if (cmdto_cnt) {
print_tags(port-dd, timed out, tagaccum, cmdto_cnt);
-
-   mtip_restart_port(port);
+   if (!test_bit(MTIP_PF_IC_ACTIVE_BIT, port-flags)) {
+   mtip_restart_port(port);
+   wake_up_interruptible(port-svc_wait);
+   }
clear_bit(MTIP_PF_EH_ACTIVE_BIT, port-flags);
-   wake_up_interruptible(port-svc_wait);
}
 
if (port-ic_pause_timer) {
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] mtip32xx: fix for crash when the device surprise removed during rebuild

2013-01-11 Thread Asai Thambi S P

When rebuild is in progress, disk-queue is yet to be created. Surprise
removing the device will call remove()- del_gendisk(). del_gendisk()
expect disk-queue be not NULL. Fix is to call put_disk() when disk_queue
is NULL.

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index a070a68..cfe65cf 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3967,7 +3967,12 @@ static int mtip_block_remove(struct driver_data *dd)
 * Delete our gendisk structure. This also removes the device
 * from /dev
 */
-   del_gendisk(dd-disk);
+   if (dd-disk) {
+   if (dd-disk-queue)
+   del_gendisk(dd-disk);
+   else
+   put_disk(dd-disk);
+   }
 
spin_lock(rssd_index_lock);
ida_remove(rssd_index_ida, dd-index);
@@ -4001,7 +4006,13 @@ static int mtip_block_shutdown(struct driver_data *dd)
Shutting down %s ...\n, dd-disk-disk_name);
 
/* Delete our gendisk structure, and cleanup the blk queue. */
-   del_gendisk(dd-disk);
+   if (dd-disk) {
+   if (dd-disk-queue)
+   del_gendisk(dd-disk);
+   else
+   put_disk(dd-disk);
+   }
+
 
spin_lock(rssd_index_lock);
ida_remove(rssd_index_ida, dd-index);
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] mtip32xx: Remove dead code

2012-09-05 Thread Asai Thambi S P
Removed the dead code in mtip_hw_read_registers() and mtip_hw_read_flags().

Reported-by: Coverity
Signed-off-by: Asai Thambi S P 
Signed-off-by: Selvan Mani 
---
 drivers/block/mtip32xx/mtip32xx.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 362ce4a..e6519e2 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2592,9 +2592,6 @@ static ssize_t mtip_hw_read_registers(struct file *f, 
char __user *ubuf,
if (!len || size)
return 0;
 
-   if (size < 0)
-   return -EINVAL;
-
size += sprintf([size], "H/ S ACTive  : [ 0x");
 
for (n = dd->slot_groups-1; n >= 0; n--)
@@ -2664,9 +2661,6 @@ static ssize_t mtip_hw_read_flags(struct file *f, char 
__user *ubuf,
if (!len || size)
return 0;
 
-   if (size < 0)
-   return -EINVAL;
-
size += sprintf([size], "Flag-port : [ %08lX ]\n",
dd->port->flags);
size += sprintf([size], "Flag-dd   : [ %08lX ]\n",
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] mtip32xx: Change printk to pr_xxxx

2012-09-05 Thread Asai Thambi S P
Changed printk to be compliant with latest style changes

Signed-off-by: Asai Thambi S P 
Signed-off-by: Selvan Mani 
---
 drivers/block/mtip32xx/mtip32xx.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 06bc273..362ce4a 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4213,12 +4213,12 @@ static int __init mtip_init(void)
 {
int error;
 
-   printk(KERN_INFO MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n");
+   pr_info(MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n");
 
/* Allocate a major block device number to use with this driver. */
error = register_blkdev(0, MTIP_DRV_NAME);
if (error <= 0) {
-   printk(KERN_ERR "Unable to register block device (%d)\n",
+   pr_err("Unable to register block device (%d)\n",
error);
return -EBUSY;
}
@@ -4227,7 +4227,7 @@ static int __init mtip_init(void)
if (!dfs_parent) {
dfs_parent = debugfs_create_dir("rssd", NULL);
if (IS_ERR_OR_NULL(dfs_parent)) {
-   printk(KERN_WARNING "Error creating debugfs parent\n");
+   pr_warn("Error creating debugfs parent\n");
dfs_parent = NULL;
}
}
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] mtip32xx: Proper reporting of write protect status on big-endian

2012-09-05 Thread Asai Thambi S P
Proper reporting of write protect status on big-endian

Signed-off-by: Asai Thambi S P 
Signed-off-by: Selvan Mani 
---
 drivers/block/mtip32xx/mtip32xx.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index cf557a4..06bc273 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3218,8 +3218,8 @@ static int mtip_hw_init(struct driver_data *dd)
"Unable to check write protect progress\n");
else
dev_info(>pdev->dev,
-   "Write protect progress: %d%% (%d blocks)\n",
-   attr242.cur, attr242.data);
+   "Write protect progress: %u%% (%u blocks)\n",
+   attr242.cur, le32_to_cpu(attr242.data));
return rv;
 
 out3:
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] mtip32xx: Increase timeout for standby command

2012-09-05 Thread Asai Thambi S P
Increased timeout for standby command to work with larger capacity drives

Signed-off-by: Asai Thambi S P 
Signed-off-by: Selvan Mani 
---
 drivers/block/mtip32xx/mtip32xx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 2553c73..cf557a4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2047,7 +2047,7 @@ static void mtip_set_timeout(struct host_to_dev_fis *fis, 
unsigned int *timeout)
*timeout = 24; /* 4 minutes */
break;
case ATA_CMD_STANDBYNOW1:
-   *timeout = 1;  /* 10 seconds */
+   *timeout = 12;  /* 2 minutes */
break;
case 0xF7:
case 0xFA:
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] mtip32xx: Handle NCQ commands during the security locked state

2012-09-05 Thread Asai Thambi S P
Return error for NCQ commands when the drive is in security locked state

Signed-off-by: Asai Thambi S P 
Signed-off-by: Selvan Mani 
---
 drivers/block/mtip32xx/mtip32xx.c |   10 +-
 drivers/block/mtip32xx/mtip32xx.h |2 ++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index a935f4f..2553c73 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1148,11 +1148,15 @@ static bool mtip_pause_ncq(struct mtip_port *port,
reply = port->rxfis + RX_FIS_D2H_REG;
task_file_data = readl(port->mmio+PORT_TFDATA);
 
-   if ((task_file_data & 1) || (fis->command == ATA_CMD_SEC_ERASE_UNIT))
+   if (fis->command == ATA_CMD_SEC_ERASE_UNIT)
+   clear_bit(MTIP_DDF_SEC_LOCK_BIT, >dd->dd_flag);
+
+   if ((task_file_data & 1))
return false;
 
if (fis->command == ATA_CMD_SEC_ERASE_PREP) {
set_bit(MTIP_PF_SE_ACTIVE_BIT, >flags);
+   set_bit(MTIP_DDF_SEC_LOCK_BIT, >dd->dd_flag);
port->ic_pause_timer = jiffies;
return true;
} else if ((fis->command == ATA_CMD_DOWNLOAD_MICRO) &&
@@ -3619,6 +3623,10 @@ static void mtip_make_request(struct request_queue 
*queue, struct bio *bio)
bio_endio(bio, -ENODATA);
return;
}
+   if (unlikely(test_bit(MTIP_DDF_SEC_LOCK_BIT, >dd_flag))) {
+   bio_endio(bio, -ENODATA);
+   return;
+   }
}
 
if (unlikely(!bio_has_data(bio))) {
diff --git a/drivers/block/mtip32xx/mtip32xx.h 
b/drivers/block/mtip32xx/mtip32xx.h
index 0255d19..18627a1 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -137,10 +137,12 @@ enum {
MTIP_PF_SVC_THD_STOP_BIT= 8,
 
/* below are bit numbers in 'dd_flag' defined in driver_data */
+   MTIP_DDF_SEC_LOCK_BIT   = 0,
MTIP_DDF_REMOVE_PENDING_BIT = 1,
MTIP_DDF_OVER_TEMP_BIT  = 2,
MTIP_DDF_WRITE_PROTECT_BIT  = 3,
MTIP_DDF_STOP_IO  = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) | \
+   (1 << MTIP_DDF_SEC_LOCK_BIT) | \
(1 << MTIP_DDF_OVER_TEMP_BIT) | \
(1 << MTIP_DDF_WRITE_PROTECT_BIT)),
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] mtip32xx: Add support for new devices

2012-09-05 Thread Asai Thambi S P

Added supported device IDs in pci table

Signed-off-by: Asai Thambi S P 
Signed-off-by: Selvan Mani 
---
 drivers/block/mtip32xx/mtip32xx.c |8 +++-
 drivers/block/mtip32xx/mtip32xx.h |8 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index a8fddeb..a935f4f 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4168,7 +4168,13 @@ static void mtip_pci_shutdown(struct pci_dev *pdev)
 
 /* Table of device ids supported by this driver. */
 static DEFINE_PCI_DEVICE_TABLE(mtip_pci_tbl) = {
-   {  PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320H_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320M_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320S_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P325M_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P420H_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P420M_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P425M_DEVICE_ID) },
{ 0 }
 };
 
diff --git a/drivers/block/mtip32xx/mtip32xx.h 
b/drivers/block/mtip32xx/mtip32xx.h
index f51fc23..0255d19 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -76,7 +76,13 @@
 
 /* Micron Vendor ID & P320x SSD Device ID */
 #define PCI_VENDOR_ID_MICRON0x1344
-#define P320_DEVICE_ID 0x5150
+#define P320H_DEVICE_ID0x5150
+#define P320M_DEVICE_ID0x5151
+#define P320S_DEVICE_ID0x5152
+#define P325M_DEVICE_ID0x5153
+#define P420H_DEVICE_ID0x5160
+#define P420M_DEVICE_ID0x5161
+#define P425M_DEVICE_ID0x5163
 
 /* Driver name and version strings */
 #define MTIP_DRV_NAME  "mtip32xx"
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] mtip32xx: Support for new devices and minor changes

2012-09-05 Thread Asai Thambi S P
This patchset adds support for new devices and few minor changes.

Asai Thambi S P (6):
  mtip32xx: Add support for new devices
  mtip32xx: Handle NCQ commands during the security locked state
  mtip32xx: Increase timeout for standby command
  mtip32xx: Proper reporting of write protect status on big-endian
  mtip32xx: Change printk to pr_
  mtip32xx: Remove dead code

 drivers/block/mtip32xx/mtip32xx.c |   36 ++--
 drivers/block/mtip32xx/mtip32xx.h |   10 +-
 2 files changed, 31 insertions(+), 15 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] mtip32xx: Support for new devices and minor changes

2012-09-05 Thread Asai Thambi S P
This patchset adds support for new devices and few minor changes.

Asai Thambi S P (6):
  mtip32xx: Add support for new devices
  mtip32xx: Handle NCQ commands during the security locked state
  mtip32xx: Increase timeout for standby command
  mtip32xx: Proper reporting of write protect status on big-endian
  mtip32xx: Change printk to pr_
  mtip32xx: Remove dead code

 drivers/block/mtip32xx/mtip32xx.c |   36 ++--
 drivers/block/mtip32xx/mtip32xx.h |   10 +-
 2 files changed, 31 insertions(+), 15 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] mtip32xx: Add support for new devices

2012-09-05 Thread Asai Thambi S P

Added supported device IDs in pci table

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Selvan Mani sm...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |8 +++-
 drivers/block/mtip32xx/mtip32xx.h |8 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index a8fddeb..a935f4f 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4168,7 +4168,13 @@ static void mtip_pci_shutdown(struct pci_dev *pdev)
 
 /* Table of device ids supported by this driver. */
 static DEFINE_PCI_DEVICE_TABLE(mtip_pci_tbl) = {
-   {  PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320H_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320M_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320S_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P325M_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P420H_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P420M_DEVICE_ID) },
+   { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P425M_DEVICE_ID) },
{ 0 }
 };
 
diff --git a/drivers/block/mtip32xx/mtip32xx.h 
b/drivers/block/mtip32xx/mtip32xx.h
index f51fc23..0255d19 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -76,7 +76,13 @@
 
 /* Micron Vendor ID  P320x SSD Device ID */
 #define PCI_VENDOR_ID_MICRON0x1344
-#define P320_DEVICE_ID 0x5150
+#define P320H_DEVICE_ID0x5150
+#define P320M_DEVICE_ID0x5151
+#define P320S_DEVICE_ID0x5152
+#define P325M_DEVICE_ID0x5153
+#define P420H_DEVICE_ID0x5160
+#define P420M_DEVICE_ID0x5161
+#define P425M_DEVICE_ID0x5163
 
 /* Driver name and version strings */
 #define MTIP_DRV_NAME  mtip32xx
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] mtip32xx: Handle NCQ commands during the security locked state

2012-09-05 Thread Asai Thambi S P
Return error for NCQ commands when the drive is in security locked state

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Selvan Mani sm...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |   10 +-
 drivers/block/mtip32xx/mtip32xx.h |2 ++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index a935f4f..2553c73 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1148,11 +1148,15 @@ static bool mtip_pause_ncq(struct mtip_port *port,
reply = port-rxfis + RX_FIS_D2H_REG;
task_file_data = readl(port-mmio+PORT_TFDATA);
 
-   if ((task_file_data  1) || (fis-command == ATA_CMD_SEC_ERASE_UNIT))
+   if (fis-command == ATA_CMD_SEC_ERASE_UNIT)
+   clear_bit(MTIP_DDF_SEC_LOCK_BIT, port-dd-dd_flag);
+
+   if ((task_file_data  1))
return false;
 
if (fis-command == ATA_CMD_SEC_ERASE_PREP) {
set_bit(MTIP_PF_SE_ACTIVE_BIT, port-flags);
+   set_bit(MTIP_DDF_SEC_LOCK_BIT, port-dd-dd_flag);
port-ic_pause_timer = jiffies;
return true;
} else if ((fis-command == ATA_CMD_DOWNLOAD_MICRO) 
@@ -3619,6 +3623,10 @@ static void mtip_make_request(struct request_queue 
*queue, struct bio *bio)
bio_endio(bio, -ENODATA);
return;
}
+   if (unlikely(test_bit(MTIP_DDF_SEC_LOCK_BIT, dd-dd_flag))) {
+   bio_endio(bio, -ENODATA);
+   return;
+   }
}
 
if (unlikely(!bio_has_data(bio))) {
diff --git a/drivers/block/mtip32xx/mtip32xx.h 
b/drivers/block/mtip32xx/mtip32xx.h
index 0255d19..18627a1 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -137,10 +137,12 @@ enum {
MTIP_PF_SVC_THD_STOP_BIT= 8,
 
/* below are bit numbers in 'dd_flag' defined in driver_data */
+   MTIP_DDF_SEC_LOCK_BIT   = 0,
MTIP_DDF_REMOVE_PENDING_BIT = 1,
MTIP_DDF_OVER_TEMP_BIT  = 2,
MTIP_DDF_WRITE_PROTECT_BIT  = 3,
MTIP_DDF_STOP_IO  = ((1  MTIP_DDF_REMOVE_PENDING_BIT) | \
+   (1  MTIP_DDF_SEC_LOCK_BIT) | \
(1  MTIP_DDF_OVER_TEMP_BIT) | \
(1  MTIP_DDF_WRITE_PROTECT_BIT)),
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] mtip32xx: Increase timeout for standby command

2012-09-05 Thread Asai Thambi S P
Increased timeout for standby command to work with larger capacity drives

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Selvan Mani sm...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 2553c73..cf557a4 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2047,7 +2047,7 @@ static void mtip_set_timeout(struct host_to_dev_fis *fis, 
unsigned int *timeout)
*timeout = 24; /* 4 minutes */
break;
case ATA_CMD_STANDBYNOW1:
-   *timeout = 1;  /* 10 seconds */
+   *timeout = 12;  /* 2 minutes */
break;
case 0xF7:
case 0xFA:
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] mtip32xx: Proper reporting of write protect status on big-endian

2012-09-05 Thread Asai Thambi S P
Proper reporting of write protect status on big-endian

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Selvan Mani sm...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index cf557a4..06bc273 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3218,8 +3218,8 @@ static int mtip_hw_init(struct driver_data *dd)
Unable to check write protect progress\n);
else
dev_info(dd-pdev-dev,
-   Write protect progress: %d%% (%d blocks)\n,
-   attr242.cur, attr242.data);
+   Write protect progress: %u%% (%u blocks)\n,
+   attr242.cur, le32_to_cpu(attr242.data));
return rv;
 
 out3:
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] mtip32xx: Change printk to pr_xxxx

2012-09-05 Thread Asai Thambi S P
Changed printk to be compliant with latest style changes

Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Selvan Mani sm...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 06bc273..362ce4a 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -4213,12 +4213,12 @@ static int __init mtip_init(void)
 {
int error;
 
-   printk(KERN_INFO MTIP_DRV_NAME  Version  MTIP_DRV_VERSION \n);
+   pr_info(MTIP_DRV_NAME  Version  MTIP_DRV_VERSION \n);
 
/* Allocate a major block device number to use with this driver. */
error = register_blkdev(0, MTIP_DRV_NAME);
if (error = 0) {
-   printk(KERN_ERR Unable to register block device (%d)\n,
+   pr_err(Unable to register block device (%d)\n,
error);
return -EBUSY;
}
@@ -4227,7 +4227,7 @@ static int __init mtip_init(void)
if (!dfs_parent) {
dfs_parent = debugfs_create_dir(rssd, NULL);
if (IS_ERR_OR_NULL(dfs_parent)) {
-   printk(KERN_WARNING Error creating debugfs parent\n);
+   pr_warn(Error creating debugfs parent\n);
dfs_parent = NULL;
}
}
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] mtip32xx: Remove dead code

2012-09-05 Thread Asai Thambi S P
Removed the dead code in mtip_hw_read_registers() and mtip_hw_read_flags().

Reported-by: Coverity
Signed-off-by: Asai Thambi S P asamymuth...@micron.com
Signed-off-by: Selvan Mani sm...@micron.com
---
 drivers/block/mtip32xx/mtip32xx.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c 
b/drivers/block/mtip32xx/mtip32xx.c
index 362ce4a..e6519e2 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2592,9 +2592,6 @@ static ssize_t mtip_hw_read_registers(struct file *f, 
char __user *ubuf,
if (!len || size)
return 0;
 
-   if (size  0)
-   return -EINVAL;
-
size += sprintf(buf[size], H/ S ACTive  : [ 0x);
 
for (n = dd-slot_groups-1; n = 0; n--)
@@ -2664,9 +2661,6 @@ static ssize_t mtip_hw_read_flags(struct file *f, char 
__user *ubuf,
if (!len || size)
return 0;
 
-   if (size  0)
-   return -EINVAL;
-
size += sprintf(buf[size], Flag-port : [ %08lX ]\n,
dd-port-flags);
size += sprintf(buf[size], Flag-dd   : [ %08lX ]\n,
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/