diff options
Diffstat (limited to 'drivers/scsi/ahci.c')
-rw-r--r-- | drivers/scsi/ahci.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index e2a5657d5fd..8420204c2ea 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -313,8 +313,15 @@ static int ahci_port_start(struct ata_port *ap) | |||
313 | return -ENOMEM; | 313 | return -ENOMEM; |
314 | memset(pp, 0, sizeof(*pp)); | 314 | memset(pp, 0, sizeof(*pp)); |
315 | 315 | ||
316 | ap->pad = dma_alloc_coherent(dev, ATA_DMA_PAD_BUF_SZ, &ap->pad_dma, GFP_KERNEL); | ||
317 | if (!ap->pad) { | ||
318 | kfree(pp); | ||
319 | return -ENOMEM; | ||
320 | } | ||
321 | |||
316 | mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL); | 322 | mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL); |
317 | if (!mem) { | 323 | if (!mem) { |
324 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | ||
318 | kfree(pp); | 325 | kfree(pp); |
319 | return -ENOMEM; | 326 | return -ENOMEM; |
320 | } | 327 | } |
@@ -390,6 +397,7 @@ static void ahci_port_stop(struct ata_port *ap) | |||
390 | ap->private_data = NULL; | 397 | ap->private_data = NULL; |
391 | dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, | 398 | dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, |
392 | pp->cmd_slot, pp->cmd_slot_dma); | 399 | pp->cmd_slot, pp->cmd_slot_dma); |
400 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | ||
393 | kfree(pp); | 401 | kfree(pp); |
394 | } | 402 | } |
395 | 403 | ||
@@ -468,23 +476,23 @@ static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
468 | static void ahci_fill_sg(struct ata_queued_cmd *qc) | 476 | static void ahci_fill_sg(struct ata_queued_cmd *qc) |
469 | { | 477 | { |
470 | struct ahci_port_priv *pp = qc->ap->private_data; | 478 | struct ahci_port_priv *pp = qc->ap->private_data; |
471 | unsigned int i; | 479 | struct scatterlist *sg; |
480 | struct ahci_sg *ahci_sg; | ||
472 | 481 | ||
473 | VPRINTK("ENTER\n"); | 482 | VPRINTK("ENTER\n"); |
474 | 483 | ||
475 | /* | 484 | /* |
476 | * Next, the S/G list. | 485 | * Next, the S/G list. |
477 | */ | 486 | */ |
478 | for (i = 0; i < qc->n_elem; i++) { | 487 | ahci_sg = pp->cmd_tbl_sg; |
479 | u32 sg_len; | 488 | ata_for_each_sg(sg, qc) { |
480 | dma_addr_t addr; | 489 | dma_addr_t addr = sg_dma_address(sg); |
481 | 490 | u32 sg_len = sg_dma_len(sg); | |
482 | addr = sg_dma_address(&qc->sg[i]); | 491 | |
483 | sg_len = sg_dma_len(&qc->sg[i]); | 492 | ahci_sg->addr = cpu_to_le32(addr & 0xffffffff); |
484 | 493 | ahci_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16); | |
485 | pp->cmd_tbl_sg[i].addr = cpu_to_le32(addr & 0xffffffff); | 494 | ahci_sg->flags_size = cpu_to_le32(sg_len - 1); |
486 | pp->cmd_tbl_sg[i].addr_hi = cpu_to_le32((addr >> 16) >> 16); | 495 | ahci_sg++; |
487 | pp->cmd_tbl_sg[i].flags_size = cpu_to_le32(sg_len - 1); | ||
488 | } | 496 | } |
489 | } | 497 | } |
490 | 498 | ||