35 #include <linux/export.h>
51 *buf = kzalloc(
sizeof(
struct drm_buffer) + nr_pages*
sizeof(
char *),
55 DRM_ERROR(
"Failed to allocate drm buffer object to hold"
56 " %d bytes in %d pages.\n",
63 for (idx = 0; idx < nr_pages; ++
idx) {
70 if ((*buf)->data[idx] ==
NULL) {
71 DRM_ERROR(
"Failed to allocate %dth page for drm"
72 " buffer with %d bytes and %d pages.\n",
73 idx + 1, size, nr_pages);
84 if ((*buf)->data[idx])
85 kfree((*buf)->data[idx]);
87 for (--idx; idx >= 0; --
idx)
88 kfree((*buf)->data[idx]);
108 if (size > buf->
size) {
109 DRM_ERROR(
"Requesting to copy %d bytes to a drm buffer with"
115 for (idx = 0; idx < nr_pages; ++
idx) {
119 min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
120 DRM_ERROR(
"Failed to copy user data (%p) to drm buffer"
121 " (%p) %dth page.\n",
122 user_data, buf, idx);
142 for (idx = 0; idx < nr_pages; ++
idx)
163 int objsize,
void *stack_obj)
165 int idx = drm_buffer_index(buf);
166 int page = drm_buffer_page(buf);
174 memcpy(stack_obj, &buf->
data[page][idx], beginsz);
176 memcpy(stack_obj + beginsz, &buf->
data[page + 1][0],
182 drm_buffer_advance(buf, objsize);