ia64/xen-unstable

view xen/drivers/scsi/aacraid/dpcsup.c @ 945:db2e1ea917df

bitkeeper revision 1.596.1.3 (3fb3b41eWUoRU0H8A0jEX5roXjxKkA)

Many files:
Greatly simplified Xen softirqs. They are now only executed in outermost Xen activation; they are never called within an irq context.
author kaf24@scramble.cl.cam.ac.uk
date Thu Nov 13 16:41:02 2003 +0000 (2003-11-13)
parents 3946af49a538
children 890460f07ddf
line source
1 /*
2 * Adaptec AAC series RAID controller driver
3 * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com>
4 *
5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux.
7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com)
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * Module Name:
25 * dpcsup.c
26 *
27 * Abstract: All DPC processing routines for the cyclone board occur here.
28 *
29 *
30 */
32 #include <linux/config.h>
33 #include <linux/kernel.h>
34 #include <linux/init.h>
35 #include <linux/types.h>
36 #include <linux/sched.h>
37 #include <linux/pci.h>
38 #include <linux/spinlock.h>
39 #include <linux/slab.h>
40 /*#include <linux/completion.h>*/
41 #include <linux/blk.h>
42 /*#include <asm/semaphore.h>*/
43 #include "scsi.h"
44 #include "hosts.h"
46 #include "aacraid.h"
48 /**
49 * aac_response_normal - Handle command replies
50 * @q: Queue to read from
51 *
52 * This DPC routine will be run when the adapter interrupts us to let us
53 * know there is a response on our normal priority queue. We will pull off
54 * all QE there are and wake up all the waiters before exiting. We will
55 * take a spinlock out on the queue before operating on it.
56 */
58 unsigned int aac_response_normal(struct aac_queue * q)
59 {
60 struct aac_dev * dev = q->dev;
61 struct aac_entry *entry;
62 struct hw_fib * hwfib;
63 struct fib * fib;
64 int consumed = 0;
65 unsigned long flags;
67 spin_lock_irqsave(q->lock, flags);
69 /*
70 * Keep pulling response QEs off the response queue and waking
71 * up the waiters until there are no more QEs. We then return
72 * back to the system. If no response was requesed we just
73 * deallocate the Fib here and continue.
74 */
75 while(aac_consumer_get(dev, q, &entry))
76 {
77 u32 fast ;
78 fast = (entry->addr & cpu_to_le32(0x01));
79 // fib = &dev->fibs[(entry->addr >> 1)];
80 // hwfib = fib->hw_fib;
81 hwfib = bus_to_virt(le32_to_cpu(entry->addr & cpu_to_le32(~0x01)));
82 fib = &dev->fibs[hwfib->header.SenderData];
84 aac_consumer_free(dev, q, HostNormRespQueue);
85 /*
86 * Remove this fib from the Outstanding I/O queue.
87 * But only if it has not already been timed out.
88 *
89 * If the fib has been timed out already, then just
90 * continue. The caller has already been notified that
91 * the fib timed out.
92 */
93 if (!(fib->flags & FIB_CONTEXT_FLAG_TIMED_OUT)) {
94 list_del(&fib->queue);
95 dev->queues->queue[AdapNormCmdQueue].numpending--;
96 } else {
97 printk(KERN_WARNING "aacraid: FIB timeout (%x).\n", fib->flags);
98 continue;
99 }
100 spin_unlock_irqrestore(q->lock, flags);
102 if (fast) {
103 /*
104 * Doctor the fib
105 */
106 *(u32 *)hwfib->data = cpu_to_le32(ST_OK);
107 hwfib->header.XferState |= cpu_to_le32(AdapterProcessed);
108 }
110 FIB_COUNTER_INCREMENT(aac_config.FibRecved);
112 if (hwfib->header.Command == cpu_to_le16(NuFileSystem))
113 {
114 u32 *pstatus = (u32 *)hwfib->data;
115 if (*pstatus & cpu_to_le32(0xffff0000))
116 *pstatus = cpu_to_le32(ST_OK);
117 }
118 if (hwfib->header.XferState & cpu_to_le32(NoResponseExpected | Async))
119 {
120 if (hwfib->header.XferState & cpu_to_le32(NoResponseExpected))
121 FIB_COUNTER_INCREMENT(aac_config.NoResponseRecved);
122 else
123 FIB_COUNTER_INCREMENT(aac_config.AsyncRecved);
124 /*
125 * NOTE: we cannot touch the fib after this
126 * call, because it may have been deallocated.
127 */
128 fib->callback(fib->callback_data, fib);
129 } else {
130 #if 0
131 unsigned long flagv;
132 spin_lock_irqsave(&fib->event_lock, flagv);
133 #endif
134 fib->done = 1;
135 #if 0
136 up(&fib->event_wait);
137 spin_unlock_irqrestore(&fib->event_lock, flagv);
138 #endif
139 FIB_COUNTER_INCREMENT(aac_config.NormalRecved);
140 }
141 consumed++;
142 spin_lock_irqsave(q->lock, flags);
143 }
145 if (consumed > aac_config.peak_fibs)
146 aac_config.peak_fibs = consumed;
147 if (consumed == 0)
148 aac_config.zero_fibs++;
150 spin_unlock_irqrestore(q->lock, flags);
151 return 0;
152 }
155 /**
156 * aac_command_normal - handle commands
157 * @q: queue to process
158 *
159 * This DPC routine will be queued when the adapter interrupts us to
160 * let us know there is a command on our normal priority queue. We will
161 * pull off all QE there are and wake up all the waiters before exiting.
162 * We will take a spinlock out on the queue before operating on it.
163 */
165 unsigned int aac_command_normal(struct aac_queue *q)
166 {
167 struct aac_dev * dev = q->dev;
168 struct aac_entry *entry;
169 unsigned long flags;
171 spin_lock_irqsave(q->lock, flags);
173 /*
174 * Keep pulling response QEs off the response queue and waking
175 * up the waiters until there are no more QEs. We then return
176 * back to the system.
177 */
178 dprintk((KERN_INFO
179 "dev=%p, dev->comm_phys=%x, dev->comm_addr=%p, dev->comm_size=%u\n",
180 dev, (u32)dev->comm_phys, dev->comm_addr, (unsigned)dev->comm_size));
182 while(aac_consumer_get(dev, q, &entry))
183 {
184 struct fib fibctx;
185 struct fib *fib = &fibctx;
186 u32 hw_fib_pa = le32_to_cpu(entry->addr & cpu_to_le32(~0x01));
187 struct hw_fib * hw_fib_va = ((dev->comm_phys <= hw_fib_pa)
188 && (hw_fib_pa < (dev->comm_phys + dev->comm_size)))
189 ? dev->comm_addr + (hw_fib_pa - dev->comm_phys)
190 : /* inconceivable */ bus_to_virt(hw_fib_pa);
191 dprintk((KERN_INFO "hw_fib_pa=%x hw_fib_va=%p\n", hw_fib_pa, hw_fib_va));
193 /*
194 * Allocate a FIB at all costs. For non queued stuff
195 * we can just use the stack so we are happy. We need
196 * a fib object in order to manage the linked lists
197 */
198 if (dev->aif_thread)
199 if((fib = kmalloc(sizeof(struct fib), GFP_ATOMIC))==NULL)
200 fib = &fibctx;
202 memset(fib, 0, sizeof(struct fib));
203 INIT_LIST_HEAD(&fib->fiblink);
204 fib->type = FSAFS_NTC_FIB_CONTEXT;
205 fib->size = sizeof(struct fib);
206 fib->hw_fib = hw_fib_va;
207 fib->data = hw_fib_va->data;
208 fib->dev = dev;
210 if (dev->aif_thread && fib != &fibctx)
211 {
212 list_add_tail(&fib->fiblink, &q->cmdq);
213 aac_consumer_free(dev, q, HostNormCmdQueue);
214 #if 0
215 wake_up_interruptible(&q->cmdready);
216 #endif
217 } else {
218 aac_consumer_free(dev, q, HostNormCmdQueue);
219 spin_unlock_irqrestore(q->lock, flags);
220 /*
221 * Set the status of this FIB
222 */
223 *(u32 *)hw_fib_va->data = cpu_to_le32(ST_OK);
224 fib_adapter_complete(fib, sizeof(u32));
225 spin_lock_irqsave(q->lock, flags);
226 }
227 }
228 spin_unlock_irqrestore(q->lock, flags);
229 return 0;
230 }