fixes for bc_cat master nokia
authorGrazvydas Ignotas <notasas@gmail.com>
Thu, 3 Jul 2014 21:47:08 +0000 (00:47 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 4 Jul 2014 00:35:24 +0000 (03:35 +0300)
Makefile
pvr/bc_cat.c
pvr/deviceclass.c
pvr/sysinfo.h

index 92787d4..4783eff 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,4 +3,4 @@ MAKECMDGOALS = all
 endif
 
 $(MAKECMDGOALS):
 endif
 
 $(MAKECMDGOALS):
-       make -C pvr $@
+       $(MAKE) -C pvr $@
index 53de981..698c1b3 100644 (file)
@@ -369,6 +369,7 @@ static PVRSRV_ERROR BC_DestroyBuffers(int id)
         }
 
     BCFreeKernelMem(psDevInfo->psSystemBuffer);
         }
 
     BCFreeKernelMem(psDevInfo->psSystemBuffer);
+    psDevInfo->psSystemBuffer = NULL;
     
     psDevInfo->ui32NumBuffers = 0;
     psDevInfo->sBufferInfo.pixelformat = PVRSRV_PIXEL_FORMAT_UNKNOWN;
     
     psDevInfo->ui32NumBuffers = 0;
     psDevInfo->sBufferInfo.pixelformat = PVRSRV_PIXEL_FORMAT_UNKNOWN;
@@ -497,7 +498,7 @@ static PVRSRV_ERROR BC_Unregister(int id)
 static int __init bc_cat_init(void)
 {
     struct device *bc_dev;
 static int __init bc_cat_init(void)
 {
     struct device *bc_dev;
-    int id;
+    int id = 0;
 
     /* texture buffer width should be multiple of 8 for OMAP3 ES3.x,
      * or 32 for ES2.x */
 
     /* texture buffer width should be multiple of 8 for OMAP3 ES3.x,
      * or 32 for ES2.x */
@@ -511,9 +512,8 @@ static int __init bc_cat_init(void)
     }
 
     bc_class = class_create(THIS_MODULE, DEVNAME);
     }
 
     bc_class = class_create(THIS_MODULE, DEVNAME);
-
     if (IS_ERR(bc_class)) {
     if (IS_ERR(bc_class)) {
-       printk(KERN_ERR DRVNAME ": upable to create device class\n");
+       printk(KERN_ERR DRVNAME ": unable to create device class\n");
        goto ExitUnregister;
     }
 
        goto ExitUnregister;
     }
 
@@ -529,18 +529,23 @@ static int __init bc_cat_init(void)
         if (BC_Register(id) != PVRSRV_OK) {
             printk (KERN_ERR DRVNAME ": can't register BC service %d\n", id);
             if (id > 0) {
         if (BC_Register(id) != PVRSRV_OK) {
             printk (KERN_ERR DRVNAME ": can't register BC service %d\n", id);
             if (id > 0) {
-                /* lets live with the drivers that we were able to create soi
+                /* let's live with the drivers that we were able to create so
                  * far, even though it isn't as many as we'd like
                  */
                  * far, even though it isn't as many as we'd like
                  */
+                 device_destroy(bc_class, MKDEV(major, id));
                  break;
             }
                  break;
             }
-            goto ExitUnregister;
+            goto ExitDestroyClass;
         }
     }
 
     return 0;
 
 ExitDestroyClass:
         }
     }
 
     return 0;
 
 ExitDestroyClass:
+    for (; id >= 0; id--) {
+        BC_Unregister(id);
+        device_destroy(bc_class, MKDEV(major, id));
+    }
     class_destroy(bc_class);
 ExitUnregister:
     unregister_chrdev(major, DEVNAME);
     class_destroy(bc_class);
 ExitUnregister:
     unregister_chrdev(major, DEVNAME);
@@ -554,12 +559,10 @@ static void __exit bc_cat_cleanup(void)
 
     for (id = 0; id < DEVICE_COUNT; id++) {
         if (BC_DestroyBuffers(id) != PVRSRV_OK) {
 
     for (id = 0; id < DEVICE_COUNT; id++) {
         if (BC_DestroyBuffers(id) != PVRSRV_OK) {
-            printk(KERN_ERR DRVNAME ": can't free texture buffers\n");
-            return;
+            printk(KERN_ERR DRVNAME ": can't free texture buffers, dev %d\n", id);
         }
         if (BC_Unregister(id) != PVRSRV_OK) {
         }
         if (BC_Unregister(id) != PVRSRV_OK) {
-            printk(KERN_ERR DRVNAME ": can't un-register BC service\n");
-            return;
+            printk(KERN_ERR DRVNAME ": can't un-register BC service, dev %d\n", id);
         }
         device_destroy(bc_class, MKDEV(major, id));
     }
         }
         device_destroy(bc_class, MKDEV(major, id));
     }
@@ -583,17 +586,16 @@ static PVRSRV_ERROR BCAllocContigMemory(IMG_UINT32 ui32Size,
                                  IMG_CPU_VIRTADDR *pLinAddr, 
                                  IMG_CPU_PHYADDR *pPhysAddr)
 {
                                  IMG_CPU_VIRTADDR *pLinAddr, 
                                  IMG_CPU_PHYADDR *pPhysAddr)
 {
-    IMG_VOID *pvLinAddr;
-    gfp_t mask = GFP_KERNEL;
-    
-    pvLinAddr = alloc_pages_exact(ui32Size, mask);
-/*    printk("pvLinAddr=%p, ui32Size=%ld\n", pvLinAddr, ui32Size);*/
-    
-    if (pvLinAddr == IMG_NULL)
-        return PVRSRV_ERROR_OUT_OF_MEMORY;
+    dma_addr_t dma;
+    void *pvLinAddr;
 
 
-    pPhysAddr->uiAddr = virt_to_phys(pvLinAddr);
+    pvLinAddr = dma_alloc_coherent(NULL, ui32Size, &dma, GFP_KERNEL);
+    if (pvLinAddr == NULL)
+    {
+            return PVRSRV_ERROR_OUT_OF_MEMORY;
+    }
 
 
+    pPhysAddr->uiAddr = dma;
     *pLinAddr = pvLinAddr;
 
     return PVRSRV_OK;
     *pLinAddr = pvLinAddr;
 
     return PVRSRV_OK;
@@ -604,7 +606,7 @@ static IMG_VOID BCFreeContigMemory(IMG_UINT32 ui32Size,
                         IMG_CPU_VIRTADDR LinAddr, 
                         IMG_CPU_PHYADDR PhysAddr)
 {
                         IMG_CPU_VIRTADDR LinAddr, 
                         IMG_CPU_PHYADDR PhysAddr)
 {
-    free_pages_exact(LinAddr, ui32Size);
+    dma_free_coherent(NULL, ui32Size, LinAddr, (dma_addr_t)PhysAddr.uiAddr);
 }
 
 static IMG_SYS_PHYADDR CpuPAddrToSysPAddrBC(IMG_CPU_PHYADDR cpu_paddr)
 }
 
 static IMG_SYS_PHYADDR CpuPAddrToSysPAddrBC(IMG_CPU_PHYADDR cpu_paddr)
@@ -716,7 +718,7 @@ static long bc_ioctl(struct file *file,
                 return -EFAULT;
 
             idx = params->input;
                 return -EFAULT;
 
             idx = params->input;
-            if (idx < 0 || idx > devinfo->ui32NumBuffers) {
+            if (idx < 0 || idx >= devinfo->ui32NumBuffers) {
                 printk(KERN_ERR DRVNAME
                         ": BCIOGET_BUFFERADDR - idx out of range\n");
                 return -EINVAL;
                 printk(KERN_ERR DRVNAME
                         ": BCIOGET_BUFFERADDR - idx out of range\n");
                 return -EINVAL;
index d7f3f21..2f50679 100644 (file)
@@ -196,7 +196,12 @@ static enum PVRSRV_ERROR PVRSRVRegisterDCDeviceKM(
        psDeviceNode->sDevId.eDeviceClass = PVRSRV_DEVICE_CLASS_DISPLAY;
        psDeviceNode->psSysData = psSysData;
 
        psDeviceNode->sDevId.eDeviceClass = PVRSRV_DEVICE_CLASS_DISPLAY;
        psDeviceNode->psSysData = psSysData;
 
-       AllocateDeviceID(psSysData, &psDeviceNode->sDevId.ui32DeviceIndex);
+       if (AllocateDeviceID(psSysData,
+                       &psDeviceNode->sDevId.ui32DeviceIndex) != PVRSRV_OK) {
+               PVR_DPF(PVR_DBG_ERROR,
+                       "PVRSRVRegisterDCDeviceKM: Failed deviceId alloc");
+               goto ErrorExit;
+       }
        psDCInfo->ui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
        if (pui32DeviceID)
                *pui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
        psDCInfo->ui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
        if (pui32DeviceID)
                *pui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
@@ -341,7 +346,12 @@ static enum PVRSRV_ERROR PVRSRVRegisterBCDeviceKM(
        psDeviceNode->sDevId.eDeviceClass = PVRSRV_DEVICE_CLASS_BUFFER;
        psDeviceNode->psSysData = psSysData;
 
        psDeviceNode->sDevId.eDeviceClass = PVRSRV_DEVICE_CLASS_BUFFER;
        psDeviceNode->psSysData = psSysData;
 
-       AllocateDeviceID(psSysData, &psDeviceNode->sDevId.ui32DeviceIndex);
+       if (AllocateDeviceID(psSysData,
+                       &psDeviceNode->sDevId.ui32DeviceIndex) != PVRSRV_OK) {
+               PVR_DPF(PVR_DBG_ERROR,
+                       "PVRSRVRegisterBCDeviceKM: Failed deviceId alloc");
+               goto ErrorExit;
+       }
        psBCInfo->ui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
        if (pui32DeviceID)
                *pui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
        psBCInfo->ui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
        if (pui32DeviceID)
                *pui32DeviceID = psDeviceNode->sDevId.ui32DeviceIndex;
index 2af219d..643959c 100644 (file)
@@ -35,7 +35,7 @@ enum SYS_DEVICE_TYPE {
        SYS_DEVICE_FORCE_I16                    = 0x7fff
 };
 
        SYS_DEVICE_FORCE_I16                    = 0x7fff
 };
 
-#define SYS_DEVICE_COUNT                       3
+#define SYS_DEVICE_COUNT                       15
 
 #define PRM_REG32(offset)                      (offset)
 #define CM_REG32(offset)                       (offset)
 
 #define PRM_REG32(offset)                      (offset)
 #define CM_REG32(offset)                       (offset)