[vbox-dev] [PATCH 5/7] Additions: linux/drm: Change vbox_irq.c to kernel coding style

2017-06-08 Thread Hans de Goede
This is the result of running linux/scripts/Lindent + manual cleanups.
After this the file passes linux/scripts/checkpatch -f
except for the LINUX_VERSION_CODE checks.

This patch contains no functional changes, only coding style fixes,
including changing uintXX_t types to uXX.

Signed-off-by: Hans de Goede 
---
 src/VBox/Additions/linux/drm/vbox_irq.c | 244 +---
 1 file changed, 133 insertions(+), 111 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_irq.c 
b/src/VBox/Additions/linux/drm/vbox_irq.c
index 7fdf8660..c9b4079f 100644
--- a/src/VBox/Additions/linux/drm/vbox_irq.c
+++ b/src/VBox/Additions/linux/drm/vbox_irq.c
@@ -40,73 +40,87 @@
 
 static void vbox_clear_irq(void)
 {
-outl((uint32_t)~0, VGA_PORT_HGSMI_HOST);
+   outl((u32)~0, VGA_PORT_HGSMI_HOST);
 }
 
-static uint32_t vbox_get_flags(struct vbox_private *vbox)
+static u32 vbox_get_flags(struct vbox_private *vbox)
 {
return readl(vbox->guest_heap + HOST_FLAGS_OFFSET);
 }
 
 void vbox_report_hotplug(struct vbox_private *vbox)
 {
-schedule_work(&vbox->hotplug_work);
+   schedule_work(&vbox->hotplug_work);
 }
 
 irqreturn_t vbox_irq_handler(int irq, void *arg)
 {
-struct drm_device *dev = (struct drm_device *) arg;
-struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
-uint32_t host_flags = vbox_get_flags(vbox);
-
-if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
-return IRQ_NONE;
-
-/* Due to a bug in the initial host implementation of hot-plug interrupts,
- * the hot-plug and cursor capability flags were never cleared.  
Fortunately
- * we can tell when they would have been set by checking that the VSYNC 
flag
- * is not set. */
-if (   host_flags & (HGSMIHOSTFLAGS_HOTPLUG | 
HGSMIHOSTFLAGS_CURSOR_CAPABILITIES)
-&& !(host_flags & HGSMIHOSTFLAGS_VSYNC))
-vbox_report_hotplug(vbox);
-vbox_clear_irq();
-return IRQ_HANDLED;
+   struct drm_device *dev = (struct drm_device *)arg;
+   struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
+   u32 host_flags = vbox_get_flags(vbox);
+
+   if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
+   return IRQ_NONE;
+
+   /*
+* Due to a bug in the initial host implementation of hot-plug irqs,
+* the hot-plug and cursor capability flags were never cleared.
+* Fortunately we can tell when they would have been set by checking
+* that the VSYNC flag is not set.
+*/
+   if (host_flags &
+   (HGSMIHOSTFLAGS_HOTPLUG | HGSMIHOSTFLAGS_CURSOR_CAPABILITIES) &&
+   !(host_flags & HGSMIHOSTFLAGS_VSYNC))
+   vbox_report_hotplug(vbox);
+
+   vbox_clear_irq();
+
+   return IRQ_HANDLED;
 }
 
