aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-10-05 15:55:09 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-23 15:12:36 -0400
commit4d85b471593d03e141f9160a58574b9204363267 (patch)
tree322457b73d4b5872ddb5c0651d8820933f0a68c4 /drivers
parenta44131b35ec1a46ed75014d818cb9d5706117b49 (diff)
[SCSI] sym53c8xx: Simplify DAC DMA handling
By introducing the use_dac(), set_dac() and DMA_DAC_MASK macros, we can eliminate a lot of ifdefs from the code. We now rely on the compiler to optimise away a few things that we'd formerly relied on the preprocessor to do. This makes sym_setup_bus_dma_mask() small enough to inline into its only caller. Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw.c2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c32
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c23
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h11
4 files changed, 26 insertions, 42 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c
index 3d4db802c06f..aa230d23eda4 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw.c
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.c
@@ -167,7 +167,7 @@ sym_fw2_patch(struct sym_hcb *np)
167 * Remove useless 64 bit DMA specific SCRIPTS, 167 * Remove useless 64 bit DMA specific SCRIPTS,
168 * when this feature is not available. 168 * when this feature is not available.
169 */ 169 */
170 if (!np->use_dac) { 170 if (!use_dac(np)) {
171 scripta0->is_dmap_dirty[0] = cpu_to_scr(SCR_NO_OP); 171 scripta0->is_dmap_dirty[0] = cpu_to_scr(SCR_NO_OP);
172 scripta0->is_dmap_dirty[1] = 0; 172 scripta0->is_dmap_dirty[1] = 0;
173 scripta0->is_dmap_dirty[2] = cpu_to_scr(SCR_NO_OP); 173 scripta0->is_dmap_dirty[2] = cpu_to_scr(SCR_NO_OP);
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index c1d9f6989664..55012970912b 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -1265,31 +1265,6 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev)
1265} 1265}
1266 1266
1267/* 1267/*
1268 * Ask/tell the system about DMA addressing.
1269 */
1270static int sym_setup_bus_dma_mask(struct sym_hcb *np)
1271{
1272#if SYM_CONF_DMA_ADDRESSING_MODE > 0
1273#if SYM_CONF_DMA_ADDRESSING_MODE == 1
1274#define DMA_DAC_MASK DMA_40BIT_MASK
1275#elif SYM_CONF_DMA_ADDRESSING_MODE == 2
1276#define DMA_DAC_MASK DMA_64BIT_MASK
1277#endif
1278 if ((np->features & FE_DAC) &&
1279 !pci_set_dma_mask(np->s.device, DMA_DAC_MASK)) {
1280 np->use_dac = 1;
1281 return 0;
1282 }
1283#endif
1284
1285 if (!pci_set_dma_mask(np->s.device, DMA_32BIT_MASK))
1286 return 0;
1287
1288 printf_warning("%s: No suitable DMA available\n", sym_name(np));
1289 return -1;
1290}
1291
1292/*
1293 * Host attach and initialisations. 1268 * Host attach and initialisations.
1294 * 1269 *
1295 * Allocate host data and ncb structure. 1270 * Allocate host data and ncb structure.
@@ -1362,8 +1337,13 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt,
1362 strlcpy(np->s.chip_name, dev->chip.name, sizeof(np->s.chip_name)); 1337 strlcpy(np->s.chip_name, dev->chip.name, sizeof(np->s.chip_name));
1363 sprintf(np->s.inst_name, "sym%d", np->s.unit); 1338 sprintf(np->s.inst_name, "sym%d", np->s.unit);
1364 1339
1365 if (sym_setup_bus_dma_mask(np)) 1340 if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) &&
1341 !pci_set_dma_mask(np->s.device, DMA_DAC_MASK)) {
1342 set_dac(np);
1343 } else if (pci_set_dma_mask(np->s.device, DMA_32BIT_MASK)) {
1344 printf_warning("%s: No suitable DMA available\n", sym_name(np));
1366 goto attach_failed; 1345 goto attach_failed;
1346 }
1367 1347
1368 /* 1348 /*
1369 * Try to map the controller chip to 1349 * Try to map the controller chip to
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index 39f84bbe6856..5d0d356e1e74 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -778,19 +778,12 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
778 * 64 bit addressing (895A/896/1010) ? 778 * 64 bit addressing (895A/896/1010) ?
779 */ 779 */
780 if (np->features & FE_DAC) { 780 if (np->features & FE_DAC) {
781#if SYM_CONF_DMA_ADDRESSING_MODE == 0 781 if (!use_dac(np))
782 np->rv_ccntl1 |= (DDAC); 782 np->rv_ccntl1 |= (DDAC);
783#elif SYM_CONF_DMA_ADDRESSING_MODE == 1 783 else if (SYM_CONF_DMA_ADDRESSING_MODE == 1)
784 if (!np->use_dac) 784 np->rv_ccntl1 |= (XTIMOD | EXTIBMV);
785 np->rv_ccntl1 |= (DDAC); 785 else if (SYM_CONF_DMA_ADDRESSING_MODE == 2)
786 else 786 np->rv_ccntl1 |= (0 | EXTIBMV);
787 np->rv_ccntl1 |= (XTIMOD | EXTIBMV);
788#elif SYM_CONF_DMA_ADDRESSING_MODE == 2
789 if (!np->use_dac)
790 np->rv_ccntl1 |= (DDAC);
791 else
792 np->rv_ccntl1 |= (0 | EXTIBMV);
793#endif
794 } 787 }
795 788
796 /* 789 /*
@@ -1322,7 +1315,7 @@ int sym_lookup_dmap(struct sym_hcb *np, u32 h, int s)
1322{ 1315{
1323 int i; 1316 int i;
1324 1317
1325 if (!np->use_dac) 1318 if (!use_dac(np))
1326 goto weird; 1319 goto weird;
1327 1320
1328 /* Look up existing mappings */ 1321 /* Look up existing mappings */
@@ -1837,7 +1830,7 @@ void sym_start_up (struct sym_hcb *np, int reason)
1837 * Set up scratch C and DRS IO registers to map the 32 bit 1830 * Set up scratch C and DRS IO registers to map the 32 bit
1838 * DMA address range our data structures are located in. 1831 * DMA address range our data structures are located in.
1839 */ 1832 */
1840 if (np->use_dac) { 1833 if (use_dac(np)) {
1841 np->dmap_bah[0] = 0; /* ??? */ 1834 np->dmap_bah[0] = 0; /* ??? */
1842 OUTL(np, nc_scrx[0], np->dmap_bah[0]); 1835 OUTL(np, nc_scrx[0], np->dmap_bah[0]);
1843 OUTL(np, nc_drs, np->dmap_bah[0]); 1836 OUTL(np, nc_drs, np->dmap_bah[0]);
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index f76b27f0aa2c..4354571a63ef 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -1026,6 +1026,14 @@ struct sym_hcb {
1026#endif 1026#endif
1027}; 1027};
1028 1028
1029#if SYM_CONF_DMA_ADDRESSING_MODE == 0
1030#define use_dac(np) 0
1031#define set_dac(np) do { } while (0)
1032#else
1033#define use_dac(np) (np)->use_dac
1034#define set_dac(np) (np)->use_dac = 1
1035#endif
1036
1029#define HCB_BA(np, lbl) (np->hcb_ba + offsetof(struct sym_hcb, lbl)) 1037#define HCB_BA(np, lbl) (np->hcb_ba + offsetof(struct sym_hcb, lbl))
1030 1038
1031 1039
@@ -1068,18 +1076,21 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram
1068 */ 1076 */
1069 1077
1070#if SYM_CONF_DMA_ADDRESSING_MODE == 0 1078#if SYM_CONF_DMA_ADDRESSING_MODE == 0
1079#define DMA_DAC_MASK DMA_32BIT_MASK
1071#define sym_build_sge(np, data, badd, len) \ 1080#define sym_build_sge(np, data, badd, len) \
1072do { \ 1081do { \
1073 (data)->addr = cpu_to_scr(badd); \ 1082 (data)->addr = cpu_to_scr(badd); \
1074 (data)->size = cpu_to_scr(len); \ 1083 (data)->size = cpu_to_scr(len); \
1075} while (0) 1084} while (0)
1076#elif SYM_CONF_DMA_ADDRESSING_MODE == 1 1085#elif SYM_CONF_DMA_ADDRESSING_MODE == 1
1086#define DMA_DAC_MASK DMA_40BIT_MASK
1077#define sym_build_sge(np, data, badd, len) \ 1087#define sym_build_sge(np, data, badd, len) \
1078do { \ 1088do { \
1079 (data)->addr = cpu_to_scr(badd); \ 1089 (data)->addr = cpu_to_scr(badd); \
1080 (data)->size = cpu_to_scr((((badd) >> 8) & 0xff000000) + len); \ 1090 (data)->size = cpu_to_scr((((badd) >> 8) & 0xff000000) + len); \
1081} while (0) 1091} while (0)
1082#elif SYM_CONF_DMA_ADDRESSING_MODE == 2 1092#elif SYM_CONF_DMA_ADDRESSING_MODE == 2
1093#define DMA_DAC_MASK DMA_64BIT_MASK
1083int sym_lookup_dmap(struct sym_hcb *np, u32 h, int s); 1094int sym_lookup_dmap(struct sym_hcb *np, u32 h, int s);
1084static __inline void 1095static __inline void
1085sym_build_sge(struct sym_hcb *np, struct sym_tblmove *data, u64 badd, int len) 1096sym_build_sge(struct sym_hcb *np, struct sym_tblmove *data, u64 badd, int len)