From a908eb9936ba06678720226feed891d01827066f Mon Sep 17 00:00:00 2001 From: Gianluca Gennari Date: Sun, 2 Jun 2013 17:24:24 -0300 Subject: [media] rtl28xxu: fix buffer overflow when probing Rafael Micro r820t tuner As suggested by Antti, this patch replaces: https://patchwork.kernel.org/patch/2649861/ The buffer overflow is fixed by reading only the r820t ID register. Signed-off-by: Gianluca Gennari Acked-by: Antti Palosaari Reviewed-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 22015fe..2cc8ec7 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -376,7 +376,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf}; struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf}; struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; - struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 5, buf}; + struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 1, buf}; dev_dbg(&d->udev->dev, "%s:\n", __func__); @@ -481,9 +481,9 @@ static int rtl2832u_read_config(struct dvb_usb_device *d) goto found; } - /* check R820T by reading tuner stats at I2C addr 0x1a */ + /* check R820T ID register; reg=00 val=69 */ ret = rtl28xxu_ctrl_msg(d, &req_r820t); - if (ret == 0) { + if (ret == 0 && buf[0] == 0x69) { priv->tuner = TUNER_RTL2832_R820T; priv->tuner_name = "R820T"; goto found; -- cgit v0.10.2 From 722a860ecb29aa34ec6f7d7f32b949209e86a2f3 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 14 Jun 2013 10:44:30 -0300 Subject: [media] exynos4-is: Fix FIMC-IS clocks initialization The ISP clock register content is not preserved over the ISP power domain off/on cycle. Instead of setting the clock frequencies once at probe time the clock rates set up is moved to the runtime_resume handler, which is invoked after the related power domain is already enabled, ensuring the clocks are properly configured when the device is actively used. This fixes the FIMC-IS malfunctions and STREAM ON timeout errors accuring on some boards: [ 59.860000] fimc_is_general_irq_handler:583 ISR_NDONE: 5: 0x800003e8, IS_ERROR_UNKNOWN [ 59.860000] fimc_is_general_irq_handler:586 IS_ERROR_TIME_OUT Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c index 520e439..0741945 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.c +++ b/drivers/media/platform/exynos4-is/fimc-is.c @@ -834,23 +834,11 @@ static int fimc_is_probe(struct platform_device *pdev) goto err_clk; } pm_runtime_enable(dev); - /* - * Enable only the ISP power domain, keep FIMC-IS clocks off until - * the whole clock tree is configured. The ISP power domain needs - * be active in order to acces any CMU_ISP clock registers. - */ - ret = pm_runtime_get_sync(dev); - if (ret < 0) - goto err_irq; - - ret = fimc_is_setup_clocks(is); - pm_runtime_put_sync(dev); + ret = pm_runtime_get_sync(dev); if (ret < 0) goto err_irq; - is->clk_init = true; - is->alloc_ctx = vb2_dma_contig_init_ctx(dev); if (IS_ERR(is->alloc_ctx)) { ret = PTR_ERR(is->alloc_ctx); @@ -872,6 +860,8 @@ static int fimc_is_probe(struct platform_device *pdev) if (ret < 0) goto err_dfs; + pm_runtime_put_sync(dev); + dev_dbg(dev, "FIMC-IS registered successfully\n"); return 0; @@ -891,9 +881,11 @@ err_clk: static int fimc_is_runtime_resume(struct device *dev) { struct fimc_is *is = dev_get_drvdata(dev); + int ret; - if (!is->clk_init) - return 0; + ret = fimc_is_setup_clocks(is); + if (ret) + return ret; return fimc_is_enable_clocks(is); } @@ -902,9 +894,7 @@ static int fimc_is_runtime_suspend(struct device *dev) { struct fimc_is *is = dev_get_drvdata(dev); - if (is->clk_init) - fimc_is_disable_clocks(is); - + fimc_is_disable_clocks(is); return 0; } diff --git a/drivers/media/platform/exynos4-is/fimc-is.h b/drivers/media/platform/exynos4-is/fimc-is.h index 606a7c9..d7db133 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.h +++ b/drivers/media/platform/exynos4-is/fimc-is.h @@ -264,7 +264,6 @@ struct fimc_is { spinlock_t slock; struct clk *clocks[ISS_CLKS_MAX]; - bool clk_init; void __iomem *regs; void __iomem *pmu_regs; int irq; -- cgit v0.10.2 From 5f63adbb4cb9f952a8daee97f89c8811da5fd68a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 20 Jun 2013 05:46:00 -0300 Subject: [media] s5p makefiles: don't override other selections on obj-[ym] The $obj-m/$obj-y vars should be adding new modules to build, not overriding it. So, it should never use $obj-y := foo.o instead, it should use: $obj-y += foo.o Failing to do that is very bad, as it will suppress needed modules. Signed-off-by: Mauro Carvalho Chehab diff --git a/drivers/media/platform/s5p-jpeg/Makefile b/drivers/media/platform/s5p-jpeg/Makefile index ddc2900..d18cb5e 100644 --- a/drivers/media/platform/s5p-jpeg/Makefile +++ b/drivers/media/platform/s5p-jpeg/Makefile @@ -1,2 +1,2 @@ s5p-jpeg-objs := jpeg-core.o -obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) := s5p-jpeg.o +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o diff --git a/drivers/media/platform/s5p-mfc/Makefile b/drivers/media/platform/s5p-mfc/Makefile index 379008c..15f59b3 100644 --- a/drivers/media/platform/s5p-mfc/Makefile +++ b/drivers/media/platform/s5p-mfc/Makefile @@ -1,4 +1,4 @@ -obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) := s5p-mfc.o +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc.o s5p-mfc-y += s5p_mfc.o s5p_mfc_intr.o s5p-mfc-y += s5p_mfc_dec.o s5p_mfc_enc.o s5p-mfc-y += s5p_mfc_ctrl.o s5p_mfc_pm.o -- cgit v0.10.2 From bb69ee27b96110c509d5b92c9ee541d81a821706 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 20 Jun 2013 10:35:53 -0300 Subject: [media] Fix build when drivers are builtin and frontend modules There are a large number of reports that the media build is not compiling when some drivers are compiled as builtin, while the needed frontends are compiled as module. On the last one of such reports: From: kbuild test robot Subject: saa7134-dvb.c:undefined reference to `zl10039_attach' The .config file has: CONFIG_VIDEO_SAA7134=y CONFIG_VIDEO_SAA7134_DVB=y # CONFIG_MEDIA_ATTACH is not set CONFIG_DVB_ZL10039=m And it produces all those errors: drivers/built-in.o: In function `set_type': tuner-core.c:(.text+0x2f263e): undefined reference to `tea5767_attach' tuner-core.c:(.text+0x2f273e): undefined reference to `tda9887_attach' drivers/built-in.o: In function `tuner_probe': tuner-core.c:(.text+0x2f2d20): undefined reference to `tea5767_autodetection' drivers/built-in.o: In function `av7110_attach': av7110.c:(.text+0x330bda): undefined reference to `ves1x93_attach' av7110.c:(.text+0x330bf7): undefined reference to `stv0299_attach' av7110.c:(.text+0x330c63): undefined reference to `tda8083_attach' av7110.c:(.text+0x330d09): undefined reference to `ves1x93_attach' av7110.c:(.text+0x330d33): undefined reference to `tda8083_attach' av7110.c:(.text+0x330d5d): undefined reference to `stv0297_attach' av7110.c:(.text+0x330dbe): undefined reference to `stv0299_attach' drivers/built-in.o: In function `tuner_attach_dtt7520x': ngene-cards.c:(.text+0x3381cb): undefined reference to `dvb_pll_attach' drivers/built-in.o: In function `demod_attach_lg330x': ngene-cards.c:(.text+0x33828a): undefined reference to `lgdt330x_attach' drivers/built-in.o: In function `demod_attach_stv0900': ngene-cards.c:(.text+0x3383d5): undefined reference to `stv090x_attach' drivers/built-in.o: In function `cineS2_probe': ngene-cards.c:(.text+0x338b7f): undefined reference to `drxk_attach' drivers/built-in.o: In function `configure_tda827x_fe': saa7134-dvb.c:(.text+0x346ae7): undefined reference to `tda10046_attach' drivers/built-in.o: In function `dvb_init': saa7134-dvb.c:(.text+0x347283): undefined reference to `mt352_attach' saa7134-dvb.c:(.text+0x3472cd): undefined reference to `mt352_attach' saa7134-dvb.c:(.text+0x34731c): undefined reference to `tda10046_attach' saa7134-dvb.c:(.text+0x34733c): undefined reference to `tda10046_attach' saa7134-dvb.c:(.text+0x34735c): undefined reference to `tda10046_attach' saa7134-dvb.c:(.text+0x347378): undefined reference to `tda10046_attach' saa7134-dvb.c:(.text+0x3473db): undefined reference to `tda10046_attach' drivers/built-in.o:saa7134-dvb.c:(.text+0x347502): more undefined references to `tda10046_attach' follow drivers/built-in.o: In function `dvb_init': saa7134-dvb.c:(.text+0x347812): undefined reference to `mt352_attach' saa7134-dvb.c:(.text+0x347951): undefined reference to `mt312_attach' saa7134-dvb.c:(.text+0x3479a9): undefined reference to `mt312_attach' >> saa7134-dvb.c:(.text+0x3479c1): undefined reference to `zl10039_attach' This is happening because a builtin module can't use directly a symbol found on a module. By enabling CONFIG_MEDIA_ATTACH, the configuration becomes valid, as dvb_attach() macro loads the module if needed, making the symbol available to the builtin module. While this bug started to appear after the patches that use IS_DEFINED macro (like changeset 7b34be71db533f3e0cf93d53cf62d036cdb5418a), this bug is a way ancient than that. The thing is that, before the IS_DEFINED() patches, the logic used to be: && defined(MODULE)) struct dvb_frontend *zl10039_attach(struct dvb_frontend *fe, u8 i2c_addr, struct i2c_adapter *i2c); static inline struct dvb_frontend *zl10039_attach(struct dvb_frontend *fe, u8 i2c_addr, struct i2c_adapter *i2c) { printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } The above code, with the .config file used, was evoluting to FALSE (instead of TRUE as it should be, as CONFIG_DVB_ZL10039 is 'm'), and were adding the static inline code at saa7134-dvb, instead of the external call. So, while it weren't producing any compilation error, the code weren't working either. So, as the overhead for using CONFIG_MEDIA_ATTACH is minimal, just enable it, if MODULES is defined. Signed-off-by: Mauro Carvalho Chehab diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 7f5a7ca..8270388 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig @@ -136,9 +136,9 @@ config DVB_NET # This Kconfig option is used by both PCI and USB drivers config TTPCI_EEPROM - tristate - depends on I2C - default n + tristate + depends on I2C + default n source "drivers/media/dvb-core/Kconfig" @@ -189,6 +189,12 @@ config MEDIA_SUBDRV_AUTOSELECT If unsure say Y. +config MEDIA_ATTACH + bool + depends on MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT || MEDIA_RADIO_SUPPORT + depends on MODULES + default MODULES + source "drivers/media/i2c/Kconfig" source "drivers/media/tuners/Kconfig" source "drivers/media/dvb-frontends/Kconfig" diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig index f6768ca..15665de 100644 --- a/drivers/media/tuners/Kconfig +++ b/drivers/media/tuners/Kconfig @@ -1,23 +1,3 @@ -config MEDIA_ATTACH - bool "Load and attach frontend and tuner driver modules as needed" - depends on MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT || MEDIA_RADIO_SUPPORT - depends on MODULES - default y if !EXPERT - help - Remove the static dependency of DVB card drivers on all - frontend modules for all possible card variants. Instead, - allow the card drivers to only load the frontend modules - they require. - - Also, tuner module will automatically load a tuner driver - when needed, for analog mode. - - This saves several KBytes of memory. - - Note: You will need module-init-tools v3.2 or later for this feature. - - If unsure say Y. - # Analog TV tuners, auto-loaded via tuner.ko config MEDIA_TUNER tristate -- cgit v0.10.2