-/** Check that the position hints provided by the host are suitable for GNOME
+/**
+ * Check that the position hints provided by the host are suitable for GNOME
  * shell (i.e. all screens disjoint and hints for all enabled screens) and if
  * not replace them with default ones.  Providing valid hints improves the
- * chances that we will get a known screen layout for pointer mapping. */
+ * chances that we will get a known screen layout for pointer mapping.
+ */
 static void validate_or_set_position_hints(struct vbox_private *vbox)
 {
-int i, j;
-uint16_t currentx = 0;
-bool valid = true;
-
-for (i = 0; i < vbox->num_crtcs; ++i) {
-for (j = 0; j < i; ++j) {
-struct VBVAMODEHINT *hintsi = &vbox->last_mode_hints[i];
-struct VBVAMODEHINT *hintsj = &vbox->last_mode_hints[j];
-
-if (hintsi->fEnabled && hintsj->fEnabled) {
-if ((hintsi->dx >= 0x || hintsi->dy >= 0x ||
- hintsj->dx >= 0x || hintsj->dy >= 0x) ||
-(hintsi->dx < hintsj->dx + (hintsj->cx & 0x8fff) &&
- hintsi->dx + (hintsi->cx & 0x8fff) > hintsj->dx) ||
-(hintsi->dy < hintsj->dy + (hintsj->cy & 0x8fff) &&
- hintsi->dy + (hintsi->cy & 0x8fff) > hintsj->dy))
-valid = false;
-}
-}
-}
-if (!valid)
-for (i = 0; i < vbox->num_crtcs; ++i) {
-if (vbox->last_mode_hints[i].fEnabled) {
-vbox->last_mode_hints[i].dx = currentx;
-vbox->last_mode_hints[i].dy = 0;
-currentx += vbox->last_mode_hints[i].cx & 0x8fff;
-}
-}
+   int i, j;
+   u16 currentx = 0;
+   bool valid = true;
+
+   for (i = 0; i < vbox->num_crtcs; ++i) {
+   for (j = 0; j < i; ++j) {
+   struct VBVAMODEHINT *hintsi = &vbox->last_mode_hints[i];
+   struct VBVAMODEHINT *hintsj = &vbox->last_mode_hints[j];
+
+   if (hintsi->fEnabled && hintsj->fEnabled) {
+   if (hintsi->dx >= 0x ||
+   hintsi->dy >= 0x ||
+

[vbox-dev] [PATCH 2/7] Additions: linux/drm: Change vbox_drv.h to kernel coding style

2017-06-08 Thread Hans de Goede
This is the result of running linux/scripts/Lindent + manual cleanups.
After this the file passes linux/scripts/checkpatch -f
except for the LINUX_VERSION_CODE checks.

This patch contains no functional changes, only coding style fixes,
including changing uintXX_t types to uXX.

Signed-off-by: Hans de Goede 
---
 src/VBox/Additions/linux/drm/vbox_drv.h | 267 
 1 file changed, 133 insertions(+), 134 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_drv.h 
b/src/VBox/Additions/linux/drm/vbox_drv.h
index d21cded6..0d411b18 100644
--- a/src/VBox/Additions/linux/drm/vbox_drv.h
+++ b/src/VBox/Additions/linux/drm/vbox_drv.h
@@ -49,14 +49,12 @@
 #include 
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
-# include 
+#include 
 #endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-# include 
+#include 
 #endif
 
-/* #include "vboxvideo.h" */
-
 #include "product-generated.h"
 
 #define DRIVER_AUTHOR   VBOX_VENDOR
@@ -71,64 +69,69 @@
 
 #define VBOX_MAX_CURSOR_WIDTH  64
 #define VBOX_MAX_CURSOR_HEIGHT 64
-#define CURSOR_PIXEL_COUNT VBOX_MAX_CURSOR_WIDTH * VBOX_MAX_CURSOR_HEIGHT
-#define CURSOR_DATA_SIZE CURSOR_PIXEL_COUNT * 4 + CURSOR_PIXEL_COUNT / 8
+#define CURSOR_PIXEL_COUNT (VBOX_MAX_CURSOR_WIDTH * VBOX_MAX_CURSOR_HEIGHT)
+#define CURSOR_DATA_SIZE (CURSOR_PIXEL_COUNT * 4 + CURSOR_PIXEL_COUNT / 8)
 
 #define VBOX_MAX_SCREENS  32
 
-#define GUEST_HEAP_OFFSET(vbox) (vbox->full_vram_size - 
VBVA_ADAPTER_INFORMATION_SIZE)
+#define GUEST_HEAP_OFFSET(vbox) ((vbox)->full_vram_size - \
+VBVA_ADAPTER_INFORMATION_SIZE)
 #define GUEST_HEAP_SIZE   VBVA_ADAPTER_INFORMATION_SIZE
 #define GUEST_HEAP_USABLE_SIZE (VBVA_ADAPTER_INFORMATION_SIZE - \
-sizeof(HGSMIHOSTFLAGS))
+   sizeof(HGSMIHOSTFLAGS))
 #define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
 
 struct vbox_fbdev;
 
 struct vbox_private {
-struct drm_device *dev;
-
-u8 __iomem *guest_heap;
-u8 __iomem *vbva_buffers;
-struct gen_pool *guest_pool;
-struct VBVABUFFERCONTEXT *vbva_info;
-bool any_pitch;
-unsigned num_crtcs;
-/** Amount of available VRAM, including space used for buffers. */
-uint32_t full_vram_size;
-/** Amount of available VRAM, not including space used for buffers. */
-uint32_t available_vram_size;
-/** Array of structures for receiving mode hints. */
-VBVAMODEHINT *last_mode_hints;
-
-struct vbox_fbdev *fbdev;
-
-int fb_mtrr;
-
-struct {
-struct drm_global_reference mem_global_ref;
-struct ttm_bo_global_ref bo_global_ref;
-struct ttm_bo_device bdev;
-bool mm_initialised;
-} ttm;
-
-struct mutex hw_mutex;
-bool isr_installed;
-/** We decide whether or not user-space supports display hot-plug
- * depending on whether they react to a hot-plug event after the initial
- * mode query. */
-bool initial_mode_queried;
-struct work_struct hotplug_work;
-uint32_t input_mapping_width;
-uint32_t input_mapping_height;
-/** Is user-space using an X.Org-style layout of one large frame-buffer
- * encompassing all screen ones or is the fbdev console active? */
-bool single_framebuffer;
-uint32_t cursor_width;
-uint32_t cursor_height;
-uint32_t cursor_hot_x;
-uint32_t cursor_hot_y;
-size_t cursor_data_size;
-uint8_t cursor_data[CURSOR_DATA_SIZE];
+   struct drm_device *dev;
+
+   u8 __iomem *guest_heap;
+   u8 __iomem *vbva_buffers;
+   struct gen_pool *guest_pool;
+   struct VBVABUFFERCONTEXT *vbva_info;
+   bool any_pitch;
+   unsigned int num_crtcs;
+   /** Amount of available VRAM, including space used for buffers. */
+   u32 full_vram_size;
+   /** Amount of available VRAM, not including space used for buffers. */
+   u32 available_vram_size;
+   /** Array of structures for receiving mode hints. */
+   VBVAMODEHINT *last_mode_hints;
+
+   struct vbox_fbdev *fbdev;
+
+   int fb_mtrr;
+
+   struct {
+   struct drm_global_reference mem_global_ref;
+   struct ttm_bo_global_ref bo_global_ref;
+   struct ttm_bo_device bdev;
+   bool mm_initialised;
+   } ttm;
+
+   struct mutex hw_mutex; /* protects modeset and accel/vbva accesses */
+   bool isr_installed;
+   /**
+* We decide whether or not user-space supports display hot-plug
+* depending on whether they react to a hot-plug event after the initial
+* mode query.
+*/
+   bool initial_mode_queried;
+   struct work_struct hotplug_work;
+   u32 input_mapping_width;
+   u32 input_mapping_height;
+   /**
+* Is user-space using an X.Org-style layout of one large frame-buffer
+* encompassing all screen ones or is the fbdev console active?
+*/
+   bool single_framebuffer;
+   u32 cursor_width;
+   u32 curs

[vbox-dev] [PATCH 0/7] Additions: linux/drm: Change vbox_*.? files to kernel coding style

2017-06-08 Thread Hans de Goede
Hi,

Here is the first batch of patches to change the various vbox_*.? files
in the linux drm/kms driver to the kernel coding style.

You hereby have my and Red Hat's permission to use these patches under
the MIT license.

Regards,

Hans
___
vbox-dev mailing list
vbox-dev@virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev


[vbox-dev] [PATCH 1/7] Additions: linux/drm: Change vbox_drv.c to kernel coding style

2017-06-08 Thread Hans de Goede
This is the result of running linux/scripts/Lindent + manual cleanups.
After this the file passes linux/scripts/checkpatch -f
except for the LINUX_VERSION_CODE checks.

This patch contains no functional changes, only coding style fixes,
including changing uintXX_t types to uXX.

Signed-off-by: Hans de Goede 
---
 src/VBox/Additions/linux/drm/vbox_drv.c | 318 
 1 file changed, 161 insertions(+), 157 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_drv.c 
b/src/VBox/Additions/linux/drm/vbox_drv.c
index 00924fe8..b7af0061 100644
--- a/src/VBox/Additions/linux/drm/vbox_drv.c
+++ b/src/VBox/Additions/linux/drm/vbox_drv.c
@@ -51,133 +51,128 @@ module_param_named(modeset, vbox_modeset, int, 0400);
 
 static struct drm_driver driver;
 
-static const struct pci_device_id pciidlist[] =
-{
-{0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-{0, 0, 0},
+static const struct pci_device_id pciidlist[] = {
+   { 0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+   { 0, 0, 0},
 };
-
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
 static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent)
 {
-return drm_get_pci_dev(pdev, ent, &driver);
+   return drm_get_pci_dev(pdev, ent, &driver);
 }
 
-
 static void vbox_pci_remove(struct pci_dev *pdev)
 {
-struct drm_device *dev = pci_get_drvdata(pdev);
+   struct drm_device *dev = pci_get_drvdata(pdev);
 
-drm_put_dev(dev);
+   drm_put_dev(dev);
 }
 
-
-
 static int vbox_drm_freeze(struct drm_device *dev)
 {
-drm_kms_helper_poll_disable(dev);
+   drm_kms_helper_poll_disable(dev);
 
-pci_save_state(dev->pdev);
+   pci_save_state(dev->pdev);
 
-console_lock();
-vbox_fbdev_set_suspend(dev, 1);
-console_unlock();
-return 0;
+   console_lock();
+   vbox_fbdev_set_suspend(dev, 1);
+   console_unlock();
+
+   return 0;
 }
 
 static int vbox_drm_thaw(struct drm_device *dev)
 {
-int error = 0;
+   drm_mode_config_reset(dev);
+   drm_helper_resume_force_mode(dev);
 
-drm_mode_config_reset(dev);
-drm_helper_resume_force_mode(dev);
+   console_lock();
+   vbox_fbdev_set_suspend(dev, 0);
+   console_unlock();
 
-console_lock();
-vbox_fbdev_set_suspend(dev, 0);
-console_unlock();
-return error;
+   return 0;
 }
 
 static int vbox_drm_resume(struct drm_device *dev)
 {
-int ret;
+   int ret;
+
+   if (pci_enable_device(dev->pdev))
+   return -EIO;
 
-if (pci_enable_device(dev->pdev))
-return -EIO;
+   ret = vbox_drm_thaw(dev);
+   if (ret)
+   return ret;
 
-   ret = vbox_drm_thaw(dev);
-if (ret)
-   return ret;
+   drm_kms_helper_poll_enable(dev);
 
-drm_kms_helper_poll_enable(dev);
-return 0;
+   return 0;
 }
 
 static int vbox_pm_suspend(struct device *dev)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct drm_device *ddev = pci_get_drvdata(pdev);
-int error;
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct drm_device *ddev = pci_get_drvdata(pdev);
+   int error;
+
+   error = vbox_drm_freeze(ddev);
+   if (error)
+   return error;
 
-error = vbox_drm_freeze(ddev);
-if (error)
-return error;
+   pci_disable_device(pdev);
+   pci_set_power_state(pdev, PCI_D3hot);
 
-pci_disable_device(pdev);
-pci_set_power_state(pdev, PCI_D3hot);
-return 0;
+   return 0;
 }
 
 static int vbox_pm_resume(struct device *dev)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct drm_device *ddev = pci_get_drvdata(pdev);
-return vbox_drm_resume(ddev);
+   struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev));
+
+   return vbox_drm_resume(ddev);
 }
 
 static int vbox_pm_freeze(struct device *dev)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct drm_device *ddev = pci_get_drvdata(pdev);
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct drm_device *ddev = pci_get_drvdata(pdev);
 
