media: mfc: DRV3.2: expand debugging mode
authorAyoung Sim <a.sim@samsung.com>
Mon, 2 Apr 2018 04:49:38 +0000 (13:49 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:22 +0000 (20:22 +0300)
Change-Id: I817e12b450ea0229b6cc9985c774012ac4974767
Signed-off-by: Ayoung Sim <a.sim@samsung.com>
drivers/media/platform/exynos/mfc/s5p_mfc.c
drivers/media/platform/exynos/mfc/s5p_mfc_irq.c
drivers/media/platform/exynos/mfc/s5p_mfc_mem.c
drivers/media/platform/exynos/mfc/s5p_mfc_pm.c
drivers/media/platform/exynos/mfc/s5p_mfc_regs_v10.h

index 31631127599e07436d217d8e144679e00b324249..17e66ca69d8e4f928e450f0034b660227a0c4854 100644 (file)
@@ -341,6 +341,7 @@ static int mfc_init_instance(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
                                dev->drm_fw_buf.daddr, 0, 0);
                if (ret != DRMDRV_OK) {
                        mfc_err_ctx("failed MFC DRM F/W prot(%#x)\n", ret);
+                       call_dop(dev, dump_and_stop_debug_mode, dev);
                        dev->fw.drm_status = 0;
                } else {
                        dev->fw.drm_status = 1;
@@ -410,8 +411,10 @@ err_context_alloc:
                /* Request buffer unprotection for DRM F/W */
                smc_ret = exynos_smc(SMC_DRM_PPMP_MFCFW_UNPROT,
                                        dev->drm_fw_buf.daddr, 0, 0);
-               if (smc_ret != DRMDRV_OK)
+               if (smc_ret != DRMDRV_OK) {
                        mfc_err_ctx("failed MFC DRM F/W unprot(%#x)\n", smc_ret);
+                       call_dop(dev, dump_and_stop_debug_mode, dev);
+               }
        }
 #endif
 
@@ -720,6 +723,7 @@ static int s5p_mfc_release(struct file *file)
                                        dev->drm_fw_buf.daddr, 0, 0);
                        if (ret != DRMDRV_OK) {
                                mfc_err_ctx("failed MFC DRM F/W unprot(%#x)\n", ret);
+                               call_dop(dev, dump_and_stop_debug_mode, dev);
                                goto err_release;
                        }
                }
index af512fa883478d5cf8c699ca9564d050bd67dba2..6ca13cafa96c1145cae389e98806f9ef28ca752f 100644 (file)
@@ -1261,6 +1261,18 @@ static int mfc_handle_seq_enc(struct s5p_mfc_ctx *ctx)
        return 0;
 }
 
+static inline int is_err_condition(unsigned int err)
+{
+       if (err == S5P_FIMV_ERR_NO_AVAILABLE_DPB ||
+               err == S5P_FIMV_ERR_INSUFFICIENT_DPB_SIZE ||
+               err == S5P_FIMV_ERR_INSUFFICIENT_NUM_DPB ||
+               err == S5P_FIMV_ERR_INSUFFICIENT_MV_BUF_SIZE ||
+               err == S5P_FIMV_ERR_INSUFFICIENT_SCRATCH_BUF_SIZE)
+               return 1;
+
+       return 0;
+}
+
 irqreturn_t s5p_mfc_top_half_irq(int irq, void *priv)
 {
        struct s5p_mfc_dev *dev = priv;
@@ -1524,6 +1536,7 @@ irqreturn_t s5p_mfc_irq(int irq, void *priv)
 
        if (s5p_mfc_pm_get_pwr_ref_cnt(dev) == 0) {
                mfc_err_dev("no mfc power on\n");
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                goto irq_end;
        }
 
@@ -1545,6 +1558,9 @@ irqreturn_t s5p_mfc_irq(int irq, void *priv)
                        (err && (reason != S5P_FIMV_R2H_CMD_ERR_RET)))
                call_dop(dev, dump_regs, dev);
 
