From 8bf6845b22d060844f535c1b5901eb16a34869fd Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 21 Oct 2003 15:14:51 -0400 Subject: [PATCH] [libata] add per-driver port init/shutdown hooks, with helper defaults --- drivers/scsi/ata_piix.c | 6 ++++++ drivers/scsi/libata-core.c | 33 +++++++++++++++++++++++++++------ drivers/scsi/sata_promise.c | 4 ++++ drivers/scsi/sata_sil.c | 2 ++ drivers/scsi/sata_svw.c | 2 ++ drivers/scsi/sata_via.c | 3 +++ include/linux/libata.h | 10 ++++++++++ 7 files changed, 54 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index f002f6b8a13ae..22e52f39e8aa3 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -117,6 +117,9 @@ static struct ata_port_operations piix_pata_ops = { .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + + .port_start = ata_port_start, + .port_stop = ata_port_stop, }; static struct ata_port_operations piix_sata_ops = { @@ -137,6 +140,9 @@ static struct ata_port_operations piix_sata_ops = { .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + + .port_start = ata_port_start, + .port_stop = ata_port_stop, }; static struct ata_port_info piix_port_info[] = { diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 4538fb07199f9..e3dfc95025ffe 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -2666,6 +2666,26 @@ err_out: goto out; } +int ata_port_start (struct ata_port *ap) +{ + struct pci_dev *pdev = ap->host_set->pdev; + + ap->prd = pci_alloc_consistent(pdev, ATA_PRD_TBL_SZ, &ap->prd_dma); + if (!ap->prd) + return -ENOMEM; + + DPRINTK("prd alloc, virt %p, dma %x\n", ap->prd, ap->prd_dma); + + return 0; +} + +void ata_port_stop (struct ata_port *ap) +{ + struct pci_dev *pdev = ap->host_set->pdev; + + pci_free_consistent(pdev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); +} + /** * ata_host_remove - * @ap: @@ -2685,7 +2705,7 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister) ata_thread_kill(ap); /* FIXME: check return val */ - pci_free_consistent(ap->host_set->pdev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); + ap->ops->port_stop(ap); } /** @@ -2766,9 +2786,9 @@ static struct ata_port * ata_host_add(struct ata_probe_ent *ent, struct ata_host_set *host_set, unsigned int port_no) { - struct pci_dev *pdev = ent->pdev; struct Scsi_Host *host; struct ata_port *ap; + int rc; DPRINTK("ENTER\n"); host = scsi_host_alloc(ent->sht, sizeof(struct ata_port)); @@ -2779,10 +2799,9 @@ static struct ata_port * ata_host_add(struct ata_probe_ent *ent, ata_host_init(ap, host, host_set, ent, port_no); - ap->prd = pci_alloc_consistent(pdev, ATA_PRD_TBL_SZ, &ap->prd_dma); - if (!ap->prd) + rc = ap->ops->port_start(ap); + if (rc) goto err_out; - DPRINTK("prd alloc, virt %p, dma %x\n", ap->prd, ap->prd_dma); ap->thr_pid = kernel_thread(ata_thread, ap, CLONE_FS | CLONE_FILES); if (ap->thr_pid < 0) { @@ -2794,7 +2813,7 @@ static struct ata_port * ata_host_add(struct ata_probe_ent *ent, return ap; err_out_free: - pci_free_consistent(ap->host_set->pdev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); + ap->ops->port_stop(ap); err_out: scsi_host_put(host); @@ -3276,6 +3295,8 @@ EXPORT_SYMBOL_GPL(ata_check_status_pio); EXPORT_SYMBOL_GPL(ata_check_status_mmio); EXPORT_SYMBOL_GPL(ata_exec_command_pio); EXPORT_SYMBOL_GPL(ata_exec_command_mmio); +EXPORT_SYMBOL_GPL(ata_port_start); +EXPORT_SYMBOL_GPL(ata_port_stop); EXPORT_SYMBOL_GPL(ata_interrupt); EXPORT_SYMBOL_GPL(ata_fill_sg); EXPORT_SYMBOL_GPL(ata_bmdma_start_pio); diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 01f268397b4a2..1eeb2dfffc777 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@ -105,6 +105,8 @@ static struct ata_port_operations pdc_sata_ops = { .irq_handler = pdc_interrupt, .scr_read = pdc_sata_scr_read, .scr_write = pdc_sata_scr_write, + .port_start = ata_port_start, + .port_stop = ata_port_stop, }; static struct ata_port_operations pdc_20621_ops = { @@ -121,6 +123,8 @@ static struct ata_port_operations pdc_20621_ops = { .fill_sg = ata_fill_sg, .eng_timeout = pdc_eng_timeout, .irq_handler = pdc_interrupt, + .port_start = ata_port_start, + .port_stop = ata_port_stop, }; static struct ata_port_info pdc_port_info[] = { diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index adb0dd249ff66..ce80f6290e1f5 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c @@ -106,6 +106,8 @@ static struct ata_port_operations sil_ops = { .irq_handler = ata_interrupt, .scr_read = sil_scr_read, .scr_write = sil_scr_write, + .port_start = ata_port_start, + .port_stop = ata_port_stop, }; static struct ata_port_info sil_port_info[] = { diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index 3a369e2d1dcbc..5053074195f7b 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c @@ -235,6 +235,8 @@ static struct ata_port_operations k2_sata_ops = { .irq_handler = ata_interrupt, .scr_read = k2_sata_scr_read, .scr_write = k2_sata_scr_write, + .port_start = ata_port_start, + .port_stop = ata_port_stop, }; diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c index 692b16bb6625e..97a341ec96f0e 100644 --- a/drivers/scsi/sata_via.c +++ b/drivers/scsi/sata_via.c @@ -98,6 +98,9 @@ static struct ata_port_operations svia_sata_ops = { .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + + .port_start = ata_port_start, + .port_stop = ata_port_stop, }; static struct ata_port_info svia_port_info[] = { diff --git a/include/linux/libata.h b/include/linux/libata.h index a8377cb315efd..ccc998635ac97 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -215,6 +215,7 @@ struct ata_host_set { unsigned long irq; void *mmio_base; unsigned int n_ports; + void *private_data; struct ata_port * ports[0]; }; @@ -264,6 +265,8 @@ struct ata_queued_cmd { ata_qc_cb_t callback; struct semaphore sem; + + void *private_data; }; struct ata_host_stats { @@ -333,6 +336,8 @@ struct ata_port { struct semaphore thr_sem; struct timer_list thr_timer; unsigned long thr_timeout; + + void *private_data; }; struct ata_port_operations { @@ -363,6 +368,9 @@ struct ata_port_operations { u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, u32 val); + + int (*port_start) (struct ata_port *ap); + void (*port_stop) (struct ata_port *ap); }; struct ata_port_info { @@ -406,6 +414,8 @@ extern u8 ata_check_status_pio(struct ata_port *ap); extern u8 ata_check_status_mmio(struct ata_port *ap); extern void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf); extern void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); +extern int ata_port_start (struct ata_port *ap); +extern void ata_port_stop (struct ata_port *ap); extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); extern void ata_fill_sg(struct ata_queued_cmd *qc); extern void ata_bmdma_start_mmio (struct ata_queued_cmd *qc); -- 2.53.0