Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc

Issue 1841683003: ui/ozone: Flush CPU caches when mapping/unmapping prime pixmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use base::ScopedFD Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
index 26d123a2a452209637a928aa78f7b07d1d1dd3a9..cb1561e99c5e92d64848926ae8966f9f54c63ea0 100644
--- a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
+++ b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
@@ -4,7 +4,9 @@
#include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h"
+#include <errno.h>
#include <fcntl.h>
+#include <linux/dma-buf.h>
#include <stddef.h>
#include <sys/mman.h>
#include <xf86drm.h>
@@ -14,6 +16,25 @@
namespace ui {
+namespace {
+
+void PrimeSyncStart(int dmabuf_fd) {
+ struct dma_buf_sync sync_start = {0};
+
+ sync_start.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ;
+ if (drmIoctl(dmabuf_fd, DMA_BUF_IOCTL_SYNC, &sync_start))
+ LOG(ERROR) << "fail to sync start dma buf fd, errno: " << errno;
spang 2016/03/30 00:19:00 PLOG(ERROR)
vignatti (out of this project) 2016/03/30 20:04:23 Done.
+}
+
+void PrimeSyncEnd(int dmabuf_fd) {
+ struct dma_buf_sync sync_end = {0};
+
+ sync_end.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE;
+ if (drmIoctl(dmabuf_fd, DMA_BUF_IOCTL_SYNC, &sync_end))
+ LOG(ERROR) << "fail to sync end dma buf fd, errno " << errno;
spang 2016/03/30 00:19:00 PLOG(ERROR)
vignatti (out of this project) 2016/03/30 20:04:23 Done.
+}
+}
spang 2016/03/30 00:19:00 Add a newline between the braces and say } // na
vignatti (out of this project) 2016/03/30 20:04:23 Done.
+
// static
scoped_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf(
int dmabuf_fd,
@@ -26,7 +47,7 @@ scoped_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf(
ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd,
const gfx::Size& size,
int stride)
- : size_(size), stride_(stride) {
+ : dmabuf_fd_(dmabuf_fd), size_(size), stride_(stride) {
TRACE_EVENT0("drm", "ClientNativePixmapDmaBuf");
size_t map_size = stride_ * size_.height();
data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED,
@@ -36,16 +57,22 @@ ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd,
ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() {
TRACE_EVENT0("drm", "~ClientNativePixmapDmaBuf");
+
size_t size = stride_ * size_.height();
int ret = munmap(data_, size);
DCHECK(!ret);
}
void* ClientNativePixmapDmaBuf::Map() {
+ TRACE_EVENT0("nativepixmap", "DmaBuf:Map");
spang 2016/03/30 00:19:00 Please, use "drm". This doesn't warrant its own tr
vignatti (out of this project) 2016/03/30 20:04:23 Done.
+ PrimeSyncStart(dmabuf_fd_.get());
return data_;
}
-void ClientNativePixmapDmaBuf::Unmap() {}
+void ClientNativePixmapDmaBuf::Unmap() {
+ TRACE_EVENT0("nativepixmap", "DmaBuf:Unmap");
+ PrimeSyncEnd(dmabuf_fd_.get());
+}
void ClientNativePixmapDmaBuf::GetStride(int* stride) const {
*stride = stride_;

Powered by Google App Engine
This is Rietveld 408576698