Commit 8ac2b42a45896641ed292deaf038a1d2703d85a6
1 parent
993da8f9ea
Exists in
master
and in
4 other branches
ide: add IDE_HFLAG_CLEAR_SIMPLEX host flag
* Rename 'simplex_stat' variable to 'dma_stat' in ide_get_or_set_dma_base(). * Factor out code for forcing host out of "simplex" mode from ide_get_or_set_dma_base() to ide_pci_clear_simplex() helper. * Add IDE_HFLAG_CLEAR_SIMPLEX host flag and set it in alim15x3 (for M5229), amd74xx (for AMD 7409), cmd64x (for CMD643), generic (for Netcell) and serverworks (for CSB5) host drivers. * Make ide_get_or_set_dma_base() test for IDE_HFLAG_CLEAR_SIMPLEX host flag instead of checking dev->device (BTW the code was buggy because it didn't check for dev->vendor, luckily none of these PCI Device IDs was used by some other vendor for PCI IDE controller). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Showing 7 changed files with 50 additions and 50 deletions Side-by-side Diff
drivers/ide/pci/alim15x3.c
... | ... | @@ -775,7 +775,7 @@ |
775 | 775 | }; |
776 | 776 | |
777 | 777 | struct ide_port_info d = ali15x3_chipset; |
778 | - u8 rev = dev->revision; | |
778 | + u8 rev = dev->revision, idx = id->driver_data; | |
779 | 779 | |
780 | 780 | if (pci_dev_present(ati_rs100)) |
781 | 781 | printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n"); |
... | ... | @@ -798,6 +798,9 @@ |
798 | 798 | d.udma_mask = ATA_UDMA6; |
799 | 799 | } |
800 | 800 | |
801 | + if (idx == 0) | |
802 | + d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | |
803 | + | |
801 | 804 | #if defined(CONFIG_SPARC64) |
802 | 805 | d.init_hwif = init_hwif_common_ali15x3; |
803 | 806 | #endif /* CONFIG_SPARC64 */ |
... | ... | @@ -807,7 +810,7 @@ |
807 | 810 | |
808 | 811 | static const struct pci_device_id alim15x3_pci_tbl[] = { |
809 | 812 | { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 }, |
810 | - { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 0 }, | |
813 | + { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 1 }, | |
811 | 814 | { 0, }, |
812 | 815 | }; |
813 | 816 | MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl); |
drivers/ide/pci/amd74xx.c
... | ... | @@ -295,6 +295,7 @@ |
295 | 295 | if (idx == 1) { |
296 | 296 | if (dev->revision <= 7) |
297 | 297 | d.swdma_mask = 0; |
298 | + d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | |
298 | 299 | } else if (idx == 4) { |
299 | 300 | if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && |
300 | 301 | dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) |
drivers/ide/pci/cmd64x.c
... | ... | @@ -443,7 +443,9 @@ |
443 | 443 | .init_chipset = init_chipset_cmd64x, |
444 | 444 | .init_hwif = init_hwif_cmd64x, |
445 | 445 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, |
446 | - .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, | |
446 | + .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | | |
447 | + IDE_HFLAG_ABUSE_PREFETCH | | |
448 | + IDE_HFLAG_BOOTABLE, | |
447 | 449 | .pio_mask = ATA_PIO5, |
448 | 450 | .mwdma_mask = ATA_MWDMA2, |
449 | 451 | .udma_mask = 0x00, /* no udma */ |
drivers/ide/pci/generic.c
... | ... | @@ -104,7 +104,8 @@ |
104 | 104 | |
105 | 105 | { /* 14 */ |
106 | 106 | .name = "Revolution", |
107 | - .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | |
107 | + .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | | |
108 | + IDE_HFLAG_TRUST_BIOS_FOR_DMA | | |
108 | 109 | IDE_HFLAG_OFF_BOARD, |
109 | 110 | .swdma_mask = ATA_SWDMA2, |
110 | 111 | .mwdma_mask = ATA_MWDMA2, |
drivers/ide/pci/serverworks.c
... | ... | @@ -418,7 +418,9 @@ |
418 | 418 | |
419 | 419 | d = serverworks_chipsets[idx]; |
420 | 420 | |
421 | - if (idx == 2 || idx == 3) { | |
421 | + if (idx == 1) | |
422 | + d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | |
423 | + else if (idx == 2 || idx == 3) { | |
422 | 424 | if ((PCI_FUNC(dev->devfn) & 1) == 0) { |
423 | 425 | if (pci_resource_start(dev, 0) != 0x01f1) |
424 | 426 | d.host_flags &= ~IDE_HFLAG_BOOTABLE; |
drivers/ide/setup-pci.c
... | ... | @@ -140,6 +140,16 @@ |
140 | 140 | } |
141 | 141 | |
142 | 142 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
143 | +static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) | |
144 | +{ | |
145 | + u8 dma_stat = inb(dma_base + 2); | |
146 | + | |
147 | + outb(dma_stat & 0x60, dma_base + 2); | |
148 | + dma_stat = inb(dma_base + 2); | |
149 | + if (dma_stat & 0x80) | |
150 | + printk(KERN_INFO "%s: simplex device: DMA forced\n", name); | |
151 | +} | |
152 | + | |
143 | 153 | /** |
144 | 154 | * ide_get_or_set_dma_base - setup BMIBA |
145 | 155 | * @d: IDE port info |
... | ... | @@ -154,6 +164,7 @@ |
154 | 164 | { |
155 | 165 | unsigned long dma_base = 0; |
156 | 166 | struct pci_dev *dev = hwif->pci_dev; |
167 | + u8 dma_stat = 0; | |
157 | 168 | |
158 | 169 | if (hwif->mmio) |
159 | 170 | return hwif->dma_base; |
160 | 171 | |
161 | 172 | |
... | ... | @@ -174,52 +185,30 @@ |
174 | 185 | if (hwif->channel) |
175 | 186 | dma_base += 8; |
176 | 187 | |
177 | - if ((d->host_flags & IDE_HFLAG_CS5520) == 0) { | |
178 | - u8 simplex_stat = 0; | |
188 | + if (d->host_flags & IDE_HFLAG_CS5520) | |
189 | + goto out; | |
179 | 190 | |
180 | - switch(dev->device) { | |
181 | - case PCI_DEVICE_ID_AL_M5219: | |
182 | - case PCI_DEVICE_ID_AL_M5229: | |
183 | - case PCI_DEVICE_ID_AMD_VIPER_7409: | |
184 | - case PCI_DEVICE_ID_CMD_643: | |
185 | - case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE: | |
186 | - case PCI_DEVICE_ID_REVOLUTION: | |
187 | - simplex_stat = inb(dma_base + 2); | |
188 | - outb(simplex_stat & 0x60, dma_base + 2); | |
189 | - simplex_stat = inb(dma_base + 2); | |
190 | - if (simplex_stat & 0x80) { | |
191 | - printk(KERN_INFO "%s: simplex device: " | |
192 | - "DMA forced\n", | |
193 | - d->name); | |
194 | - } | |
195 | - break; | |
196 | - default: | |
197 | - /* | |
198 | - * If the device claims "simplex" DMA, | |
199 | - * this means only one of the two interfaces | |
200 | - * can be trusted with DMA at any point in time. | |
201 | - * So we should enable DMA only on one of the | |
202 | - * two interfaces. | |
203 | - */ | |
204 | - simplex_stat = hwif->INB(dma_base + 2); | |
205 | - if (simplex_stat & 0x80) { | |
206 | - /* simplex device? */ | |
207 | -/* | |
208 | - * At this point we haven't probed the drives so we can't make the | |
209 | - * appropriate decision. Really we should defer this problem | |
210 | - * until we tune the drive then try to grab DMA ownership if we want | |
211 | - * to be the DMA end. This has to be become dynamic to handle hot | |
212 | - * plug. | |
213 | - */ | |
214 | - if (hwif->mate && hwif->mate->dma_base) { | |
215 | - printk(KERN_INFO "%s: simplex device: " | |
216 | - "DMA disabled\n", | |
217 | - d->name); | |
218 | - dma_base = 0; | |
219 | - } | |
220 | - } | |
221 | - } | |
191 | + if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { | |
192 | + ide_pci_clear_simplex(dma_base, d->name); | |
193 | + goto out; | |
222 | 194 | } |
195 | + | |
196 | + /* | |
197 | + * If the device claims "simplex" DMA, this means that only one of | |
198 | + * the two interfaces can be trusted with DMA at any point in time | |
199 | + * (so we should enable DMA only on one of the two interfaces). | |
200 | + * | |
201 | + * FIXME: At this point we haven't probed the drives so we can't make | |
202 | + * the appropriate decision. Really we should defer this problem until | |
203 | + * we tune the drive then try to grab DMA ownership if we want to be | |
204 | + * the DMA end. This has to be become dynamic to handle hot-plug. | |
205 | + */ | |
206 | + dma_stat = hwif->INB(dma_base + 2); | |
207 | + if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { | |
208 | + printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); | |
209 | + dma_base = 0; | |
210 | + } | |
211 | +out: | |
223 | 212 | return dma_base; |
224 | 213 | } |
225 | 214 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
include/linux/ide.h
... | ... | @@ -1093,6 +1093,8 @@ |
1093 | 1093 | IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), |
1094 | 1094 | /* host is CY82C693 */ |
1095 | 1095 | IDE_HFLAG_CY82C693 = (1 << 27), |
1096 | + /* force host out of "simplex" mode */ | |
1097 | + IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), | |
1096 | 1098 | }; |
1097 | 1099 | |
1098 | 1100 | #ifdef CONFIG_BLK_DEV_OFFBOARD |