stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on not-supported SoCs
       [not found] <20201207190517.262051-1-krzk@kernel.org>
@ 2020-12-07 19:05 ` Krzysztof Kozlowski
  2020-12-08  5:56   ` Pankaj Dubey
  2021-01-03 16:10   ` Krzysztof Kozlowski
  2020-12-07 19:05 ` [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision register error Krzysztof Kozlowski
  1 sibling, 2 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2020-12-07 19:05 UTC (permalink / raw)
  To: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc, linux-kernel
  Cc: Sylwester Nawrocki, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Arnd Bergmann, Chanwoo Choi, Alim Akhtar, Pankaj Dubey, stable

From: Marek Szyprowski <m.szyprowski@samsung.com>

Check if the SoC is really supported before gathering the needed
resources. This fixes endless deferred probe on some SoCs other than
Exynos5422 (like Exynos5410).

Fixes: 5ea428595cc5 ("soc: samsung: Add Exynos Adaptive Supply Voltage driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/soc/samsung/exynos-asv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/samsung/exynos-asv.c b/drivers/soc/samsung/exynos-asv.c
index 8abf4dfaa5c5..f653e3533f0f 100644
--- a/drivers/soc/samsung/exynos-asv.c
+++ b/drivers/soc/samsung/exynos-asv.c
@@ -119,11 +119,6 @@ static int exynos_asv_probe(struct platform_device *pdev)
 	u32 product_id = 0;
 	int ret, i;
 
-	cpu_dev = get_cpu_device(0);
-	ret = dev_pm_opp_get_opp_count(cpu_dev);
-	if (ret < 0)
-		return -EPROBE_DEFER;
-
 	asv = devm_kzalloc(&pdev->dev, sizeof(*asv), GFP_KERNEL);
 	if (!asv)
 		return -ENOMEM;
@@ -144,6 +139,11 @@ static int exynos_asv_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	cpu_dev = get_cpu_device(0);
+	ret = dev_pm_opp_get_opp_count(cpu_dev);
+	if (ret < 0)
+		return -EPROBE_DEFER;
+
 	ret = of_property_read_u32(pdev->dev.of_node, "samsung,asv-bin",
 				   &asv->of_bin);
 	if (ret < 0)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision register error
       [not found] <20201207190517.262051-1-krzk@kernel.org>
  2020-12-07 19:05 ` [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on not-supported SoCs Krzysztof Kozlowski
@ 2020-12-07 19:05 ` Krzysztof Kozlowski
  2020-12-08  6:14   ` Pankaj Dubey
  2021-01-03 16:11   ` Krzysztof Kozlowski
  1 sibling, 2 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2020-12-07 19:05 UTC (permalink / raw)
  To: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc, linux-kernel
  Cc: Sylwester Nawrocki, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Arnd Bergmann, Chanwoo Choi, Alim Akhtar, Pankaj Dubey, stable

If regmap_read() fails, the product_id local variable will contain
random value from the stack.  Do not try to parse such value and fail
the ASV driver probe.

Fixes: 5ea428595cc5 ("soc: samsung: Add Exynos Adaptive Supply Voltage driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/soc/samsung/exynos-asv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/samsung/exynos-asv.c b/drivers/soc/samsung/exynos-asv.c
index f653e3533f0f..5daeadc36382 100644
--- a/drivers/soc/samsung/exynos-asv.c
+++ b/drivers/soc/samsung/exynos-asv.c
@@ -129,7 +129,13 @@ static int exynos_asv_probe(struct platform_device *pdev)
 		return PTR_ERR(asv->chipid_regmap);
 	}
 
-	regmap_read(asv->chipid_regmap, EXYNOS_CHIPID_REG_PRO_ID, &product_id);
+	ret = regmap_read(asv->chipid_regmap, EXYNOS_CHIPID_REG_PRO_ID,
+			  &product_id);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Cannot read revision from ChipID: %d\n",
+			ret);
+		return -ENODEV;
+	}
 
 	switch (product_id & EXYNOS_MASK) {
 	case 0xE5422000:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on not-supported SoCs
  2020-12-07 19:05 ` [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on not-supported SoCs Krzysztof Kozlowski
@ 2020-12-08  5:56   ` Pankaj Dubey
  2021-01-03 16:10   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 6+ messages in thread
From: Pankaj Dubey @ 2020-12-08  5:56 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski',
	linux-arm-kernel, linux-samsung-soc, linux-kernel
  Cc: 'Sylwester Nawrocki', 'Marek Szyprowski',
	'Bartlomiej Zolnierkiewicz', 'Arnd Bergmann',
	'Chanwoo Choi', 'Alim Akhtar',
	stable



> -----Original Message-----
> From: Krzysztof Kozlowski <krzk@kernel.org>
> Sent: Tuesday, December 8, 2020 12:35 AM
> To: Krzysztof Kozlowski <krzk@kernel.org>; linux-arm-
> kernel@lists.infradead.org; linux-samsung-soc@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: Sylwester Nawrocki <snawrocki@kernel.org>; Marek Szyprowski
> <m.szyprowski@samsung.com>; Bartlomiej Zolnierkiewicz
> <b.zolnierkie@samsung.com>; Arnd Bergmann <arnd@arndb.de>; Chanwoo
> Choi <cw00.choi@samsung.com>; Alim Akhtar <alim.akhtar@samsung.com>;
> Pankaj Dubey <pankaj.dubey@samsung.com>; stable@vger.kernel.org
> Subject: [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on
not-
> supported SoCs
> 
> From: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> Check if the SoC is really supported before gathering the needed
resources.
> This fixes endless deferred probe on some SoCs other than
> Exynos5422 (like Exynos5410).
> 
> Fixes: 5ea428595cc5 ("soc: samsung: Add Exynos Adaptive Supply Voltage
> driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/soc/samsung/exynos-asv.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/soc/samsung/exynos-asv.c
> b/drivers/soc/samsung/exynos-asv.c
> index 8abf4dfaa5c5..f653e3533f0f 100644
> --- a/drivers/soc/samsung/exynos-asv.c
> +++ b/drivers/soc/samsung/exynos-asv.c
> @@ -119,11 +119,6 @@ static int exynos_asv_probe(struct platform_device
> *pdev)
>  	u32 product_id = 0;
>  	int ret, i;
> 
> -	cpu_dev = get_cpu_device(0);
> -	ret = dev_pm_opp_get_opp_count(cpu_dev);
> -	if (ret < 0)
> -		return -EPROBE_DEFER;
> -
>  	asv = devm_kzalloc(&pdev->dev, sizeof(*asv), GFP_KERNEL);
>  	if (!asv)
>  		return -ENOMEM;
> @@ -144,6 +139,11 @@ static int exynos_asv_probe(struct platform_device
> *pdev)
>  		return -ENODEV;
>  	}
> 
> +	cpu_dev = get_cpu_device(0);
> +	ret = dev_pm_opp_get_opp_count(cpu_dev);
> +	if (ret < 0)
> +		return -EPROBE_DEFER;
> +
>  	ret = of_property_read_u32(pdev->dev.of_node, "samsung,asv-
> bin",
>  				   &asv->of_bin);
>  	if (ret < 0)
> --
> 2.25.1

Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision register error
  2020-12-07 19:05 ` [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision register error Krzysztof Kozlowski
@ 2020-12-08  6:14   ` Pankaj Dubey
  2021-01-03 16:11   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 6+ messages in thread
From: Pankaj Dubey @ 2020-12-08  6:14 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski',
	linux-arm-kernel, linux-samsung-soc, linux-kernel
  Cc: 'Sylwester Nawrocki', 'Marek Szyprowski',
	'Bartlomiej Zolnierkiewicz', 'Arnd Bergmann',
	'Chanwoo Choi', 'Alim Akhtar',
	stable



> -----Original Message-----
> From: Krzysztof Kozlowski <krzk@kernel.org>
> Sent: Tuesday, December 8, 2020 12:35 AM
> To: Krzysztof Kozlowski <krzk@kernel.org>; linux-arm-
> kernel@lists.infradead.org; linux-samsung-soc@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: Sylwester Nawrocki <snawrocki@kernel.org>; Marek Szyprowski
> <m.szyprowski@samsung.com>; Bartlomiej Zolnierkiewicz
> <b.zolnierkie@samsung.com>; Arnd Bergmann <arnd@arndb.de>; Chanwoo
> Choi <cw00.choi@samsung.com>; Alim Akhtar <alim.akhtar@samsung.com>;
> Pankaj Dubey <pankaj.dubey@samsung.com>; stable@vger.kernel.org
> Subject: [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision
> register error
> 
> If regmap_read() fails, the product_id local variable will contain random
value
> from the stack.  Do not try to parse such value and fail the ASV driver
probe.
> 
> Fixes: 5ea428595cc5 ("soc: samsung: Add Exynos Adaptive Supply Voltage
> driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/soc/samsung/exynos-asv.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/samsung/exynos-asv.c
> b/drivers/soc/samsung/exynos-asv.c
> index f653e3533f0f..5daeadc36382 100644
> --- a/drivers/soc/samsung/exynos-asv.c
> +++ b/drivers/soc/samsung/exynos-asv.c
> @@ -129,7 +129,13 @@ static int exynos_asv_probe(struct platform_device
> *pdev)
>  		return PTR_ERR(asv->chipid_regmap);
>  	}
> 
> -	regmap_read(asv->chipid_regmap, EXYNOS_CHIPID_REG_PRO_ID,
> &product_id);
> +	ret = regmap_read(asv->chipid_regmap,
> EXYNOS_CHIPID_REG_PRO_ID,
> +			  &product_id);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "Cannot read revision from
> ChipID: %d\n",
> +			ret);
> +		return -ENODEV;
> +	}
> 
>  	switch (product_id & EXYNOS_MASK) {
>  	case 0xE5422000:
> --
> 2.25.1

Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on not-supported SoCs
  2020-12-07 19:05 ` [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on not-supported SoCs Krzysztof Kozlowski
  2020-12-08  5:56   ` Pankaj Dubey
@ 2021-01-03 16:10   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-01-03 16:10 UTC (permalink / raw)
  To: linux-arm-kernel, linux-samsung-soc, linux-kernel
  Cc: Sylwester Nawrocki, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Arnd Bergmann, Chanwoo Choi, Alim Akhtar, Pankaj Dubey, stable

On Mon, Dec 07, 2020 at 08:05:14PM +0100, Krzysztof Kozlowski wrote:
> From: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> Check if the SoC is really supported before gathering the needed
> resources. This fixes endless deferred probe on some SoCs other than
> Exynos5422 (like Exynos5410).
> 
> Fixes: 5ea428595cc5 ("soc: samsung: Add Exynos Adaptive Supply Voltage driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/soc/samsung/exynos-asv.c | 10 +++++-----

Thanks, applied.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision register error
  2020-12-07 19:05 ` [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision register error Krzysztof Kozlowski
  2020-12-08  6:14   ` Pankaj Dubey
@ 2021-01-03 16:11   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-01-03 16:11 UTC (permalink / raw)
  To: linux-arm-kernel, linux-samsung-soc, linux-kernel
  Cc: Sylwester Nawrocki, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
	Arnd Bergmann, Chanwoo Choi, Alim Akhtar, Pankaj Dubey, stable

On Mon, Dec 07, 2020 at 08:05:15PM +0100, Krzysztof Kozlowski wrote:
> If regmap_read() fails, the product_id local variable will contain
> random value from the stack.  Do not try to parse such value and fail
> the ASV driver probe.
> 
> Fixes: 5ea428595cc5 ("soc: samsung: Add Exynos Adaptive Supply Voltage driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/soc/samsung/exynos-asv.c | 8 +++++++-

Applied.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-03 16:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20201207190517.262051-1-krzk@kernel.org>
2020-12-07 19:05 ` [PATCH v2 1/4] soc: samsung: exynos-asv: don't defer early on not-supported SoCs Krzysztof Kozlowski
2020-12-08  5:56   ` Pankaj Dubey
2021-01-03 16:10   ` Krzysztof Kozlowski
2020-12-07 19:05 ` [PATCH v2 2/4] soc: samsung: exynos-asv: handle reading revision register error Krzysztof Kozlowski
2020-12-08  6:14   ` Pankaj Dubey
2021-01-03 16:11   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).