2002-03-11 09:58:02

by Jochen Friedrich

[permalink] [raw]
Subject: Busmaster DMA broken in 2.4.18 on Alpha

Hi,

it looks like the change to pci_iommu.c in 2.4.18 breaks busmaster DMA for
alpha. The reason is that ISA_DMA_MASK is now 0xffffffff instead of
0x00ffffff as it was before. So the allocated memory is no longer
reachable from the ISA card.

I had to revert this change to make my ISA token ring card (tms380 based)
work again on alpha.

Cheers,
Jochen


2002-03-11 11:45:54

by Kurt Garloff

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

Hi Jochen,

On Mon, Mar 11, 2002 at 10:57:40AM +0100, Jochen Friedrich wrote:
> it looks like the change to pci_iommu.c in 2.4.18 breaks busmaster DMA for
> alpha. The reason is that ISA_DMA_MASK is now 0xffffffff instead of
> 0x00ffffff as it was before. So the allocated memory is no longer
> reachable from the ISA card.
>
> I had to revert this change to make my ISA token ring card (tms380 based)
> work again on alpha.

You have a Miata mainboard, right?

The problem is that the chipset does corrupt data when you do busmaster DMA
read (from memory) over an 8k page boundary on the primary PCI bus.
(Secondary is not affected.)
Therefore you could e.g. not use IDE DMA on Miata.

I created a workaround specific to the ide-dma driver, but Ivan came up with
a much more general and better solution:
The PCI mapping via tbia is not used any more, but instead the PCI monster
window, which can map up to 4GB into PCI space. (Miata can theoretically have
6GB, but I did not yet hear any complaints.)
It first broke floppy support as the pci_map would fail. The floppy chip is
an ISA device. But it can address full 32bit on Miata, so the ISA_DMA_MASK
was adapted to this.
(Ivan, correct me if I got the details wrong.)

Unfortunately, your ISA card does not seem to be able to address 32 bits.
(I guess no non-on-chip ISA adapter will.)

Seems we need two different ISA_DMA_MASKS ...

Maybe it would be easier to special case the floppy driver's calls to
pci_map when a Miata(21174) has been detected and the workaround been
applied.

Regards,
--
Kurt Garloff <[email protected]> Eindhoven, NL
GPG key: See mail header, key servers Linux kernel development
SuSE Linux AG, Nuernberg, DE SCSI, Security


Attachments:
(No filename) (1.72 kB)
(No filename) (232.00 B)
Download all attachments

2002-03-11 13:54:13

by Jochen Friedrich

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

Hi Kurt,

> You have a Miata mainboard, right?

Nope. It's an Avanti board (Alpha Server 400).

> Unfortunately, your ISA card does not seem to be able to address 32 bits.
> (I guess no non-on-chip ISA adapter will.)

IIRC, the ISA bus only has a 24bit address bus.

> Seems we need two different ISA_DMA_MASKS ...

Looks like it.

Cheers,
--jochen

2002-03-11 14:22:50

by Ivan Kokshaysky

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

On Mon, Mar 11, 2002 at 12:45:11PM +0100, Kurt Garloff wrote:
> Unfortunately, your ISA card does not seem to be able to address 32 bits.
> (I guess no non-on-chip ISA adapter will.)

No, the ability to address 32 bits is property of an ISA bridge, not
of any particular ISA card or device. Most alphas do have 32-bit ISA DMA.

For that particular driver the following hack should work.
However, ideally we should have ISA_DMA_MASK in asm/dma.h defined
for all architectures...

Ivan.

--- linux/drivers/net/tokenring/tms380tr.h.orig Fri May 25 20:58:07 2001
+++ linux/drivers/net/tokenring/tms380tr.h Mon Mar 11 15:52:06 2002
@@ -462,7 +462,12 @@ typedef struct {
*/

/* XXX is there some better way to do this? */
+#if defined(__alpha__)
+#define ISA_MAX_ADDRESS (MAX_DMA_ADDRESS - IDENT_ADDR - 1 < 0xffffffff ? \
+ MAX_DMA_ADDRESS - IDENT_ADDR - 1 : 0xffffffff)
+#else
#define ISA_MAX_ADDRESS 0x00ffffff
+#endif
#define PCI_MAX_ADDRESS 0xffffffff

#pragma pack(1)

2002-03-11 14:32:29

by Jochen Friedrich

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

Hi Ivan,

> No, the ability to address 32 bits is property of an ISA bridge, not
> of any particular ISA card or device. Most alphas do have 32-bit ISA DMA.

This is wrong for bus master DMA. tms380tr.c sets DMA_MODE_CASCADE and the
addressing is done by the ISA card. As the card only has 24bit, the DMA is
limited to 24 bits.

Your patch would only cause a machine check, but DMA still wouldn't work.

Cheers,
--jochen

2002-03-11 15:13:35

by Jay Estabrook

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

