zynqmp_r5: remove IPI handler
authorWendy Liang <jliang@xilinx.com>
Tue, 2 Feb 2016 06:51:12 +0000 (22:51 -0800)
committerWendy Liang <jliang@xilinx.com>
Tue, 9 Feb 2016 19:55:45 +0000 (11:55 -0800)
It is not necessary to have IPI handler.

Signed-off-by: Wendy Liang <jliang@xilinx.com>
apps/machine/zynqmp_r5/platform_info.c
lib/include/openamp/env.h
lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
lib/system/generic/bm_env.c
lib/system/generic/machine/zynqmp_r5/machine_system.c

index a6ac65b0e27304beab431a4ee2c14b117fa57581..bfa50926dce8463eea9c205f92a83a5f170bca62 100755 (executable)
@@ -47,7 +47,7 @@
 #define SHM_SIZE                          0x00200000
 #define IPI_BASEADDR                      0xff310000
 #define IPI_CHN_BITMASK                   0x01000000 /* IPI channel bit mask APU<->RPU0 */
-#define VRING0_IPI_INTR_VECT              -1
+#define VRING0_IPI_INTR_VECT              0xFFFFFFFF
 #define VRING1_IPI_INTR_VECT              65
 #define MASTER_CPU_ID                     0
 #define REMOTE_CPU_ID                     1
index dce66650b80dbf5daa246b261bf82314d6b75f14..9f2995d2b72f7fb337b31ce6f5e399894a56059c 100644 (file)
@@ -338,9 +338,27 @@ void env_restore_interrupts();
 
 void env_register_isr(int vector, void *data,
                      void (*isr) (int vector, void *data));
+/**
+ * env_register_isr_shared
+ *
+ * Registers interrupt handler for the given shared interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param data   - private data
+ * @param isr    - interrupt handler
+ * @oaram name   - interrup handler name
+ * @param shared - if the interrupt is a shared interrupt
+ */
+
+void env_register_isr_shared(int vector, void *data,
+                     void (*isr) (int vector, void *data),
+                     char *name,
+                     int shared);
 
 void env_update_isr(int vector, void *data,
-                   void (*isr) (int vector, void *data));
+                   void (*isr) (int vector, void *data),
+                   char *name,
+                   int shared);
 
 /**
  * env_enable_interrupt
index 764c384c58f6ac6c0d30d3d5ecd58672702d1195..41fb19f4a08f557fd10e2d22cf41d76aa8b3b772 100644 (file)
@@ -54,7 +54,8 @@ static int _enable_interrupt(struct proc_vring *vring_hw);
 static void _notify(int cpu_id, struct proc_intr *intr_info);
 static int _boot_cpu(int cpu_id, unsigned int load_addr);
 static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
+static void _ipi_handler(int vect_id, void *data);
+static void _ipi_handler_deinit(int vect_id, void *data);
 static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
 
 /*--------------------------- Globals ---------------------------------- */
@@ -70,48 +71,53 @@ struct hil_platform_ops proc_ops = {
 extern void ipi_enable_interrupt(unsigned int vector);
 extern void ipi_isr(int vect_id, void *data);
 
+/* static variables */
+static struct ipi_info saved_ipi_info;
+
 /*------------------- Extern variable -----------------------------------*/
 extern struct hil_proc proc_table[];
 extern const int proc_table_size;
 
-extern void ipi_register_interrupt(unsigned long ipi_base_addr,
-                                  unsigned int intr_mask, void *data,
-                                  void *ipi_handler);
-
-void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
-                 void *data)
+void _ipi_handler(int vect_id, void *data)
 {
-       (void)ipi_base_addr;
-       (void)intr_mask;
-       struct proc_vring *vring_hw = (struct proc_vring *)data;
-       platform_dcache_all_flush();
-       hil_isr(vring_hw);
+       (void) vect_id;
+       struct proc_vring *vring_hw = (struct proc_vring *)(data);
+       struct ipi_info *chn_ipi_info =
+               (struct ipi_info *)(vring_hw->intr_info.data);
+       unsigned int ipi_base_addr = chn_ipi_info->ipi_base_addr;
+       unsigned int ipi_intr_status =
+           (unsigned int)HIL_MEM_READ32(ipi_base_addr + IPI_ISR_OFFSET);
+       if (ipi_intr_status && chn_ipi_info->ipi_chn_mask) {
+               platform_dcache_all_flush();
+               hil_isr(vring_hw);
+               HIL_MEM_WRITE32((ipi_base_addr + IPI_ISR_OFFSET),
+                               chn_ipi_info->ipi_chn_mask);
+       }
 }
 
