aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/advansys.c104
1 files changed, 41 insertions, 63 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index e79f7955f6ea..73d974a15fca 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -1380,7 +1380,6 @@ typedef struct asc_dvc_cfg {
1380 uchar sdtr_period_offset[ASC_MAX_TID + 1]; 1380 uchar sdtr_period_offset[ASC_MAX_TID + 1];
1381 ushort pci_slot_info; 1381 ushort pci_slot_info;
1382 uchar adapter_info[6]; 1382 uchar adapter_info[6];
1383 struct device *dev;
1384} ASC_DVC_CFG; 1383} ASC_DVC_CFG;
1385 1384
1386#define ASC_DEF_DVC_CNTL 0xFFFF 1385#define ASC_DEF_DVC_CNTL 0xFFFF
@@ -1831,7 +1830,6 @@ static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
1831static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int); 1830static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
1832static ushort AscInitAscDvcVar(ASC_DVC_VAR *); 1831static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
1833static ushort AscInitFromEEP(ASC_DVC_VAR *); 1832static ushort AscInitFromEEP(ASC_DVC_VAR *);
1834static ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
1835static ushort AscInitMicroCodeVar(ASC_DVC_VAR *); 1833static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
1836static int AscTestExternalLram(ASC_DVC_VAR *); 1834static int AscTestExternalLram(ASC_DVC_VAR *);
1837static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar); 1835static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
@@ -2827,7 +2825,6 @@ typedef struct adv_dvc_cfg {
2827 ushort serial1; /* EEPROM serial number word 1 */ 2825 ushort serial1; /* EEPROM serial number word 1 */
2828 ushort serial2; /* EEPROM serial number word 2 */ 2826 ushort serial2; /* EEPROM serial number word 2 */
2829 ushort serial3; /* EEPROM serial number word 3 */ 2827 ushort serial3; /* EEPROM serial number word 3 */
2830 struct device *dev; /* pointer to the pci dev structure for this board */
2831} ADV_DVC_CFG; 2828} ADV_DVC_CFG;
2832 2829
2833struct adv_dvc_var; 2830struct adv_dvc_var;
@@ -3000,7 +2997,6 @@ static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
3000 */ 2997 */
3001static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *); 2998static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3002static int AdvISR(ADV_DVC_VAR *); 2999static int AdvISR(ADV_DVC_VAR *);
3003static int AdvInitGetConfig(ADV_DVC_VAR *);
3004static int AdvInitAsc3550Driver(ADV_DVC_VAR *); 3000static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
3005static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *); 3001static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
3006static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *); 3002static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
@@ -3597,6 +3593,7 @@ typedef struct adv_req {
3597 * field. It is guaranteed to be allocated from DMA-able memory. 3593 * field. It is guaranteed to be allocated from DMA-able memory.
3598 */ 3594 */
3599typedef struct asc_board { 3595typedef struct asc_board {
3596 struct device *dev;
3600 int id; /* Board Id */ 3597 int id; /* Board Id */
3601 uint flags; /* Board flags */ 3598 uint flags; /* Board flags */
3602 union { 3599 union {
@@ -4672,7 +4669,6 @@ static void asc_scsi_done_list(struct scsi_cmnd *scp)
4672 ASC_DBG(2, "asc_scsi_done_list: begin\n"); 4669 ASC_DBG(2, "asc_scsi_done_list: begin\n");
4673 while (scp != NULL) { 4670 while (scp != NULL) {
4674 asc_board_t *boardp; 4671 asc_board_t *boardp;
4675 struct device *dev;
4676 4672
4677 ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp); 4673 ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
4678 tscp = REQPNEXT(scp); 4674 tscp = REQPNEXT(scp);
@@ -4680,17 +4676,12 @@ static void asc_scsi_done_list(struct scsi_cmnd *scp)
4680 4676
4681 boardp = ASC_BOARDP(scp->device->host); 4677 boardp = ASC_BOARDP(scp->device->host);
4682 4678
4683 if (ASC_NARROW_BOARD(boardp))
4684 dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
4685 else
4686 dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
4687
4688 if (scp->use_sg) 4679 if (scp->use_sg)
4689 dma_unmap_sg(dev, 4680 dma_unmap_sg(boardp->dev,
4690 (struct scatterlist *)scp->request_buffer, 4681 (struct scatterlist *)scp->request_buffer,
4691 scp->use_sg, scp->sc_data_direction); 4682 scp->use_sg, scp->sc_data_direction);
4692 else if (scp->request_bufflen) 4683 else if (scp->request_bufflen)
4693 dma_unmap_single(dev, scp->SCp.dma_handle, 4684 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
4694 scp->request_bufflen, 4685 scp->request_bufflen,
4695 scp->sc_data_direction); 4686 scp->sc_data_direction);
4696 4687
@@ -4929,8 +4920,6 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
4929 */ 4920 */
4930static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp) 4921static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
4931{ 4922{
4932 struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
4933
4934 /* 4923 /*
4935 * Mutually exclusive access is required to 'asc_scsi_q' and 4924 * Mutually exclusive access is required to 'asc_scsi_q' and
4936 * 'asc_sg_head' until after the request is started. 4925 * 'asc_sg_head' until after the request is started.
@@ -4994,7 +4983,7 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
4994 */ 4983 */
4995 ASC_STATS(scp->device->host, cont_cnt); 4984 ASC_STATS(scp->device->host, cont_cnt);
4996 scp->SCp.dma_handle = scp->request_bufflen ? 4985 scp->SCp.dma_handle = scp->request_bufflen ?
4997 dma_map_single(dev, scp->request_buffer, 4986 dma_map_single(boardp->dev, scp->request_buffer,
4998 scp->request_bufflen, 4987 scp->request_bufflen,
4999 scp->sc_data_direction) : 0; 4988 scp->sc_data_direction) : 0;
5000 asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle); 4989 asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
@@ -5012,15 +5001,14 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
5012 struct scatterlist *slp; 5001 struct scatterlist *slp;
5013 5002
5014 slp = (struct scatterlist *)scp->request_buffer; 5003 slp = (struct scatterlist *)scp->request_buffer;
5015 use_sg = 5004 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
5016 dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction); 5005 scp->sc_data_direction);
5017 5006
5018 if (use_sg > scp->device->host->sg_tablesize) { 5007 if (use_sg > scp->device->host->sg_tablesize) {
5019 ASC_PRINT3 5008 ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
5020 ("asc_build_req: board %d: use_sg %d > sg_tablesize %d\n", 5009 "sg_tablesize %d\n", boardp->id, use_sg,
5021 boardp->id, use_sg, 5010 scp->device->host->sg_tablesize);
5022 scp->device->host->sg_tablesize); 5011 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
5023 dma_unmap_sg(dev, slp, scp->use_sg,
5024 scp->sc_data_direction); 5012 scp->sc_data_direction);
5025 scp->result = HOST_BYTE(DID_ERROR); 5013 scp->result = HOST_BYTE(DID_ERROR);
5026 asc_enqueue(&boardp->done, scp, ASC_BACK); 5014 asc_enqueue(&boardp->done, scp, ASC_BACK);
@@ -5081,7 +5069,6 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
5081 ADV_SCSI_REQ_Q *scsiqp; 5069 ADV_SCSI_REQ_Q *scsiqp;
5082 int i; 5070 int i;
5083 int ret; 5071 int ret;
5084 struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
5085 5072
5086 /* 5073 /*
5087 * Allocate an adv_req_t structure from the board to execute 5074 * Allocate an adv_req_t structure from the board to execute
@@ -5168,7 +5155,7 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
5168 if (scp->request_bufflen) { 5155 if (scp->request_bufflen) {
5169 scsiqp->vdata_addr = scp->request_buffer; 5156 scsiqp->vdata_addr = scp->request_buffer;
5170 scp->SCp.dma_handle = 5157 scp->SCp.dma_handle =
5171 dma_map_single(dev, scp->request_buffer, 5158 dma_map_single(boardp->dev, scp->request_buffer,
5172 scp->request_bufflen, 5159 scp->request_bufflen,
5173 scp->sc_data_direction); 5160 scp->sc_data_direction);
5174 } else { 5161 } else {
@@ -5189,22 +5176,21 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
5189 int use_sg; 5176 int use_sg;
5190 5177
5191 slp = (struct scatterlist *)scp->request_buffer; 5178 slp = (struct scatterlist *)scp->request_buffer;
5192 use_sg = 5179 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
5193 dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction); 5180 scp->sc_data_direction);
5194 5181
5195 if (use_sg > ADV_MAX_SG_LIST) { 5182 if (use_sg > ADV_MAX_SG_LIST) {
5196 ASC_PRINT3 5183 ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
5197 ("adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n", 5184 "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
5198 boardp->id, use_sg, 5185 scp->device->host->sg_tablesize);
5199 scp->device->host->sg_tablesize); 5186 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
5200 dma_unmap_sg(dev, slp, scp->use_sg,
5201 scp->sc_data_direction); 5187 scp->sc_data_direction);
5202 scp->result = HOST_BYTE(DID_ERROR); 5188 scp->result = HOST_BYTE(DID_ERROR);
5203 asc_enqueue(&boardp->done, scp, ASC_BACK); 5189 asc_enqueue(&boardp->done, scp, ASC_BACK);
5204 5190
5205 /* 5191 /*
5206 * Free the 'adv_req_t' structure by adding it back to the 5192 * Free the 'adv_req_t' structure by adding it back
5207 * board free list. 5193 * to the board free list.
5208 */ 5194 */
5209 reqp->next_reqp = boardp->adv_reqp; 5195 reqp->next_reqp = boardp->adv_reqp;
5210 boardp->adv_reqp = reqp; 5196 boardp->adv_reqp = reqp;
@@ -5212,12 +5198,11 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
5212 return ASC_ERROR; 5198 return ASC_ERROR;
5213 } 5199 }
5214 5200
5215 if ((ret = 5201 ret = adv_get_sglist(boardp, reqp, scp, use_sg);
5216 adv_get_sglist(boardp, reqp, scp, 5202 if (ret != ADV_SUCCESS) {
5217 use_sg)) != ADV_SUCCESS) {
5218 /* 5203 /*
5219 * Free the adv_req_t structure by adding it back to the 5204 * Free the adv_req_t structure by adding it back to
5220 * board free list. 5205 * the board free list.
5221 */ 5206 */
5222 reqp->next_reqp = boardp->adv_reqp; 5207 reqp->next_reqp = boardp->adv_reqp;
5223 boardp->adv_reqp = reqp; 5208 boardp->adv_reqp = reqp;
@@ -10219,30 +10204,21 @@ static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
10219 return warn_code; 10204 return warn_code;
10220} 10205}
10221 10206
10222static ushort __devinit AscInitSetConfig(ASC_DVC_VAR *asc_dvc) 10207static unsigned short __devinit
10208AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
10223{ 10209{
10224 ushort warn_code = 0; 10210 PortAddr iop_base = asc_dvc->iop_base;
10211 unsigned short cfg_msw;
10212 unsigned short warn_code = 0;
10225 10213
10226 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG; 10214 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
10227 if (asc_dvc->err_code != 0) 10215 if (asc_dvc->err_code != 0)
10228 return (UW_ERR); 10216 return UW_ERR;
10229 if (AscFindSignature(asc_dvc->iop_base)) { 10217 if (!AscFindSignature(asc_dvc->iop_base)) {
10230 warn_code |= AscInitFromAscDvcVar(asc_dvc);
10231 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
10232 } else {
10233 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; 10218 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
10219 return 0;
10234 } 10220 }
10235 return (warn_code);
10236}
10237
10238static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
10239{
10240 PortAddr iop_base;
10241 ushort cfg_msw;
10242 ushort warn_code;
10243 10221
10244 iop_base = asc_dvc->iop_base;
10245 warn_code = 0;
10246 cfg_msw = AscGetChipCfgMsw(iop_base); 10222 cfg_msw = AscGetChipCfgMsw(iop_base);
10247 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) { 10223 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
10248 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK)); 10224 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
@@ -10265,7 +10241,6 @@ static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
10265 } 10241 }
10266#ifdef CONFIG_PCI 10242#ifdef CONFIG_PCI
10267 if (asc_dvc->bus_type & ASC_IS_PCI) { 10243 if (asc_dvc->bus_type & ASC_IS_PCI) {
10268 struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
10269 cfg_msw &= 0xFFC0; 10244 cfg_msw &= 0xFFC0;
10270 AscSetChipCfgMsw(iop_base, cfg_msw); 10245 AscSetChipCfgMsw(iop_base, cfg_msw);
10271 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) { 10246 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
@@ -10295,7 +10270,9 @@ static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
10295 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed); 10270 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
10296 } 10271 }
10297#endif /* CONFIG_ISA */ 10272#endif /* CONFIG_ISA */
10298 return (warn_code); 10273
10274 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
10275 return warn_code;
10299} 10276}
10300 10277
10301static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc) 10278static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
@@ -13599,11 +13576,11 @@ static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata =
13599 * For a non-fatal error return a warning code. If there are no warnings 13576 * For a non-fatal error return a warning code. If there are no warnings
13600 * then 0 is returned. 13577 * then 0 is returned.
13601 */ 13578 */
13602static int __devinit AdvInitGetConfig(ADV_DVC_VAR *asc_dvc) 13579static int __devinit
13580AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
13603{ 13581{
13604 unsigned short warn_code = 0; 13582 unsigned short warn_code = 0;
13605 AdvPortAddr iop_base = asc_dvc->iop_base; 13583 AdvPortAddr iop_base = asc_dvc->iop_base;
13606 struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
13607 u16 cmd; 13584 u16 cmd;
13608 int status; 13585 int status;
13609 13586
@@ -17094,6 +17071,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
17094 memset(boardp, 0, sizeof(asc_board_t)); 17071 memset(boardp, 0, sizeof(asc_board_t));
17095 boardp->id = asc_board_count++; 17072 boardp->id = asc_board_count++;
17096 spin_lock_init(&boardp->lock); 17073 spin_lock_init(&boardp->lock);
17074 boardp->dev = dev;
17097 17075
17098 /* 17076 /*
17099 * Handle both narrow and wide boards. 17077 * Handle both narrow and wide boards.
@@ -17180,7 +17158,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
17180#endif /* CONFIG_PROC_FS */ 17158#endif /* CONFIG_PROC_FS */
17181 17159
17182 if (ASC_NARROW_BOARD(boardp)) { 17160 if (ASC_NARROW_BOARD(boardp)) {
17183 asc_dvc_varp->cfg->dev = dev;
17184 /* 17161 /*
17185 * Set the board bus type and PCI IRQ before 17162 * Set the board bus type and PCI IRQ before
17186 * calling AscInitGetConfig(). 17163 * calling AscInitGetConfig().
@@ -17220,7 +17197,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
17220 break; 17197 break;
17221 } 17198 }
17222 } else { 17199 } else {
17223 adv_dvc_varp->cfg->dev = dev;
17224 /* 17200 /*
17225 * For Wide boards set PCI information before calling 17201 * For Wide boards set PCI information before calling
17226 * AdvInitGetConfig(). 17202 * AdvInitGetConfig().
@@ -17289,7 +17265,9 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
17289 } 17265 }
17290 } else { 17266 } else {
17291 ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n"); 17267 ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
17292 if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) { 17268
17269 ret = AdvInitGetConfig(pdev, adv_dvc_varp);
17270 if (ret != 0) {
17293 ASC_PRINT2 17271 ASC_PRINT2
17294 ("AdvInitGetConfig: board %d: warning: 0x%x\n", 17272 ("AdvInitGetConfig: board %d: warning: 0x%x\n",
17295 boardp->id, ret); 17273 boardp->id, ret);
@@ -17345,7 +17323,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
17345 * Modify board configuration. 17323 * Modify board configuration.
17346 */ 17324 */
17347 ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n"); 17325 ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
17348 switch (ret = AscInitSetConfig(asc_dvc_varp)) { 17326 switch (ret = AscInitSetConfig(pdev, asc_dvc_varp)) {
17349 case 0: /* No error. */ 17327 case 0: /* No error. */
17350 break; 17328 break;
17351 case ASC_WARN_IO_PORT_ROTATE: 17329 case ASC_WARN_IO_PORT_ROTATE: