diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/dc395x.c | 48 | ||||
-rw-r--r-- | drivers/scsi/dpt_i2o.c | 9 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_sx4.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_scan.c | 16 | ||||
-rw-r--r-- | drivers/scsi/scsi_transport_fc.c | 19 |
6 files changed, 57 insertions, 38 deletions
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 929170dcd3cb..600ba1202864 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c | |||
@@ -183,7 +183,7 @@ | |||
183 | * cross a page boundy. | 183 | * cross a page boundy. |
184 | */ | 184 | */ |
185 | #define SEGMENTX_LEN (sizeof(struct SGentry)*DC395x_MAX_SG_LISTENTRY) | 185 | #define SEGMENTX_LEN (sizeof(struct SGentry)*DC395x_MAX_SG_LISTENTRY) |
186 | #define VIRTX_LEN (sizeof(void *) * DC395x_MAX_SG_LISTENTRY) | 186 | |
187 | 187 | ||
188 | struct SGentry { | 188 | struct SGentry { |
189 | u32 address; /* bus! address */ | 189 | u32 address; /* bus! address */ |
@@ -235,7 +235,6 @@ struct ScsiReqBlk { | |||
235 | u8 sg_count; /* No of HW sg entries for this request */ | 235 | u8 sg_count; /* No of HW sg entries for this request */ |
236 | u8 sg_index; /* Index of HW sg entry for this request */ | 236 | u8 sg_index; /* Index of HW sg entry for this request */ |
237 | u32 total_xfer_length; /* Total number of bytes remaining to be transfered */ | 237 | u32 total_xfer_length; /* Total number of bytes remaining to be transfered */ |
238 | void **virt_map; | ||
239 | unsigned char *virt_addr; /* Virtual address of current transfer position */ | 238 | unsigned char *virt_addr; /* Virtual address of current transfer position */ |
240 | 239 | ||
241 | /* | 240 | /* |
@@ -1022,14 +1021,14 @@ static void build_srb(struct scsi_cmnd *cmd, struct DeviceCtlBlk *dcb, | |||
1022 | reqlen, cmd->request_buffer, cmd->use_sg, | 1021 | reqlen, cmd->request_buffer, cmd->use_sg, |
1023 | srb->sg_count); | 1022 | srb->sg_count); |
1024 | 1023 | ||
1024 | srb->virt_addr = page_address(sl->page); | ||
1025 | for (i = 0; i < srb->sg_count; i++) { | 1025 | for (i = 0; i < srb->sg_count; i++) { |
1026 | u32 seglen = (u32)sg_dma_len(sl + i); | 1026 | u32 busaddr = (u32)sg_dma_address(&sl[i]); |
1027 | sgp[i].address = (u32)sg_dma_address(sl + i); | 1027 | u32 seglen = (u32)sl[i].length; |
1028 | sgp[i].address = busaddr; | ||
1028 | sgp[i].length = seglen; | 1029 | sgp[i].length = seglen; |
1029 | srb->total_xfer_length += seglen; | 1030 | srb->total_xfer_length += seglen; |
1030 | srb->virt_map[i] = kmap(sl[i].page); | ||
1031 | } | 1031 | } |
1032 | srb->virt_addr = srb->virt_map[0]; | ||
1033 | sgp += srb->sg_count - 1; | 1032 | sgp += srb->sg_count - 1; |
1034 | 1033 | ||
1035 | /* | 1034 | /* |
@@ -1976,7 +1975,6 @@ static void sg_update_list(struct ScsiReqBlk *srb, u32 left) | |||
1976 | int segment = cmd->use_sg; | 1975 | int segment = cmd->use_sg; |
1977 | u32 xferred = srb->total_xfer_length - left; /* bytes transfered */ | 1976 | u32 xferred = srb->total_xfer_length - left; /* bytes transfered */ |
1978 | struct SGentry *psge = srb->segment_x + srb->sg_index; | 1977 | struct SGentry *psge = srb->segment_x + srb->sg_index; |
1979 | void **virt = srb->virt_map; | ||
1980 | 1978 | ||
1981 | dprintkdbg(DBG_0, | 1979 | dprintkdbg(DBG_0, |
1982 | "sg_update_list: Transfered %i of %i bytes, %i remain\n", | 1980 | "sg_update_list: Transfered %i of %i bytes, %i remain\n", |
@@ -2016,16 +2014,16 @@ static void sg_update_list(struct ScsiReqBlk *srb, u32 left) | |||
2016 | 2014 | ||
2017 | /* We have to walk the scatterlist to find it */ | 2015 | /* We have to walk the scatterlist to find it */ |
2018 | sg = (struct scatterlist *)cmd->request_buffer; | 2016 | sg = (struct scatterlist *)cmd->request_buffer; |
2019 | idx = 0; | ||
2020 | while (segment--) { | 2017 | while (segment--) { |
2021 | unsigned long mask = | 2018 | unsigned long mask = |
2022 | ~((unsigned long)sg->length - 1) & PAGE_MASK; | 2019 | ~((unsigned long)sg->length - 1) & PAGE_MASK; |
2023 | if ((sg_dma_address(sg) & mask) == (psge->address & mask)) { | 2020 | if ((sg_dma_address(sg) & mask) == (psge->address & mask)) { |
2024 | srb->virt_addr = virt[idx] + (psge->address & ~PAGE_MASK); | 2021 | srb->virt_addr = (page_address(sg->page) |
2022 | + psge->address - | ||
2023 | (psge->address & PAGE_MASK)); | ||
2025 | return; | 2024 | return; |
2026 | } | 2025 | } |
2027 | ++sg; | 2026 | ++sg; |
2028 | ++idx; | ||
2029 | } | 2027 | } |
2030 | 2028 | ||
2031 | dprintkl(KERN_ERR, "sg_update_list: sg_to_virt failed\n"); | 2029 | dprintkl(KERN_ERR, "sg_update_list: sg_to_virt failed\n"); |
@@ -2151,7 +2149,7 @@ static void data_out_phase0(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb, | |||
2151 | DC395x_read32(acb, TRM_S1040_DMA_CXCNT)); | 2149 | DC395x_read32(acb, TRM_S1040_DMA_CXCNT)); |
2152 | } | 2150 | } |
2153 | /* | 2151 | /* |
2154 | * calculate all the residue data that not yet transfered | 2152 | * calculate all the residue data that not yet tranfered |
2155 | * SCSI transfer counter + left in SCSI FIFO data | 2153 | * SCSI transfer counter + left in SCSI FIFO data |
2156 | * | 2154 | * |
2157 | * .....TRM_S1040_SCSI_COUNTER (24bits) | 2155 | * .....TRM_S1040_SCSI_COUNTER (24bits) |
@@ -3269,7 +3267,6 @@ static void pci_unmap_srb(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb) | |||
3269 | struct scsi_cmnd *cmd = srb->cmd; | 3267 | struct scsi_cmnd *cmd = srb->cmd; |
3270 | enum dma_data_direction dir = cmd->sc_data_direction; | 3268 | enum dma_data_direction dir = cmd->sc_data_direction; |
3271 | if (cmd->use_sg && dir != PCI_DMA_NONE) { | 3269 | if (cmd->use_sg && dir != PCI_DMA_NONE) { |
3272 | int i; | ||
3273 | /* unmap DC395x SG list */ | 3270 | /* unmap DC395x SG list */ |
3274 | dprintkdbg(DBG_SG, "pci_unmap_srb: list=%08x(%05x)\n", | 3271 | dprintkdbg(DBG_SG, "pci_unmap_srb: list=%08x(%05x)\n", |
3275 | srb->sg_bus_addr, SEGMENTX_LEN); | 3272 | srb->sg_bus_addr, SEGMENTX_LEN); |
@@ -3279,8 +3276,6 @@ static void pci_unmap_srb(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb) | |||
3279 | dprintkdbg(DBG_SG, "pci_unmap_srb: segs=%i buffer=%p\n", | 3276 | dprintkdbg(DBG_SG, "pci_unmap_srb: segs=%i buffer=%p\n", |
3280 | cmd->use_sg, cmd->request_buffer); | 3277 | cmd->use_sg, cmd->request_buffer); |
3281 | /* unmap the sg segments */ | 3278 | /* unmap the sg segments */ |
3282 | for (i = 0; i < srb->sg_count; i++) | ||
3283 | kunmap(virt_to_page(srb->virt_map[i])); | ||
3284 | pci_unmap_sg(acb->dev, | 3279 | pci_unmap_sg(acb->dev, |
3285 | (struct scatterlist *)cmd->request_buffer, | 3280 | (struct scatterlist *)cmd->request_buffer, |
3286 | cmd->use_sg, dir); | 3281 | cmd->use_sg, dir); |
@@ -3327,7 +3322,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, | |||
3327 | 3322 | ||
3328 | if (cmd->use_sg) { | 3323 | if (cmd->use_sg) { |
3329 | struct scatterlist* sg = (struct scatterlist *)cmd->request_buffer; | 3324 | struct scatterlist* sg = (struct scatterlist *)cmd->request_buffer; |
3330 | ptr = (struct ScsiInqData *)(srb->virt_map[0] + sg->offset); | 3325 | ptr = (struct ScsiInqData *)(page_address(sg->page) + sg->offset); |
3331 | } else { | 3326 | } else { |
3332 | ptr = (struct ScsiInqData *)(cmd->request_buffer); | 3327 | ptr = (struct ScsiInqData *)(cmd->request_buffer); |
3333 | } | 3328 | } |
@@ -4262,9 +4257,8 @@ static void adapter_sg_tables_free(struct AdapterCtlBlk *acb) | |||
4262 | const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN; | 4257 | const unsigned srbs_per_page = PAGE_SIZE/SEGMENTX_LEN; |
4263 | 4258 | ||
4264 | for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page) | 4259 | for (i = 0; i < DC395x_MAX_SRB_CNT; i += srbs_per_page) |
4265 | kfree(acb->srb_array[i].segment_x); | 4260 | if (acb->srb_array[i].segment_x) |
4266 | 4261 | kfree(acb->srb_array[i].segment_x); | |
4267 | vfree(acb->srb_array[0].virt_map); | ||
4268 | } | 4262 | } |
4269 | 4263 | ||
4270 | 4264 | ||
@@ -4280,12 +4274,9 @@ static int __devinit adapter_sg_tables_alloc(struct AdapterCtlBlk *acb) | |||
4280 | int srb_idx = 0; | 4274 | int srb_idx = 0; |
4281 | unsigned i = 0; | 4275 | unsigned i = 0; |
4282 | struct SGentry *ptr; | 4276 | struct SGentry *ptr; |
4283 | void **virt_array; | ||
4284 | 4277 | ||
4285 | for (i = 0; i < DC395x_MAX_SRB_CNT; i++) { | 4278 | for (i = 0; i < DC395x_MAX_SRB_CNT; i++) |
4286 | acb->srb_array[i].segment_x = NULL; | 4279 | acb->srb_array[i].segment_x = NULL; |
4287 | acb->srb_array[i].virt_map = NULL; | ||
4288 | } | ||
4289 | 4280 | ||
4290 | dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages); | 4281 | dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages); |
4291 | while (pages--) { | 4282 | while (pages--) { |
@@ -4306,19 +4297,6 @@ static int __devinit adapter_sg_tables_alloc(struct AdapterCtlBlk *acb) | |||
4306 | ptr + (i * DC395x_MAX_SG_LISTENTRY); | 4297 | ptr + (i * DC395x_MAX_SG_LISTENTRY); |
4307 | else | 4298 | else |
4308 | dprintkl(KERN_DEBUG, "No space for tmsrb SG table reserved?!\n"); | 4299 | dprintkl(KERN_DEBUG, "No space for tmsrb SG table reserved?!\n"); |
4309 | |||
4310 | virt_array = vmalloc((DC395x_MAX_SRB_CNT + 1) * DC395x_MAX_SG_LISTENTRY * sizeof(void*)); | ||
4311 | |||
4312 | if (!virt_array) { | ||
4313 | adapter_sg_tables_free(acb); | ||
4314 | return 1; | ||
4315 | } | ||
4316 | |||
4317 | for (i = 0; i < DC395x_MAX_SRB_CNT + 1; i++) { | ||
4318 | acb->srb_array[i].virt_map = virt_array; | ||
4319 | virt_array += DC395x_MAX_SG_LISTENTRY; | ||
4320 | } | ||
4321 | |||
4322 | return 0; | 4300 | return 0; |
4323 | } | 4301 | } |
4324 | 4302 | ||
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index e2370529c632..7235f94f1191 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -907,9 +907,13 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
907 | raptorFlag = TRUE; | 907 | raptorFlag = TRUE; |
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | if (pci_request_regions(pDev, "dpt_i2o")) { | |
911 | PERROR("dpti: adpt_config_hba: pci request region failed\n"); | ||
912 | return -EINVAL; | ||
913 | } | ||
911 | base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size); | 914 | base_addr_virt = ioremap(base_addr0_phys,hba_map0_area_size); |
912 | if (!base_addr_virt) { | 915 | if (!base_addr_virt) { |
916 | pci_release_regions(pDev); | ||
913 | PERROR("dpti: adpt_config_hba: io remap failed\n"); | 917 | PERROR("dpti: adpt_config_hba: io remap failed\n"); |
914 | return -EINVAL; | 918 | return -EINVAL; |
915 | } | 919 | } |
@@ -919,6 +923,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
919 | if (!msg_addr_virt) { | 923 | if (!msg_addr_virt) { |
920 | PERROR("dpti: adpt_config_hba: io remap failed on BAR1\n"); | 924 | PERROR("dpti: adpt_config_hba: io remap failed on BAR1\n"); |
921 | iounmap(base_addr_virt); | 925 | iounmap(base_addr_virt); |
926 | pci_release_regions(pDev); | ||
922 | return -EINVAL; | 927 | return -EINVAL; |
923 | } | 928 | } |
924 | } else { | 929 | } else { |
@@ -932,6 +937,7 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev | |||
932 | iounmap(msg_addr_virt); | 937 | iounmap(msg_addr_virt); |
933 | } | 938 | } |
934 | iounmap(base_addr_virt); | 939 | iounmap(base_addr_virt); |
940 | pci_release_regions(pDev); | ||
935 | return -ENOMEM; | 941 | return -ENOMEM; |
936 | } | 942 | } |
937 | memset(pHba, 0, sizeof(adpt_hba)); | 943 | memset(pHba, 0, sizeof(adpt_hba)); |
@@ -1027,6 +1033,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba) | |||
1027 | up(&adpt_configuration_lock); | 1033 | up(&adpt_configuration_lock); |
1028 | 1034 | ||
1029 | iounmap(pHba->base_addr_virt); | 1035 | iounmap(pHba->base_addr_virt); |
1036 | pci_release_regions(pHba->pDev); | ||
1030 | if(pHba->msg_addr_virt != pHba->base_addr_virt){ | 1037 | if(pHba->msg_addr_virt != pHba->base_addr_virt){ |
1031 | iounmap(pHba->msg_addr_virt); | 1038 | iounmap(pHba->msg_addr_virt); |
1032 | } | 1039 | } |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 794fb559efb0..6a75ec2187fd 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -385,6 +385,7 @@ int ata_scsi_error(struct Scsi_Host *host) | |||
385 | * appropriate place | 385 | * appropriate place |
386 | */ | 386 | */ |
387 | host->host_failed--; | 387 | host->host_failed--; |
388 | INIT_LIST_HEAD(&host->eh_cmd_q); | ||
388 | 389 | ||
389 | DPRINTK("EXIT\n"); | 390 | DPRINTK("EXIT\n"); |
390 | return 0; | 391 | return 0; |
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 140cea05de3f..efd7d7a61135 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c | |||
@@ -468,7 +468,7 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc) | |||
468 | for (i = 0; i < last; i++) { | 468 | for (i = 0; i < last; i++) { |
469 | buf[idx++] = cpu_to_le32(sg_dma_address(&sg[i])); | 469 | buf[idx++] = cpu_to_le32(sg_dma_address(&sg[i])); |
470 | buf[idx++] = cpu_to_le32(sg_dma_len(&sg[i])); | 470 | buf[idx++] = cpu_to_le32(sg_dma_len(&sg[i])); |
471 | total_len += sg[i].length; | 471 | total_len += sg_dma_len(&sg[i]); |
472 | } | 472 | } |
473 | buf[idx - 1] |= cpu_to_le32(ATA_PRD_EOT); | 473 | buf[idx - 1] |= cpu_to_le32(ATA_PRD_EOT); |
474 | sgt_len = idx * 4; | 474 | sgt_len = idx * 4; |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 2d3c4ac475f2..48edd67982a5 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -336,9 +336,23 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, | |||
336 | unsigned long flags; | 336 | unsigned long flags; |
337 | const int size = sizeof(struct scsi_target) | 337 | const int size = sizeof(struct scsi_target) |
338 | + shost->transportt->target_size; | 338 | + shost->transportt->target_size; |
339 | struct scsi_target *starget = kmalloc(size, GFP_ATOMIC); | 339 | struct scsi_target *starget; |
340 | struct scsi_target *found_target; | 340 | struct scsi_target *found_target; |
341 | 341 | ||
342 | /* | ||
343 | * Obtain the real parent from the transport. The transport | ||
344 | * is allowed to fail (no error) if there is nothing at that | ||
345 | * target id. | ||
346 | */ | ||
347 | if (shost->transportt->target_parent) { | ||
348 | spin_lock_irqsave(shost->host_lock, flags); | ||
349 | parent = shost->transportt->target_parent(shost, channel, id); | ||
350 | spin_unlock_irqrestore(shost->host_lock, flags); | ||
351 | if (!parent) | ||
352 | return NULL; | ||
353 | } | ||
354 | |||
355 | starget = kmalloc(size, GFP_KERNEL); | ||
342 | if (!starget) { | 356 | if (!starget) { |
343 | printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); | 357 | printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); |
344 | return NULL; | 358 | return NULL; |
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 35d1c1e8e345..e6412fce423c 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
@@ -1022,6 +1022,23 @@ static int fc_rport_match(struct attribute_container *cont, | |||
1022 | return &i->rport_attr_cont.ac == cont; | 1022 | return &i->rport_attr_cont.ac == cont; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | |||
1026 | /* | ||
1027 | * Must be called with shost->host_lock held | ||
1028 | */ | ||
1029 | static struct device *fc_target_parent(struct Scsi_Host *shost, | ||
1030 | int channel, uint id) | ||
1031 | { | ||
1032 | struct fc_rport *rport; | ||
1033 | |||
1034 | list_for_each_entry(rport, &fc_host_rports(shost), peers) | ||
1035 | if ((rport->channel == channel) && | ||
1036 | (rport->scsi_target_id == id)) | ||
1037 | return &rport->dev; | ||
1038 | |||
1039 | return NULL; | ||
1040 | } | ||
1041 | |||
1025 | struct scsi_transport_template * | 1042 | struct scsi_transport_template * |
1026 | fc_attach_transport(struct fc_function_template *ft) | 1043 | fc_attach_transport(struct fc_function_template *ft) |
1027 | { | 1044 | { |
@@ -1057,6 +1074,8 @@ fc_attach_transport(struct fc_function_template *ft) | |||
1057 | 1074 | ||
1058 | /* Transport uses the shost workq for scsi scanning */ | 1075 | /* Transport uses the shost workq for scsi scanning */ |
1059 | i->t.create_work_queue = 1; | 1076 | i->t.create_work_queue = 1; |
1077 | |||
1078 | i->t.target_parent = fc_target_parent; | ||
1060 | 1079 | ||
1061 | /* | 1080 | /* |
1062 | * Setup SCSI Target Attributes. | 1081 | * Setup SCSI Target Attributes. |