1 --- linux-2.6.0-test11/drivers/scsi/ini9100u.c 2003-11-26 12:43:26.000000000 -0800
2 +++ linux-2.6.0-test11-work/drivers/scsi/ini9100u.c 2003-12-09 15:34:17.000000000 -0800
6 * - Changed the assumption that HZ = 100
7 + * 10/17/03 mc - v1.04
8 + * - added new DMA API support
9 **************************************************************************/
11 #define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S)
13 -#error Please convert me to Documentation/DMA-mapping.txt
15 #ifndef LINUX_VERSION_CODE
16 #include <linux/version.h>
18 @@ -143,13 +143,12 @@ unsigned int i91u_debug = DEBUG_DEFAULT;
20 static Scsi_Host_Template driver_template = {
21 .proc_name = "INI9100U",
22 - .proc_info = "INI9100U",
24 .detect = i91u_detect,
25 .release = i91u_release,
26 .queuecommand = i91u_queue,
27 - .abort = i91u_abort,
28 - .reset = i91u_reset,
29 +// .abort = i91u_abort,
30 +// .reset = i91u_reset,
31 .bios_param = i91u_biosparam,
34 @@ -162,7 +161,7 @@ static Scsi_Host_Template driver_templat
35 char *i91uCopyright = "Copyright (C) 1996-98";
36 char *i91uInitioName = "by Initio Corporation";
37 char *i91uProductName = "INI-9X00U/UW";
38 -char *i91uVersion = "v1.03g";
39 +char *i91uVersion = "v1.04";
41 #define TULSZ(sz) (sizeof(sz) / sizeof(sz[0]))
42 #define TUL_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
43 @@ -238,12 +237,12 @@ static void i91uAppendSRBToQueue(HCS * p
45 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
47 - pSRB->next = NULL; /* Pointer to next */
48 + pSRB->host_scribble = NULL; /* Pointer to next */
50 if (pHCB->pSRB_head == NULL)
51 pHCB->pSRB_head = pSRB;
53 - pHCB->pSRB_tail->next = pSRB; /* Pointer to next */
54 + pHCB->pSRB_tail->host_scribble = (char *)pSRB; /* Pointer to next */
55 pHCB->pSRB_tail = pSRB;
57 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
58 @@ -265,8 +264,8 @@ static Scsi_Cmnd *i91uPopSRBFromQueue(HC
59 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
61 if ((pSRB = pHCB->pSRB_head) != NULL) {
62 - pHCB->pSRB_head = pHCB->pSRB_head->next;
64 + pHCB->pSRB_head = (struct scsi_cmnd *)pHCB->pSRB_head->host_scribble;
65 + pSRB->host_scribble = NULL;
67 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
69 @@ -308,6 +307,12 @@ int tul_NewReturnNumberOfAdapters(void)
70 if (((dRegValue & 0xFF00) >> 8) == 0xFF)
72 wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
73 + if (pci_set_dma_mask(pDev, 0xffffffff)) {
75 + "i91u: Could not set 32 bit DMA mask\n");
79 if (Addi91u_into_Adapter_table(wBIOS,
80 (pDev->resource[0].start),
82 @@ -346,12 +351,7 @@ int i91u_detect(Scsi_Host_Template * tpn
85 /* Get total number of adapters in the motherboard */
87 iAdapters = tul_NewReturnNumberOfAdapters();
89 - iAdapters = tul_ReturnNumberOfAdapters();
92 if (iAdapters == 0) /* If no tulip founded, return */
95 @@ -370,7 +370,7 @@ int i91u_detect(Scsi_Host_Template * tpn
97 for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) {
98 i = tul_num_ch * tul_num_scb * sizeof(SCB);
99 - if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL)
100 + if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC)) != NULL)
103 if (tul_scb == NULL) {
104 @@ -381,7 +381,7 @@ int i91u_detect(Scsi_Host_Template * tpn
107 for (i = 0; i < tul_num_ch * tul_num_scb; i++, pSCB++) {
108 - pSCB->SCB_SGPAddr = (U32) VIRT_TO_BUS(&pSCB->SCB_SGList[0]);
109 + pSCB->SCB_SGPAddr = (u32)&pSCB->SCB_SGList[0];
112 for (i = 0, pHCB = &tul_hcs[0]; /* Get pointer for control block */
113 @@ -476,6 +476,7 @@ static void i91uBuildSCB(HCS * pHCB, SCB
114 SG *pSG; /* Pointer to SG list */
117 + dma_addr_t dma_addr;
119 pSCB->SCB_Post = i91uSCBPost; /* i91u's callback routine */
120 pSCB->SCB_Srb = SCpnt;
121 @@ -484,11 +485,13 @@ static void i91uBuildSCB(HCS * pHCB, SCB
122 pSCB->SCB_Target = SCpnt->device->id;
123 pSCB->SCB_Lun = SCpnt->device->lun;
124 pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW;
125 - pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */
127 - pSCB->SCB_SensePtr = (U32) VIRT_TO_BUS(SCpnt->sense_buffer);
129 + pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */
130 + dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer,
131 + SENSE_SIZE, DMA_FROM_DEVICE);
132 + pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr);
133 pSCB->SCB_SenseLen = SENSE_SIZE;
134 + SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr;
136 pSCB->SCB_CDBLen = SCpnt->cmd_len;
137 pSCB->SCB_HaStat = 0;
138 @@ -503,30 +506,32 @@ static void i91uBuildSCB(HCS * pHCB, SCB
141 pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
142 - if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* treat it as regular I/O */
143 - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address);
144 - TotalLen = pSrbSG->length;
145 - pSCB->SCB_SGLen = 0;
146 - } else { /* Assign SG physical address */
147 - pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr;
148 - pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */
149 - for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */
151 - i++, pSG++, pSrbSG++) {
152 - pSG->SG_Ptr = (U32) VIRT_TO_BUS(pSrbSG->address);
153 - TotalLen += pSG->SG_Len = pSrbSG->length;
155 - pSCB->SCB_SGLen = i;
157 + pSCB->SCB_SGLen = dma_map_sg(&pHCB->pci_dev->dev, pSrbSG,
158 + SCpnt->use_sg, SCpnt->sc_data_direction);
160 + pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr;
161 + pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */
162 + for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */
163 + i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) {
164 + pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG));
165 + TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG));
168 pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ?
169 TotalLen : SCpnt->request_bufflen;
170 - } else { /* Non SG */
171 - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(SCpnt->request_buffer);
172 - pSCB->SCB_BufLen = SCpnt->request_bufflen;
173 + } else if (SCpnt->request_bufflen) { /* Non SG */
174 + dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->request_buffer,
175 + SCpnt->request_bufflen,
176 + SCpnt->sc_data_direction);
177 + SCpnt->SCp.dma_handle = dma_addr;
178 + pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
179 + pSCB->SCB_BufLen = cpu_to_le32((u32)SCpnt->request_bufflen);
180 + pSCB->SCB_SGLen = 0;
182 + pSCB->SCB_BufLen = 0;
190 @@ -623,6 +628,28 @@ int i91u_biosparam(struct scsi_device *s
194 +static void i91u_unmap_cmnd(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd)
196 + /* auto sense buffer */
197 + if (cmnd->SCp.ptr) {
198 + dma_unmap_single(&pci_dev->dev,
199 + (dma_addr_t)((unsigned long)cmnd->SCp.ptr),
200 + SENSE_SIZE, SCSI_DATA_READ);
201 + cmnd->SCp.ptr = NULL;
204 + /* request buffer */
205 + if (cmnd->use_sg) {
206 + dma_unmap_sg(&pci_dev->dev, cmnd->request_buffer,
208 + scsi_to_pci_dma_dir(cmnd->sc_data_direction));
209 + } else if (cmnd->request_bufflen) {
210 + dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
211 + cmnd->request_bufflen,
212 + scsi_to_pci_dma_dir(cmnd->sc_data_direction));
216 /*****************************************************************************
217 Function name : i91uSCBPost
218 Description : This is callback routine be called when tulip finish one
219 @@ -686,6 +713,8 @@ static void i91uSCBPost(BYTE * pHcb, BYT
221 printk("pSRB is NULL\n");
224 + i91u_unmap_cmnd(pHCB->pci_dev, pSRB);
225 pSRB->scsi_done(pSRB); /* Notify system DONE */
226 if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL)
227 /* Find the next pending SRB */