diff options
author | Jens Axboe <axboe@fb.com> | 2017-04-27 18:29:26 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-05-02 09:52:08 -0400 |
commit | 0f6422a2c57c6afcf66ead903dc3fa6641184aa4 (patch) | |
tree | 710a060a7311921641138122017f26a60599a0f0 /drivers/block | |
parent | c0332694903a37cf8ecdc9102d5c9e09cf8643d0 (diff) |
mtip32xx: get rid of 'atomic' argument to mtip_exec_internal_command()
All callers can safely block. Kill the atomic/block argument, and
remove the argument from all callers.
Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/mtip32xx/mtip32xx.c | 148 |
1 files changed, 43 insertions, 105 deletions
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 02804cc79d82..d81d797ee65d 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c | |||
@@ -609,11 +609,6 @@ static void mtip_completion(struct mtip_port *port, | |||
609 | complete(waiting); | 609 | complete(waiting); |
610 | } | 610 | } |
611 | 611 | ||
612 | static void mtip_null_completion(struct mtip_port *port, | ||
613 | int tag, struct mtip_cmd *command, int status) | ||
614 | { | ||
615 | } | ||
616 | |||
617 | static int mtip_read_log_page(struct mtip_port *port, u8 page, u16 *buffer, | 612 | static int mtip_read_log_page(struct mtip_port *port, u8 page, u16 *buffer, |
618 | dma_addr_t buffer_dma, unsigned int sectors); | 613 | dma_addr_t buffer_dma, unsigned int sectors); |
619 | static int mtip_get_smart_attr(struct mtip_port *port, unsigned int id, | 614 | static int mtip_get_smart_attr(struct mtip_port *port, unsigned int id, |
@@ -1117,7 +1112,6 @@ static int mtip_exec_internal_command(struct mtip_port *port, | |||
1117 | dma_addr_t buffer, | 1112 | dma_addr_t buffer, |
1118 | int buf_len, | 1113 | int buf_len, |
1119 | u32 opts, | 1114 | u32 opts, |
1120 | gfp_t atomic, | ||
1121 | unsigned long timeout) | 1115 | unsigned long timeout) |
1122 | { | 1116 | { |
1123 | struct mtip_cmd_sg *command_sg; | 1117 | struct mtip_cmd_sg *command_sg; |
@@ -1146,30 +1140,22 @@ static int mtip_exec_internal_command(struct mtip_port *port, | |||
1146 | 1140 | ||
1147 | clear_bit(MTIP_PF_DM_ACTIVE_BIT, &port->flags); | 1141 | clear_bit(MTIP_PF_DM_ACTIVE_BIT, &port->flags); |
1148 | 1142 | ||
1149 | if (atomic == GFP_KERNEL) { | 1143 | if (fis->command != ATA_CMD_STANDBYNOW1) { |
1150 | if (fis->command != ATA_CMD_STANDBYNOW1) { | 1144 | /* wait for io to complete if non atomic */ |
1151 | /* wait for io to complete if non atomic */ | 1145 | if (mtip_quiesce_io(port, |
1152 | if (mtip_quiesce_io(port, | 1146 | MTIP_QUIESCE_IO_TIMEOUT_MS, GFP_KERNEL) < 0) { |
1153 | MTIP_QUIESCE_IO_TIMEOUT_MS, atomic) < 0) { | 1147 | dev_warn(&dd->pdev->dev, "Failed to quiesce IO\n"); |
1154 | dev_warn(&dd->pdev->dev, | 1148 | mtip_put_int_command(dd, int_cmd); |
1155 | "Failed to quiesce IO\n"); | 1149 | clear_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags); |
1156 | mtip_put_int_command(dd, int_cmd); | 1150 | wake_up_interruptible(&port->svc_wait); |
1157 | clear_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags); | 1151 | return -EBUSY; |
1158 | wake_up_interruptible(&port->svc_wait); | ||
1159 | return -EBUSY; | ||
1160 | } | ||
1161 | } | 1152 | } |
1162 | |||
1163 | /* Set the completion function and data for the command. */ | ||
1164 | int_cmd->comp_data = &wait; | ||
1165 | int_cmd->comp_func = mtip_completion; | ||
1166 | |||
1167 | } else { | ||
1168 | /* Clear completion - we're going to poll */ | ||
1169 | int_cmd->comp_data = NULL; | ||
1170 | int_cmd->comp_func = mtip_null_completion; | ||
1171 | } | 1153 | } |
1172 | 1154 | ||
1155 | /* Set the completion function and data for the command. */ | ||
1156 | int_cmd->comp_data = &wait; | ||
1157 | int_cmd->comp_func = mtip_completion; | ||
1158 | |||
1173 | /* Copy the command to the command table */ | 1159 | /* Copy the command to the command table */ |
1174 | memcpy(int_cmd->command, fis, fis_len*4); | 1160 | memcpy(int_cmd->command, fis, fis_len*4); |
1175 | 1161 | ||
@@ -1198,81 +1184,41 @@ static int mtip_exec_internal_command(struct mtip_port *port, | |||
1198 | /* Issue the command to the hardware */ | 1184 | /* Issue the command to the hardware */ |
1199 | mtip_issue_non_ncq_command(port, MTIP_TAG_INTERNAL); | 1185 | mtip_issue_non_ncq_command(port, MTIP_TAG_INTERNAL); |
1200 | 1186 | ||
1201 | if (atomic == GFP_KERNEL) { | 1187 | /* Wait for the command to complete or timeout. */ |
1202 | /* Wait for the command to complete or timeout. */ | 1188 | rv = wait_for_completion_interruptible_timeout(&wait, |
1203 | if ((rv = wait_for_completion_interruptible_timeout( | 1189 | msecs_to_jiffies(timeout)); |
1204 | &wait, | 1190 | if (rv <= 0) { |
1205 | msecs_to_jiffies(timeout))) <= 0) { | 1191 | if (rv == -ERESTARTSYS) { /* interrupted */ |
1206 | 1192 | dev_err(&dd->pdev->dev, | |
1207 | if (rv == -ERESTARTSYS) { /* interrupted */ | 1193 | "Internal command [%02X] was interrupted after %u ms\n", |
1208 | dev_err(&dd->pdev->dev, | 1194 | fis->command, |
1209 | "Internal command [%02X] was interrupted after %u ms\n", | 1195 | jiffies_to_msecs(jiffies - start)); |
1210 | fis->command, | 1196 | rv = -EINTR; |
1211 | jiffies_to_msecs(jiffies - start)); | ||
1212 | rv = -EINTR; | ||
1213 | goto exec_ic_exit; | ||
1214 | } else if (rv == 0) /* timeout */ | ||
1215 | dev_err(&dd->pdev->dev, | ||
1216 | "Internal command did not complete [%02X] within timeout of %lu ms\n", | ||
1217 | fis->command, timeout); | ||
1218 | else | ||
1219 | dev_err(&dd->pdev->dev, | ||
1220 | "Internal command [%02X] wait returned code [%d] after %lu ms - unhandled\n", | ||
1221 | fis->command, rv, timeout); | ||
1222 | |||
1223 | if (mtip_check_surprise_removal(dd->pdev) || | ||
1224 | test_bit(MTIP_DDF_REMOVE_PENDING_BIT, | ||
1225 | &dd->dd_flag)) { | ||
1226 | dev_err(&dd->pdev->dev, | ||
1227 | "Internal command [%02X] wait returned due to SR\n", | ||
1228 | fis->command); | ||
1229 | rv = -ENXIO; | ||
1230 | goto exec_ic_exit; | ||
1231 | } | ||
1232 | mtip_device_reset(dd); /* recover from timeout issue */ | ||
1233 | rv = -EAGAIN; | ||
1234 | goto exec_ic_exit; | 1197 | goto exec_ic_exit; |
1235 | } | 1198 | } else if (rv == 0) /* timeout */ |
1236 | } else { | 1199 | dev_err(&dd->pdev->dev, |
1237 | u32 hba_stat, port_stat; | 1200 | "Internal command did not complete [%02X] within timeout of %lu ms\n", |
1238 | 1201 | fis->command, timeout); | |
1239 | /* Spin for <timeout> checking if command still outstanding */ | 1202 | else |
1240 | timeout = jiffies + msecs_to_jiffies(timeout); | 1203 | dev_err(&dd->pdev->dev, |
1241 | while ((readl(port->cmd_issue[MTIP_TAG_INTERNAL]) | 1204 | "Internal command [%02X] wait returned code [%d] after %lu ms - unhandled\n", |
1242 | & (1 << MTIP_TAG_INTERNAL)) | 1205 | fis->command, rv, timeout); |
1243 | && time_before(jiffies, timeout)) { | ||
1244 | if (mtip_check_surprise_removal(dd->pdev)) { | ||
1245 | rv = -ENXIO; | ||
1246 | goto exec_ic_exit; | ||
1247 | } | ||
1248 | if ((fis->command != ATA_CMD_STANDBYNOW1) && | ||
1249 | test_bit(MTIP_DDF_REMOVE_PENDING_BIT, | ||
1250 | &dd->dd_flag)) { | ||
1251 | rv = -ENXIO; | ||
1252 | goto exec_ic_exit; | ||
1253 | } | ||
1254 | port_stat = readl(port->mmio + PORT_IRQ_STAT); | ||
1255 | if (!port_stat) | ||
1256 | continue; | ||
1257 | 1206 | ||
1258 | if (port_stat & PORT_IRQ_ERR) { | 1207 | if (mtip_check_surprise_removal(dd->pdev) || |
1259 | dev_err(&dd->pdev->dev, | 1208 | test_bit(MTIP_DDF_REMOVE_PENDING_BIT, |
1260 | "Internal command [%02X] failed\n", | 1209 | &dd->dd_flag)) { |
1261 | fis->command); | 1210 | dev_err(&dd->pdev->dev, |
1262 | mtip_device_reset(dd); | 1211 | "Internal command [%02X] wait returned due to SR\n", |
1263 | rv = -EIO; | 1212 | fis->command); |
1264 | goto exec_ic_exit; | 1213 | rv = -ENXIO; |
1265 | } else { | 1214 | goto exec_ic_exit; |
1266 | writel(port_stat, port->mmio + PORT_IRQ_STAT); | ||
1267 | hba_stat = readl(dd->mmio + HOST_IRQ_STAT); | ||
1268 | if (hba_stat) | ||
1269 | writel(hba_stat, | ||
1270 | dd->mmio + HOST_IRQ_STAT); | ||
1271 | } | ||
1272 | break; | ||
1273 | } | 1215 | } |
1216 | mtip_device_reset(dd); /* recover from timeout issue */ | ||
1217 | rv = -EAGAIN; | ||
1218 | goto exec_ic_exit; | ||
1274 | } | 1219 | } |
1275 | 1220 | ||
1221 | rv = 0; | ||
1276 | if (readl(port->cmd_issue[MTIP_TAG_INTERNAL]) | 1222 | if (readl(port->cmd_issue[MTIP_TAG_INTERNAL]) |
1277 | & (1 << MTIP_TAG_INTERNAL)) { | 1223 | & (1 << MTIP_TAG_INTERNAL)) { |
1278 | rv = -ENXIO; | 1224 | rv = -ENXIO; |
@@ -1391,7 +1337,6 @@ static int mtip_get_identify(struct mtip_port *port, void __user *user_buffer) | |||
1391 | port->identify_dma, | 1337 | port->identify_dma, |
1392 | sizeof(u16) * ATA_ID_WORDS, | 1338 | sizeof(u16) * ATA_ID_WORDS, |
1393 | 0, | 1339 | 0, |
1394 | GFP_KERNEL, | ||
1395 | MTIP_INT_CMD_TIMEOUT_MS) | 1340 | MTIP_INT_CMD_TIMEOUT_MS) |
1396 | < 0) { | 1341 | < 0) { |
1397 | rv = -1; | 1342 | rv = -1; |
@@ -1477,7 +1422,6 @@ static int mtip_standby_immediate(struct mtip_port *port) | |||
1477 | 0, | 1422 | 0, |
1478 | 0, | 1423 | 0, |
1479 | 0, | 1424 | 0, |
1480 | GFP_ATOMIC, | ||
1481 | timeout); | 1425 | timeout); |
1482 | dbg_printk(MTIP_DRV_NAME "Time taken to complete standby cmd: %d ms\n", | 1426 | dbg_printk(MTIP_DRV_NAME "Time taken to complete standby cmd: %d ms\n", |
1483 | jiffies_to_msecs(jiffies - start)); | 1427 | jiffies_to_msecs(jiffies - start)); |
@@ -1523,7 +1467,6 @@ static int mtip_read_log_page(struct mtip_port *port, u8 page, u16 *buffer, | |||
1523 | buffer_dma, | 1467 | buffer_dma, |
1524 | sectors * ATA_SECT_SIZE, | 1468 | sectors * ATA_SECT_SIZE, |
1525 | 0, | 1469 | 0, |
1526 | GFP_ATOMIC, | ||
1527 | MTIP_INT_CMD_TIMEOUT_MS); | 1470 | MTIP_INT_CMD_TIMEOUT_MS); |
1528 | } | 1471 | } |
1529 | 1472 | ||
@@ -1558,7 +1501,6 @@ static int mtip_get_smart_data(struct mtip_port *port, u8 *buffer, | |||
1558 | buffer_dma, | 1501 | buffer_dma, |
1559 | ATA_SECT_SIZE, | 1502 | ATA_SECT_SIZE, |
1560 | 0, | 1503 | 0, |
1561 | GFP_ATOMIC, | ||
1562 | 15000); | 1504 | 15000); |
1563 | } | 1505 | } |
1564 | 1506 | ||
@@ -1686,7 +1628,6 @@ static int mtip_send_trim(struct driver_data *dd, unsigned int lba, | |||
1686 | dma_addr, | 1628 | dma_addr, |
1687 | ATA_SECT_SIZE, | 1629 | ATA_SECT_SIZE, |
1688 | 0, | 1630 | 0, |
1689 | GFP_KERNEL, | ||
1690 | MTIP_TRIM_TIMEOUT_MS) < 0) | 1631 | MTIP_TRIM_TIMEOUT_MS) < 0) |
1691 | rv = -EIO; | 1632 | rv = -EIO; |
1692 | 1633 | ||
@@ -1850,7 +1791,6 @@ static int exec_drive_task(struct mtip_port *port, u8 *command) | |||
1850 | 0, | 1791 | 0, |
1851 | 0, | 1792 | 0, |
1852 | 0, | 1793 | 0, |
1853 | GFP_KERNEL, | ||
1854 | to) < 0) { | 1794 | to) < 0) { |
1855 | return -1; | 1795 | return -1; |
1856 | } | 1796 | } |
@@ -1946,7 +1886,6 @@ static int exec_drive_command(struct mtip_port *port, u8 *command, | |||
1946 | (xfer_sz ? dma_addr : 0), | 1886 | (xfer_sz ? dma_addr : 0), |
1947 | (xfer_sz ? ATA_SECT_SIZE * xfer_sz : 0), | 1887 | (xfer_sz ? ATA_SECT_SIZE * xfer_sz : 0), |
1948 | 0, | 1888 | 0, |
1949 | GFP_KERNEL, | ||
1950 | to) | 1889 | to) |
1951 | < 0) { | 1890 | < 0) { |
1952 | rv = -EFAULT; | 1891 | rv = -EFAULT; |
@@ -2189,7 +2128,6 @@ static int exec_drive_taskfile(struct driver_data *dd, | |||
2189 | dma_buffer, | 2128 | dma_buffer, |
2190 | transfer_size, | 2129 | transfer_size, |
2191 | 0, | 2130 | 0, |
2192 | GFP_KERNEL, | ||
2193 | timeout) < 0) { | 2131 | timeout) < 0) { |
2194 | err = -EIO; | 2132 | err = -EIO; |
2195 | goto abort; | 2133 | goto abort; |