+       if (is_err_condition(err))
+               call_dop(dev, dump_and_stop_debug_mode, dev);
+
 #ifdef NAL_Q_ENABLE
        if (dev->nal_q_handle) {
                ret = mfc_nal_q_irq(dev, reason, err);
index 9fe6c624b1335fe1d3ac9015814a1d26c5c71a85..a5deb58065b03348376ee3258b269fbc92ddeb43 100644 (file)
@@ -114,6 +114,7 @@ int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
        if (IS_ERR(special_buf->dma_buf)) {
                mfc_err_ctx("Failed to allocate buffer (err %ld)\n",
                                PTR_ERR(special_buf->dma_buf));
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                goto err_ion_alloc;
        }
 
@@ -121,6 +122,7 @@ int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
        if (IS_ERR(special_buf->attachment)) {
                mfc_err_ctx("Failed to get dma_buf_attach (err %ld)\n",
                                PTR_ERR(special_buf->attachment));
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                goto err_attach;
        }
 
@@ -129,6 +131,7 @@ int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
        if (IS_ERR(special_buf->sgt)) {
                mfc_err_ctx("Failed to get sgt (err %ld)\n",
                                PTR_ERR(special_buf->sgt));
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                goto err_map;
        }
 
@@ -137,6 +140,7 @@ int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
        if (IS_ERR_VALUE(special_buf->daddr)) {
                mfc_err_ctx("Failed to allocate iova (err 0x%p)\n",
                                &special_buf->daddr);
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                goto err_iovmm;
        }
 
@@ -144,6 +148,7 @@ int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
        if (IS_ERR(special_buf->vaddr)) {
                mfc_err_ctx("Failed to get vaddr (err 0x%p)\n",
                                &special_buf->vaddr);
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                goto err_vaddr;
        }
 
@@ -222,6 +227,7 @@ int s5p_mfc_bufcon_get_daddr(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *mfc_bu
                if (IS_ERR(mfc_buf->dmabufs[i][plane])) {
                        mfc_err_ctx("Failed to get dma_buf (err %ld)",
                                        PTR_ERR(mfc_buf->dmabufs[i][plane]));
+                       call_dop(dev, dump_and_stop_debug_mode, dev);
                        goto err_get_daddr;
                }
 
@@ -229,6 +235,7 @@ int s5p_mfc_bufcon_get_daddr(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *mfc_bu
                if (IS_ERR(mfc_buf->attachments[i][plane])) {
                        mfc_err_ctx("Failed to get dma_buf_attach (err %ld)",
                                        PTR_ERR(mfc_buf->attachments[i][plane]));
+                       call_dop(dev, dump_and_stop_debug_mode, dev);
                        goto err_get_daddr;
                }
 
@@ -237,6 +244,7 @@ int s5p_mfc_bufcon_get_daddr(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *mfc_bu
                if (IS_ERR_VALUE(mfc_buf->addr[i][plane])) {
                        mfc_err_ctx("Failed to allocate iova (err %pa)",
                                        &mfc_buf->addr[i][plane]);
+                       call_dop(dev, dump_and_stop_debug_mode, dev);
                        goto err_get_daddr;
                }
 
index 59a81b12f96a8f1bf60ac2e5618e9dfebdd35c0e..e301b539022a2150f61de8ded250efbd050cb5d4 100644 (file)
@@ -48,6 +48,7 @@ int s5p_mfc_pm_clock_on(struct s5p_mfc_dev *dev)
        ret = clk_enable(dev->pm.clock);
        if (ret < 0) {
                mfc_err_dev("clk_enable failed (%d)\n", ret);
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                return ret;
        }
        dev->pm.clock_on_steps |= 0x1 << 1;
@@ -67,6 +68,7 @@ int s5p_mfc_pm_clock_on(struct s5p_mfc_dev *dev)
                dev->pm.clock_on_steps |= 0x1 << 3;
                if (ret != DRMDRV_OK) {
                        mfc_err_dev("Protection Enable failed! ret(%u)\n", ret);
+                       call_dop(dev, dump_and_stop_debug_mode, dev);
                        spin_unlock_irqrestore(&dev->pm.clklock, flags);
                        clk_disable(dev->pm.clock);
                        return -EACCES;
@@ -125,6 +127,7 @@ void s5p_mfc_pm_clock_off(struct s5p_mfc_dev *dev)
                                        dev->id, SMC_PROTECTION_DISABLE);
                        if (ret != DRMDRV_OK) {
                                mfc_err_dev("Protection Disable failed! ret(%u)\n", ret);
+                               call_dop(dev, dump_and_stop_debug_mode, dev);
                                spin_unlock_irqrestore(&dev->pm.clklock, flags);
                                clk_disable(dev->pm.clock);
                                return;
@@ -152,6 +155,7 @@ int s5p_mfc_pm_power_on(struct s5p_mfc_dev *dev)
        ret = pm_runtime_get_sync(dev->pm.device);
        if (ret < 0) {
                mfc_err_dev("Failed to get power: ret(%d)\n", ret);
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                goto err_power_on;
        }
 
@@ -196,6 +200,7 @@ int s5p_mfc_pm_power_off(struct s5p_mfc_dev *dev)
        ret = pm_runtime_put_sync(dev->pm.device);
        if (ret < 0) {
                mfc_err_dev("Failed to put power: ret(%d)\n", ret);
+               call_dop(dev, dump_and_stop_debug_mode, dev);
                return ret;
        }
 
index 25613bd5451bc706644ce4fa761d5368843cf6a1..af8ce4faab72ae710a555af617511c1893ca21b1 100644 (file)
 #define S5P_FIMV_WARN_STATUS_MASK                      0xFFFF
 #define S5P_FIMV_WARN_STATUS_SHIFT                     16
 /* Error number */
+#define S5P_FIMV_ERR_NO_AVAILABLE_DPB                  33
 #define S5P_FIMV_ERR_NO_KEY_FRAME                      34
 #define S5P_FIMV_ERR_VPS_ONLY_ERROR                    42
+#define S5P_FIMV_ERR_INSUFFICIENT_DPB_SIZE             57
+#define S5P_FIMV_ERR_INSUFFICIENT_NUM_DPB              58
+#define S5P_FIMV_ERR_INSUFFICIENT_MV_BUF_SIZE          60
 #define S5P_FIMV_ERR_NULL_SCRATCH                      61
+#define S5P_FIMV_ERR_INSUFFICIENT_SCRATCH_BUF_SIZE     62
 
 #define S5P_FIMV_ERR_UNSUPPORTED_FEATURE               100
 #define S5P_FIMV_ERR_UNSUPPORTED_RESOLUTION            101