a2091.c (53555fb7bceb14f5fdb9358290daf64d0ea0f56a) a2091.c (dbb2da557a6a87c88bbb4b1fef037091b57f701b)
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/types.h>
3#include <linux/init.h>
4#include <linux/interrupt.h>
5#include <linux/mm.h>
6#include <linux/slab.h>
7#include <linux/spinlock.h>
8#include <linux/zorro.h>

--- 30 unchanged lines hidden (view full) ---

39 spin_lock_irqsave(instance->host_lock, flags);
40 wd33c93_intr(instance);
41 spin_unlock_irqrestore(instance->host_lock, flags);
42 return IRQ_HANDLED;
43}
44
45static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
46{
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/types.h>
3#include <linux/init.h>
4#include <linux/interrupt.h>
5#include <linux/mm.h>
6#include <linux/slab.h>
7#include <linux/spinlock.h>
8#include <linux/zorro.h>

--- 30 unchanged lines hidden (view full) ---

39 spin_lock_irqsave(instance->host_lock, flags);
40 wd33c93_intr(instance);
41 spin_unlock_irqrestore(instance->host_lock, flags);
42 return IRQ_HANDLED;
43}
44
45static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
46{
47 struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd);
47 struct Scsi_Host *instance = cmd->device->host;
48 struct a2091_hostdata *hdata = shost_priv(instance);
49 struct WD33C93_hostdata *wh = &hdata->wh;
50 struct a2091_scsiregs *regs = hdata->regs;
51 unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
48 struct Scsi_Host *instance = cmd->device->host;
49 struct a2091_hostdata *hdata = shost_priv(instance);
50 struct WD33C93_hostdata *wh = &hdata->wh;
51 struct a2091_scsiregs *regs = hdata->regs;
52 unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
52 unsigned long addr = virt_to_bus(cmd->SCp.ptr);
53 unsigned long addr = virt_to_bus(scsi_pointer->ptr);
53
54 /* don't allow DMA if the physical address is bad */
55 if (addr & A2091_XFER_MASK) {
54
55 /* don't allow DMA if the physical address is bad */
56 if (addr & A2091_XFER_MASK) {
56 wh->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff;
57 wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff;
57 wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len,
58 GFP_KERNEL);
59
60 /* can't allocate memory; use PIO */
61 if (!wh->dma_bounce_buffer) {
62 wh->dma_bounce_len = 0;
63 return 1;
64 }

--- 7 unchanged lines hidden (view full) ---

72 kfree(wh->dma_bounce_buffer);
73 wh->dma_bounce_buffer = NULL;
74 wh->dma_bounce_len = 0;
75 return 1;
76 }
77
78 if (!dir_in) {
79 /* copy to bounce buffer for a write */
58 wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len,
59 GFP_KERNEL);
60
61 /* can't allocate memory; use PIO */
62 if (!wh->dma_bounce_buffer) {
63 wh->dma_bounce_len = 0;
64 return 1;
65 }

--- 7 unchanged lines hidden (view full) ---