-if (!ddev || !ddev->dev_private)
-return -ENODEV;
-return vbox_drm_freeze(ddev);
+   if (!ddev || !ddev->dev_private)
+   return -ENODEV;
 
+   return vbox_drm_freeze(ddev);
 }
 
 static int vbox_pm_thaw(struct device *dev)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct drm_device *ddev = pci_get_drvdata(pdev);
-return vbox_drm_thaw(ddev);
+   struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev));
+
+   return vbox_drm_thaw(ddev);
 }
 
 static int vbox_pm_poweroff(struct device *dev)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct drm_device *ddev = pci_get_drvdata(pdev);
+   struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev));
 
-return vbox_drm_freeze(ddev);
+   return vbox_drm_freeze(ddev);
 }
 
 static const struct dev_pm_ops vbox_pm_ops = {
-.suspend = vbox_pm_suspend,
-.resume = vbox_pm_resume,
-.freeze = vbox_pm_fre

[vbox-dev] [PATCH 3/7] Additions: linux/drm: Change vbox_fb.c to kernel coding style

2017-06-08 Thread Hans de Goede
This is the result of running linux/scripts/Lindent + manual cleanups.
After this the file passes linux/scripts/checkpatch -f
except for the LINUX_VERSION_CODE checks.

This patch contains no functional changes, only coding style fixes,
including changing uintXX_t types to uXX.

Signed-off-by: Hans de Goede 
---
 src/VBox/Additions/linux/drm/vbox_fb.c | 618 +
 1 file changed, 315 insertions(+), 303 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_fb.c 
b/src/VBox/Additions/linux/drm/vbox_fb.c
index cf538c1a..0519bd61 100644
--- a/src/VBox/Additions/linux/drm/vbox_fb.c
+++ b/src/VBox/Additions/linux/drm/vbox_fb.c
@@ -46,7 +46,6 @@
 #include 
 #include 
 
-
 #include 
 #include 
 #include 
@@ -58,407 +57,420 @@
  * Tell the host about dirty rectangles to update.
  */
 static void vbox_dirty_update(struct vbox_fbdev *fbdev,
- int x, int y, int width, int height)
+ int x, int y, int width, int height)
 {
-struct drm_gem_object *obj;
-struct vbox_bo *bo;
-int ret = -EBUSY;
-bool store_for_later = false;
-int x2, y2;
-unsigned long flags;
-struct drm_clip_rect rect;
-
-obj = fbdev->afb.obj;
-bo = gem_to_vbox_bo(obj);
-
-/*
- * try and reserve the BO, if we fail with busy
- * then the BO is being moved and we should
- * store up the damage until later.
- */
-if (drm_can_sleep())
-ret = vbox_bo_reserve(bo, true);
-if (ret) {
-if (ret != -EBUSY)
-return;
-
-store_for_later = true;
-}
-
-x2 = x + width - 1;
-y2 = y + height - 1;
-spin_lock_irqsave(&fbdev->dirty_lock, flags);
-
-if (fbdev->y1 < y)
-y = fbdev->y1;
-if (fbdev->y2 > y2)
-y2 = fbdev->y2;
-if (fbdev->x1 < x)
-x = fbdev->x1;
-if (fbdev->x2 > x2)
-x2 = fbdev->x2;
-
-if (store_for_later) {
-fbdev->x1 = x;
-fbdev->x2 = x2;
-fbdev->y1 = y;
-fbdev->y2 = y2;
-spin_unlock_irqrestore(&fbdev->dirty_lock, flags);
-return;
-}
-
-fbdev->x1 = fbdev->y1 = INT_MAX;
-fbdev->x2 = fbdev->y2 = 0;
-spin_unlock_irqrestore(&fbdev->dirty_lock, flags);
-
-/* Not sure why the original code subtracted 1 here, but I will keep it 
that
- * way to avoid unnecessary differences. */
-rect.x1 = x;
-rect.x2 = x2 + 1;
-rect.y1 = y;
-rect.y2 = y2 + 1;
-vbox_framebuffer_dirty_rectangles(&fbdev->afb.base, &rect, 1);
-
-vbox_bo_unreserve(bo);
+   struct drm_gem_object *obj;
+   struct vbox_bo *bo;
+   int ret = -EBUSY;
+   bool store_for_later = false;
+   int x2, y2;
+   unsigned long flags;
+   struct drm_clip_rect rect;
+
+   obj = fbdev->afb.obj;
+   bo = gem_to_vbox_bo(obj);
+
+   /*
+* try and reserve the BO, if we fail with busy
+* then the BO is being moved and we should
+* store up the damage until later.
+*/
+   if (drm_can_sleep())
+   ret = vbox_bo_reserve(bo, true);
+   if (ret) {
+   if (ret != -EBUSY)
+   return;
+
+   store_for_later = true;
+   }
+
+   x2 = x + width - 1;
+   y2 = y + height - 1;
+   spin_lock_irqsave(&fbdev->dirty_lock, flags);
+
+   if (fbdev->y1 < y)
+   y = fbdev->y1;
+   if (fbdev->y2 > y2)
+   y2 = fbdev->y2;
+   if (fbdev->x1 < x)
+   x = fbdev->x1;
+   if (fbdev->x2 > x2)
+   x2 = fbdev->x2;
+
+   if (store_for_later) {
+   fbdev->x1 = x;
+   fbdev->x2 = x2;
+   fbdev->y1 = y;
+   fbdev->y2 = y2;
+   spin_unlock_irqrestore(&fbdev->dirty_lock, flags);
+   return;
+   }
+
+   fbdev->x1 = INT_MAX;
+   fbdev->y1 = INT_MAX;
+   fbdev->x2 = 0;
+   fbdev->y2 = 0;
+
+   spin_unlock_irqrestore(&fbdev->dirty_lock, flags);
+
+   /*
+* Not sure why the original code subtracted 1 here, but I will keep
+* it that way to avoid unnecessary differences.
+*/
+   rect.x1 = x;
+   rect.x2 = x2 + 1;
+   rect.y1 = y;
+   rect.y2 = y2 + 1;
+   vbox_framebuffer_dirty_rectangles(&fbdev->afb.base, &rect, 1);
+
+   vbox_bo_unreserve(bo);
 }
 
 #ifdef CONFIG_FB_DEFERRED_IO
