[vbox-dev] [PATCH 2/3] additions/linux/drm: Remove unnecessary wrapping of guest_pool in a struct
Hans de Goede
hdegoede at redhat.com
Wed May 17 14:59:42 UTC 2017
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
src/VBox/Additions/linux/drm/HGSMIBuffers.h | 10 ++++------
src/VBox/Additions/linux/drm/vbox_drv.h | 2 +-
src/VBox/Additions/linux/drm/vbox_irq.c | 4 ++--
src/VBox/Additions/linux/drm/vbox_main.c | 26 +++++++++++++-------------
src/VBox/Additions/linux/drm/vbox_mode.c | 24 ++++++++++++------------
5 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/src/VBox/Additions/linux/drm/HGSMIBuffers.h b/src/VBox/Additions/linux/drm/HGSMIBuffers.h
index 3c295488..2852477f 100644
--- a/src/VBox/Additions/linux/drm/HGSMIBuffers.h
+++ b/src/VBox/Additions/linux/drm/HGSMIBuffers.h
@@ -33,9 +33,7 @@
#include <HGSMIDefs.h>
#include <linux/genalloc.h>
-typedef struct HGSMIGUESTCOMMANDCONTEXT {
- struct gen_pool *guest_pool;
-} HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
+typedef struct gen_pool *PHGSMIGUESTCOMMANDCONTEXT;
void *hgsmi_buffer_alloc(struct gen_pool *guest_pool, size_t size,
u8 channel, u16 channel_info);
@@ -47,8 +45,8 @@ int hgsmi_buffer_submit(struct gen_pool *guest_pool, void *buf);
* kernel style names.
*/
#define VBoxHGSMIBufferAlloc(ctx, size, ch, ch_info) \
- hgsmi_buffer_alloc((ctx)->guest_pool, size, ch, ch_info)
-#define VBoxHGSMIBufferFree(ctx, buf) hgsmi_buffer_free((ctx)->guest_pool, buf)
-#define VBoxHGSMIBufferSubmit(ctx, buf) hgsmi_buffer_submit((ctx)->guest_pool, buf)
+ hgsmi_buffer_alloc(ctx, size, ch, ch_info)
+#define VBoxHGSMIBufferFree(ctx, buf) hgsmi_buffer_free(ctx, buf)
+#define VBoxHGSMIBufferSubmit(ctx, buf) hgsmi_buffer_submit(ctx, buf)
#endif
diff --git a/src/VBox/Additions/linux/drm/vbox_drv.h b/src/VBox/Additions/linux/drm/vbox_drv.h
index d034244c..d4421e38 100644
--- a/src/VBox/Additions/linux/drm/vbox_drv.h
+++ b/src/VBox/Additions/linux/drm/vbox_drv.h
@@ -87,7 +87,7 @@ struct vbox_private {
u8 __iomem *guest_heap;
u8 __iomem *vbva_buffers;
- HGSMIGUESTCOMMANDCONTEXT submit_info;
+ struct gen_pool *guest_pool;
struct VBVABUFFERCONTEXT *vbva_info;
bool any_pitch;
unsigned num_crtcs;
diff --git a/src/VBox/Additions/linux/drm/vbox_irq.c b/src/VBox/Additions/linux/drm/vbox_irq.c
index ff2f6ac9..f95650a0 100644
--- a/src/VBox/Additions/linux/drm/vbox_irq.c
+++ b/src/VBox/Additions/linux/drm/vbox_irq.c
@@ -123,7 +123,7 @@ static void vbox_update_mode_hints(struct vbox_private *vbox)
unsigned crtc_id;
int rc;
- rc = VBoxHGSMIGetModeHints(&vbox->submit_info, vbox->num_crtcs,
+ rc = VBoxHGSMIGetModeHints(vbox->guest_pool, vbox->num_crtcs,
vbox->last_mode_hints);
if (RT_FAILURE(rc)) {
printk("vboxvideo: VBoxHGSMIGetModeHints failed, rc=%i.\n", rc);
@@ -149,7 +149,7 @@ static void vbox_update_mode_hints(struct vbox_private *vbox)
vbox_connector->vbox_crtc->y_hint = hints->dy;
vbox_connector->mode_hint.disconnected = disconnected;
if (vbox_connector->vbox_crtc->disconnected != disconnected) {
- VBoxHGSMIProcessDisplayInfo(&vbox->submit_info, crtc_id,
+ VBoxHGSMIProcessDisplayInfo(vbox->guest_pool, crtc_id,
0, 0, 0, hints->cx * 4, hints->cx,
hints->cy, 0, flags);
vbox_connector->vbox_crtc->disconnected = disconnected;
diff --git a/src/VBox/Additions/linux/drm/vbox_main.c b/src/VBox/Additions/linux/drm/vbox_main.c
index e76945dd..431aa69d 100644
--- a/src/VBox/Additions/linux/drm/vbox_main.c
+++ b/src/VBox/Additions/linux/drm/vbox_main.c
@@ -63,7 +63,7 @@ void vbox_enable_accel(struct vbox_private *vbox)
if (vbox->vbva_info[i].pVBVA == NULL) {
vbva = (struct VBVABUFFER *) ((u8 *)vbox->vbva_buffers
+ i * VBVA_MIN_BUFFER_SIZE);
- if (!VBoxVBVAEnable(&vbox->vbva_info[i], &vbox->submit_info, vbva, i)) {
+ if (!VBoxVBVAEnable(&vbox->vbva_info[i], vbox->guest_pool, vbva, i)) {
/* very old host or driver error. */
printk(KERN_ERR "vboxvideo: VBoxVBVAEnable failed - heap allocation error.\n");
return;
@@ -77,7 +77,7 @@ void vbox_disable_accel(struct vbox_private *vbox)
unsigned i;
for (i = 0; i < vbox->num_crtcs; ++i)
- VBoxVBVADisable(&vbox->vbva_info[i], &vbox->submit_info, i);
+ VBoxVBVADisable(&vbox->vbva_info[i], vbox->guest_pool, i);
}
void vbox_report_caps(struct vbox_private *vbox)
@@ -87,7 +87,7 @@ void vbox_report_caps(struct vbox_private *vbox)
| VBVACAPS_USE_VBVA_ONLY;
if (vbox->initial_mode_queried)
caps |= VBVACAPS_VIDEO_MODE_HINTS;
- VBoxHGSMISendCapsInfo(&vbox->submit_info, caps);
+ VBoxHGSMISendCapsInfo(vbox->guest_pool, caps);
}
/** Send information about dirty rectangles to VBVA. If necessary we enable
@@ -123,9 +123,9 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
cmd_hdr.w = (uint16_t)rects[i].x2 - rects[i].x1;
cmd_hdr.h = (uint16_t)rects[i].y2 - rects[i].y1;
if (VBoxVBVABufferBeginUpdate(&vbox->vbva_info[crtc_id],
- &vbox->submit_info))
+ vbox->guest_pool))
{
- VBoxVBVAWrite(&vbox->vbva_info[crtc_id], &vbox->submit_info, &cmd_hdr,
+ VBoxVBVAWrite(&vbox->vbva_info[crtc_id], vbox->guest_pool, &cmd_hdr,
sizeof(cmd_hdr));
VBoxVBVABufferEndUpdate(&vbox->vbva_info[crtc_id]);
}
@@ -263,8 +263,8 @@ static bool have_hgsmi_mode_hints(struct vbox_private *vbox)
{
uint32_t have_hints, have_cursor;
- return RT_SUCCESS(VBoxQueryConfHGSMI(&vbox->submit_info, VBOX_VBVA_CONF32_MODE_HINT_REPORTING, &have_hints))
- && RT_SUCCESS(VBoxQueryConfHGSMI(&vbox->submit_info, VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING, &have_cursor))
+ return RT_SUCCESS(VBoxQueryConfHGSMI(vbox->guest_pool, VBOX_VBVA_CONF32_MODE_HINT_REPORTING, &have_hints))
+ && RT_SUCCESS(VBoxQueryConfHGSMI(vbox->guest_pool, VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING, &have_cursor))
&& have_hints == VINF_SUCCESS
&& have_cursor == VINF_SUCCESS;
}
@@ -286,11 +286,11 @@ static int vbox_hw_init(struct vbox_private *vbox)
return -ENOMEM;
/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
- vbox->submit_info.guest_pool = gen_pool_create(4, -1);
- if (!vbox->submit_info.guest_pool)
+ vbox->guest_pool = gen_pool_create(4, -1);
+ if (!vbox->guest_pool)
return -ENOMEM;
- ret = gen_pool_add_virt(vbox->submit_info.guest_pool,
+ ret = gen_pool_add_virt(vbox->guest_pool,
(unsigned long)vbox->guest_heap,
GUEST_HEAP_OFFSET(vbox),
GUEST_HEAP_USABLE_SIZE, -1);
@@ -300,7 +300,7 @@ static int vbox_hw_init(struct vbox_private *vbox)
/* Reduce available VRAM size to reflect the guest heap. */
vbox->available_vram_size = GUEST_HEAP_OFFSET(vbox);
/* Linux drm represents monitors as a 32-bit array. */
- vbox->num_crtcs = min(VBoxHGSMIGetMonitorCount(&vbox->submit_info),
+ vbox->num_crtcs = min(VBoxHGSMIGetMonitorCount(vbox->guest_pool),
(uint32_t)VBOX_MAX_SCREENS);
if (!have_hgsmi_mode_hints(vbox))
return -ENOTSUPP;
@@ -384,8 +384,8 @@ int vbox_driver_unload(struct drm_device *dev)
vbox_hw_fini(vbox);
vbox_mm_fini(vbox);
- if (vbox->submit_info.guest_pool)
- gen_pool_destroy(vbox->submit_info.guest_pool);
+ if (vbox->guest_pool)
+ gen_pool_destroy(vbox->guest_pool);
if (vbox->guest_heap)
pci_iounmap(dev->pdev, vbox->guest_heap);
kfree(vbox);
diff --git a/src/VBox/Additions/linux/drm/vbox_mode.c b/src/VBox/Additions/linux/drm/vbox_mode.c
index c4812739..c2c93da6 100644
--- a/src/VBox/Additions/linux/drm/vbox_mode.c
+++ b/src/VBox/Additions/linux/drm/vbox_mode.c
@@ -100,7 +100,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
flags = VBVA_SCREEN_F_ACTIVE;
flags |= (crtc->enabled && !vbox_crtc->blanked ? 0 : VBVA_SCREEN_F_BLANK);
flags |= (vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0);
- VBoxHGSMIProcessDisplayInfo(&vbox->submit_info, vbox_crtc->crtc_id,
+ VBoxHGSMIProcessDisplayInfo(vbox->guest_pool, vbox_crtc->crtc_id,
x_offset, y_offset,
crtc->x * bpp / 8 + crtc->y * pitch,
pitch, width, height,
@@ -121,7 +121,7 @@ static int vbox_set_view(struct drm_crtc *crtc)
* second and so on. The first match wins. We cheat around this by making
* the first view be the managed memory plus the first command buffer, the
* second the same plus the second buffer and so on. */
- p = VBoxHGSMIBufferAlloc(&vbox->submit_info, sizeof(VBVAINFOVIEW), HGSMI_CH_VBVA,
+ p = VBoxHGSMIBufferAlloc(vbox->guest_pool, sizeof(VBVAINFOVIEW), HGSMI_CH_VBVA,
VBVA_INFO_VIEW);
if (p)
{
@@ -131,8 +131,8 @@ static int vbox_set_view(struct drm_crtc *crtc)
pInfo->u32ViewSize = vbox->available_vram_size - vbox_crtc->fb_offset
+ vbox_crtc->crtc_id * VBVA_MIN_BUFFER_SIZE;
pInfo->u32MaxScreenSize = vbox->available_vram_size - vbox_crtc->fb_offset;
- VBoxHGSMIBufferSubmit(&vbox->submit_info, p);
- VBoxHGSMIBufferFree(&vbox->submit_info, p);
+ VBoxHGSMIBufferSubmit(vbox->guest_pool, p);
+ VBoxHGSMIBufferFree(vbox->guest_pool, p);
}
else
return -ENOMEM;
@@ -296,7 +296,7 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,
rc = vbox_set_view(crtc);
if (!rc)
vbox_do_modeset(crtc, mode);
- VBoxHGSMIUpdateInputMapping(&vbox->submit_info, 0, 0,
+ VBoxHGSMIUpdateInputMapping(vbox->guest_pool, 0, 0,
vbox->input_mapping_width,
vbox->input_mapping_height);
mutex_unlock(&vbox->hw_mutex);
@@ -535,7 +535,7 @@ static int vbox_get_modes(struct drm_connector *connector)
* this place in the code rather than elsewhere.
* We need to report the flags location before reporting the IRQ
* capability. */
- VBoxHGSMIReportFlagsLocation(&vbox->submit_info, GUEST_HEAP_OFFSET(vbox) +
+ VBoxHGSMIReportFlagsLocation(vbox->guest_pool, GUEST_HEAP_OFFSET(vbox) +
HOST_FLAGS_OFFSET);
if (vbox_connector->vbox_crtc->crtc_id == 0)
vbox_report_caps(vbox);
@@ -728,7 +728,7 @@ static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
/* Re-set this regularly as in 5.0.20 and earlier the information was lost
* on save and restore. */
- VBoxHGSMIUpdateInputMapping(&vbox->submit_info, 0, 0,
+ VBoxHGSMIUpdateInputMapping(vbox->guest_pool, 0, 0,
vbox->input_mapping_width,
vbox->input_mapping_height);
if (!handle) {
@@ -741,14 +741,14 @@ static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
if (to_vbox_crtc(crtci)->cursor_enabled)
cursor_enabled = true;
if (!cursor_enabled)
- VBoxHGSMIUpdatePointerShape(&vbox->submit_info, 0, 0, 0, 0, 0, NULL, 0);
+ VBoxHGSMIUpdatePointerShape(vbox->guest_pool, 0, 0, 0, 0, 0, NULL, 0);
return 0;
}
vbox_crtc->cursor_enabled = true;
if ( width > VBOX_MAX_CURSOR_WIDTH || height > VBOX_MAX_CURSOR_HEIGHT
|| width == 0 || height == 0)
return -EINVAL;
- rc = VBoxQueryConfHGSMI(&vbox->submit_info,
+ rc = VBoxQueryConfHGSMI(vbox->guest_pool,
VBOX_VBVA_CONF32_CURSOR_CAPABILITIES, &caps);
ret = rc == VINF_SUCCESS ? 0 : rc == VERR_NO_MEMORY ? -ENOMEM : -EINVAL;
if (ret)
@@ -789,7 +789,7 @@ static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
| VBOX_MOUSE_POINTER_SHAPE
| VBOX_MOUSE_POINTER_ALPHA;
copy_cursor_image(src, dst, width, height, mask_size);
- rc = VBoxHGSMIUpdatePointerShape(&vbox->submit_info, flags,
+ rc = VBoxHGSMIUpdatePointerShape(vbox->guest_pool, flags,
vbox->cursor_hot_x,
vbox->cursor_hot_y,
width, height, dst,
@@ -834,7 +834,7 @@ static int vbox_cursor_move(struct drm_crtc *crtc,
/* We compare these to unsigned later and don't need to handle negative. */
if (x + crtc_x < 0 || y + crtc_y < 0 || vbox->cursor_data_size == 0)
return 0;
- rc = VBoxHGSMICursorPosition(&vbox->submit_info, true, x + crtc_x,
+ rc = VBoxHGSMICursorPosition(vbox->guest_pool, true, x + crtc_x,
y + crtc_y, &host_x, &host_y);
/* Work around a bug after save and restore in 5.0.20 and earlier. */
if (RT_FAILURE(rc) || (host_x == 0 && host_y == 0))
@@ -849,7 +849,7 @@ static int vbox_cursor_move(struct drm_crtc *crtc,
return 0;
vbox->cursor_hot_x = hot_x;
vbox->cursor_hot_y = hot_y;
- rc = VBoxHGSMIUpdatePointerShape(&vbox->submit_info, flags, hot_x, hot_y,
+ rc = VBoxHGSMIUpdatePointerShape(vbox->guest_pool, flags, hot_x, hot_y,
vbox->cursor_width, vbox->cursor_height,
vbox->cursor_data,
vbox->cursor_data_size);
--
2.12.2
More information about the vbox-dev
mailing list