Apart from the older NE2000 card also recognise RTL8139 and set bus master bit for it. This makes it work in MorphOS which uses it in a different (DMA) mode than the Linux driver.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu --- openbios-devel/drivers/pci.c | 11 +++++++++++ openbios-devel/drivers/pci_database.c | 6 ++++++ openbios-devel/include/drivers/pci.h | 1 + 3 files changed, 18 insertions(+)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c index ca4de87..b3cce17 100644 --- a/openbios-devel/drivers/pci.c +++ b/openbios-devel/drivers/pci.c @@ -596,6 +596,17 @@ int ide_config_cb2 (const pci_config_t *config) int eth_config_cb (const pci_config_t *config) { phandle_t ph = get_cur_dev(); + pci_addr addr = 0x80000000u | config->dev; + + /* Enable bus master bit for RTL8139 */ + if (pci_config_read16(addr, PCI_VENDOR_ID) == PCI_VENDOR_ID_REALTEK && + pci_config_read16(addr, PCI_DEVICE_ID) == PCI_DEVICE_ID_REALTEK_RTL8139) { + uint16_t cmd; + + cmd = pci_config_read16(addr, PCI_COMMAND); + cmd |= PCI_COMMAND_BUS_MASTER; + pci_config_write16(addr, PCI_COMMAND, cmd); + }
set_property(ph, "network-type", "ethernet", 9); set_property(ph, "removable", "network", 8); diff --git a/openbios-devel/drivers/pci_database.c b/openbios-devel/drivers/pci_database.c index 3b670d3..4fb3530 100644 --- a/openbios-devel/drivers/pci_database.c +++ b/openbios-devel/drivers/pci_database.c @@ -129,6 +129,12 @@ static const pci_dev_t eth_devices[] = { NULL, "ethernet", }, { + PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_RTL8139, + NULL, "RTL8139", "RTL8139 PCI", NULL, + 0, 0, 0, + NULL, "ethernet", + }, + { /* Virtio-network controller */ PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_NET, NULL, "virtio-net", NULL, diff --git a/openbios-devel/include/drivers/pci.h b/openbios-devel/include/drivers/pci.h index 2eb5685..5772b79 100644 --- a/openbios-devel/include/drivers/pci.h +++ b/openbios-devel/include/drivers/pci.h @@ -202,6 +202,7 @@ extern const pci_arch_t *arch;
#define PCI_VENDOR_ID_REALTEK 0x10ec #define PCI_DEVICE_ID_REALTEK_RTL8029 0x8029 +#define PCI_DEVICE_ID_REALTEK_RTL8139 0x8139
#define PCI_VENDOR_ID_QEMU 0x1234 #define PCI_DEVICE_ID_QEMU_VGA 0x1111
On 03.06.14 01:34, BALATON Zoltan wrote:
Apart from the older NE2000 card also recognise RTL8139 and set bus master bit for it. This makes it work in MorphOS which uses it in a different (DMA) mode than the Linux driver.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu
Please create a helper that tells you whether it's safe to enable bus mastering (why doesn't MorphOS do this itself?) on a particular harware platform. Check for that every time you want to enable bus mastering.
static bool should_enable_bus_mastering(void) { #ifdef IS_QEMU_ON_PPC return true; #else return false; #endif }
Alex
openbios-devel/drivers/pci.c | 11 +++++++++++ openbios-devel/drivers/pci_database.c | 6 ++++++ openbios-devel/include/drivers/pci.h | 1 + 3 files changed, 18 insertions(+)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c index ca4de87..b3cce17 100644 --- a/openbios-devel/drivers/pci.c +++ b/openbios-devel/drivers/pci.c @@ -596,6 +596,17 @@ int ide_config_cb2 (const pci_config_t *config) int eth_config_cb (const pci_config_t *config) { phandle_t ph = get_cur_dev();
pci_addr addr = 0x80000000u | config->dev;
/* Enable bus master bit for RTL8139 */
if (pci_config_read16(addr, PCI_VENDOR_ID) == PCI_VENDOR_ID_REALTEK &&
pci_config_read16(addr, PCI_DEVICE_ID) == PCI_DEVICE_ID_REALTEK_RTL8139) {
uint16_t cmd;
cmd = pci_config_read16(addr, PCI_COMMAND);
cmd |= PCI_COMMAND_BUS_MASTER;
pci_config_write16(addr, PCI_COMMAND, cmd);
}
set_property(ph, "network-type", "ethernet", 9); set_property(ph, "removable", "network", 8);
diff --git a/openbios-devel/drivers/pci_database.c b/openbios-devel/drivers/pci_database.c index 3b670d3..4fb3530 100644 --- a/openbios-devel/drivers/pci_database.c +++ b/openbios-devel/drivers/pci_database.c @@ -129,6 +129,12 @@ static const pci_dev_t eth_devices[] = { NULL, "ethernet", }, {
PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_RTL8139,
NULL, "RTL8139", "RTL8139 PCI", NULL,
0, 0, 0,
NULL, "ethernet",
- },
- { /* Virtio-network controller */ PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_NET, NULL, "virtio-net", NULL,
diff --git a/openbios-devel/include/drivers/pci.h b/openbios-devel/include/drivers/pci.h index 2eb5685..5772b79 100644 --- a/openbios-devel/include/drivers/pci.h +++ b/openbios-devel/include/drivers/pci.h @@ -202,6 +202,7 @@ extern const pci_arch_t *arch;
#define PCI_VENDOR_ID_REALTEK 0x10ec #define PCI_DEVICE_ID_REALTEK_RTL8029 0x8029 +#define PCI_DEVICE_ID_REALTEK_RTL8139 0x8139
#define PCI_VENDOR_ID_QEMU 0x1234 #define PCI_DEVICE_ID_QEMU_VGA 0x1111
On 25/06/14 22:16, Alexander Graf wrote:
On 03.06.14 01:34, BALATON Zoltan wrote:
Apart from the older NE2000 card also recognise RTL8139 and set bus master bit for it. This makes it work in MorphOS which uses it in a different (DMA) mode than the Linux driver.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu
Please create a helper that tells you whether it's safe to enable bus mastering (why doesn't MorphOS do this itself?) on a particular harware platform. Check for that every time you want to enable bus mastering.
static bool should_enable_bus_mastering(void) { #ifdef IS_QEMU_ON_PPC return true; #else return false; #endif }
Yeah. We're definitely overdue a CONFIG_QEMU or similar option across all architectures into which we can hide the sins of emulation ;)
ATB,
Mark.
On Wed, 25 Jun 2014, Mark Cave-Ayland wrote:
On 25/06/14 22:16, Alexander Graf wrote:
On 03.06.14 01:34, BALATON Zoltan wrote:
Apart from the older NE2000 card also recognise RTL8139 and set bus master bit for it. This makes it work in MorphOS which uses it in a different (DMA) mode than the Linux driver.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu
Please create a helper that tells you whether it's safe to enable bus mastering (why doesn't MorphOS do this itself?) on a particular harware platform. Check for that every time you want to enable bus mastering.
static bool should_enable_bus_mastering(void) { #ifdef IS_QEMU_ON_PPC return true; #else return false; #endif }
Yeah. We're definitely overdue a CONFIG_QEMU or similar option across all architectures into which we can hide the sins of emulation ;)
I'll send a version shortly with some #if defined(CONFIG_QEMU) around enabling bus mastering for both patches. It's probably better than a follow up.
Regards, BALATON Zoltan
On Wed, 25 Jun 2014, Alexander Graf wrote:
On 03.06.14 01:34, BALATON Zoltan wrote:
Apart from the older NE2000 card also recognise RTL8139 and set bus master bit for it. This makes it work in MorphOS which uses it in a different (DMA) mode than the Linux driver.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu
Please create a helper that tells you whether it's safe to enable bus mastering (why doesn't MorphOS do this itself?) on a particular harware
On why MorphOS does not do it: good question. I guess it expects that Open Firmware which supports booting from the network initialises the card so it does not have to do the PCI config itself. But I don't know just gussing. On QEMU it only works with this patch, otherwise DMA from the card fails.
Regards, BALATON Zoltan
On 26.06.14 00:25, BALATON Zoltan wrote:
On Wed, 25 Jun 2014, Alexander Graf wrote:
On 03.06.14 01:34, BALATON Zoltan wrote:
Apart from the older NE2000 card also recognise RTL8139 and set bus master bit for it. This makes it work in MorphOS which uses it in a different (DMA) mode than the Linux driver.
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu
Please create a helper that tells you whether it's safe to enable bus mastering (why doesn't MorphOS do this itself?) on a particular harware
On why MorphOS does not do it: good question. I guess it expects that Open Firmware which supports booting from the network initialises the card so it does not have to do the PCI config itself. But I don't know just gussing. On QEMU it only works with this patch, otherwise DMA from the card fails.
Yeah, that makes it an OS specific quirk hack :). I'm ok with those, but we should make sure we have comments explaining what we're dealing with here. In a few years from now nobody will find these email threads anymore.
Alex