73 kfree(wh->dma_bounce_buffer);
74 wh->dma_bounce_buffer = NULL;
75 wh->dma_bounce_len = 0;
76 return 1;
77 }
78
79 if (!dir_in) {
80 /* copy to bounce buffer for a write */
80 memcpy(wh->dma_bounce_buffer, cmd->SCp.ptr,
81 cmd->SCp.this_residual);
81 memcpy(wh->dma_bounce_buffer, scsi_pointer->ptr,
82 scsi_pointer->this_residual);
82 }
83 }
84
85 /* setup dma direction */
86 if (!dir_in)
87 cntr |= CNTR_DDIR;
88
89 /* remember direction */
90 wh->dma_dir = dir_in;
91
92 regs->CNTR = cntr;
93
94 /* setup DMA *physical* address */
95 regs->ACR = addr;
96
97 if (dir_in) {
98 /* invalidate any cache */
83 }
84 }
85
86 /* setup dma direction */
87 if (!dir_in)
88 cntr |= CNTR_DDIR;
89
90 /* remember direction */
91 wh->dma_dir = dir_in;
92
93 regs->CNTR = cntr;
94
95 /* setup DMA *physical* address */
96 regs->ACR = addr;
97
98 if (dir_in) {
99 /* invalidate any cache */
99 cache_clear(addr, cmd->SCp.this_residual);
100 cache_clear(addr, scsi_pointer->this_residual);
100 } else {
101 /* push any dirty cache */
101 } else {
102 /* push any dirty cache */
102 cache_push(addr, cmd->SCp.this_residual);
103 cache_push(addr, scsi_pointer->this_residual);
103 }
104 /* start DMA */
105 regs->ST_DMA = 1;
106
107 /* return success */
108 return 0;
109}
110
111static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
112 int status)
113{
104 }
105 /* start DMA */
106 regs->ST_DMA = 1;
107
108 /* return success */
109 return 0;
110}
111
112static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
113 int status)
114{
115 struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(SCpnt);
114 struct a2091_hostdata *hdata = shost_priv(instance);
115 struct WD33C93_hostdata *wh = &hdata->wh;
116 struct a2091_scsiregs *regs = hdata->regs;
117
118 /* disable SCSI interrupts */
119 unsigned short cntr = CNTR_PDMD;
120
121 if (!wh->dma_dir)

--- 16 unchanged lines hidden (view full) ---

138 regs->SP_DMA = 1;
139
140 /* restore the CONTROL bits (minus the direction flag) */
141 regs->CNTR = CNTR_PDMD | CNTR_INTEN;
142
143 /* copy from a bounce buffer, if necessary */
144 if (status && wh->dma_bounce_buffer) {
145 if (wh->dma_dir)
116 struct a2091_hostdata *hdata = shost_priv(instance);
117 struct WD33C93_hostdata *wh = &hdata->wh;
118 struct a2091_scsiregs *regs = hdata->regs;
119
120 /* disable SCSI interrupts */
121 unsigned short cntr = CNTR_PDMD;
122
123 if (!wh->dma_dir)

--- 16 unchanged lines hidden (view full) ---

140 regs->SP_DMA = 1;
141
142 /* restore the CONTROL bits (minus the direction flag) */
143 regs->CNTR = CNTR_PDMD | CNTR_INTEN;
144
145 /* copy from a bounce buffer, if necessary */
146 if (status && wh->dma_bounce_buffer) {
147 if (wh->dma_dir)
146 memcpy(SCpnt->SCp.ptr, wh->dma_bounce_buffer,
147 SCpnt->SCp.this_residual);
148 memcpy(scsi_pointer->ptr, wh->dma_bounce_buffer,
149 scsi_pointer->this_residual);
148 kfree(wh->dma_bounce_buffer);
149 wh->dma_bounce_buffer = NULL;
150 wh->dma_bounce_len = 0;
151 }
152}
153
154static struct scsi_host_template a2091_scsi_template = {
155 .module = THIS_MODULE,

--- 4 unchanged lines hidden (view full) ---

160 .queuecommand = wd33c93_queuecommand,
161 .eh_abort_handler = wd33c93_abort,
162 .eh_host_reset_handler = wd33c93_host_reset,
163 .can_queue = CAN_QUEUE,
164 .this_id = 7,
165 .sg_tablesize = SG_ALL,
166 .cmd_per_lun = CMD_PER_LUN,
167 .dma_boundary = PAGE_SIZE - 1,
150 kfree(wh->dma_bounce_buffer);
151 wh->dma_bounce_buffer = NULL;
152 wh->dma_bounce_len = 0;
153 }
154}
155
156static struct scsi_host_template a2091_scsi_template = {
157 .module = THIS_MODULE,

--- 4 unchanged lines hidden (view full) ---

162 .queuecommand = wd33c93_queuecommand,
163 .eh_abort_handler = wd33c93_abort,
164 .eh_host_reset_handler = wd33c93_host_reset,
165 .can_queue = CAN_QUEUE,
166 .this_id = 7,
167 .sg_tablesize = SG_ALL,
168 .cmd_per_lun = CMD_PER_LUN,
169 .dma_boundary = PAGE_SIZE - 1,
170 .cmd_size = sizeof(struct scsi_pointer),
168};
169
170static int a2091_probe(struct zorro_dev *z, const struct zorro_device_id *ent)
171{
172 struct Scsi_Host *instance;
173 int error;
174 struct a2091_scsiregs *regs;
175 wd33c93_regs wdregs;

--- 93 unchanged lines hidden ---
171};
172
173static int a2091_probe(struct zorro_dev *z, const struct zorro_device_id *ent)
174{
175 struct Scsi_Host *instance;
176 int error;
177 struct a2091_scsiregs *regs;
178 wd33c93_regs wdregs;

--- 93 unchanged lines hidden ---