vdec: fixed the issue of the swap memory leak. [1/1]
authorNanxin Qin <nanxin.qin@amlogic.com>
Tue, 26 May 2020 12:44:59 +0000 (20:44 +0800)
committerNanxin Qin <nanxin.qin@amlogic.com>
Tue, 26 May 2020 13:06:00 +0000 (06:06 -0700)
PD#SWPL-26496

Problem:
cobalt can't play clear stream after play DRM stream

Solution:
if the swap memory did not free, then the tvp pool
hold a mass of memory that caused to clear stream
playback fail as not enough memory to decoding.

Verify:
u212

Change-Id: I18fcbe228a72c2d445f47058aed4401365365aec
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
drivers/frame_provider/decoder/utils/vdec_input.c

index 767bf9a7d098228ca5b6fd02a150c96da9914e81..284dc0237ab976d00b8de9f7284365f25e3c85bd 100644 (file)
@@ -1116,16 +1116,18 @@ void vdec_input_release(struct vdec_input_s *input)
        }
 
        /* release swap pages */
-       if (input->swap_page) {
-               if (vdec_secure(input->vdec))
+       if (vdec_secure(input->vdec)) {
+               if (input->swap_page_phys)
                        codec_mm_free_for_dma("SWAP", input->swap_page_phys);
-               else
+       } else {
+               if (input->swap_page) {
                        dma_free_coherent(v4l_get_dev_from_codec_mm(),
                                PAGE_SIZE, input->swap_page,
-                                       input->swap_page_phys);
-               input->swap_page = NULL;
-               input->swap_page_phys = 0;
+                               input->swap_page_phys);
+               }
        }
+       input->swap_page = NULL;
+       input->swap_page_phys = 0;
        input->swap_valid = false;
 }
 EXPORT_SYMBOL(vdec_input_release);