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

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: 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..a7ac8cb5f81308250a664723a26529ba3a22ec10 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,27 @@
namespace ui {
+namespace {
+
+void PrimeSyncStart(int dmabuf_fd) {
+ struct dma_buf_sync sync_start;
+
+ memset(&sync_start, 0, sizeof(sync_start));
dshwang 2016/03/29 13:23:40 we can change it to c++ style. struct dma_buf_sync
vignatti (out of this project) 2016/03/29 21:08:30 Done.
+ 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;
+}
+
+void PrimeSyncEnd(int dmabuf_fd) {
+ struct dma_buf_sync sync_end;
+
+ memset(&sync_end, 0, sizeof(sync_end));
+ 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;
+}
+}
+
// static
scoped_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf(
int dmabuf_fd,
@@ -26,7 +49,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 +59,23 @@ ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd,
ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() {
TRACE_EVENT0("drm", "~ClientNativePixmapDmaBuf");
+ close(dmabuf_fd_);
+
size_t size = stride_ * size_.height();
int ret = munmap(data_, size);
DCHECK(!ret);
}
void* ClientNativePixmapDmaBuf::Map() {
+ TRACE_EVENT0("nativepixmap", "DmaBuf:Map");
+ PrimeSyncStart(dmabuf_fd_);
return data_;
}
-void ClientNativePixmapDmaBuf::Unmap() {}
+void ClientNativePixmapDmaBuf::Unmap() {
+ TRACE_EVENT0("nativepixmap", "DmaBuf:Unmap");
+ PrimeSyncEnd(dmabuf_fd_);
+}
void ClientNativePixmapDmaBuf::GetStride(int* stride) const {
*stride = stride_;

Powered by Google App Engine
This is Rietveld 408576698