On Mon, Mar 11, 2002 at 05:10:58PM +0300, Ivan Kokshaysky wrote:
> On Mon, Mar 11, 2002 at 12:45:11PM +0100, Kurt Garloff wrote:
> > Unfortunately, your ISA card does not seem to be able to address 32 bits.
> > (I guess no non-on-chip ISA adapter will.)
>
> No, the ability to address 32 bits is property of an ISA bridge, not
> of any particular ISA card or device.

That's not quite true, either.

There are ISA cards, regardless of what ISA bus machine they are
plugged into, that are able to generate only something less than
32-bits worth of address. I believe that the Adaptec 1540 SCSI
controller is one of these, since I had some exposure to its
limitations a while ago; it can generate only 24-bit addresses, IIRC.

Since ISA devices don't have pci_dev structures, there's (currently)
no way to pass an ISA device-dependent DMA mask to the IOMMU routines.
Perhaps there needs to be an addition to the API that would allow
for this (pci_set_isa_device_dma_mask()) ???

> Most alphas do have 32-bit ISA DMA.

True. For those notable exceptions (XL, Ruffian, Nautilus), we can still
depend on the MAX_DMA_ADDRESS to override any device-dependent mask.

--Jay++

-----------------------------------------------------------------------------
Jay A Estabrook Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K15 (508) 467-2080
200 Forest Street, Marlboro MA 01752 [email protected]
-----------------------------------------------------------------------------

2002-03-11 15:23:44

by David Miller

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

From: Jay Estabrook <[email protected]>
Date: Mon, 11 Mar 2002 10:02:00 -0500

Since ISA devices don't have pci_dev structures, there's (currently)
no way to pass an ISA device-dependent DMA mask to the IOMMU routines.
Perhaps there needs to be an addition to the API that would allow
for this (pci_set_isa_device_dma_mask()) ???

What you could do currently is whip up a dummy pci_dev structure with
the mask you want and pass that into the PCI dma routines. So you
could, for example, default to 24-bit DMA mask when you get "NULL"
as pci_dev, but cook up a special one using a 32-bit DMA mask for the
floppy ISA device in question.

The idea in 2.5.x is to move to a generic struct device, at which time
something like this can be done much more cleanly.

2002-03-11 15:36:24

by Alan

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

> There are ISA cards, regardless of what ISA bus machine they are
> plugged into, that are able to generate only something less than
> 32-bits worth of address. I believe that the Adaptec 1540 SCSI

All busmasters in fact. There are only 24 address wires on the ISA bus. That
covers stuff from tpqic02 through pcnet/isa, lance and aha154x.

Alan

2002-03-11 15:56:17

by Jay Estabrook

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

On Mon, Mar 11, 2002 at 07:16:56AM -0800, David S. Miller wrote:
> From: Jay Estabrook <[email protected]>
> Date: Mon, 11 Mar 2002 10:02:00 -0500
>
> Since ISA devices don't have pci_dev structures, there's (currently)
> no way to pass an ISA device-dependent DMA mask to the IOMMU routines.
> Perhaps there needs to be an addition to the API that would allow
> for this (pci_set_isa_device_dma_mask()) ???
>
> What you could do currently is whip up a dummy pci_dev structure with
> the mask you want and pass that into the PCI dma routines. So you
> could, for example, default to 24-bit DMA mask when you get "NULL"
> as pci_dev, but cook up a special one using a 32-bit DMA mask for the
> floppy ISA device in question.

Yup, that'd work, though it would put the floppy's resources in with
the PCI devices, rather than kept separate as ISA. Should work fine,
though.

> The idea in 2.5.x is to move to a generic struct device, at which time
> something like this can be done much more cleanly.

Sounds good, if only it'd compile on Alpha... ;-}

--Jay++

-----------------------------------------------------------------------------
Jay A Estabrook Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K15 (508) 467-2080
200 Forest Street, Marlboro MA 01752 [email protected]
-----------------------------------------------------------------------------

2002-03-11 18:14:02

by Ivan Kokshaysky

[permalink] [raw]
Subject: Re: Busmaster DMA broken in 2.4.18 on Alpha

On Mon, Mar 11, 2002 at 10:02:00AM -0500, Jay Estabrook wrote:
> There are ISA cards, regardless of what ISA bus machine they are
> plugged into, that are able to generate only something less than
> 32-bits worth of address.

Indeed, I missed that.

> Since ISA devices don't have pci_dev structures, there's (currently)
> no way to pass an ISA device-dependent DMA mask to the IOMMU routines.
> Perhaps there needs to be an addition to the API that would allow
> for this (pci_set_isa_device_dma_mask()) ???

Yes, it would be nice to have something like this.

Another workaround also seems to be possible - for ISA devices
use mask other than 0x00ffffff _only_ if we don't have working
IOMMU. This doesn't help to get older Miatas work with such
type of ISA cards though...

Ivan.