-void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
-                        void *data)
+void _ipi_handler_deinit(int vect_id, void *data)
 {
-       (void)ipi_base_addr;
-       (void)intr_mask;
-       (void)data;
+       (void) vect_id;
+       struct ipi_info *chn_ipi_info =
+               (struct ipi_info *)(data);
+       unsigned int ipi_base_addr = chn_ipi_info->ipi_base_addr;
+       unsigned int ipi_intr_status =
+           (unsigned int)HIL_MEM_READ32(ipi_base_addr + IPI_ISR_OFFSET);
+       if (ipi_intr_status && chn_ipi_info->ipi_chn_mask) {
+               HIL_MEM_WRITE32((ipi_base_addr + IPI_ISR_OFFSET),
+                               chn_ipi_info->ipi_chn_mask);
+       }
        return;
 }
 
-int _enable_interrupt(struct proc_vring *vring_hw)
+static int _enable_interrupt(struct proc_vring *vring_hw)
 {
-
-       struct ipi_info *chn_ipi_info =
-           (struct ipi_info *)(vring_hw->intr_info.data);
-
        if (vring_hw->intr_info.vect_id == 0xFFFFFFFF)
                return 0;
-       /* Register IPI handler */
-       ipi_register_handler(chn_ipi_info->ipi_base_addr,
-                            chn_ipi_info->ipi_chn_mask, vring_hw,
-                            _ipi_handler);
+
        /* Register ISR */
-       env_register_isr(vring_hw->intr_info.vect_id,
-                        &(chn_ipi_info->ipi_base_addr), ipi_isr);
+       env_register_isr_shared(vring_hw->intr_info.vect_id,
+                        vring_hw, _ipi_handler, "remoteproc_a53", 1);
        /* Enable IPI interrupt */
        env_enable_interrupt(vring_hw->intr_info.vect_id,
                             vring_hw->intr_info.priority,
@@ -119,15 +125,20 @@ int _enable_interrupt(struct proc_vring *vring_hw)
        return 0;
 }
 
+/* In case there is an interrupt received after deinit. */
 void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
 {
        struct ipi_info *chn_ipi_info =
            (struct ipi_info *)(vring_hw->intr_info.data);
-       env_disable_interrupts();
-       ipi_register_handler(chn_ipi_info->ipi_base_addr,
-                            chn_ipi_info->ipi_chn_mask, 0,
-                            _ipi_handler_deinit);
-       env_restore_interrupts();
+
+       if (vring_hw->intr_info.vect_id == 0xFFFFFFFF)
+               return;
+       saved_ipi_info.ipi_base_addr = chn_ipi_info->ipi_base_addr;
+       saved_ipi_info.ipi_chn_mask = chn_ipi_info->ipi_chn_mask;
+
+       env_update_isr(vring_hw->intr_info.vect_id, &saved_ipi_info,
+                    _ipi_handler_deinit,
+                    "remoteproc_a53", 1);
 }
 
 void _notify(int cpu_id, struct proc_intr *intr_info)
@@ -140,7 +151,8 @@ void _notify(int cpu_id, struct proc_intr *intr_info)
        platform_dcache_all_flush();
        env_wmb();
        /* Trigger IPI */
-       ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+       HIL_MEM_WRITE32((chn_ipi_info->ipi_base_addr + IPI_TRIG_OFFSET),
+                       chn_ipi_info->ipi_chn_mask);
 }
 
 int _boot_cpu(int cpu_id, unsigned int load_addr)
index 2c25873d3de2aeab8e075fac78901041bf6fd774..a3a372b4a732d5bec9ba1b90085a627d1da1ec82 100755 (executable)
@@ -60,6 +60,8 @@ struct isr_info {
        int vector;
        int priority;
        int type;
+       char *name;
+       int shared;
        void *data;
        void (*isr)(int vector, void *data);
 };
@@ -367,15 +369,19 @@ void env_restore_interrupts()
 }
 
 /**
- * env_register_isr
+ * env_register_isr_shared
  *
  * Registers interrupt handler for the given interrupt vector.
  *
  * @param vector - interrupt vector number
  * @param isr    - interrupt handler
+ * @param name   - interrupt name
+ * @param shared - if the interrupt is shared or not
  */
