[PDK-9594] UDMA: Fix issues with Event Disable and Enable for shared events
authorDon Dominic <a0486429@ti.com>
Wed, 7 Apr 2021 09:33:43 +0000 (15:03 +0530)
committerAnkur <ankurbaranwal@ti.com>
Thu, 8 Apr 2021 06:23:33 +0000 (01:23 -0500)
- Udma_eventDisable and Udma_eventEnable was failing in case of eventMode=UDMA_EVENT_MODE_SHARED

Rootcause:
- In case of shared events, eventHandle->vintrNum will be invalid (since it relies on master event)
- Here the Enable and Disable APIs vintrBitNum computation goes wrong and results in CSL API failure.

Fix:
- Store the vintrNum in newly added eventPrms->vintrNum
- For shared events populate with the vintrNum for Master Event
- For exlcusive events, populate its own vintrNum
  - This is similar to existing implementation fod coreIntrNum for same scenario

Signed-off-by: Don Dominic <a0486429@ti.com>
packages/ti/drv/udma/include/udma_event.h
packages/ti/drv/udma/src/udma_event.c

index 3062a437698373099d45787bdd87247b6e74077e..ff5478fe91f65efe362115b34a6e00f25b7f6553 100644 (file)
@@ -293,6 +293,8 @@ typedef struct
      *   register. This is used to clear if interrupt occurred */
     uint64_t                intrMask;
     /**< [OUT] Interrupt mask to check and clear */
+    uint32_t                vintrNum;
+    /**< [OUT] IA Virtual interrupt number allocated. */
     uint32_t                coreIntrNum;
     /**< [OUT] Core interrupt number allocated.
      *   This number can be used to register with the OSAL 
index 2c39e202659e82ea9b4886ef1d06c80a784ddf35..6aa8ffe576ff0f941477573b694f765b248aed37 100755 (executable)
@@ -203,11 +203,14 @@ int32_t Udma_eventRegister(Udma_DrvHandle drvHandle,
                 if(NULL_PTR == eventHandle->eventPrms.masterEventHandle)
                 {
                     /* This is master handle - copy directly from here itself */
+                    eventPrms->vintrNum     = eventHandle->vintrNum;
                     eventPrms->coreIntrNum  = eventHandle->coreIntrNum;
                 }
                 else
                 {
-                    /* Copy core number from master handle */
+                    /* Copy from master handle */
+                    eventPrms->vintrNum       = 
+                        eventHandle->eventPrms.masterEventHandle->vintrNum;
                     eventPrms->coreIntrNum    =
                         eventHandle->eventPrms.masterEventHandle->coreIntrNum;
                 }
@@ -215,6 +218,7 @@ int32_t Udma_eventRegister(Udma_DrvHandle drvHandle,
                 eventHandle->eventPrms.intrStatusReg   = eventPrms->intrStatusReg;
                 eventHandle->eventPrms.intrClearReg    = eventPrms->intrClearReg;
                 eventHandle->eventPrms.intrMask        = eventPrms->intrMask;
+                eventHandle->eventPrms.vintrNum        = eventPrms->vintrNum;
                 eventHandle->eventPrms.coreIntrNum     = eventPrms->coreIntrNum;
             }
         }
@@ -311,7 +315,13 @@ int32_t Udma_eventDisable(Udma_EventHandle eventHandle)
         drvHandle = eventHandle->drvHandle;
         if(NULL_PTR != drvHandle)
         {
-            vintrNum = eventHandle->vintrNum;
+            /* In case of shared events "eventHandle->vintrNum" will be invalid,
+            * since it relies on the master event.
+            * Hence, use "eventHandle->eventPrms.vintrNum" 
+            * which will be populated with,
+            * master events vintrNum for shared events and 
+            * its own vintrNum for exlcusive events. */
+            vintrNum = eventHandle->eventPrms.vintrNum;
             vintrBitNum = vintrNum * UDMA_MAX_EVENTS_PER_VINTR;
             vintrBitNum += eventHandle->vintrBitNum;
 
@@ -335,7 +345,13 @@ int32_t Udma_eventEnable(Udma_EventHandle eventHandle)
         drvHandle = eventHandle->drvHandle;
         if(NULL_PTR != drvHandle)
         {
-            vintrNum = eventHandle->vintrNum;
+            /* In case of shared events "eventHandle->vintrNum" will be invalid,
+             * since it relies on the master event.
+             * Hence, use "eventHandle->eventPrms.vintrNum" 
+             * which will be populated with,
+             * master events vintrNum for shared events and 
+             * its own vintrNum exlcusive events. */
+            vintrNum = eventHandle->eventPrms.vintrNum;
             vintrBitNum = vintrNum * UDMA_MAX_EVENTS_PER_VINTR;
             vintrBitNum += eventHandle->vintrBitNum;
 
@@ -457,6 +473,7 @@ void UdmaEventPrms_init(Udma_EventPrms *eventPrms)
         eventPrms->intrStatusReg        = (volatile uint64_t *) NULL_PTR;
         eventPrms->intrClearReg         = (volatile uint64_t *) NULL_PTR;
         eventPrms->intrMask             = 0U;
+        eventPrms->vintrNum             = UDMA_EVENT_INVALID;
         eventPrms->coreIntrNum          = UDMA_INTR_INVALID;
     }