Skip to content

Commit

Permalink
kernel-explorer: Implement SPU ports/interrupt tags information
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed May 14, 2021
1 parent 6dca588 commit 12487cb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
6 changes: 1 addition & 5 deletions rpcs3/Emu/Cell/SPUThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,7 @@ class spu_thread : public cpu_thread
std::weak_ptr<lv2_event_queue> spup[64]; // SPU Ports
spu_channel exit_status{}; // Threaded SPU exit status (not a channel, but the interface fits)
atomic_t<u32> last_exit_status; // Value to be written in exit_status after checking group termination

private:
lv2_spu_group* const group; // SPU Thread Group (only safe to access in the spu thread itself)
public:

lv2_spu_group* const group; // SPU Thread Group (access by the spu threads in the group only! From other threads obtain a shared pointer to group using group ID)
const u32 index; // SPU index
std::shared_ptr<utils::shm> shm; // SPU memory
const std::add_pointer_t<u8> ls; // SPU LS pointer
Expand Down
56 changes: 54 additions & 2 deletions rpcs3/rpcs3qt/kernel_explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void kernel_explorer::Update()

if (mem.pshared)
{
add_leaf(node, qstr(fmt::format("Shared Mem 0x%08x: Size: 0x%x (%0.2f MB), Granularity: %s, Mappings: %u Key: %#llx", id, mem.size, size_mb, mem.align == 0x10000u ? "64K" : "1MB", +mem.counter, mem.key)));
add_leaf(node, qstr(fmt::format("Shared Mem 0x%08x: Size: 0x%x (%0.2f MB), Granularity: %s, Mappings: %u, Key: %#llx", id, mem.size, size_mb, mem.align == 0x10000u ? "64K" : "1MB", +mem.counter, mem.key)));
break;
}

Expand Down Expand Up @@ -541,7 +541,59 @@ void kernel_explorer::Update()

idm::select<named_thread<spu_thread>>([&](u32 /*id*/, spu_thread& spu)
{
add_leaf(find_node(m_tree, additional_nodes::spu_threads), qstr(fmt::format(u8"SPU 0x%07x: “%s”, State: %s, Type: %s", spu.lv2_id, *spu.spu_tname.load(), spu.state.load(), spu.get_type())));
QTreeWidgetItem* spu_thread_tree = add_solid_node(m_tree, find_node(m_tree, additional_nodes::spu_threads), qstr(fmt::format(u8"SPU 0x%07x: “%s”, State: %s, Type: %s", spu.lv2_id, *spu.spu_tname.load(), spu.state.load(), spu.get_type())));

if (spu.get_type() == spu_type::threaded)
{
reader_lock lock(spu.group->mutex);

bool has_non_expired_port = false;
const auto first_spu = spu.group->threads[0].get();

// Always show information of the first thread in group
// Or if information differs from that thread
if (&spu == first_spu || std::any_of(std::begin(spu.spup), std::end(spu.spup), [&](const auto& port)
{
// Flag to avoid reporting information if no SPU ports are attached (inaccurate, lv2_event_queue::check is accurate but more expensive)
has_non_expired_port |= !port.expired();

// Check if ports do not match with the first thread
const auto& test = first_spu->spup[&port - spu.spup];
return port.owner_before(test) || test.owner_before(port);
}))
{
for (const auto& port : spu.spup)
{
if (const auto q = port.lock(); lv2_event_queue::check(q))
{
add_leaf(spu_thread_tree, qstr(fmt::format("SPU Port %u: Queue ID: 0x%08x", &port - spu.spup, q->id)));
}
}
}
else if (has_non_expired_port)
{
// Avoid duplication of information between threads which is common
add_leaf(spu_thread_tree, qstr(fmt::format("SPU Ports: As SPU 0x%07x", first_spu->lv2_id)));
}

for (const auto& pair : spu.spuq)
{
if (const auto q = pair.second.lock(); lv2_event_queue::check(q))
{
add_leaf(spu_thread_tree, qstr(fmt::format("SPU Queue: Queue ID: 0x%08x, Key: 0x%x", q->id, pair.first)));
}
}
}
else
{
for (const auto& ctrl : spu.int_ctrl)
{
if (const auto tag = ctrl.tag.lock())
{
add_leaf(spu_thread_tree, qstr(fmt::format("Interrupt Tag %u: ID: 0x%x, Mask: 0x%x, Status: 0x%x", &ctrl - spu.int_ctrl.data(), tag->id, +ctrl.mask, +ctrl.stat)));
}
}
}
});

idm::select<lv2_spu_group>([&](u32 id, lv2_spu_group& tg)
Expand Down

0 comments on commit 12487cb

Please sign in to comment.