Skip to content

Commit ecba1d2

Browse files
committed
sys_fs: Remove PPU sleep hacks
1 parent fcff16b commit ecba1d2

File tree

1 file changed

+14
-28
lines changed

1 file changed

+14
-28
lines changed

rpcs3/Emu/Cell/lv2/sys_fs.cpp

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,6 @@ lv2_file::open_result_t lv2_file::open(std::string_view vpath, s32 flags, s32 mo
10361036
error_code sys_fs_open(ppu_thread& ppu, vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, s32 mode, vm::cptr<void> arg, u64 size)
10371037
{
10381038
ppu.state += cpu_flag::wait;
1039-
lv2_obj::sleep(ppu);
10401039

10411040
sys_fs.warning("sys_fs_open(path=%s, flags=%#o, fd=*0x%x, mode=%#o, arg=*0x%x, size=0x%llx)", path, flags, fd, mode, arg, size);
10421041

@@ -1085,7 +1084,6 @@ error_code sys_fs_open(ppu_thread& ppu, vm::cptr<char> path, s32 flags, vm::ptr<
10851084
error_code sys_fs_read(ppu_thread& ppu, u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread)
10861085
{
10871086
ppu.state += cpu_flag::wait;
1088-
lv2_obj::sleep(ppu);
10891087

10901088
sys_fs.trace("sys_fs_read(fd=%d, buf=*0x%x, nbytes=0x%llx, nread=*0x%x)", fd, buf, nbytes, nread);
10911089

@@ -1122,6 +1120,11 @@ error_code sys_fs_read(ppu_thread& ppu, u32 fd, vm::ptr<void> buf, u64 nbytes, v
11221120
return CELL_OK;
11231121
}
11241122

1123+
if (nbytes >= 0x100000 && file->type != lv2_file_type::regular)
1124+
{
1125+
lv2_obj::sleep(ppu);
1126+
}
1127+
11251128
std::unique_lock lock(file->mp->mutex);
11261129

11271130
if (!file->file)
@@ -1154,7 +1157,6 @@ error_code sys_fs_read(ppu_thread& ppu, u32 fd, vm::ptr<void> buf, u64 nbytes, v
11541157
error_code sys_fs_write(ppu_thread& ppu, u32 fd, vm::cptr<void> buf, u64 nbytes, vm::ptr<u64> nwrite)
11551158
{
11561159
ppu.state += cpu_flag::wait;
1157-
lv2_obj::sleep(ppu);
11581160

11591161
sys_fs.trace("sys_fs_write(fd=%d, buf=*0x%x, nbytes=0x%llx, nwrite=*0x%x)", fd, buf, nbytes, nwrite);
11601162

@@ -1237,7 +1239,6 @@ error_code sys_fs_write(ppu_thread& ppu, u32 fd, vm::cptr<void> buf, u64 nbytes,
12371239
error_code sys_fs_close(ppu_thread& ppu, u32 fd)
12381240
{
12391241
ppu.state += cpu_flag::wait;
1240-
lv2_obj::sleep(ppu);
12411242

12421243
const auto file = idm::get_unlocked<lv2_fs_object, lv2_file>(fd);
12431244

@@ -1314,7 +1315,6 @@ error_code sys_fs_close(ppu_thread& ppu, u32 fd)
13141315
error_code sys_fs_opendir(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<u32> fd)
13151316
{
13161317
ppu.state += cpu_flag::wait;
1317-
lv2_obj::sleep(ppu);
13181318

13191319
sys_fs.warning("sys_fs_opendir(path=%s, fd=*0x%x)", path, fd);
13201320

@@ -1491,7 +1491,6 @@ error_code sys_fs_readdir(ppu_thread& ppu, u32 fd, vm::ptr<CellFsDirent> dir, vm
14911491
error_code sys_fs_closedir(ppu_thread& ppu, u32 fd)
14921492
{
14931493
ppu.state += cpu_flag::wait;
1494-
lv2_obj::sleep(ppu);
14951494

14961495
sys_fs.warning("sys_fs_closedir(fd=%d)", fd);
14971496

@@ -1506,7 +1505,6 @@ error_code sys_fs_closedir(ppu_thread& ppu, u32 fd)
15061505
error_code sys_fs_stat(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<CellFsStat> sb)
15071506
{
15081507
ppu.state += cpu_flag::wait;
1509-
lv2_obj::sleep(ppu);
15101508

15111509
sys_fs.warning("sys_fs_stat(path=%s, sb=*0x%x)", path, sb);
15121510

@@ -1610,7 +1608,6 @@ error_code sys_fs_stat(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<CellFsStat>
16101608
error_code sys_fs_fstat(ppu_thread& ppu, u32 fd, vm::ptr<CellFsStat> sb)
16111609
{
16121610
ppu.state += cpu_flag::wait;
1613-
lv2_obj::sleep(ppu);
16141611

16151612
sys_fs.warning("sys_fs_fstat(fd=%d, sb=*0x%x)", fd, sb);
16161613

@@ -1666,7 +1663,6 @@ error_code sys_fs_link(ppu_thread&, vm::cptr<char> from, vm::cptr<char> to)
16661663
error_code sys_fs_mkdir(ppu_thread& ppu, vm::cptr<char> path, s32 mode)
16671664
{
16681665
ppu.state += cpu_flag::wait;
1669-
lv2_obj::sleep(ppu);
16701666

16711667
sys_fs.warning("sys_fs_mkdir(path=%s, mode=%#o)", path, mode);
16721668

@@ -1728,7 +1724,6 @@ error_code sys_fs_mkdir(ppu_thread& ppu, vm::cptr<char> path, s32 mode)
17281724
error_code sys_fs_rename(ppu_thread& ppu, vm::cptr<char> from, vm::cptr<char> to)
17291725
{
17301726
ppu.state += cpu_flag::wait;
1731-
lv2_obj::sleep(ppu);
17321727

17331728
sys_fs.warning("sys_fs_rename(from=%s, to=%s)", from, to);
17341729

@@ -1794,7 +1789,6 @@ error_code sys_fs_rename(ppu_thread& ppu, vm::cptr<char> from, vm::cptr<char> to
17941789
error_code sys_fs_rmdir(ppu_thread& ppu, vm::cptr<char> path)
17951790
{
17961791
ppu.state += cpu_flag::wait;
1797-
lv2_obj::sleep(ppu);
17981792

17991793
sys_fs.warning("sys_fs_rmdir(path=%s)", path);
18001794

@@ -1850,7 +1844,6 @@ error_code sys_fs_rmdir(ppu_thread& ppu, vm::cptr<char> path)
18501844
error_code sys_fs_unlink(ppu_thread& ppu, vm::cptr<char> path)
18511845
{
18521846
ppu.state += cpu_flag::wait;
1853-
lv2_obj::sleep(ppu);
18541847

18551848
sys_fs.warning("sys_fs_unlink(path=%s)", path);
18561849

@@ -1951,8 +1944,6 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
19511944
case 0x8000000a: // cellFsReadWithOffset
19521945
case 0x8000000b: // cellFsWriteWithOffset
19531946
{
1954-
lv2_obj::sleep(ppu);
1955-
19561947
const auto arg = vm::static_ptr_cast<lv2_file_op_rw>(_arg);
19571948

19581949
if (_size < arg.size())
@@ -1992,6 +1983,11 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
19921983
sys_fs.error("%s type: Writing %u bytes to FD=%d (path=%s)", file->type, arg->size, file->name.data());
19931984
}
19941985

1986+
if (op == 0x8000000a && file->type != lv2_file_type::regular && arg->size >= 0x100000)
1987+
{
1988+
lv2_obj::sleep(ppu);
1989+
}
1990+
19951991
std::unique_lock wlock(file->mp->mutex, std::defer_lock);
19961992
std::shared_lock rlock(file->mp->mutex, std::defer_lock);
19971993

@@ -2047,8 +2043,6 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
20472043

20482044
case 0x80000009: // cellFsSdataOpenByFd
20492045
{
2050-
lv2_obj::sleep(ppu);
2051-
20522046
const auto arg = vm::static_ptr_cast<lv2_file_op_09>(_arg);
20532047

20542048
if (_size < arg.size())
@@ -2102,8 +2096,6 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
21022096

21032097
case 0xc0000002: // cellFsGetFreeSize (TODO)
21042098
{
2105-
lv2_obj::sleep(ppu);
2106-
21072099
const auto arg = vm::static_ptr_cast<lv2_file_c0000002>(_arg);
21082100

21092101
const auto& mp = g_fxo->get<lv2_fs_mount_info_map>().lookup("/dev_hdd0");
@@ -2418,8 +2410,6 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
24182410

24192411
case 0xe0000012: // cellFsGetDirectoryEntries
24202412
{
2421-
lv2_obj::sleep(ppu);
2422-
24232413
const auto arg = vm::static_ptr_cast<lv2_file_op_dir::dir_info>(_arg);
24242414

24252415
if (_size < arg.size())
@@ -2434,8 +2424,6 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
24342424
return CELL_EBADF;
24352425
}
24362426

2437-
ppu.check_state();
2438-
24392427
u32 read_count = 0;
24402428

24412429
// NOTE: This function is actually capable of reading only one entry at a time
@@ -2593,7 +2581,6 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
25932581
error_code sys_fs_lseek(ppu_thread& ppu, u32 fd, s64 offset, s32 whence, vm::ptr<u64> pos)
25942582
{
25952583
ppu.state += cpu_flag::wait;
2596-
lv2_obj::sleep(ppu);
25972584

25982585
sys_fs.trace("sys_fs_lseek(fd=%d, offset=0x%llx, whence=0x%x, pos=*0x%x)", fd, offset, whence, pos);
25992586

@@ -2639,7 +2626,6 @@ error_code sys_fs_lseek(ppu_thread& ppu, u32 fd, s64 offset, s32 whence, vm::ptr
26392626
error_code sys_fs_fdatasync(ppu_thread& ppu, u32 fd)
26402627
{
26412628
ppu.state += cpu_flag::wait;
2642-
lv2_obj::sleep(ppu);
26432629

26442630
sys_fs.trace("sys_fs_fdadasync(fd=%d)", fd);
26452631

@@ -2650,6 +2636,8 @@ error_code sys_fs_fdatasync(ppu_thread& ppu, u32 fd)
26502636
return CELL_EBADF;
26512637
}
26522638

2639+
lv2_obj::sleep(ppu);
2640+
26532641
std::lock_guard lock(file->mp->mutex);
26542642

26552643
if (!file->file)
@@ -2664,7 +2652,6 @@ error_code sys_fs_fdatasync(ppu_thread& ppu, u32 fd)
26642652
error_code sys_fs_fsync(ppu_thread& ppu, u32 fd)
26652653
{
26662654
ppu.state += cpu_flag::wait;
2667-
lv2_obj::sleep(ppu);
26682655

26692656
sys_fs.trace("sys_fs_fsync(fd=%d)", fd);
26702657

@@ -2675,6 +2662,8 @@ error_code sys_fs_fsync(ppu_thread& ppu, u32 fd)
26752662
return CELL_EBADF;
26762663
}
26772664

2665+
lv2_obj::sleep(ppu);
2666+
26782667
std::lock_guard lock(file->mp->mutex);
26792668

26802669
if (!file->file)
@@ -2763,7 +2752,6 @@ error_code sys_fs_get_block_size(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<u
27632752
error_code sys_fs_truncate(ppu_thread& ppu, vm::cptr<char> path, u64 size)
27642753
{
27652754
ppu.state += cpu_flag::wait;
2766-
lv2_obj::sleep(ppu);
27672755

27682756
sys_fs.warning("sys_fs_truncate(path=%s, size=0x%llx)", path, size);
27692757

@@ -2815,7 +2803,6 @@ error_code sys_fs_truncate(ppu_thread& ppu, vm::cptr<char> path, u64 size)
28152803
error_code sys_fs_ftruncate(ppu_thread& ppu, u32 fd, u64 size)
28162804
{
28172805
ppu.state += cpu_flag::wait;
2818-
lv2_obj::sleep(ppu);
28192806

28202807
sys_fs.warning("sys_fs_ftruncate(fd=%d, size=0x%llx)", fd, size);
28212808

@@ -3021,7 +3008,6 @@ error_code sys_fs_disk_free(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<u64> t
30213008
error_code sys_fs_utime(ppu_thread& ppu, vm::cptr<char> path, vm::cptr<CellFsUtimbuf> timep)
30223009
{
30233010
ppu.state += cpu_flag::wait;
3024-
lv2_obj::sleep(ppu);
30253011

30263012
sys_fs.warning("sys_fs_utime(path=%s, timep=*0x%x)", path, timep);
30273013
sys_fs.warning("** actime=%u, modtime=%u", timep->actime, timep->modtime);

0 commit comments

Comments
 (0)