-static void vbox_deferred_io(struct fb_info *info,
- struct list_head *pagelist)
+static void vbox_deferred_io(struct fb_info *info, struct list_head *pagelist)
 {
-struct vbox_fbdev *fbdev = info->par;
-unsigned long start, end, min, max;
-struct page *page;
-int y1, y2;
-
-min = ULONG_MAX;
-max = 0;
-list_for_each_entry(page, pagelist, lru) {
-start = page->index << PAGE_SHIFT;
-end = start + PAGE_SIZE - 1;
-min = min(min, start);
-max = max(max, end);
-   

[vbox-dev] [PATCH 4/7] Additions: linux/drm: Fix checkpatch warning in vbox_hgsmi.c

2017-06-08 Thread Hans de Goede
Fix:

CHECK: Alignment should match open parenthesis
 #123: FILE: drivers/staging/vboxvideo/vbox_hgsmi.c:123:
offset = gen_pool_virt_to_phys(guest_pool,
(unsigned long)buf - sizeof(HGSMIBUFFERHEADER));

Signed-off-by: Hans de Goede 
---
 src/VBox/Additions/linux/drm/vbox_hgsmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_hgsmi.c 
b/src/VBox/Additions/linux/drm/vbox_hgsmi.c
index c074db7e..eff5618c 100644
--- a/src/VBox/Additions/linux/drm/vbox_hgsmi.c
+++ b/src/VBox/Additions/linux/drm/vbox_hgsmi.c
@@ -119,8 +119,8 @@ int hgsmi_buffer_submit(struct gen_pool *guest_pool, void 
*buf)
 {
phys_addr_t offset;
 
-   offset = gen_pool_virt_to_phys(guest_pool,
-   (unsigned long)buf - sizeof(HGSMIBUFFERHEADER));
+   offset = gen_pool_virt_to_phys(guest_pool, (unsigned long)buf -
+  sizeof(HGSMIBUFFERHEADER));
outl(offset, VGA_PORT_HGSMI_GUEST);
/* Make the compiler aware that the host has changed memory. */
mb();
-- 
2.13.0

___
vbox-dev mailing list
vbox-dev@virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev


[vbox-dev] [PATCH 6/7] Additions: linux/drm: Change vbox_main.c to kernel coding style

2017-06-08 Thread Hans de Goede
This is the result of running linux/scripts/Lindent + manual cleanups.
After this the file passes linux/scripts/checkpatch -f
except for the LINUX_VERSION_CODE checks.

This patch contains no functional changes, only coding style fixes,
including changing uintXX_t types to uXX.

Signed-off-by: Hans de Goede 
---
 src/VBox/Additions/linux/drm/vbox_main.c | 705 ---
 1 file changed, 370 insertions(+), 335 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_main.c 
b/src/VBox/Additions/linux/drm/vbox_main.c
index aea5ddb9..2bf6bc2c 100644
--- a/src/VBox/Additions/linux/drm/vbox_main.c
+++ b/src/VBox/Additions/linux/drm/vbox_main.c
@@ -42,331 +42,366 @@
 
 static void vbox_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
-struct vbox_framebuffer *vbox_fb = to_vbox_framebuffer(fb);
-if (vbox_fb->obj)
-drm_gem_object_unreference_unlocked(vbox_fb->obj);
+   struct vbox_framebuffer *vbox_fb = to_vbox_framebuffer(fb);
 
-drm_framebuffer_cleanup(fb);
-kfree(fb);
+   if (vbox_fb->obj)
+   drm_gem_object_unreference_unlocked(vbox_fb->obj);
+
+   drm_framebuffer_cleanup(fb);
+   kfree(fb);
 }
 
 void vbox_enable_accel(struct vbox_private *vbox)
 {
-unsigned i;
-struct VBVABUFFER *vbva;
-
-if (!vbox->vbva_info || !vbox->vbva_buffers) { /* Should never happen... */
-printk(KERN_ERR "vboxvideo: failed to set up VBVA.\n");
-return;
-}
-for (i = 0; i < vbox->num_crtcs; ++i) {
-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->guest_pool, vbva, 
i)) {
-/* very old host or driver error. */
-printk(KERN_ERR "vboxvideo: VBoxVBVAEnable failed - heap 
allocation error.\n");
-return;
-}
-}
-}
+   unsigned int i;
+   struct VBVABUFFER *vbva;
+
+   if (!vbox->vbva_info || !vbox->vbva_buffers) {
+   /* Should never happen... */
+   DRM_ERROR("vboxvideo: failed to set up VBVA.\n");
+   return;
+   }
+
+   for (i = 0; i < vbox->num_crtcs; ++i) {
+   if (!vbox->vbva_info[i].pVBVA) {
+   vbva = (struct VBVABUFFER *)
+   ((u8 *)vbox->vbva_buffers +
+i * VBVA_MIN_BUFFER_SIZE);
+   if (!VBoxVBVAEnable(&vbox->vbva_info[i],
+   vbox->guest_pool, vbva, i)) {
+   /* very old host or driver error. */
+   DRM_ERROR("vboxvideo: VBoxVBVAEnable failed - 
heap allocation error.\n");
+   return;
+   }
+   }
+   }
 }
 
 void vbox_disable_accel(struct vbox_private *vbox)
 {
-unsigned i;
+   unsigned int i;
 
-for (i = 0; i < vbox->num_crtcs; ++i)
-VBoxVBVADisable(&vbox->vbva_info[i], vbox->guest_pool, i);
+   for (i = 0; i < vbox->num_crtcs; ++i)
+   VBoxVBVADisable(&vbox->vbva_info[i], vbox->guest_pool, i);
 }
 
 void vbox_report_caps(struct vbox_private *vbox)
 {
-uint32_t caps =VBVACAPS_DISABLE_CURSOR_INTEGRATION
- | VBVACAPS_IRQ
- | VBVACAPS_USE_VBVA_ONLY;
-if (vbox->initial_mode_queried)
-caps |= VBVACAPS_VIDEO_MODE_HINTS;
-VBoxHGSMISendCapsInfo(vbox->guest_pool, caps);
+   u32 caps = VBVACAPS_DISABLE_CURSOR_INTEGRATION
+   | VBVACAPS_IRQ | VBVACAPS_USE_VBVA_ONLY;
+   if (vbox->initial_mode_queried)
+   caps |= VBVACAPS_VIDEO_MODE_HINTS;
+   VBoxHGSMISendCapsInfo(vbox->guest_pool, caps);
 }
 
-/** Send information about dirty rectangles to VBVA.  If necessary we enable
+/**
+ * Send information about dirty rectangles to VBVA.  If necessary we enable
  * VBVA first, as this is normally disabled after a change of master in case
  * the new master does not send dirty rectangle information (is this even
- * allowed?) */
+ * allowed?)
+ */
 void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
-   struct drm_clip_rect *rects,
-   unsigned num_rects)
+  struct drm_clip_rect *rects,
+  unsigned int num_rects)
 {
-struct vbox_private *vbox = fb->dev->dev_private;
-struct drm_crtc *crtc;
-unsigned i;
-
-mutex_lock(&vbox->hw_mutex);
-list_for_each_entry(crtc, &fb->dev->mode_config.crtc_list, head) {
-if (CRTC_FB(crtc) == fb) {
-vbox_enable_accel(vbox);
-for (i = 0; i < num_rects; ++i)
-{
-unsigned crtc_id = to_vbox_crtc(crtc)->crtc_id;
-VBVACMDH

[vbox-dev] [PATCH 7/7] Additions: linux/drm: Change vbox_mode.c to kernel coding style

2017-06-08 Thread Hans de Goede
This is the result of running linux/scripts/Lindent + manual cleanups.
After this the file passes linux/scripts/checkpatch -f
except for the LINUX_VERSION_CODE checks.

This patch contains no functional changes, only coding style fixes,
including changing uintXX_t types to uXX.

Signed-off-by: Hans de Goede 
---
 src/VBox/Additions/linux/drm/vbox_mode.c | 1281 --
 1 file changed, 667 insertions(+), 614 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_mode.c 
b/src/VBox/Additions/linux/drm/vbox_mode.c
index b7504dd0..28d7b5dc 100644
--- a/src/VBox/Additions/linux/drm/vbox_mode.c
+++ b/src/VBox/Additions/linux/drm/vbox_mode.c
@@ -43,818 +43,871 @@
 #include 
 #include 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
-# include 
+#include 
 #endif
 
 static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
-uint32_t handle, uint32_t width, uint32_t height,
-int32_t hot_x, int32_t hot_y);
+   u32 handle, u32 width, u32 height,
+   s32 hot_x, s32 hot_y);
 static int vbox_cursor_move(struct drm_crtc *crtc, int x, int y);
 
-/** Set a graphics mode.  Poke any required values into registers, do an HGSMI
+/**
+ * Set a graphics mode.  Poke any required values into registers, do an HGSMI
  * mode set and tell the host we support advanced graphics functions.
  */
 static void vbox_do_modeset(struct drm_crtc *crtc,
-const struct drm_display_mode *mode)
-{
-struct vbox_crtc   *vbox_crtc = to_vbox_crtc(crtc);
-struct vbox_private *vbox;
-int width, height, bpp, pitch;
-unsigned crtc_id;
-uint16_t flags;
-int32_t x_offset, y_offset;
-
-vbox = crtc->dev->dev_private;
-width = mode->hdisplay ? mode->hdisplay : 640;
-height = mode->vdisplay ? mode->vdisplay : 480;
-crtc_id = vbox_crtc->crtc_id;
+   const struct drm_display_mode *mode)
+{
+   struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
+   struct vbox_private *vbox;
+   int width, height, bpp, pitch;
+   unsigned int crtc_id;
+   u16 flags;
+   s32 x_offset, y_offset;
+
+   vbox = crtc->dev->dev_private;
+   width = mode->hdisplay ? mode->hdisplay : 640;
+   height = mode->vdisplay ? mode->vdisplay : 480;
+   crtc_id = vbox_crtc->crtc_id;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-bpp   = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
-pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
+   bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
+   pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
-bpp   = crtc->enabled ? CRTC_FB(crtc)->bits_per_pixel : 32;
-pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
+   bpp = crtc->enabled ? CRTC_FB(crtc)->bits_per_pixel : 32;
+   pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
 #else
-bpp   = crtc->enabled ? CRTC_FB(crtc)->bits_per_pixel : 32;
-pitch = crtc->enabled ? CRTC_FB(crtc)->pitch : width * bpp / 8;
+   bpp = crtc->enabled ? CRTC_FB(crtc)->bits_per_pixel : 32;
+   pitch = crtc->enabled ? CRTC_FB(crtc)->pitch : width * bpp / 8;
 #endif
-x_offset = vbox->single_framebuffer ? crtc->x : vbox_crtc->x_hint;
-y_offset = vbox->single_framebuffer ? crtc->y : vbox_crtc->y_hint;
-/* This is the old way of setting graphics modes.  It assumed one screen
- * and a frame-buffer at the start of video RAM.  On older versions of
- * VirtualBox, certain parts of the code still assume that the first
- * screen is programmed this way, so try to fake it. */
-if (   vbox_crtc->crtc_id == 0
-&& crtc->enabled
-&& vbox_crtc->fb_offset / pitch < 0x - crtc->y
-&& vbox_crtc->fb_offset % (bpp / 8) == 0)
-VBoxVideoSetModeRegisters(width, height, pitch * 8 / bpp,
+   x_offset = vbox->single_framebuffer ? crtc->x : vbox_crtc->x_hint;
+   y_offset = vbox->single_framebuffer ? crtc->y : vbox_crtc->y_hint;
+
+   /*
+* This is the old way of setting graphics modes.  It assumed one screen
+* and a frame-buffer at the start of video RAM.  On older versions of
+* VirtualBox, certain parts of the code still assume that the first
+* screen is programmed this way, so try to fake it.
+*/
+   if (vbox_crtc->crtc_id == 0 && crtc->enabled &&
+   vbox_crtc->fb_offset / pitch < 0x - crtc->y &&
+   vbox_crtc->fb_offset % (bpp / 8) == 0)
+   VBoxVideoSetModeRegisters(
+   width, height, pitch * 8 / bpp,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
-  CRTC_FB(crtc)->format->cpp[0] * 8,
+   CRTC_FB(crtc)->format->cpp[0] * 8,
 #else
-

[vbox-dev] [Patch] No more eRRRors.

2017-06-08 Thread Kalogrianitis Socratis
I was going through a VBoxHardening.log while searching for "error". I bumped 
upon a string that looked like it, but it wasn't. it was an ERRROR with 3 "R"s. 
So, a global search for "errror" and a replace, results in the following patch. 
Sure, most of them are in comments but there are two in the actual results, 
like the one in "SUPHardenedVerifyImage-win.cpp" that actually bit me. And you 
might as well fix them all, while at it.

Meanwhile, going through them, I saw two instances of "NS_ERROR_UNEXPECTD" 
which clearly mean "NS_ERROR_UNEXPECTED", like the rest 239 instances in the 
trunk. So I fixed those as well.

This patch is provided under the MIT license.

Socratis



Index: 
src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/public/ipcITransactionService.idl
===
--- 
src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/public/ipcITransactionService.idl
  (revision 67279)
+++ 
src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/public/ipcITransactionService.idl
  (working copy)
@@ -160,7 +160,7 @@
 *
 * @returns NS_ERROR_FAILURE is something goes wrong
 *
-* @returns NS_ERRROR_UNEXPECTD if the domain does not have an observer 
+* @returns NS_ERROR_UNEXPECTED if the domain does not have an observer 
 *  attached
 */
   void detach(in ACString aDomainName);
@@ -188,7 +188,7 @@
 *
 * @returns NS_ERROR_FAILURE is something goes wrong
 *
-* @returns NS_ERRROR_UNEXPECTD if the domain does not have an observer 
+* @returns NS_ERROR_UNEXPECTED if the domain does not have an observer 
 *  attached
 */
   void flush(in ACString aDomainName, in PRBool aLockingCall);



Index: 
src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
===
--- 
src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
  (revision 67279)
+++ 
src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
  (working copy)
@@ -2195,7 +2195,7 @@
 
   @retval EFI_SUCCES   The check on the Data IN PDU is passed and some 
update
actions are taken.
-  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol errror happened.
+  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.
   @retval EFI_BAD_BUFFER_SIZEE The buffer was not the proper size for the 
request.
   @retval Others   Other errors as indicated.
 **/
@@ -2284,7 +2284,7 @@
   @param[in, out]  PacketThe EXT SCSI PASS THRU request packet.
 
   @retval EFI_SUCCES The R2T PDU is valid and the solicited data is 
sent out.
-  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.
+  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
   @retval Others Other errors as indicated.
 **/
 EFI_STATUS
@@ -2350,7 +2350,7 @@
   @param[in, out]  Packet   The EXT SCSI PASS THRU request packet.
 
   @retval EFI_SUCCES The Response PDU is processed.
-  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.
+  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
   @retval EFI_BAD_BUFFER_SIZEE The buffer was not the proper size for the 
request.
   @retval Others Other errors as indicated.
 **/
@@ -2457,7 +2457,7 @@
 
   @retval EFI_SUCCES The NOP In PDU is processed and the related 
sequence
  numbers are updated.
-  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.
+  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
 **/
 EFI_STATUS
 IScsiOnNopInRcvd (



Index: src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiProto.c
===
--- src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiProto.c  
(revision 67279)
+++ src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiProto.c  
(working copy)
@@ -2502,7 +2502,7 @@
 
   @retval EFI_SUCCES   The check on the Data IN PDU is passed and some 
update
actions are taken.
-  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol errror occurred.
+  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error occurred.
   @retval EFI_BAD_BUFFER_SIZEE The buffer was not the proper size for the 
request.
   @retval Others   Other errors as indicated.
 
@@ -2593,7 +2593,7 @@
   @param[in, out]  PacketThe EXT SCSI PASS THRU request packet.
 
   @retval EFI_SUCCES The R2T PDU is valid and the solicited data is 
sent out.
-  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror occurred.
+  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error occurred.
   @retval Others Other errors as indicated.
 
 **/
@@ -2661,7 +2661,7 @@
   @param[in, out]  Packet   The EXT SCSI PASS