[ide] pmac: use more ide_hwif_t fields

Use dmatable_dma, sg_table, sg_nents and sg_dma_direction fields
of ide_hwif_t and remove their equivalents from pmac_ide_hwif_t.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 1c854f6f
...@@ -78,10 +78,6 @@ typedef struct pmac_ide_hwif { ...@@ -78,10 +78,6 @@ typedef struct pmac_ide_hwif {
*/ */
volatile struct dbdma_regs __iomem * dma_regs; volatile struct dbdma_regs __iomem * dma_regs;
struct dbdma_cmd* dma_table_cpu; struct dbdma_cmd* dma_table_cpu;
dma_addr_t dma_table_dma;
struct scatterlist* sg_table;
int sg_nents;
int sg_dma_direction;
#endif #endif
} pmac_ide_hwif_t; } pmac_ide_hwif_t;
...@@ -1562,26 +1558,23 @@ pmac_ide_probe(void) ...@@ -1562,26 +1558,23 @@ pmac_ide_probe(void)
#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
/* /*
* This is very close to the generic ide-dma version of the function except * We build & map the sglist for a given request.
* that we don't use the fields in the hwif but our own copies for sg_table
* and friends. We build & map the sglist for a given request
*/ */
static int __pmac static int __pmac
pmac_ide_build_sglist(ide_drive_t *drive, struct request *rq) pmac_ide_build_sglist(ide_drive_t *drive, struct request *rq)
{ {
ide_hwif_t *hwif = HWIF(drive); ide_hwif_t *hwif = HWIF(drive);
pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; struct scatterlist *sg = hwif->sg_table;
struct scatterlist *sg = pmif->sg_table;
int nents; int nents;
nents = blk_rq_map_sg(drive->queue, rq, sg); nents = blk_rq_map_sg(drive->queue, rq, sg);
if (rq_data_dir(rq) == READ) if (rq_data_dir(rq) == READ)
pmif->sg_dma_direction = PCI_DMA_FROMDEVICE; hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
else else
pmif->sg_dma_direction = PCI_DMA_TODEVICE; hwif->sg_dma_direction = PCI_DMA_TODEVICE;
return pci_map_sg(hwif->pci_dev, sg, nents, pmif->sg_dma_direction); return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
} }
/* /*
...@@ -1591,18 +1584,17 @@ static int __pmac ...@@ -1591,18 +1584,17 @@ static int __pmac
pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq) pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
{ {
ide_hwif_t *hwif = HWIF(drive); ide_hwif_t *hwif = HWIF(drive);
pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; struct scatterlist *sg = hwif->sg_table;
struct scatterlist *sg = pmif->sg_table;
int nents = 0; int nents = 0;
ide_task_t *args = rq->special; ide_task_t *args = rq->special;
unsigned char *virt_addr = rq->buffer; unsigned char *virt_addr = rq->buffer;
int sector_count = rq->nr_sectors; int sector_count = rq->nr_sectors;
if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE) if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
pmif->sg_dma_direction = PCI_DMA_TODEVICE; hwif->sg_dma_direction = PCI_DMA_TODEVICE;
else else
pmif->sg_dma_direction = PCI_DMA_FROMDEVICE; hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
if (sector_count > 128) { if (sector_count > 128) {
sg_init_one(&sg[nents], virt_addr, 128 * SECTOR_SIZE); sg_init_one(&sg[nents], virt_addr, 128 * SECTOR_SIZE);
nents++; nents++;
...@@ -1611,8 +1603,8 @@ pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq) ...@@ -1611,8 +1603,8 @@ pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
} }
sg_init_one(&sg[nents], virt_addr, sector_count * SECTOR_SIZE); sg_init_one(&sg[nents], virt_addr, sector_count * SECTOR_SIZE);
nents++; nents++;
return pci_map_sg(hwif->pci_dev, sg, nents, pmif->sg_dma_direction); return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
} }
/* /*
...@@ -1640,14 +1632,14 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) ...@@ -1640,14 +1632,14 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
/* Build sglist */ /* Build sglist */
if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE)
pmif->sg_nents = i = pmac_ide_raw_build_sglist(drive, rq); hwif->sg_nents = i = pmac_ide_raw_build_sglist(drive, rq);
else else
pmif->sg_nents = i = pmac_ide_build_sglist(drive, rq); hwif->sg_nents = i = pmac_ide_build_sglist(drive, rq);
if (!i) if (!i)
return 0; return 0;
/* Build DBDMA commands list */ /* Build DBDMA commands list */
sg = pmif->sg_table; sg = hwif->sg_table;
while (i && sg_dma_len(sg)) { while (i && sg_dma_len(sg)) {
u32 cur_addr; u32 cur_addr;
u32 cur_len; u32 cur_len;
...@@ -1692,16 +1684,16 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) ...@@ -1692,16 +1684,16 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
memset(table, 0, sizeof(struct dbdma_cmd)); memset(table, 0, sizeof(struct dbdma_cmd));
st_le16(&table->command, DBDMA_STOP); st_le16(&table->command, DBDMA_STOP);
mb(); mb();
writel(pmif->dma_table_dma, &dma->cmdptr); writel(hwif->dmatable_dma, &dma->cmdptr);
return 1; return 1;
} }
printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name);
use_pio_instead: use_pio_instead:
pci_unmap_sg(hwif->pci_dev, pci_unmap_sg(hwif->pci_dev,
pmif->sg_table, hwif->sg_table,
pmif->sg_nents, hwif->sg_nents,
pmif->sg_dma_direction); hwif->sg_dma_direction);
return 0; /* revert to PIO for this request */ return 0; /* revert to PIO for this request */
} }
...@@ -1709,14 +1701,14 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) ...@@ -1709,14 +1701,14 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
static void __pmac static void __pmac
pmac_ide_destroy_dmatable (ide_drive_t *drive) pmac_ide_destroy_dmatable (ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif;
struct pci_dev *dev = HWIF(drive)->pci_dev; struct pci_dev *dev = HWIF(drive)->pci_dev;
pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; struct scatterlist *sg = hwif->sg_table;
struct scatterlist *sg = pmif->sg_table; int nents = hwif->sg_nents;
int nents = pmif->sg_nents;
if (nents) { if (nents) {
pci_unmap_sg(dev, sg, nents, pmif->sg_dma_direction); pci_unmap_sg(dev, sg, nents, hwif->sg_dma_direction);
pmif->sg_nents = 0; hwif->sg_nents = 0;
} }
} }
...@@ -2065,19 +2057,19 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) ...@@ -2065,19 +2057,19 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent(
hwif->pci_dev, hwif->pci_dev,
(MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
&pmif->dma_table_dma); &hwif->dmatable_dma);
if (pmif->dma_table_cpu == NULL) { if (pmif->dma_table_cpu == NULL) {
printk(KERN_ERR "%s: unable to allocate DMA command list\n", printk(KERN_ERR "%s: unable to allocate DMA command list\n",
hwif->name); hwif->name);
return; return;
} }
pmif->sg_table = kmalloc(sizeof(struct scatterlist) * MAX_DCMDS, hwif->sg_table = kmalloc(sizeof(struct scatterlist) * MAX_DCMDS,
GFP_KERNEL); GFP_KERNEL);
if (pmif->sg_table == NULL) { if (hwif->sg_table == NULL) {
pci_free_consistent( hwif->pci_dev, pci_free_consistent( hwif->pci_dev,
(MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
pmif->dma_table_cpu, pmif->dma_table_dma); pmif->dma_table_cpu, hwif->dmatable_dma);
return; return;
} }
hwif->ide_dma_off_quietly = &__ide_dma_off_quietly; hwif->ide_dma_off_quietly = &__ide_dma_off_quietly;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment