summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Liam2022-10-23 05:45:45 -0400
committerGravatar Liam2022-10-23 05:45:45 -0400
commit2d90a927c9f7652aa7e259ba57fa22ddbf8bed24 (patch)
tree031c7e8278dfea30bbbecd8a971ee4c2fc31feee
parentMerge pull request #9095 from FernandoS27/meat-good-vegetable-bad (diff)
downloadyuzu-2d90a927c9f7652aa7e259ba57fa22ddbf8bed24.tar.gz
yuzu-2d90a927c9f7652aa7e259ba57fa22ddbf8bed24.tar.xz
yuzu-2d90a927c9f7652aa7e259ba57fa22ddbf8bed24.zip
core: barrier service thread shutdown
-rw-r--r--src/core/core.cpp1
-rw-r--r--src/core/hle/kernel/kernel.cpp12
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp12
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h2
-rw-r--r--src/core/hle/service/service.cpp4
-rw-r--r--src/core/hle/service/service.h2
6 files changed, 26 insertions, 7 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 7fb8bc019..40a610435 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -384,6 +384,7 @@ struct System::Impl {
384 kernel.ShutdownCores(); 384 kernel.ShutdownCores();
385 cpu_manager.Shutdown(); 385 cpu_manager.Shutdown();
386 debugger.reset(); 386 debugger.reset();
387 services->KillNVNFlinger();
387 kernel.CloseServices(); 388 kernel.CloseServices();
388 services.reset(); 389 services.reset();
389 service_manager.reset(); 390 service_manager.reset();
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index eed2dc9f3..fdc774e30 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -48,8 +48,8 @@ namespace Kernel {
48 48
49struct KernelCore::Impl { 49struct KernelCore::Impl {
50 explicit Impl(Core::System& system_, KernelCore& kernel_) 50 explicit Impl(Core::System& system_, KernelCore& kernel_)
51 : time_manager{system_}, 51 : time_manager{system_}, service_threads_manager{1, "ServiceThreadsManager"},
52 service_threads_manager{1, "ServiceThreadsManager"}, system{system_} {} 52 service_thread_barrier{2}, system{system_} {}
53 53
54 void SetMulticore(bool is_multi) { 54 void SetMulticore(bool is_multi) {
55 is_multicore = is_multi; 55 is_multicore = is_multi;
@@ -737,7 +737,12 @@ struct KernelCore::Impl {
737 } 737 }
738 738
739 void ClearServiceThreads() { 739 void ClearServiceThreads() {
740 service_threads_manager.QueueWork([this]() { service_threads.clear(); }); 740 service_threads_manager.QueueWork([this] {
741 service_threads.clear();
742 default_service_thread.reset();
743 service_thread_barrier.Sync();
744 });
745 service_thread_barrier.Sync();
741 } 746 }
742 747
743 std::mutex server_objects_lock; 748 std::mutex server_objects_lock;
@@ -802,6 +807,7 @@ struct KernelCore::Impl {
802 std::unordered_set<std::shared_ptr<ServiceThread>> service_threads; 807 std::unordered_set<std::shared_ptr<ServiceThread>> service_threads;
803 std::weak_ptr<ServiceThread> default_service_thread; 808 std::weak_ptr<ServiceThread> default_service_thread;
804 Common::ThreadWorker service_threads_manager; 809 Common::ThreadWorker service_threads_manager;
810 Common::Barrier service_thread_barrier;
805 811
806 std::array<KThread*, Core::Hardware::NUM_CPU_CORES> shutdown_threads; 812 std::array<KThread*, Core::Hardware::NUM_CPU_CORES> shutdown_threads;
807 std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; 813 std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{};
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index aa14d2cbc..dad93b38e 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -102,15 +102,19 @@ NVFlinger::~NVFlinger() {
102 system.CoreTiming().UnscheduleEvent(single_composition_event, {}); 102 system.CoreTiming().UnscheduleEvent(single_composition_event, {});
103 } 103 }
104 104
105 ShutdownLayers();
106
107 if (nvdrv) {
108 nvdrv->Close(disp_fd);
109 }
110}
111
112void NVFlinger::ShutdownLayers() {
105 for (auto& display : displays) { 113 for (auto& display : displays) {
106 for (size_t layer = 0; layer < display.GetNumLayers(); ++layer) { 114 for (size_t layer = 0; layer < display.GetNumLayers(); ++layer) {
107 display.GetLayer(layer).Core().NotifyShutdown(); 115 display.GetLayer(layer).Core().NotifyShutdown();
108 } 116 }
109 } 117 }
110
111 if (nvdrv) {
112 nvdrv->Close(disp_fd);
113 }
114} 118}
115 119
116void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { 120void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index 99509bc5b..b8191c595 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -48,6 +48,8 @@ public:
48 explicit NVFlinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_); 48 explicit NVFlinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_);
49 ~NVFlinger(); 49 ~NVFlinger();
50 50
51 void ShutdownLayers();
52
51 /// Sets the NVDrv module instance to use to send buffers to the GPU. 53 /// Sets the NVDrv module instance to use to send buffers to the GPU.
52 void SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance); 54 void SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance);
53 55
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index dadaf897f..5db6588e4 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -303,4 +303,8 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
303 303
304Services::~Services() = default; 304Services::~Services() = default;
305 305
306void Services::KillNVNFlinger() {
307 nv_flinger->ShutdownLayers();
308}
309
306} // namespace Service 310} // namespace Service
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 5bf197c51..ec9deeee4 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -238,6 +238,8 @@ public:
238 explicit Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system); 238 explicit Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system);
239 ~Services(); 239 ~Services();
240 240
241 void KillNVNFlinger();
242
241private: 243private:
242 std::unique_ptr<NVFlinger::HosBinderDriverServer> hos_binder_driver_server; 244 std::unique_ptr<NVFlinger::HosBinderDriverServer> hos_binder_driver_server;
243 std::unique_ptr<NVFlinger::NVFlinger> nv_flinger; 245 std::unique_ptr<NVFlinger::NVFlinger> nv_flinger;