Matt Sinclair has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/42423 )

Change subject: dev-hsa: Fix size of HSA Queue
......................................................................

dev-hsa: Fix size of HSA Queue

In the HSAQueueDescriptor ptr function, we mod the index by numElts, but
numElts was previously just set to size, which was the raw size of the
queue. This lead to indexing past the queue. We fix this by dividing by
the size by the AQL packet size to get the actual number of elements the
queue can hold.

We also add an assert for indexing into the queue, as there is a
scenario where the queue reports a larger size than it actually is.

Change-Id: Ie5e699379f303255305c279e58a34dc783df86a0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/42423
Reviewed-by: Matt Sinclair <[email protected]>
Reviewed-by: Matthew Poremba <[email protected]>
Maintainer: Matt Sinclair <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/dev/hsa/hsa_packet_processor.hh
1 file changed, 8 insertions(+), 1 deletion(-)

Approvals:
  Matthew Poremba: Looks good to me, approved
Matt Sinclair: Looks good to me, but someone else must approve; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/dev/hsa/hsa_packet_processor.hh b/src/dev/hsa/hsa_packet_processor.hh
index babf702..93adf57 100644
--- a/src/dev/hsa/hsa_packet_processor.hh
+++ b/src/dev/hsa/hsa_packet_processor.hh
@@ -85,7 +85,7 @@
                            uint64_t hri_ptr, uint32_t size)
           : basePointer(base_ptr), doorbellPointer(db_ptr),
             writeIndex(0), readIndex(0),
-            numElts(size), hostReadIndexPtr(hri_ptr),
+            numElts(size / AQL_PACKET_SIZE), hostReadIndexPtr(hri_ptr),
             stalledOnDmaBufAvailability(false),
             dmaInProgress(false)
         {  }
@@ -98,6 +98,13 @@

         uint64_t ptr(uint64_t ix)
         {
+            /**
+             * Sometimes queues report that their size is 512k, which would
+             * indicate numElts of 0x2000. However, they only have 256k
+             * mapped which means any index over 0x1000 will fail an
+             * address translation.
+             */
+            assert(ix % numElts < 0x1000);
             return basePointer +
                 ((ix % numElts) * objSize());
         }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42423
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie5e699379f303255305c279e58a34dc783df86a0
Gerrit-Change-Number: 42423
Gerrit-PatchSet: 3
Gerrit-Owner: Kyle Roarty <[email protected]>
Gerrit-Reviewer: Alex Dutu <[email protected]>
Gerrit-Reviewer: Matt Sinclair <[email protected]>
Gerrit-Reviewer: Matthew Poremba <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to