--- zzzz-none-000/linux-3.10.107/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c 2021-02-04 17:41:59.000000000 +0000 @@ -21,7 +21,7 @@ void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev) { - if (IS_MFCV6(dev)) { + if (IS_MFCV6_PLUS(dev)) { s5p_mfc_ops = s5p_mfc_init_hw_ops_v6(); dev->warn_start = S5P_FIMV_ERR_WARNINGS_START_V6; } else { @@ -31,11 +31,16 @@ dev->mfc_ops = s5p_mfc_ops; } -int s5p_mfc_alloc_priv_buf(struct device *dev, - struct s5p_mfc_priv_buf *b) +void s5p_mfc_init_regs(struct s5p_mfc_dev *dev) { + if (IS_MFCV6_PLUS(dev)) + dev->mfc_regs = s5p_mfc_init_regs_v6_plus(dev); +} - mfc_debug(3, "Allocating priv: %d\n", b->size); +int s5p_mfc_alloc_priv_buf(struct device *dev, dma_addr_t base, + struct s5p_mfc_priv_buf *b) +{ + mfc_debug(3, "Allocating priv: %zu\n", b->size); b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL); @@ -44,7 +49,15 @@ return -ENOMEM; } - mfc_debug(3, "Allocated addr %p %08x\n", b->virt, b->dma); + if (b->dma < base) { + mfc_err("Invaling memory configuration!\n"); + mfc_err("Allocated buffer (%pad) is lower than memory base address (%pad)\n", + &b->dma, &base); + dma_free_coherent(dev, b->size, b->virt, b->dma); + return -ENOMEM; + } + + mfc_debug(3, "Allocated addr %p %pad\n", b->virt, &b->dma); return 0; }