mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 16:31:28 +12:00
SPU: Use waitable atomics for SPU channels interface
This commit is contained in:
parent
3157a10428
commit
a029a94c73
6 changed files with 123 additions and 64 deletions
|
@ -1247,11 +1247,11 @@ void spu_thread::push_snr(u32 number, u32 value)
|
|||
// Check corresponding SNR register settings
|
||||
if ((snr_config >> number) & 1)
|
||||
{
|
||||
channel->push_or(*this, value);
|
||||
channel->push_or(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel->push(*this, value);
|
||||
channel->push(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2448,19 +2448,8 @@ s64 spu_thread::get_ch_value(u32 ch)
|
|||
busy_wait();
|
||||
}
|
||||
|
||||
u32 out = 0;
|
||||
|
||||
while (!channel.try_pop(out))
|
||||
{
|
||||
if (is_stopped())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
thread_ctrl::wait();
|
||||
}
|
||||
|
||||
check_state();
|
||||
const s64 out = channel.pop_wait(*this);
|
||||
static_cast<void>(test_stopped());
|
||||
return out;
|
||||
};
|
||||
|
||||
|
@ -2508,9 +2497,8 @@ s64 spu_thread::get_ch_value(u32 ch)
|
|||
|
||||
case MFC_RdTagStat:
|
||||
{
|
||||
if (ch_tag_stat.get_count())
|
||||
if (u32 out; ch_tag_stat.try_read(out))
|
||||
{
|
||||
u32 out = ch_tag_stat.get_value();
|
||||
ch_tag_stat.set_value(0, false);
|
||||
return out;
|
||||
}
|
||||
|
@ -2536,9 +2524,8 @@ s64 spu_thread::get_ch_value(u32 ch)
|
|||
|
||||
case MFC_RdAtomicStat:
|
||||
{
|
||||
if (ch_atomic_stat.get_count())
|
||||
if (u32 out; ch_atomic_stat.try_read(out))
|
||||
{
|
||||
u32 out = ch_atomic_stat.get_value();
|
||||
ch_atomic_stat.set_value(0, false);
|
||||
return out;
|
||||
}
|
||||
|
@ -2549,9 +2536,8 @@ s64 spu_thread::get_ch_value(u32 ch)
|
|||
|
||||
case MFC_RdListStallStat:
|
||||
{
|
||||
if (ch_stall_stat.get_count())
|
||||
if (u32 out; ch_stall_stat.try_read(out))
|
||||
{
|
||||
u32 out = ch_stall_stat.get_value();
|
||||
ch_stall_stat.set_value(0, false);
|
||||
return out;
|
||||
}
|
||||
|
@ -2658,16 +2644,14 @@ bool spu_thread::set_ch_value(u32 ch, u32 value)
|
|||
{
|
||||
if (get_type() >= spu_type::raw)
|
||||
{
|
||||
while (!ch_out_intr_mbox.try_push(value))
|
||||
if (ch_out_intr_mbox.get_count())
|
||||
{
|
||||
state += cpu_flag::wait;
|
||||
}
|
||||
|
||||
if (is_stopped())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
thread_ctrl::wait();
|
||||
if (!ch_out_intr_mbox.push_wait(*this, value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int_ctrl[2].set(SPU_INT2_STAT_MAILBOX_INT);
|
||||
|
@ -2798,16 +2782,14 @@ bool spu_thread::set_ch_value(u32 ch, u32 value)
|
|||
|
||||
case SPU_WrOutMbox:
|
||||
{
|
||||
while (!ch_out_mbox.try_push(value))
|
||||
if (ch_out_mbox.get_count())
|
||||
{
|
||||
state += cpu_flag::wait;
|
||||
}
|
||||
|
||||
if (is_stopped())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
thread_ctrl::wait();
|
||||
if (!ch_out_mbox.push_wait(*this, value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
check_state();
|
||||
|
@ -3196,7 +3178,7 @@ bool spu_thread::stop_and_signal(u32 code)
|
|||
|
||||
if (thread.get() != this)
|
||||
{
|
||||
thread_ctrl::notify(*thread);
|
||||
thread_ctrl::raw_notify(*thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3325,7 +3307,7 @@ bool spu_thread::stop_and_signal(u32 code)
|
|||
if (thread && thread.get() != this)
|
||||
{
|
||||
thread->state += cpu_flag::stop;
|
||||
thread_ctrl::notify(*thread);
|
||||
thread_ctrl::raw_notify(*thread);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue