Commit 88698680 authored by Corentin Labbe's avatar Corentin Labbe Committed by Mauro Carvalho Chehab

media: zoran: Use DMA coherent for stat_com

Instead of using a fragile virt_to_bus, let's use proper DMA coherent
for the stat_com entry.
Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent accd0214
...@@ -351,6 +351,8 @@ struct zoran { ...@@ -351,6 +351,8 @@ struct zoran {
unsigned long frame_num; unsigned long frame_num;
wait_queue_head_t test_q; wait_queue_head_t test_q;
dma_addr_t p_sc;
}; };
static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev) static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
......
...@@ -936,11 +936,17 @@ static int zr36057_init(struct zoran *zr) ...@@ -936,11 +936,17 @@ static int zr36057_init(struct zoran *zr)
zoran_open_init_params(zr); zoran_open_init_params(zr);
/* allocate memory *before* doing anything to the hardware in case allocation fails */ /* allocate memory *before* doing anything to the hardware in case allocation fails */
zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
zr->video_dev = video_device_alloc(); zr->video_dev = video_device_alloc();
if (!zr->stat_com || !zr->video_dev) { if (!zr->video_dev) {
err = -ENOMEM; err = -ENOMEM;
goto exit_free; goto exit;
}
zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev,
BUZ_NUM_STAT_COM * sizeof(u32),
&zr->p_sc, GFP_KERNEL);
if (!zr->stat_com) {
err = -ENOMEM;
goto exit_video;
} }
for (j = 0; j < BUZ_NUM_STAT_COM; j++) for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to zr36057 */ zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to zr36057 */
...@@ -958,7 +964,7 @@ static int zr36057_init(struct zoran *zr) ...@@ -958,7 +964,7 @@ static int zr36057_init(struct zoran *zr)
zr->video_dev->vfl_dir = VFL_DIR_M2M; zr->video_dev->vfl_dir = VFL_DIR_M2M;
err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, video_nr[zr->id]); err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, video_nr[zr->id]);
if (err < 0) if (err < 0)
goto exit_free; goto exit_statcom;
video_set_drvdata(zr->video_dev, zr); video_set_drvdata(zr->video_dev, zr);
zoran_init_hardware(zr); zoran_init_hardware(zr);
...@@ -973,9 +979,11 @@ static int zr36057_init(struct zoran *zr) ...@@ -973,9 +979,11 @@ static int zr36057_init(struct zoran *zr)
zr->initialized = 1; zr->initialized = 1;
return 0; return 0;
exit_free: exit_statcom:
kfree(zr->stat_com); dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), zr->stat_com, zr->p_sc);
exit_video:
kfree(zr->video_dev); kfree(zr->video_dev);
exit:
return err; return err;
} }
...@@ -1009,7 +1017,7 @@ static void zoran_remove(struct pci_dev *pdev) ...@@ -1009,7 +1017,7 @@ static void zoran_remove(struct pci_dev *pdev)
btwrite(0, ZR36057_SPGPPCR); btwrite(0, ZR36057_SPGPPCR);
free_irq(zr->pci_dev->irq, zr); free_irq(zr->pci_dev->irq, zr);
/* unmap and free memory */ /* unmap and free memory */
kfree(zr->stat_com); dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), zr->stat_com, zr->p_sc);
iounmap(zr->zr36057_mem); iounmap(zr->zr36057_mem);
pci_disable_device(zr->pci_dev); pci_disable_device(zr->pci_dev);
video_unregister_device(zr->video_dev); video_unregister_device(zr->video_dev);
......
...@@ -579,8 +579,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum zoran_codec_mode mode) ...@@ -579,8 +579,7 @@ static void zr36057_set_jpg(struct zoran *zr, enum zoran_codec_mode mode)
//btor(ZR36057_VFESPFR_VCLKPol, ZR36057_VFESPFR); //btor(ZR36057_VFESPFR_VCLKPol, ZR36057_VFESPFR);
/* code base address */ /* code base address */
reg = virt_to_bus(zr->stat_com); btwrite(zr->p_sc, ZR36057_JCBA);
btwrite(reg, ZR36057_JCBA);
/* FIFO threshold (FIFO is 160. double words) */ /* FIFO threshold (FIFO is 160. double words) */
/* NOTE: decimal values here */ /* NOTE: decimal values here */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment