Re: [PATCH] fbdev/xen-fbfront: Assign fb_info->device

2024-09-10 Thread Arthur Borsboom
On Tue, 10 Sept 2024 at 10:33, Greg KH  wrote:
>
> On Tue, Sep 10, 2024 at 10:13:01AM +0200, Roger Pau Monné wrote:
> > On Tue, Sep 10, 2024 at 09:29:30AM +0200, Thomas Zimmermann wrote:
> > > Hi
> > >
> > > Am 10.09.24 um 09:22 schrieb Roger Pau Monné:
> > > > On Mon, Sep 09, 2024 at 10:09:16PM -0400, Jason Andryuk wrote:
> > > > > From: Jason Andryuk 
> > > > >
> > > > > Probing xen-fbfront faults in video_is_primary_device().  The 
> > > > > passed-in
> > > > > struct device is NULL since xen-fbfront doesn't assign it and the
> > > > > memory is kzalloc()-ed.  Assign fb_info->device to avoid this.
> > > > >
> > > > > This was exposed by the conversion of fb_is_primary_device() to
> > > > > video_is_primary_device() which dropped a NULL check for struct 
> > > > > device.
> > > > >
> > > > > Fixes: f178e96de7f0 ("arch: Remove struct fb_info from video helpers")
> > > > > Reported-by: Arthur Borsboom 
> > > > > Closes: 
> > > > > https://lore.kernel.org/xen-devel/CALUcmUncX=lkxweisitksdy-coe8qkswhfvccneokfrkd0z...@mail.gmail.com/
> > > > > Tested-by: Arthur Borsboom 
> > > > > CC: sta...@vger.kernel.org
> > > > > Signed-off-by: Jason Andryuk 
> > > > Reviewed-by: Roger Pau Monné 
> > > >
> > > > > ---
> > > > > The other option would be to re-instate the NULL check in
> > > > > video_is_primary_device()
> > > > I do think this is needed, or at least an explanation.  The commit
> > > > message in f178e96de7f0 doesn't mention anything about
> > > > video_is_primary_device() not allowing being passed a NULL device
> > > > (like it was possible with fb_is_primary_device()).
> > > >
> > > > Otherwise callers of video_is_primary_device() would need to be
> > > > adjusted to check for device != NULL.
> > >
> > > The helper expects a non-NULL pointer. We might want to document this.
> >
> > A BUG_ON(!dev); might be enough documentation that the function
> > expected a non-NULL dev IMO.
>
> No need for that, don't check for things that will never happen.

And yet, here we are, me reporting a kernel/VM crash due to a thing
that will never happen, see 'Closes' above.

I don't want to suggest BUG_ON is the right approach; I have no idea.
I just want to mention that (!dev) did happen. :-)


[xen_fbfront] - Xen PVH VM: kernel upgrade 6.9.10 > 6.10.7 results in crash

2024-09-04 Thread Arthur Borsboom
After upgrading kernel 6.9.10 to 6.10.7 all Xen PVH VM's became unavailable.
Downgrading the kernel back to 6.9.10 makes the VM's work again.

Snippet stack trace + kernel logs (good and bad) in attachments.

Sep 01 08:59:21 web3..com kernel: xen_netfront: Initialising Xen
virtual ethernet driver
Sep 01 08:59:21 web3..com systemd-udevd[248]: vfb-0: Worker [250]
terminated by signal 9 (KILL).
Sep 01 08:59:21 web3..com kernel: BUG: kernel NULL pointer
dereference, address: 0060
Sep 01 08:59:21 web3..com kernel: #PF: supervisor read access in
kernel mode
Sep 01 08:59:21 web3..com kernel: #PF: error_code(0x) -
not-present page
Sep 01 08:59:21 web3..com kernel: PGD 0 P4D 0
Sep 01 08:59:21 web3..com kernel: Oops: Oops:  [#1] PREEMPT SMP
PTI
Sep 01 08:59:21 web3..com kernel: CPU: 0 PID: 250 Comm:
(udev-worker) Not tainted 6.10.7-arch1-1 #1
2b2df360fbb0436393dc89f6589e9eeea2964ecb
Sep 01 08:59:21 web3..com kernel: RIP:
0010:video_is_primary_device+0x9/0x40
Sep 01 08:59:21 web3..com kernel: Code: 48 89 d8 5b c3 cc cc cc cc
0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3
0f 1e fa 0f 1f 44 00 00 <48> 81 7f 60 80 e3 54 90 74 07 31 c0 c3 cc cc cc
cc 53 48 89 fb 48
Sep 01 08:59:21 web3..com kernel: RSP: :bb06808d7a60
EFLAGS: 00010246
Sep 01 08:59:21 web3..com kernel: RAX:  RBX:
90ca41367800 RCX: 
Sep 01 08:59:21 web3..com kernel: RDX:  RSI:
0246 RDI: 
Sep 01 08:59:21 web3..com kernel: RBP:  R08:
0060 R09: 
Sep 01 08:59:21 web3..com kernel: R10: bb06808d7a78 R11:
0006 R12: bb06808d7a90
Sep 01 08:59:21 web3..com kernel: R13: 90ca41367a88 R14:
90ca41367a60 R15: 90cb41330788
Sep 01 08:59:21 web3..com kernel: FS:  72bfd74c0880()
GS:90ce33a0() knlGS:
Sep 01 08:59:21 web3..com kernel: CS:  0010 DS:  ES:  CR0:
80050033
Sep 01 08:59:21 web3..com kernel: CR2: 0060 CR3:
01326002 CR4: 003706f0
Sep 01 08:59:21 web3..com kernel: DR0:  DR1:
 DR2: 
Sep 01 08:59:21 web3..com kernel: DR3:  DR6:
fffe0ff0 DR7: 0400
Sep 01 08:59:21 web3..com kernel: Call Trace:
Sep 01 08:59:21 web3..com kernel:  
Sep 01 08:59:21 web3..com kernel:  ? __die_body.cold+0x19/0x27
Sep 01 08:59:21 web3..com kernel:  ? page_fault_oops+0x15a/0x2d0
Sep 01 08:59:21 web3..com kernel:  ? __kernfs_new_node+0x17d/0x200
Sep 01 08:59:21 web3..com kernel:  ? exc_page_fault+0x81/0x190
Sep 01 08:59:21 web3..com kernel:  ? asm_exc_page_fault+0x26/0x30
Sep 01 08:59:21 web3..com kernel:  ?
video_is_primary_device+0x9/0x40
Sep 01 08:59:21 web3..com kernel:  do_fb_registered+0x100/0x110
Sep 01 08:59:21 web3..com kernel:  fbcon_fb_registered+0x4d/0x70
Sep 01 08:59:21 web3..com kernel:  register_framebuffer+0x198/0x2a0
Sep 01 08:59:21 web3..com kernel:  xenfb_probe+0x30d/0x430
[xen_fbfront 61323dae510a72b3d2c332a2b0273cf6365e9002]
Sep 01 08:59:21 web3..com kernel:  xenbus_dev_probe+0xe3/0x1d0
Sep 01 08:59:21 web3..com kernel:  really_probe+0xdb/0x340
Sep 01 08:59:21 web3..com kernel:  ? pm_runtime_barrier+0x54/0x90
Sep 01 08:59:21 web3..com kernel:  ? __pfx___driver_attach+0x10/0x10
Sep 01 08:59:21 web3..com kernel:  __driver_probe_device+0x78/0x110
Sep 01 08:59:21 web3..com kernel:  driver_probe_device+0x1f/0xa0
Sep 01 08:59:21 web3..com kernel:  __driver_attach+0xba/0x1c0
Sep 01 08:59:21 web3..com kernel:  bus_for_each_dev+0x8c/0xe0
Sep 01 08:59:21 web3..com kernel:  bus_add_driver+0x112/0x1f0
Sep 01 08:59:21 web3..com kernel:  driver_register+0x72/0xd0
Sep 01 08:59:21 web3..com kernel:
 __xenbus_register_frontend+0x2b/0x50
Sep 01 08:59:21 web3..com kernel:  ? __pfx_xenfb_init+0x10/0x10
[xen_fbfront 61323dae510a72b3d2c332a2b0273cf6365e9002]
Sep 01 08:59:21 web3..com kernel:  do_one_initcall+0x58/0x310
Sep 01 08:59:21 web3..com kernel:  do_init_module+0x60/0x220
Sep 01 08:59:21 web3..com kernel:  init_module_from_file+0x89/0xe0
Sep 01 08:59:21 web3..com kernel:
 idempotent_init_module+0x121/0x320
Sep 01 08:59:21 web3..com kernel:  __x64_sys_finit_module+0x5e/0xb0
Sep 01 08:59:21 web3..com kernel:  do_syscall_64+0x82/0x190
Sep 01 08:59:21 web3..com kernel:  ? do_user_addr_fault+0x36c/0x620
Sep 01 08:59:21 web3..com kernel:  ? clear_bhb_loop+0x25/0x80
Sep 01 08:59:21 web3..com kernel:  ? clear_bhb_loop+0x25/0x80
Sep 01 08:59:21 web3..com kernel:  ? clear_bhb_loop+0x25/0x80
Sep 01 08:59

[PATCH 1/1] GPU-DRM-GMA500: Deletion of unnecessary checks before two function calls

2014-10-26 Thread Arthur Borsboom
I still have the hardware in use and I am willing to test.

If necessary, please send me a URL to the snapshot of the kernel with the
modified code. I can compile this (takes about 8 hours ;-) on the high
speed atom n2600) and run a couple of random tests, such as starting the
WM, browsing some webpages, changing resolution, and run a 2D benchmark.

Greetings,
Arthur Borsboom
On 26 Oct 2014 13:10, "SF Markus Elfring" 
wrote:

> > What platforms have you tested the code on at this point ?
>
> None. - My "test computer" does not provide the corresponding hardware for
> the
> affected driver source files.
>
> Regards,
> Markus
>
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20141026/a28726a1/attachment.html>


[PATCH 1/1] drm/gma500: Code cleanup - styling

2014-03-20 Thread Arthur Borsboom
Removed line return in the middle of function argument list.

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_intel_display.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c 
b/drivers/gpu/drm/gma500/psb_intel_display.c
index b11cbd6..eb91fa7 100644
--- a/drivers/gpu/drm/gma500/psb_intel_display.c
+++ b/drivers/gpu/drm/gma500/psb_intel_display.c
@@ -547,8 +547,7 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
gma_crtc->mode_dev = mode_dev;
gma_crtc->cursor_addr = 0;

-   drm_crtc_helper_add(&gma_crtc->base,
-   dev_priv->ops->crtc_helper);
+   drm_crtc_helper_add(&gma_crtc->base, dev_priv->ops->crtc_helper);

/* Setup the array of drm_connector pointer array */
gma_crtc->mode_set.crtc = &gma_crtc->base;
-- 
1.9.0



[PATCH 1/1] drm/gma500: Code cleanup - inline documentation

2014-03-20 Thread Arthur Borsboom
Mainly styling fixes of inline documentation

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/framebuffer.c   |  36 ++--
 drivers/gpu/drm/gma500/psb_intel_display.c |  35 ++--
 drivers/gpu/drm/gma500/psb_intel_reg.h | 259 +
 drivers/gpu/drm/gma500/psb_irq.c   |  64 +++
 4 files changed, 181 insertions(+), 213 deletions(-)

diff --git a/drivers/gpu/drm/gma500/framebuffer.c 
b/drivers/gpu/drm/gma500/framebuffer.c
index e7fcc14..0dd015a 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -103,8 +103,10 @@ static int psbfb_pan(struct fb_var_screeninfo *var, struct 
fb_info *info)
 *  the actual fb is mapped. In our case that isn't quite true.
 */
if (psbfb->gtt->npage) {
-   /* GTT roll shifts in 4K pages, we need to shift the right
-  number of pages */
+   /*
+* GTT roll shifts in 4K pages, we need to shift the right
+  number of pages
+*/
int pages = info->fix.line_length >> 12;
psb_gtt_roll(dev, psbfb->gtt, var->yoffset * pages);
}
@@ -229,7 +231,7 @@ static struct fb_ops psbfb_unaccel_ops = {
.fb_ioctl = psbfb_ioctl,
 };

-/**
+/*
  * psb_framebuffer_init-   initialize a framebuffer
  * @dev: our DRM device
  * @fb: framebuffer to set up
@@ -270,7 +272,7 @@ static int psb_framebuffer_init(struct drm_device *dev,
return 0;
 }

-/**
+/*
  * psb_framebuffer_create  -   create a framebuffer backed by gt
  * @dev: our DRM device
  * @mode_cmd: the description of the requested mode
@@ -302,7 +304,7 @@ static struct drm_framebuffer *psb_framebuffer_create
return &fb->base;
 }

-/**
+/*
  * psbfb_alloc -   allocate frame buffer memory
  * @dev: the DRM device
  * @aligned_size: space needed
@@ -327,7 +329,7 @@ static struct gtt_range *psbfb_alloc(struct drm_device 
*dev, int aligned_size)
return NULL;
 }

-/**
+/*
  * psbfb_create-   create a framebuffer
  * @fbdev: the framebuffer device
  * @sizes: specification of the layout
@@ -386,9 +388,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,

if (backing == NULL) {
/*
-*  We couldn't get the space we wanted, fall back to the
-*  display engine requirement instead.  The HW requires
-*  the pitch to be 64 byte aligned
+* We couldn't get the space we wanted, fall back to the
+* display engine requirement instead.  The HW requires
+* the pitch to be 64 byte aligned
 */

gtt_roll = 0;   /* Don't use GTT accelerated scrolling */
@@ -489,7 +491,7 @@ out_err1:
return ret;
 }

-/**
+/*
  * psb_user_framebuffer_create -   create framebuffer
  * @dev: our DRM device
  * @filp: client file
@@ -549,9 +551,11 @@ static int psbfb_probe(struct drm_fb_helper *helper,
if (bytespp == 3)   /* no 24bit packed */
bytespp = 4;

-   /* If the mode will not fit in 32bit then switch to 16bit to get
+   /*
+* If the mode will not fit in 32bit then switch to 16bit to get
   a console on full resolution. The X mode setting server will
-  allocate its own 32bit GEM framebuffer */
+  allocate its own 32bit GEM framebuffer
+*/
if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height >
dev_priv->vram_stolen_size) {
 sizes->surface_bpp = 16;
@@ -633,7 +637,7 @@ static void psbfb_output_poll_changed(struct drm_device 
*dev)
drm_fb_helper_hotplug_event(&fbdev->psb_fb_helper);
 }

-/**
+/*
  * psb_user_framebuffer_create_handle - add hamdle to a framebuffer
  * @fb: framebuffer
  * @file_priv: our DRM file
@@ -652,7 +656,7 @@ static int psb_user_framebuffer_create_handle(struct 
drm_framebuffer *fb,
return drm_gem_handle_create(file_priv, &r->gem, handle);
 }

-/**
+/*
  * psb_user_framebuffer_destroy-   destruct user created fb
  * @fb: framebuffer
  *
@@ -666,7 +670,7 @@ static void psb_user_framebuffer_destroy(struct 
drm_framebuffer *fb)

/* Let DRM do its clean up */
drm_framebuffer_cleanup(fb);
-   /*  We are no longer using the resource in GEM */
+   /* We are no longer using the resource in GEM */
drm_gem_object_unreference_unlocked(&r->gem);
kfree(fb);
 }
@@ -761,7 +765,7 @@ void psb_modeset_init(struct drm_device *dev)
dev->mode_config.funcs = &psb_mode_funcs;

/* set memory base */
-   /* Oaktrail and Poulsbo should use BAR 2*/
+   /* Oaktrail and Poulsbo should use BAR 2 */
pci_

[PATCH 1/1] drm/gma500: Code cleanup - remove double variable assignment

2014-03-20 Thread Arthur Borsboom
The same assignment has already been taken place before in the
drm_driver struct

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index b686e56..edb903b 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -358,7 +358,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long flags)

dev->vblank_disable_allowed = true;
dev->max_vblank_count = 0xff; /* only 24 bits of frame count */
-   dev->driver->get_vblank_counter = psb_get_vblank_counter;

psb_modeset_init(dev);
psb_fbdev_init(dev);
-- 
1.9.0



[PATCH 3/3] drm/gma500: Code cleanup - inline documentation

2014-03-15 Thread Arthur Borsboom
Improve readability by adding/changing inline documentation

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c |  33 ++---
 drivers/gpu/drm/gma500/psb_drv.h | 146 ++-
 2 files changed, 58 insertions(+), 121 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 1708cca..aee8351 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -46,12 +46,25 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent);
 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);

-
+/*
+ * The table below contains a mapping of the PCI vendor ID and the PCI Device 
ID
+ * to the different groups of PowerVR 5-series chip designs
+ *
+ * 0x8086 = Intel Corporation
+ *
+ * PowerVR SGX535- Poulsbo- Intel GMA 500, Intel Atom Z5xx
+ * PowerVR SGX535- Moorestown - Intel GMA 600
+ * PowerVR SGX535- Oaktrail   - Intel GMA 600, Intel Atom Z6xx, E6xx
+ * PowerVR SGX540- Medfield   - Intel Atom Z2460
+ * PowerVR SGX544MP2 - Medfield   -
+ * PowerVR SGX545- Cedartrail - Intel GMA 3600, Intel Atom D2500, N2600
+ * PowerVR SGX545- Cedartrail - Intel GMA 3650, Intel Atom D2550, D2700,
+ *  N2800
+ */
 static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
 #if defined(CONFIG_DRM_GMA600)
-   /* Atom E620 */
{ 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
{ 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
{ 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
@@ -94,10 +107,7 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);

-/*
- * Standard IOCTLs.
- */
-
+/* Standard IOCTLs */
 #define DRM_IOCTL_GMA_ADB  \
DRM_IOWR(DRM_GMA_ADB + DRM_COMMAND_BASE, uint32_t)
 #define DRM_IOCTL_GMA_MODE_OPERATION   \
@@ -202,8 +212,7 @@ static int psb_driver_unload(struct drm_device *dev)
 {
struct drm_psb_private *dev_priv = dev->dev_private;

-   /* Kill vblank etc here */
-
+   /* TODO: Kill vblank etc here */

if (dev_priv) {
if (dev_priv->backlight_device)
@@ -272,6 +281,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long flags)
struct drm_connector *connector;
struct gma_encoder *gma_encoder;

+   /* allocating and initializing driver private data */
dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
if (dev_priv == NULL)
return -ENOMEM;
@@ -363,6 +373,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long flags)

acpi_video_register();

+   /* Setup vertical blanking handling */
ret = drm_vblank_init(dev, dev_priv->num_pipe);
if (ret)
goto out_err;
@@ -408,11 +419,11 @@ static int psb_driver_load(struct drm_device *dev, 
unsigned long flags)
return ret;
psb_intel_opregion_enable_asle(dev);
 #if 0
-   /*enable runtime pm at last*/
+   /* Enable runtime pm at last */
pm_runtime_enable(&dev->pdev->dev);
pm_runtime_set_active(&dev->pdev->dev);
 #endif
-   /*Intel drm driver load is done, continue doing pvr load*/
+   /* Intel drm driver load is done, continue doing pvr load */
return 0;
 out_err:
psb_driver_unload(dev);
@@ -553,7 +564,7 @@ static int psb_mode_operation_ioctl(struct drm_device *dev, 
void *data,
arg->data = resp;
}

-   /*do some clean up work*/
+   /* Do some clean up work */
if (mode)
drm_mode_destroy(dev, mode);
 mode_op_out:
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index 7275578..f3b12c9 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -60,10 +60,7 @@ enum {
 #define IS_MFLD(dev) (((dev)->pdev->device & 0xfff8) == 0x0130)
 #define IS_CDV(dev) (((dev)->pdev->device & 0xfff0) == 0x0be0)

-
-/*
- * Hardware offsets
- */
+/* Hardware offsets */
 #define PSB_VDC_OFFSET  0x
 #define PSB_VDC_SIZE0x8
 #define MRST_MMIO_SIZE  0xC
@@ -71,16 +68,14 @@ enum {
 #define PSB_SGX_SIZE0x8000
 #define PSB_SGX_OFFSET  0x0004
 #define MRST_SGX_OFFSET 0x0008
-/*
- * PCI resource identifiers
- */
+
+/* PCI resource identifiers */
 #define PSB_MMIO_RESOURCE   0
 #define PSB_AUX_RESOURCE0
 #define PSB_GATT_RESOURCE  

[PATCH 2/3] drm/gma500: Code cleanup - style fixes

2014-03-15 Thread Arthur Borsboom
Code cleanup by following i915 constant/variable names and ordering
Code cleanup by following directions from kernel doc: Codingstyle
Code cleanup by following directions from kernel doc: DRM

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 135 +++
 drivers/gpu/drm/gma500/psb_drv.h |  22 +++
 2 files changed, 77 insertions(+), 80 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index a10db3d..1708cca 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -37,9 +37,11 @@
 #include 
 #include 

+static struct drm_driver driver;
+
 static int drm_psb_trap_pagefaults;

-static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent);

 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
@@ -49,44 +51,44 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
 #if defined(CONFIG_DRM_GMA600)
-   { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
/* Atom E620 */
-   { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
 #endif
 #if defined(CONFIG_DRM_MEDFIELD)
-   {0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0133, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0134, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
+   { 0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0133, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0134, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
 #endif
 #if defined(CONFIG_DRM_GMA3600)
-   { 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be7, PCI_

[PATCH 1/3] drm/gma500: Code cleanup - removal of centralized exiting of function

2014-03-15 Thread Arthur Borsboom
Removed centralized exiting of function (goto statement), since it was
the only used in one single location with only a return statement.

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 1199180..a10db3d 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -169,12 +169,9 @@ static int psb_do_init(struct drm_device *dev)

uint32_t stolen_gtt;

-   int ret = -ENOMEM;
-
if (pg->mmu_gatt_start & 0x0FFF) {
dev_err(dev->dev, "Gatt must be 256M aligned. This is a 
bug.\n");
-   ret = -EINVAL;
-   goto out_err;
+   return -EINVAL;
}


@@ -199,8 +196,6 @@ static int psb_do_init(struct drm_device *dev)
/* mmu_gatt ?? */
PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
return 0;
-out_err:
-   return ret;
 }

 static int psb_driver_unload(struct drm_device *dev)
-- 
1.9.0



[PATCH 1/3] drm/gma500: Code cleanup - inline documentation

2014-03-15 Thread Arthur Borsboom
Hi Patrik,

Thanks for reviewing.

* The 80 character comment slipped with all the 80+ pci definitions. Will
fix.
* Some single line comments were already before in multiple line comment
style. Nevertheless, good moment to get rid of them. Will fix.
* Although for a beginner like me, I believe inline DRM documentation makes
reading the code easier. However, you are right that maintaining the same
documentation twice is a waste of time. Will fix.
* Driver definitions and driver history were copied from i915 to get more
in line. Nevertheless, you might be right; it might be an overkill. Will
fix.
* SGU MMX comment will be merged.
* The 72 column git commit makes sense. Maybe this explains why my editor
was predefined with this number. ;) Will fix.

Be prepared for three new patches.

On 15 March 2014 00:04, Patrik Jakobsson wrote:

> On Thu, Mar 13, 2014 at 10:49 PM, Arthur Borsboom
>  wrote:
> > Improve readability by adding/changing inline documentation
> >
> > Signed-off-by: Arthur Borsboom 
> > ---
> >  drivers/gpu/drm/gma500/psb_drv.c | 56
> +---
> >  drivers/gpu/drm/gma500/psb_drv.h | 24 +++--
> >  2 files changed, 63 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/gma500/psb_drv.c
> b/drivers/gpu/drm/gma500/psb_drv.c
> > index 1199180..5c6cdd0 100644
> > --- a/drivers/gpu/drm/gma500/psb_drv.c
> > +++ b/drivers/gpu/drm/gma500/psb_drv.c
> > @@ -44,7 +44,20 @@ static int psb_probe(struct pci_dev *pdev, const
> struct pci_device_id *ent);
> >  MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
> >  module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
> >
> > -
> > +/*
> > + * The table below contains a mapping of the PCI vendor ID and the PCI
> Device ID
> > + * to the different groups of PowerVR 5-series chip designs
> > + *
> > + * 0x8086 = Intel Corporation
> > + *
> > + * PowerVR SGX535- Poulsbo- Intel GMA 500, Intel Atom Z5xx
> > + * PowerVR SGX535- Moorestown - Intel GMA 600
> > + * PowerVR SGX535- Oaktrail   - Intel GMA 600, Intel Atom Z6xx, E6xx
> > + * PowerVR SGX540- Medfield   - Intel Atom Z2460
> > + * PowerVR SGX544MP2 - Medfield   -
> > + * PowerVR SGX545- Cedartrail - Intel GMA 3600, Intel Atom D2500,
> N2600
> > + * PowerVR SGX545- Cedartrail - Intel GMA 3650, Intel Atom D2550,
> D2700, N2800
>
> There is no reason to break the 80 col line limit here. Here is Linus'
> motivation
> if that makes more sense than mine: https://lkml.org/lkml/2012/2/3/394
>
> And sometimes we break it by mistake, but that is a different thing.
>
> > + */
> >  static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
> > { 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long)
> &psb_chip_ops },
> > { 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long)
> &psb_chip_ops },
> > @@ -207,8 +220,7 @@ static int psb_driver_unload(struct drm_device *dev)
> >  {
> > struct drm_psb_private *dev_priv = dev->dev_private;
> >
> > -   /* Kill vblank etc here */
> > -
> > +   /* TODO: Kill vblank etc here */
> >
> > if (dev_priv) {
> > if (dev_priv->backlight_device)
> > @@ -268,7 +280,22 @@ static int psb_driver_unload(struct drm_device *dev)
> > return 0;
> >  }
> >
> > -
> > +/*
> > + * psb_driver_load - setup chip and create an initial config
> > + * @dev: DRM device
> > + * @flags: startup flags, containing the driver_data field belonging to
> > + * the PCI device ID
> > + *
> > + * The driver load routine has to do several things:
> > + *   - allocating and initializing driver private data
> > + *   - performing resource allocation and mapping
> > + *   - initialize the memory manager
> > + *   - setup the DRM framebuffer with the allocated memory
> > + *   - install the IRQ handler
> > + *   - setup vertical blanking handling
> > + *   - mode setting
> > + *   - set inital output configuration
> > + */
>
> This is not a constructive comment. It just repeats the DRM documentation.
> This
> might look harmless but it is actually a bad thing. For every comment we
> add to
> the driver, we add one more place that we must remember to update when we
> change
> our code. If you look at the driver, you'll see plenty of places where
> comments
> never got removed, even though the code it talks about is long gone.
>
> And most of the time, the code speaks for itself.
>
> >  static int psb_driver_load(struct drm_device *dev, u

[PATCH 3/3] drm/gma500: Code cleanup - removal of centralized exiting of function

2014-03-13 Thread Arthur Borsboom
Removed centralized exiting of function (goto statement), since it was the only 
used in one single location with only a return statement.

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index ae95e31..8d6ad6c 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -182,12 +182,9 @@ static int psb_do_init(struct drm_device *dev)

uint32_t stolen_gtt;

-   int ret = -ENOMEM;
-
if (pg->mmu_gatt_start & 0x0FFF) {
dev_err(dev->dev, "Gatt must be 256M aligned. This is a 
bug.\n");
-   ret = -EINVAL;
-   goto out_err;
+   return -EINVAL;
}

stolen_gtt = (pg->stolen_size >> PAGE_SHIFT) * 4;
@@ -210,8 +207,6 @@ static int psb_do_init(struct drm_device *dev)
/* mmu_gatt ?? */
PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
return 0;
-out_err:
-   return ret;
 }

 static int psb_driver_unload(struct drm_device *dev)
-- 
1.9.0



[PATCH 2/3] drm/gma500: Code cleanup - style fixes

2014-03-13 Thread Arthur Borsboom
Cleanup of code by following i915 constant/variable names and ordering
Cleanup of code by following directions from kernel documentation: Codingstyle
Cleanup of code by following directions from kernel documentation: DRM

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 132 +++
 drivers/gpu/drm/gma500/psb_drv.h |  39 
 2 files changed, 77 insertions(+), 94 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 5c6cdd0..ae95e31 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -37,9 +37,11 @@
 #include 
 #include 

+static struct drm_driver driver;
+
 static int drm_psb_trap_pagefaults;

-static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent);

 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
@@ -62,44 +64,43 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
 #if defined(CONFIG_DRM_GMA600)
-   { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   /* Atom E620 */
-   { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
+   { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops },
 #endif
 #if defined(CONFIG_DRM_MEDFIELD)
-   {0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0133, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0134, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
-   {0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
+   { 0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0133, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0134, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
+   { 0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops 
},
 #endif
 #if defined(CONFIG_DRM_GMA3600)
-   { 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chi

[PATCH 1/3] drm/gma500: Code cleanup - inline documentation

2014-03-13 Thread Arthur Borsboom
Improve readability by adding/changing inline documentation

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 56 +---
 drivers/gpu/drm/gma500/psb_drv.h | 24 +++--
 2 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 1199180..5c6cdd0 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -44,7 +44,20 @@ static int psb_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent);
 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);

-
+/*
+ * The table below contains a mapping of the PCI vendor ID and the PCI Device 
ID
+ * to the different groups of PowerVR 5-series chip designs
+ *
+ * 0x8086 = Intel Corporation
+ *
+ * PowerVR SGX535- Poulsbo- Intel GMA 500, Intel Atom Z5xx
+ * PowerVR SGX535- Moorestown - Intel GMA 600
+ * PowerVR SGX535- Oaktrail   - Intel GMA 600, Intel Atom Z6xx, E6xx
+ * PowerVR SGX540- Medfield   - Intel Atom Z2460
+ * PowerVR SGX544MP2 - Medfield   -
+ * PowerVR SGX545- Cedartrail - Intel GMA 3600, Intel Atom D2500, N2600
+ * PowerVR SGX545- Cedartrail - Intel GMA 3650, Intel Atom D2550, D2700, 
N2800
+ */
 static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
@@ -207,8 +220,7 @@ static int psb_driver_unload(struct drm_device *dev)
 {
struct drm_psb_private *dev_priv = dev->dev_private;

-   /* Kill vblank etc here */
-
+   /* TODO: Kill vblank etc here */

if (dev_priv) {
if (dev_priv->backlight_device)
@@ -268,7 +280,22 @@ static int psb_driver_unload(struct drm_device *dev)
return 0;
 }

-
+/*
+ * psb_driver_load - setup chip and create an initial config
+ * @dev: DRM device
+ * @flags: startup flags, containing the driver_data field belonging to
+ * the PCI device ID
+ *
+ * The driver load routine has to do several things:
+ *   - allocating and initializing driver private data
+ *   - performing resource allocation and mapping
+ *   - initialize the memory manager
+ *   - setup the DRM framebuffer with the allocated memory
+ *   - install the IRQ handler
+ *   - setup vertical blanking handling
+ *   - mode setting
+ *   - set inital output configuration
+ */
 static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 {
struct drm_psb_private *dev_priv;
@@ -278,6 +305,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long chipset)
struct drm_connector *connector;
struct gma_encoder *gma_encoder;

+   /* allocating and initializing driver private data */
dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
if (dev_priv == NULL)
return -ENOMEM;
@@ -369,6 +397,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long chipset)

acpi_video_register();

+   /*
+* Setup vertical blanking handling
+*/
ret = drm_vblank_init(dev, dev_priv->num_pipe);
if (ret)
goto out_err;
@@ -416,11 +447,11 @@ static int psb_driver_load(struct drm_device *dev, 
unsigned long chipset)
return ret;
psb_intel_opregion_enable_asle(dev);
 #if 0
-   /*enable runtime pm at last*/
+   /* Enable runtime pm at last */
pm_runtime_enable(&dev->pdev->dev);
pm_runtime_set_active(&dev->pdev->dev);
 #endif
-   /*Intel drm driver load is done, continue doing pvr load*/
+   /* Intel drm driver load is done, continue doing pvr load */
return 0;
 out_err:
psb_driver_unload(dev);
@@ -561,7 +592,7 @@ static int psb_mode_operation_ioctl(struct drm_device *dev, 
void *data,
arg->data = resp;
}

-   /*do some clean up work*/
+   /* Do some clean up work */
if (mode)
drm_mode_destroy(dev, mode);
 mode_op_out:
@@ -614,8 +645,8 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned 
int cmd,
/* FIXME: do we need to wrap the other side of this */
 }

-
-/* When a client dies:
+/*
+ * When a client dies:
  *- Check for and clean up flipped page state
  */
 static void psb_driver_preclose(struct drm_device *dev, struct drm_file *priv)
@@ -655,6 +686,13 @@ static const struct file_operations psb_gem_fops = {
.read = drm_read,
 };

+/*
+ * DRM driver structure initialization
+ *
+ * The drm_driver structure contains static information that describes
+ * the driver and features it supports, and pointers to methods that DRM
+ * core will call to implement DRM API.
+ */
 static struct drm_driver dri

[PATCH 1/1] drm/gma500: Code cleanup and adding inline documentation

2014-03-11 Thread Arthur Borsboom
drm/gma500: Cleanup of code by following i915 constant/variable names and 
ordering
drm/gma500: Cleanup of code by following directions from kernel documentation: 
Codingstyle
drm/gma500: Cleanup of code by following directions from kernel documentation: 
DRM
drm/gma500: Improve readability by adding inline documentation
drm/gma500: Removed centralized exiting of function (goto statement), since it 
was the only used in one single location with only a return statement.

CC: Patrik Jakobsson 

Signed-off-by: Arthur Borsboom 
---
 drivers/gpu/drm/gma500/psb_drv.c | 162 +--
 drivers/gpu/drm/gma500/psb_drv.h |  58 ++
 2 files changed, 111 insertions(+), 109 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 1199180..0432136 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -37,28 +37,42 @@
 #include 
 #include 

+static struct drm_driver driver;
+
 static int drm_psb_trap_pagefaults;

-static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*ent);

 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);

-
+/*
+ * The table below contains a mapping of the PCI vendor ID and the PCI Device 
ID
+ * to the different groups of PowerVR 5-series chip designs
+ *
+ * 0x8086 = Intel Coorperation
+ *
+ * PowerVR SGX535- Poulsbo- Intel GMA 500, Intel Atom Z5xx
+ * PowerVR SGX535- Moorestown - Intel GMA 600
+ * PowerVR SGX535- Oaktrail   - Intel GMA 600, Intel Atom Z6xx, E6xx
+ * PowerVR SGX540- Medfield   - Intel Atom Z2460
+ * PowerVR SGX544MP2 - Medfield   -
+ * PowerVR SGX545- Cedartrail - Intel GMA 3600, Intel Atom D2500, N2600
+ * PowerVR SGX545- Cedartrail - Intel GMA 3650, Intel Atom D2550, D2700, 
N2800
+ */
 static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
-   { 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
-   { 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
+   {0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops},
+   {0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops},
 #if defined(CONFIG_DRM_GMA600)
-   { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
-   /* Atom E620 */
-   { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
+   {0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) 
&oaktrail_chip_ops},
 #endif
 #if defined(CONFIG_DRM_MEDFIELD)
{0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
@@ -71,31 +85,30 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
{0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
 #endif
 #if defined(CONFIG_DRM_GMA3600)
-   { 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
-   { 0x8086, 0x0be7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_o