[haiku-commits] Change in haiku[master]: openfirmware: fix dma-alloc for sparc

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 15 Mar 2020 16:22:26 +0000

From Adrien Destugues <pulkomandy@xxxxxxxxx>:

Adrien Destugues has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2359 ;)


Change subject: openfirmware: fix dma-alloc for sparc
......................................................................

openfirmware: fix dma-alloc for sparc

The dma-alloc method is in the parent node (the PCI bus), not directly
in the network device.
---
M src/system/boot/platform/openfirmware/network.cpp
1 file changed, 24 insertions(+), 4 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/59/2359/1

diff --git a/src/system/boot/platform/openfirmware/network.cpp 
b/src/system/boot/platform/openfirmware/network.cpp
index 5b3d04d..271fcbf 100644
--- a/src/system/boot/platform/openfirmware/network.cpp
+++ b/src/system/boot/platform/openfirmware/network.cpp
@@ -205,12 +205,32 @@
 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;
 }



--
To view, visit https://review.haiku-os.org/c/haiku/+/2359
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I18f6a9333f3afa78033042e75a86b00872515f2c
Gerrit-Change-Number: 2359
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: openfirmware: fix dma-alloc for sparc - Gerrit