-void env_register_isr(int vector, void *data,
-                     void (*isr) (int vector, void *data))
+void env_register_isr_shared(int vector, void *data,
+                     void (*isr) (int vector, void *data),
+                     char *name,
+                     int shared)
 {
        env_disable_interrupts();
 
@@ -383,14 +389,31 @@ void env_register_isr(int vector, void *data,
                /* Save interrupt data */
                isr_table[Intr_Count].vector = vector;
                isr_table[Intr_Count].data = data;
+               isr_table[Intr_Count].name = name;
+               isr_table[Intr_Count].shared = shared;
                isr_table[Intr_Count++].isr = isr;
        }
 
        env_restore_interrupts();
 }
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param isr    - interrupt handler
+ */
+void env_register_isr(int vector, void *data,
+                     void (*isr) (int vector, void *data))
+{
+       env_register_isr_shared(vector, data, isr, 0, 0);
+}
 
 void env_update_isr(int vector, void *data,
-                   void (*isr) (int vector, void *data))
+                   void (*isr) (int vector, void *data),
+                   char *name,
+                   int shared)
 {
        int idx;
        struct isr_info *info;
@@ -400,8 +423,12 @@ void env_update_isr(int vector, void *data,
        for (idx = 0; idx < ISR_COUNT; idx++) {
                info = &isr_table[idx];
                if (info->vector == vector) {
+                       if (name && strcmp(info->name, name)) {
+                               continue;
+                       }
                        info->data = data;
                        info->isr = isr;
+                       info->shared = shared;
                        break;
                }
        }
@@ -511,7 +538,8 @@ void bm_env_isr(int vector)
                        info->isr(info->vector, info->data);
                        env_enable_interrupt(info->vector, info->priority,
                                             info->type);
-                       break;
+                       if (!info->shared)
+                               break;
                }
        }
 }
index 2775c62c17aa32cd9fe6989da23cb55ea39e03f9..552c4d74c63f5af2db1ba729157598a4c8cfae1f 100755 (executable)
                *get_bits_ptr = tmp_val; \
        }
 
-/*
- ***********************************************************************
- * IPI handling
- *
- ***********************************************************************
- */
-
-#define IPI_TOTAL 11
-
-typedef void (*ipi_handler_t) (unsigned long ipi_base_addr,
-                              unsigned int intr_mask, void *data);
-
-struct ipi_handler_info {
-       unsigned long ipi_base_addr;
-       unsigned int intr_mask;
-       void *data;
-       ipi_handler_t ipi_handler;
-};
-
-struct ipi_handler_info ipi_handler_table[IPI_TOTAL];
-
-int ipi_index_map(unsigned int ipi_intr_mask)
-{
-       switch (ipi_intr_mask) {
-       case 0x08000000:
-               return 10;
-       case 0x04000000:
-               return 9;
-       case 0x02000000:
-               return 8;
-       case 0x01000000:
-               return 7;
-       case 0x00080000:
-               return 6;
-       case 0x00040000:
-               return 5;
-       case 0x00020000:
-               return 4;
-       case 0x00010000:
-               return 3;
-       case 0x00000200:
-               return 2;
-       case 0x00000100:
-               return 1;
-       case 0x00000001:
-               return 0;
-       default:
-               return -1;
-       }
-}
-
-void ipi_trigger(unsigned long ipi_base_addr, unsigned int trigger_mask)
-{
-       Xil_Out32((ipi_base_addr + IPI_TRIG_OFFSET), trigger_mask);
-}
-
-void ipi_register_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
-                         void *data, void *ipi_handler)
-{
-       int ipi_hd_i = ipi_index_map(intr_mask);
-       if (ipi_hd_i < 0)
-               return;
-       ipi_handler_table[ipi_hd_i].ipi_base_addr = ipi_base_addr;
-       ipi_handler_table[ipi_hd_i].intr_mask = intr_mask;
-       ipi_handler_table[ipi_hd_i].ipi_handler = (ipi_handler_t) ipi_handler;
-       ipi_handler_table[ipi_hd_i].data = data;
-       Xil_Out32((ipi_base_addr + IPI_IER_OFFSET), intr_mask);
-}
-
-void ipi_unregister_handler(unsigned long ipi_base_addr, unsigned int intr_mask)
-{
-       int ipi_hd_i = ipi_index_map(intr_mask);
-       if (ipi_hd_i < 0)
-               return;
-       memset(&(ipi_handler_table[ipi_hd_i]), 0,
-              sizeof(struct ipi_handler_info));
-}
-
-void ipi_isr(int vect_id, void *data)
-{
-       unsigned long ipi_base_addr = *((unsigned long *)data);
-       unsigned int ipi_intr_status =
-           (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
-       int i = 0;
-       do {
-               Xil_Out32((ipi_base_addr + IPI_ISR_OFFSET), ipi_intr_status);
-               for (i = 0; i < IPI_TOTAL; i++) {
-                       if (ipi_base_addr != ipi_handler_table[i].ipi_base_addr)
-                               continue;
-                       if (!
-                           (ipi_intr_status
-                            && (ipi_handler_table[i].intr_mask)))
-                               continue;
-                       ipi_handler_table[i].ipi_handler(ipi_base_addr,
-                                                        ipi_handler_table[i].
-                                                        intr_mask,
-                                                        ipi_handler_table[i].
-                                                        data);
-               }
-               ipi_intr_status =
-                   (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
-       } while (ipi_intr_status);
-}
-
 int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
                              unsigned int priority)
 {