summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/gpu/drm_device.cc
diff options
context:
space:
mode:
authordnicoara <dnicoara@chromium.org>2015-04-02 22:23:27 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-03 05:24:50 +0000
commit603aab92420707a94db0646c21c2d8e8d992ab8f (patch)
tree50eea786d48911764f49c08e362b46458f13c789 /ui/ozone/platform/drm/gpu/drm_device.cc
parent06b3b7f7592246390d5cdc27a0412d9cca6f6292 (diff)
downloadchromium_src-603aab92420707a94db0646c21c2d8e8d992ab8f.zip
chromium_src-603aab92420707a94db0646c21c2d8e8d992ab8f.tar.gz
chromium_src-603aab92420707a94db0646c21c2d8e8d992ab8f.tar.bz2
[Ozone-Drm] Block initialization of DrmDevices on taking DRM master
During GPU process restarts (possibly caused by GPU crashes) it is possible to have the new GPU process trying to take DRM master before the old one has released all DRM resources. The file lock isn't sufficient since the kernel may release opened files in a different order than what we'd like. BUG=461396 TEST=Ran Chrome on Link without drm_master_relax enabled and verified that 1) it stats up normally 2) if another process is authenticated Chrome waits for it to release master Review URL: https://codereview.chromium.org/1053803002 Cr-Commit-Position: refs/heads/master@{#323622}
Diffstat (limited to 'ui/ozone/platform/drm/gpu/drm_device.cc')
-rw-r--r--ui/ozone/platform/drm/gpu/drm_device.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/ozone/platform/drm/gpu/drm_device.cc b/ui/ozone/platform/drm/gpu/drm_device.cc
index fe95a62..fb5bbc8 100644
--- a/ui/ozone/platform/drm/gpu/drm_device.cc
+++ b/ui/ozone/platform/drm/gpu/drm_device.cc
@@ -100,6 +100,14 @@ bool CanQueryForResources(int fd) {
return !drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &resources);
}
+bool Authenticate(int fd) {
+ drm_magic_t magic;
+ memset(&magic, 0, sizeof(magic));
+ // We need to make sure the DRM device has enough privilege. Use the DRM
+ // authentication logic to figure out if the device has enough permissions.
+ return !drmGetMagic(fd, &magic) && !drmAuthMagic(fd, magic);
+}
+
} // namespace
class DrmDevice::IOWatcher
@@ -204,6 +212,26 @@ bool DrmDevice::Initialize() {
return false;
}
+ bool print_warning = true;
+ // TODO(dnicoara) Ugly hack to block until getting master. This is needed
+ // since DRM devices from an old GPU process may be getting deallocated while
+ // the new GPU process tries to take them.
+ // Move ownership of devices in the Browser process and just have the GPU
+ // processes authenticate.
+ while (!Authenticate(file_.GetPlatformFile())) {
+ PLOG_IF(WARNING, print_warning) << "Failed to take master on "
+ << device_path_.value();
+ print_warning = false;
+
+ usleep(100000);
+ file_ =
+ base::File(device_path_, base::File::FLAG_OPEN | base::File::FLAG_READ |
+ base::File::FLAG_WRITE);
+ LOG_IF(FATAL, !file_.IsValid())
+ << "Failed to open '" << device_path_.value()
+ << "': " << base::File::ErrorToString(file_.error_details());
+ }
+
#if defined(USE_DRM_ATOMIC)
plane_manager_.reset(new HardwareDisplayPlaneManagerAtomic());
#else