From edfce7b32702f506cc35552ce257855a73f9aa54 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Sun, 15 Mar 2020 17:11:57 +0100 Subject: [PATCH] openfirmware: fix dma-alloc for sparc The dma-alloc method is in the parent node (the PCI bus), not directly in the network device. Change-Id: I18f6a9333f3afa78033042e75a86b00872515f2c Reviewed-on: https://review.haiku-os.org/c/haiku/+/2359 Reviewed-by: waddlesplash --- .../boot/platform/openfirmware/network.cpp | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/system/boot/platform/openfirmware/network.cpp b/src/system/boot/platform/openfirmware/network.cpp index 5b3d04de65..271fcbfaf5 100644 --- a/src/system/boot/platform/openfirmware/network.cpp +++ b/src/system/boot/platform/openfirmware/network.cpp @@ -205,12 +205,32 @@ OFEthernetInterface::MACAddress() const void * OFEthernetInterface::AllocateSendReceiveBuffer(size_t size) { - void *dmaMemory; + void *dmaMemory = NULL; + if (of_call_method(fHandle, "dma-alloc", 1, 1, size, &dmaMemory) - == OF_FAILED) { - return NULL; + != OF_FAILED) { + return dmaMemory; } - return dmaMemory; + + // The dma-alloc method could be on the parent node (PCI bus, for example), + // rather than the device itself + intptr_t parentPackage = of_parent(of_instance_to_package(fHandle)); + + // FIXME surely there's a way to create an instance without going through + // the path? + char path[256]; + of_package_to_path(parentPackage, path, sizeof(path)); + intptr_t parentInstance = of_open(path); + + if (of_call_method(parentInstance, "dma-alloc", 1, 1, size, &dmaMemory) + != OF_FAILED) { + of_close(parentInstance); + return dmaMemory; + } + + of_close(parentInstance); + + return NULL; }