Re: [PATCH 1/3] thermal: exynos: Fix NULL pointer exception during kernel booting

2015-02-16 Thread Chanwoo Choi
Hi Lukasz,

On Tue, Feb 17, 2015 at 12:06 AM, Lukasz Majewski
l.majew...@samsung.com wrote:
 Hi Chanwoo,

 This patch fixes the NULL pointer exception during kernel booting.
 The thermal_zone _of_sensor_register() registers a sensor to DT
 thermal zone and then read the current temperature by '.get_temp'
 callback. The callback function of exynos thermal driver is
 exynos_get_temp() which must need the 'pdata' instance of exynos_tmu
 _platform_data structure.
 - exynos_get_temp() - code_to_temp() - Must need the 'pdata'
 instance

 But, exynos thermal driver is executed before getting the 'pdata'
 instance. To avoid the kernel panic, have to get the platform data by
 executing the exynos_map_dt_data() before calling
 thermal_zone_of_sensor_register() .

 I've already prepared patch for this (unfortunately it isn't yet
 applied to mainline):

 [PATCH] thermal: exynos: fix: Check if data-tmu_read callback is
 present before read

 http://www.spinics.net/lists/linux-samsung-soc/msg42245.html

There is different issue between you patch and this patch.
Your patch check the whether data-tmu_read is NULL or not.
But, my patch check the pdata is NULL or not.


 Does applying this patch help?

 BTW: How can I reproduce this error? Could you point me the SHA1 and
 repository?

I used your patch-set of linux-soc-thermal.git (branch: next). So I
applied you patchiest on Linux 3.19 for test.
- 
https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/log/?h=next

Best Regards,
Chanwoo Choi
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] thermal: exynos: Fix NULL pointer exception during kernel booting

2015-02-16 Thread Chanwoo Choi
Hi Lukasz,

On Tue, Feb 17, 2015 at 1:28 AM, Lukasz Majewski l.majew...@samsung.com wrote:
 Hi Chanwoo,

 Hi Lukasz,

 On Tue, Feb 17, 2015 at 12:06 AM, Lukasz Majewski
 l.majew...@samsung.com wrote:
  Hi Chanwoo,
 
  This patch fixes the NULL pointer exception during kernel booting.
  The thermal_zone _of_sensor_register() registers a sensor to DT
  thermal zone and then read the current temperature by '.get_temp'
  callback. The callback function of exynos thermal driver is
  exynos_get_temp() which must need the 'pdata' instance of
  exynos_tmu _platform_data structure.
  - exynos_get_temp() - code_to_temp() - Must need the 'pdata'
  instance
 
  But, exynos thermal driver is executed before getting the 'pdata'
  instance. To avoid the kernel panic, have to get the platform data
  by executing the exynos_map_dt_data() before calling
  thermal_zone_of_sensor_register() .
 
  I've already prepared patch for this (unfortunately it isn't yet
  applied to mainline):
 
  [PATCH] thermal: exynos: fix: Check if data-tmu_read callback is
  present before read
 
  http://www.spinics.net/lists/linux-samsung-soc/msg42245.html

 There is different issue between you patch and this patch.
 Your patch check the whether data-tmu_read is NULL or not.
 But, my patch check the pdata is NULL or not.

 I've tried to do the same previously. Please compare with:
 [PATCH 1/2] thermal: exynos: Reorder exynos_map_dt_data() function

 http://www.spinics.net/lists/linux-samsung-soc/msg41308.html

 Unfortunately, Abhilash found some issues with this code, so I've
 looked into different solution.

OK.



 However, I didn't need to move pdata = data-pdata; Hence, I wonder why
 it need to be reordered. Are you using Exynos3250 based device?

I think it is necessary to prevent kernel panic. We can check this
issue by analyzing
the thermal_zone_of_sensor_register() as following issue:

of_thermal_get_temp() executes the exynos_get_temp() finally. And
exynos_get_temp()
function must need the 'pdata' instance. The 'pdata' instance is
initialized on exynos_map_dt_data().
If exynos_tmu driver executes the exynos_map_dt_data() after
thermal_zone_of_sensor_register(),
this issue happen again.

[ 4211.945315] [ffc0004de6d8] of_thermal_get_temp+0x1c/0x30
[ 4211.951132] [ffc0004db86c] thermal_zone_get_temp+0x48/0x7c
[ 4211.957118] [ffc0004dd278] thermal_zone_device_update+0x20/0x110
[ 4211.963627] [ffc0004de9c8] of_thermal_set_mode+0x44/0x68
[ 4211.969443] [ffc0004decb8] thermal_zone_of_sensor_register+0x15c/0x1d8

I tested it on Exynos5433 based device.




 
  Does applying this patch help?
 
  BTW: How can I reproduce this error? Could you point me the SHA1 and
  repository?

 I used your patch-set of linux-soc-thermal.git (branch: next). So I
 applied you patchiest on Linux 3.19 for test.
 -
 https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/log/?h=next

 Is there any special .config?

There is no special configuration.
I tested this patch with CPUFREQ for cooling device.


 May I ask about the target platform?
 I will look closely on this problem tomorrow.

OK.

Best Regards,
Chanwoo Choi
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] thermal: exynos: Fix NULL pointer exception during kernel booting

2015-02-16 Thread Lukasz Majewski
Hi Chanwoo,

 Hi Lukasz,
 
 On Tue, Feb 17, 2015 at 12:06 AM, Lukasz Majewski
 l.majew...@samsung.com wrote:
  Hi Chanwoo,
 
  This patch fixes the NULL pointer exception during kernel booting.
  The thermal_zone _of_sensor_register() registers a sensor to DT
  thermal zone and then read the current temperature by '.get_temp'
  callback. The callback function of exynos thermal driver is
  exynos_get_temp() which must need the 'pdata' instance of
  exynos_tmu _platform_data structure.
  - exynos_get_temp() - code_to_temp() - Must need the 'pdata'
  instance
 
  But, exynos thermal driver is executed before getting the 'pdata'
  instance. To avoid the kernel panic, have to get the platform data
  by executing the exynos_map_dt_data() before calling
  thermal_zone_of_sensor_register() .
 
  I've already prepared patch for this (unfortunately it isn't yet
  applied to mainline):
 
  [PATCH] thermal: exynos: fix: Check if data-tmu_read callback is
  present before read
 
  http://www.spinics.net/lists/linux-samsung-soc/msg42245.html
 
 There is different issue between you patch and this patch.
 Your patch check the whether data-tmu_read is NULL or not.
 But, my patch check the pdata is NULL or not.

I've tried to do the same previously. Please compare with:
[PATCH 1/2] thermal: exynos: Reorder exynos_map_dt_data() function

http://www.spinics.net/lists/linux-samsung-soc/msg41308.html

Unfortunately, Abhilash found some issues with this code, so I've
looked into different solution.


However, I didn't need to move pdata = data-pdata; Hence, I wonder why
it need to be reordered. Are you using Exynos3250 based device?


 
 
  Does applying this patch help?
 
  BTW: How can I reproduce this error? Could you point me the SHA1 and
  repository?
 
 I used your patch-set of linux-soc-thermal.git (branch: next). So I
 applied you patchiest on Linux 3.19 for test.
 -
 https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/log/?h=next

Is there any special .config?

May I ask about the target platform?
I will look closely on this problem tomorrow.

 
 Best Regards,
 Chanwoo Choi



-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/45] exynos_drm.h: include stdint.h in userspace

2015-02-16 Thread Mikko Rapeli
Fixes compilation errors like:

drm/exynos_drm.h:30:2: error: unknown type name ‘uint64_t’

Signed-off-by: Mikko Rapeli mikko.rap...@iki.fi
---
 include/uapi/drm/exynos_drm.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
index 5575ed1..03d094d 100644
--- a/include/uapi/drm/exynos_drm.h
+++ b/include/uapi/drm/exynos_drm.h
@@ -15,6 +15,11 @@
 #ifndef _UAPI_EXYNOS_DRM_H_
 #define _UAPI_EXYNOS_DRM_H_
 
+#ifdef __KERNEL__
+#include linux/types.h
+#else
+#include stdint.h
+#endif
 #include drm/drm.h
 
 /**
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] thermal: exynos: Fix NULL pointer error and bug of PD_DET_EN of Exynos7

2015-02-16 Thread Chanwoo Choi
This patch-set fix NULL pointer error during kernel booting and the bug of
PD_DET_EN bit field of Exynos7 TMU. And the clean-up the exynos compatible
table by making oneline entry.

Chanwoo Choi (3):
  thermal: exynos: Fix NULL pointer exception during kernel booting
  thermal: exynos: Fix wrong control of power down detection mode for Exynos7
  thermal: exynos: Clean-up code to use oneline entry for exynos compatible 
table

 drivers/thermal/samsung/exynos_tmu.c | 51 
 1 file changed, 17 insertions(+), 34 deletions(-)

-- 
1.8.5.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] thermal: exynos: Fix NULL pointer exception during kernel booting

2015-02-16 Thread Chanwoo Choi
This patch fixes the NULL pointer exception during kernel booting. The 
thermal_zone
_of_sensor_register() registers a sensor to DT thermal zone and then read
the current temperature by '.get_temp' callback. The callback function
of exynos thermal driver is exynos_get_temp() which must need the 'pdata'
instance of exynos_tmu _platform_data structure.
- exynos_get_temp() - code_to_temp() - Must need the 'pdata' instance

But, exynos thermal driver is executed before getting the 'pdata' instance.
To avoid the kernel panic, have to get the platform data by executing the
exynos_map_dt_data() before calling thermal_zone_of_sensor_register() .

- kernel panic log
[ 4211.324346] PC is at 0x0
[ 4211.326867] LR is at exynos_get_temp+0x3c/0xe4
[ 4211.331289] pc : [] lr : [ffc0004df460]
[snip]
[ 4211.940625] [  (null)]   (null)
[ 4211.945315] [ffc0004de6d8] of_thermal_get_temp+0x1c/0x30
[ 4211.951132] [ffc0004db86c] thermal_zone_get_temp+0x48/0x7c
[ 4211.957118] [ffc0004dd278] thermal_zone_device_update+0x20/0x110
[ 4211.963627] [ffc0004de9c8] of_thermal_set_mode+0x44/0x68
[ 4211.969443] [ffc0004decb8] thermal_zone_of_sensor_register+0x15c/0x1d8
[ 4211.976475] [ffc0004dfbe4] exynos_tmu_probe+0x6c/0x814
[ 4211.982120] [ffc0003ef808] platform_drv_probe+0x48/0xb8
[ 4211.987846] [ffc0003edb28] driver_probe_device+0x8c/0x244
[ 4211.993747] [ffc0003eddcc] __driver_attach+0x98/0xa0
[ 4211.999216] [ffc0003ebea0] bus_for_each_dev+0x54/0x98
[ 4212.004771] [ffc0003ed66c] driver_attach+0x1c/0x28
[ 4212.010066] [ffc0003ed2e8] bus_add_driver+0x150/0x208
[ 4212.015622] [ffc0003ee6a4] driver_register+0x5c/0x11c
[ 4212.021178] [ffc0003ef73c] __platform_driver_register+0x5c/0x68
[ 4212.027600] [ffc000b64eb8] exynos_tmu_driver_init+0x14/0x20
[ 4212.033678] [ffc828d4] do_one_initcall+0x88/0x1a0
[ 4212.039235] [ffc000b34b34] kernel_init_freeable+0x1bc/0x260
[ 4212.045311] [ffc0007e9fd4] kernel_init+0xc/0xd8

Cc: Zhang Rui rui.zh...@intel.com
Cc: Eduardo Valentin edubez...@gmail.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index fbeedc0..b8846f1 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1147,17 +1147,17 @@ static int exynos_tmu_probe(struct platform_device 
*pdev)
platform_set_drvdata(pdev, data);
mutex_init(data-lock);
 
+   ret = exynos_map_dt_data(pdev);
+   if (ret)
+   return ret;
+   pdata = data-pdata;
+
data-tzd = thermal_zone_of_sensor_register(pdev-dev, 0, data,
exynos_sensor_ops);
if (IS_ERR(data-tzd)) {
pr_err(thermal: tz: %p ERROR\n, data-tzd);
return PTR_ERR(data-tzd);
}
-   ret = exynos_map_dt_data(pdev);
-   if (ret)
-   goto err_sensor;
-
-   pdata = data-pdata;
 
INIT_WORK(data-irq_work, exynos_tmu_work);
 
-- 
1.8.5.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] thermal: exynos: Fix wrong control of power down detection mode for Exynos7

2015-02-16 Thread Chanwoo Choi
This patch fixes the wrong control of PD_DET_EN (power down detection mode)
for Exynos7 because exynos7_tmu_control() always enables the power down 
detection
mode regardless 'on' parameter.

Cc: Zhang Rui rui.zh...@intel.com
Cc: Eduardo Valentin edubez...@gmail.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index b8846f1..b199fff 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -682,6 +682,7 @@ static void exynos7_tmu_control(struct platform_device 
*pdev, bool on)
 
if (on) {
con |= (1  EXYNOS_TMU_CORE_EN_SHIFT);
+   con |= (1  EXYNOS7_PD_DET_EN_SHIFT);
interrupt_en =
(of_thermal_is_trip_valid(tz, 7)
 EXYNOS7_TMU_INTEN_RISE7_SHIFT) |
@@ -704,9 +705,9 @@ static void exynos7_tmu_control(struct platform_device 
*pdev, bool on)
interrupt_en  EXYNOS_TMU_INTEN_FALL0_SHIFT;
} else {
con = ~(1  EXYNOS_TMU_CORE_EN_SHIFT);
+   con = ~(1  EXYNOS7_PD_DET_EN_SHIFT);
interrupt_en = 0; /* Disable all interrupts */
}
-   con |= 1  EXYNOS7_PD_DET_EN_SHIFT;
 
writel(interrupt_en, data-base + EXYNOS7_TMU_REG_INTEN);
writel(con, data-base + EXYNOS_TMU_REG_CONTROL);
-- 
1.8.5.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] thermal: exynos: Clean-up code to use oneline entry for exynos compatible table

2015-02-16 Thread Chanwoo Choi
This patch cleanup the code to use oneline for entry of exynos compatible
table.

Cc: Zhang Rui rui.zh...@intel.com
Cc: Eduardo Valentin edubez...@gmail.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 38 ++--
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index b199fff..7e6baf5 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -919,34 +919,16 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 }
 
 static const struct of_device_id exynos_tmu_match[] = {
-   {
-   .compatible = samsung,exynos3250-tmu,
-   },
-   {
-   .compatible = samsung,exynos4210-tmu,
-   },
-   {
-   .compatible = samsung,exynos4412-tmu,
-   },
-   {
-   .compatible = samsung,exynos5250-tmu,
-   },
-   {
-   .compatible = samsung,exynos5260-tmu,
-   },
-   {
-   .compatible = samsung,exynos5420-tmu,
-   },
-   {
-   .compatible = samsung,exynos5420-tmu-ext-triminfo,
-   },
-   {
-   .compatible = samsung,exynos5440-tmu,
-   },
-   {
-   .compatible = samsung,exynos7-tmu,
-   },
-   {},
+   { .compatible = samsung,exynos3250-tmu, },
+   { .compatible = samsung,exynos4210-tmu, },
+   { .compatible = samsung,exynos4412-tmu, },
+   { .compatible = samsung,exynos5250-tmu, },
+   { .compatible = samsung,exynos5260-tmu, },
+   { .compatible = samsung,exynos5420-tmu, },
+   { .compatible = samsung,exynos5420-tmu-ext-triminfo, },
+   { .compatible = samsung,exynos5440-tmu, },
+   { .compatible = samsung,exynos7-tmu, },
+   { /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-- 
1.8.5.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 14/15] exynos: fimg2d: unify register style

2015-02-16 Thread Tobias Jakobi
Register defines all use uppercase hex codes.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/fimg2d_reg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/exynos/fimg2d_reg.h b/exynos/fimg2d_reg.h
index 5782488..07dd634 100644
--- a/exynos/fimg2d_reg.h
+++ b/exynos/fimg2d_reg.h
@@ -15,7 +15,7 @@
 
 #define SOFT_RESET_REG (0x)
 #define INTEN_REG  (0x0004)
-#define INTC_PEND_REG  (0x000c)
+#define INTC_PEND_REG  (0x000C)
 #define FIFO_STAT_REG  (0x0010)
 #define AXI_MODE_REG   (0x001C)
 #define DMA_SFR_BASE_ADDR_REG  (0x0080)
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 15/15] exynos: fimg2d: introduce G2D_OP_INTERPOLATE

2015-02-16 Thread Tobias Jakobi
This sets up the blending equation in the following way:
out = src * src_alpha + dst * (1 - src_alpha)

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.c | 4 
 exynos/exynos_fimg2d.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 126a15d..18d5b89 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -85,6 +85,10 @@ static unsigned int g2d_get_blend_op(enum e_g2d_op op)
SET_BF(val, G2D_COEFF_MODE_ONE, 0, 0, 0,
G2D_COEFF_MODE_SRC_ALPHA, 1, 0, 0);
break;
+   case G2D_OP_INTERPOLATE:
+   SET_BF(val, G2D_COEFF_MODE_SRC_ALPHA, 0, 0, 0,
+   G2D_COEFF_MODE_SRC_ALPHA, 1, 0, 0);
+   break;
default:
fprintf(stderr, Not support operation(%d).\n, op);
SET_BF(val, G2D_COEFF_MODE_ONE, 0, 0, 0, G2D_COEFF_MODE_ZERO,
diff --git a/exynos/exynos_fimg2d.h b/exynos/exynos_fimg2d.h
index 78cff47..79e6907 100644
--- a/exynos/exynos_fimg2d.h
+++ b/exynos/exynos_fimg2d.h
@@ -149,6 +149,7 @@ enum e_g2d_op {
G2D_OP_SRC  = 0x01,
G2D_OP_DST  = 0x02,
G2D_OP_OVER = 0x03,
+   G2D_OP_INTERPOLATE  = 0x04,
G2D_OP_DISJOINT_CLEAR   = 0x10,
G2D_OP_DISJOINT_SRC = 0x11,
G2D_OP_DISJOINT_DST = 0x12,
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: EXYNOS: Don't use LDREX and STREX after disabling cache coherency

2015-02-16 Thread Krzysztof Kozlowski
During CPU shutdown the exynos_cpu_power_down() is called after
disabling cache coherency and it uses LDREX and STREX instructions (by
calling of_machine_is_compatible() - kobject_get() - kref_get()).

The LDREX and STREX should not be used after disabling the cache
coherency so just use soc_is_exynos().

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
Fixes: adc548d77c22 (ARM: EXYNOS: Use MCPM call-backs to support S2R on 
exynos5420)
Cc: sta...@vger.kernel.org
Reported-by: Stephen Boyd sb...@codeaurora.org
---
 arch/arm/mach-exynos/platsmp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 7a1ebfb8..0abb7dff73ab 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -126,8 +126,7 @@ static inline void platform_do_lowpower(unsigned int cpu, 
int *spurious)
  */
 void exynos_cpu_power_down(int cpu)
 {
-   if (cpu == 0  (of_machine_is_compatible(samsung,exynos5420) ||
-   of_machine_is_compatible(samsung,exynos5800))) {
+   if (cpu == 0  (soc_is_exynos5420() || soc_is_exynos5800())) {
/*
 * Bypass power down for CPU0 during suspend. Check for
 * the SYS_PWR_REG value to decide if we are suspending
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 05/15] exynos: add g2d_scale_and_blend

2015-02-16 Thread Tobias Jakobi
This is a combination of g2d_copy_with_scale and g2d_scale.
It is a pretty common operation to scale one buffer and then
blend it on top of another, so provide a direct way to that
operation.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.c | 129 +
 exynos/fimg2d.h|   5 ++
 2 files changed, 134 insertions(+)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 8b1a0ff..0d89b1d 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -643,3 +643,132 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
return 0;
 }
 
+/**
+ * g2d_scale_and_blend - apply scaling to source buffer and then blend to 
destination buffer
+ *
+ * @ctx: a pointer to g2d_context structure.
+ * @src: a pointer to g2d_image structure including image and buffer
+ * information to source.
+ * @dst: a pointer to g2d_image structure including image and buffer
+ * information to destination.
+ * @src_x: x start position to source buffer.
+ * @src_y: y start position to source buffer.
+ * @src_w: width value to source buffer.
+ * @src_h: height value to source buffer.
+ * @dst_x: x start position to destination buffer.
+ * @dst_y: y start position to destination buffer.
+ * @dst_w: width value to destination buffer.
+ * @dst_h: height value to destination buffer.
+ * @op: blend operation type.
+ */
+drm_public int
+g2d_scale_and_blend(struct g2d_context *ctx, struct g2d_image *src,
+   struct g2d_image *dst, unsigned int src_x, unsigned int src_y,
+   unsigned int src_w, unsigned int src_h, unsigned int dst_x,
+   unsigned int dst_y, unsigned int dst_w, unsigned int dst_h,
+   enum e_g2d_op op)
+{
+   union g2d_point_val pt;
+   union g2d_bitblt_cmd_val bitblt;
+   union g2d_blend_func_val blend;
+   unsigned int scale;
+   unsigned int scale_x, scale_y;
+
+   bitblt.val = 0;
+   blend.val = 0;
+
+   if (op == G2D_OP_SRC || op == G2D_OP_CLEAR)
+   g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
+   else
+   g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
+
+   g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst-color_mode);
+   if (dst-buf_type == G2D_IMGBUF_USERPTR)
+   g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
+   (unsigned long)dst-user_ptr[0]);
+   else
+   g2d_add_cmd(ctx, DST_BASE_ADDR_REG, dst-bo[0]);
+
+   g2d_add_cmd(ctx, DST_STRIDE_REG, dst-stride);
+
+   g2d_add_cmd(ctx, SRC_SELECT_REG, src-select_mode);
+   g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src-color_mode);
+
+   switch (src-select_mode) {
+   case G2D_SELECT_MODE_NORMAL:
+   if (src-buf_type == G2D_IMGBUF_USERPTR)
+   g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
+   (unsigned long)src-user_ptr[0]);
+   else
+   g2d_add_cmd(ctx, SRC_BASE_ADDR_REG, src-bo[0]);
+
+   g2d_add_cmd(ctx, SRC_STRIDE_REG, src-stride);
+   break;
+   case G2D_SELECT_MODE_FGCOLOR:
+   g2d_add_cmd(ctx, FG_COLOR_REG, src-color);
+   break;
+   case G2D_SELECT_MODE_BGCOLOR:
+   g2d_add_cmd(ctx, BG_COLOR_REG, src-color);
+   break;
+   default:
+   fprintf(stderr , failed to set src.\n);
+   return -EINVAL;
+   }
+
+   if (src_w == dst_w  src_h == dst_h)
+   scale = 0;
+   else {
+   scale = 1;
+   scale_x = g2d_get_scaling(src_w, dst_w);
+   scale_y = g2d_get_scaling(src_h, dst_h);
+   }
+
+   if (src_x + src_w  src-width)
+   src_w = src-width - src_x;
+   if (src_y + src_h  src-height)
+   src_h = src-height - src_y;
+
+   if (dst_x + dst_w  dst-width)
+   dst_w = dst-width - dst_x;
+   if (dst_y + dst_h  dst-height)
+   dst_h = dst-height - dst_y;
+
+   if (src_w = 0 || src_h = 0 || dst_w = 0 || dst_h = 0) {
+   fprintf(stderr, invalid width or height.\n);
+   g2d_reset(ctx);
+   return -EINVAL;
+   }
+
+   if (scale) {
+   g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR);
+   g2d_add_cmd(ctx, SRC_XSCALE_REG, scale_x);
+   g2d_add_cmd(ctx, SRC_YSCALE_REG, scale_y);
+   }
+
+   bitblt.data.alpha_blend_mode = G2D_ALPHA_BLEND_MODE_ENABLE;
+   blend.val = g2d_get_blend_op(op);
+   g2d_add_cmd(ctx, BITBLT_COMMAND_REG, bitblt.val);
+   g2d_add_cmd(ctx, BLEND_FUNCTION_REG, blend.val);
+
+   pt.val = 0;
+   pt.data.x = src_x;
+   pt.data.y = src_y;
+   g2d_add_cmd(ctx, SRC_LEFT_TOP_REG, pt.val);
+   pt.val = 0;
+   pt.data.x = src_x + src_w;
+   pt.data.y = src_y + src_h;
+ 

[PATCH v2 06/15] tests/exynos: introduce wait_for_user_input

2015-02-16 Thread Tobias Jakobi
Currently getchar() is used to pause execution after each test.
The user isn't informed if one is supposed to do anything for
the tests to continue, so print a simple message to make this
more clear.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 tests/exynos/exynos_fimg2d_test.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index 55d2970..446a6c6 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -237,6 +237,18 @@ void *create_checkerboard_pattern(unsigned int num_tiles_x,
return buf;
 }
 
+static void wait_for_user_input(int last)
+{
+   printf(press ENTER to );
+
+   if (last)
+   printf(exit test application\n);
+   else
+   printf(skip to next test\n);
+
+   getchar();
+}
+
 static void exynos_destroy_buffer(struct exynos_bo *bo)
 {
exynos_bo_destroy(bo);
@@ -756,7 +768,7 @@ int main(int argc, char **argv)
goto err_rm_fb;
}
 
-   getchar();
+   wait_for_user_input(0);
 
src = exynos_create_buffer(dev, screen_width * screen_height * 4, 0);
if (!src) {
@@ -770,7 +782,7 @@ int main(int argc, char **argv)
goto err_free_src;
}
 
-   getchar();
+   wait_for_user_input(0);
 
ret = test_case.copy_with_scale(dev, src, bo, G2D_IMGBUF_GEM);
if (ret  0) {
@@ -778,7 +790,7 @@ int main(int argc, char **argv)
goto err_free_src;
}
 
-   getchar();
+   wait_for_user_input(0);
 
ret = test_case.checkerboard(dev, src, bo, G2D_IMGBUF_GEM);
if (ret  0) {
@@ -786,7 +798,7 @@ int main(int argc, char **argv)
goto err_free_src;
}
 
-   getchar();
+   wait_for_user_input(1);
 
   /* The blend test uses the userptr functionality of exynos-drm, which *
* is currently not safe to use. If the kernel hasn't been build with *
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 11/15] exynos: add exynos prefix to fimg2d header

2015-02-16 Thread Tobias Jakobi
Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/Makefile.am|   2 +-
 exynos/exynos_fimg2d.c|   2 +-
 exynos/exynos_fimg2d.h| 328 ++
 exynos/fimg2d.h   | 328 --
 tests/exynos/exynos_fimg2d_test.c |   2 +-
 5 files changed, 331 insertions(+), 331 deletions(-)
 create mode 100644 exynos/exynos_fimg2d.h
 delete mode 100644 exynos/fimg2d.h

diff --git a/exynos/Makefile.am b/exynos/Makefile.am
index 06bee00..1715a85 100644
--- a/exynos/Makefile.am
+++ b/exynos/Makefile.am
@@ -14,7 +14,7 @@ libdrm_exynos_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
 libdrm_exynos_la_SOURCES = \
exynos_drm.c \
exynos_fimg2d.c \
-   fimg2d.h \
+   exynos_fimg2d.h \
fimg2d_reg.h
 
 libdrm_exynoscommonincludedir = ${includedir}/exynos
diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index c6f964b..126a15d 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -27,7 +27,7 @@
 #include libdrm.h
 #include exynos_drm.h
 #include fimg2d_reg.h
-#include fimg2d.h
+#include exynos_fimg2d.h
 
 #defineSET_BF(val, sc, si, scsa, scda, dc, di, dcsa, dcda) \
val.data.src_coeff = sc;\
diff --git a/exynos/exynos_fimg2d.h b/exynos/exynos_fimg2d.h
new file mode 100644
index 000..bd116cf
--- /dev/null
+++ b/exynos/exynos_fimg2d.h
@@ -0,0 +1,328 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics Co.Ltd
+ * Authors:
+ * Inki Dae inki@samsung.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+
+#ifndef _FIMG2D_H_
+#define _FIMG2D_H_
+
+#ifndef TRUE
+#define TRUE 0
+#endif
+#ifndef FALSE
+#define FALSE -1
+#endif
+
+#define G2D_MAX_CMD_NR 64
+#define G2D_MAX_GEM_CMD_NR 64
+#define G2D_MAX_CMD_LIST_NR64
+#define G2D_PLANE_MAX_NR   2
+
+enum e_g2d_color_mode {
+   /* COLOR FORMAT */
+   G2D_COLOR_FMT_XRGB,
+   G2D_COLOR_FMT_ARGB,
+   G2D_COLOR_FMT_RGB565,
+   G2D_COLOR_FMT_XRGB1555,
+   G2D_COLOR_FMT_ARGB1555,
+   G2D_COLOR_FMT_XRGB,
+   G2D_COLOR_FMT_ARGB,
+   G2D_COLOR_FMT_PRGB888,
+   G2D_COLOR_FMT_YCbCr444,
+   G2D_COLOR_FMT_YCbCr422,
+   G2D_COLOR_FMT_YCbCr420,
+   /* alpha 8bit */
+   G2D_COLOR_FMT_A8,
+   /* Luminance 8bit: gray color */
+   G2D_COLOR_FMT_L8,
+   /* alpha 1bit */
+   G2D_COLOR_FMT_A1,
+   /* alpha 4bit */
+   G2D_COLOR_FMT_A4,
+   G2D_COLOR_FMT_MASK, /* VER4.1 */
+
+   /* COLOR ORDER */
+   G2D_ORDER_AXRGB = (0  4), /* VER4.1 */
+   G2D_ORDER_RGBAX = (1  4), /* VER4.1 */
+   G2D_ORDER_AXBGR = (2  4), /* VER4.1 */
+   G2D_ORDER_BGRAX = (3  4), /* VER4.1 */
+   G2D_ORDER_MASK  = (3  4), /* VER4.1 */
+
+   /* Number of YCbCr plane */
+   G2D_YCbCr_1PLANE= (0  8), /* VER4.1 */
+   G2D_YCbCr_2PLANE= (1  8), /* VER4.1 */
+   G2D_YCbCr_PLANE_MASK= (3  8), /* VER4.1 */
+
+   /* Order in YCbCr */
+   G2D_YCbCr_ORDER_CrY1CbY0 = (0  12),   /* VER4.1 */
+   G2D_YCbCr_ORDER_CbY1CrY0 = (1  12),   /* VER4.1 */
+   G2D_YCbCr_ORDER_Y1CrY0Cb = (2  12),   /* VER4.1 */
+   G2D_YCbCr_ORDER_Y1CbY0Cr = (3  12),   /* VER4.1 */
+   G2D_YCbCr_ORDER_CrCb = G2D_YCbCr_ORDER_CrY1CbY0,/* VER4.1 */
+   G2D_YCbCr_ORDER_CbCr = G2D_YCbCr_ORDER_CbY1CrY0,/* VER4.1 */
+   G2D_YCbCr_ORDER_MASK = (3  12),/* VER4.1 */
+
+   /* CSC */
+   G2D_CSC_601 = (0  16),/* VER4.1 */
+   G2D_CSC_709 = (1  16),/* VER4.1 */
+   G2D_CSC_MASK = (1  16),   /* VER4.1 */
+
+   /* Valid value range of YCbCr */
+   G2D_YCbCr_RANGE_NARROW = (0  17), /* VER4.1 */
+   G2D_YCbCr_RANGE_WIDE = (1  17),   /* VER4.1 */
+   G2D_YCbCr_RANGE_MASK = (1  17),   /* VER4.1 */
+
+   G2D_COLOR_MODE_MASK = 0x,
+};
+
+enum e_g2d_select_mode {
+   G2D_SELECT_MODE_NORMAL  = (0  0),
+   G2D_SELECT_MODE_FGCOLOR = (1  0),
+   G2D_SELECT_MODE_BGCOLOR = (2  0),
+};
+
+enum e_g2d_repeat_mode {
+   G2D_REPEAT_MODE_REPEAT,
+   G2D_REPEAT_MODE_PAD,
+   G2D_REPEAT_MODE_REFLECT,
+   G2D_REPEAT_MODE_CLAMP,
+   G2D_REPEAT_MODE_NONE,
+};
+
+enum e_g2d_scale_mode {
+   G2D_SCALE_MODE_NONE = 0,
+   G2D_SCALE_MODE_NEAREST,
+   G2D_SCALE_MODE_BILINEAR,
+   G2D_SCALE_MODE_MAX,
+};
+
+enum e_g2d_buf_type {
+   

[PATCH v2 10/15] tests/exynos: improve error handling

2015-02-16 Thread Tobias Jakobi
Check for a useable connector and also if the resolution is sane
(width and height are both non-zero).

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 tests/exynos/exynos_fimg2d_test.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index cffe11b..497d57a 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -725,10 +725,22 @@ int main(int argc, char **argv)
connector_find_mode(dev-fd, con, resources);
drmModeFreeResources(resources);
 
+   if (!con.mode) {
+   fprintf(stderr, failed to find usable connector\n);
+   ret = -EFAULT;
+   goto err_drm_close;
+   }
+
screen_width = con.mode-hdisplay;
screen_height = con.mode-vdisplay;
 
-   printf(screen width  = %d, screen height = %d\n, screen_width,
+   if (screen_width == 0 || screen_height == 0) {
+   fprintf(stderr, failed to find sane resolution on 
connector\n);
+   ret = -EFAULT;
+   goto err_drm_close;
+   }
+
+   printf(screen width = %d, screen height = %d\n, screen_width,
screen_height);
 
bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0);
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 01/15] tests/exynos: fimg2d: add a checkerboard test

2015-02-16 Thread Tobias Jakobi
This makes it easier to spot memory corruptions which don't become
visible when using a plain buffer filled with a solid color (so
corruptions that are just a permutation of the bytes in the buffer).

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 tests/exynos/exynos_fimg2d_test.c | 117 ++
 1 file changed, 117 insertions(+)

diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index c6bd558..41fb869 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -55,6 +55,9 @@ struct fimg2d_test_case {
int (*blend)(struct exynos_device *dev,
struct exynos_bo *src, struct exynos_bo *dst,
enum e_g2d_buf_type);
+   int (*checkerboard)(struct exynos_device *dev,
+   struct exynos_bo *src, struct exynos_bo *dst,
+   enum e_g2d_buf_type);
 };
 
 struct connector {
@@ -207,6 +210,33 @@ static struct exynos_bo *exynos_create_buffer(struct 
exynos_device *dev,
return bo;
 }
 
+/* Allocate buffer and fill it with checkerboard pattern, where the tiles *
+ * have a random color. The caller has to free the buffer.*/
+void *create_checkerboard_pattern(unsigned int num_tiles_x,
+   unsigned int num_tiles_y, 
unsigned int tile_size)
+{
+   unsigned int *buf;
+   unsigned int x, y, i, j;
+   const unsigned int stride = num_tiles_x * tile_size;
+
+   if (posix_memalign((void*)buf, 64, num_tiles_y * tile_size * stride * 
4) != 0)
+   return NULL;
+
+   for (x = 0; x  num_tiles_x; ++x) {
+   for (y = 0; y  num_tiles_y; ++y) {
+   const unsigned int color = 0xff00 + (random()  
0xff);
+
+   for (i = 0; i  tile_size; ++i) {
+   for (j = 0; j  tile_size; ++j) {
+   buf[x * tile_size + y * stride * 
tile_size + i + j * stride] = color;
+   }
+   }
+   }
+   }
+
+   return buf;
+}
+
 static void exynos_destroy_buffer(struct exynos_bo *bo)
 {
exynos_bo_destroy(bo);
@@ -533,11 +563,90 @@ err_free_userptr:
return 0;
 }
 
+static int g2d_checkerboard_test(struct exynos_device *dev,
+   struct exynos_bo *src,
+   struct exynos_bo *dst,
+   enum e_g2d_buf_type type)
+{
+   struct g2d_context *ctx;
+   struct g2d_image src_img = {0}, dst_img = {0};
+   unsigned int src_x, src_y, dst_x, dst_y, img_w, img_h;
+   void *checkerboard = NULL;
+   int ret;
+
+   ctx = g2d_init(dev-fd);
+   if (!ctx)
+   return -EFAULT;
+
+   dst_img.bo[0] = dst-handle;
+
+   src_x = 0;
+   src_y = 0;
+   dst_x = 0;
+   dst_y = 0;
+
+   checkerboard = create_checkerboard_pattern(screen_width / 32, 
screen_height / 32, 32);
+   if (checkerboard == NULL) {
+   ret = -1;
+   goto fail;
+   }
+
+   img_w = screen_width - (screen_width % 32);
+   img_h = screen_height - (screen_height % 32);
+
+   switch (type) {
+   case G2D_IMGBUF_GEM:
+   memcpy(src-vaddr, checkerboard, img_w * img_h * 4);
+   src_img.bo[0] = src-handle;
+   break;
+   case G2D_IMGBUF_USERPTR:
+   src_img.user_ptr[0].userptr = (unsigned long)checkerboard;
+   src_img.user_ptr[0].size = img_w * img_h * 4;
+   break;
+   default:
+   ret = -EFAULT;
+   goto fail;
+   }
+
+   printf(checkerboard test with %s.\n,
+   type == G2D_IMGBUF_GEM ? gem : userptr);
+
+   src_img.width = img_w;
+   src_img.height = img_h;
+   src_img.stride = src_img.width * 4;
+   src_img.buf_type = type;
+   src_img.color_mode = G2D_COLOR_FMT_ARGB | G2D_ORDER_AXRGB;
+
+   dst_img.width = screen_width;
+   dst_img.height = screen_height;
+   dst_img.stride = dst_img.width * 4;
+   dst_img.buf_type = G2D_IMGBUF_GEM;
+   dst_img.color_mode = G2D_COLOR_FMT_ARGB | G2D_ORDER_AXRGB;
+   src_img.color = 0xff00;
+   ret = g2d_solid_fill(ctx, dst_img, src_x, src_y, screen_width, 
screen_height);
+   if (ret  0)
+   goto fail;
+
+   ret = g2d_copy(ctx, src_img, dst_img, src_x, src_y, dst_x, dst_y,
+   img_w, img_h);
+   if (ret  0)
+   goto fail;
+
+   g2d_exec(ctx);
+
+fail:
+   free(checkerboard);
+   g2d_fini(ctx);
+
+   return ret;
+}
+
 static struct fimg2d_test_case test_case = {
.solid_fill = g2d_solid_fill_test,
.copy = g2d_copy_test,
.copy_with_scale = g2d_copy_with_scale_test,

[PATCH v2 08/15] exynos: introduce g2d_add_base_addr helper function

2015-02-16 Thread Tobias Jakobi
In almost all functions the base address register is written, so it
makes sense to have a helper function for this.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.c | 87 +++---
 1 file changed, 33 insertions(+), 54 deletions(-)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index b79081e..c08974a 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -41,6 +41,11 @@
 
 #define MIN(a, b)  ((a)  (b) ? (a) : (b))
 
+enum g2d_base_addr_reg {
+   g2d_dst = 0,
+   g2d_src
+};
+
 static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst)
 {
/* The G2D hw scaling factor is a normalized inverse of the scaling 
factor. *
@@ -132,6 +137,25 @@ static int g2d_add_cmd(struct g2d_context *ctx, unsigned 
long cmd,
 }
 
 /*
+ * g2d_add_base_addr - helper function to set dst/src base address register.
+ *
+ * @ctx: a pointer to g2d_context structure.
+ * @img: a pointer to the dst/src g2d_image structure.
+ * @reg: the register that should be set.
+ */
+static void g2d_add_base_addr(struct g2d_context *ctx, struct g2d_image *img,
+   enum g2d_base_addr_reg reg)
+{
+   const unsigned long cmd = (reg == g2d_dst) ? DST_BASE_ADDR_REG : 
SRC_BASE_ADDR_REG;
+
+   if (img-buf_type == G2D_IMGBUF_USERPTR)
+   g2d_add_cmd(ctx, cmd | G2D_BUF_USERPTR,
+   (unsigned long)img-user_ptr[0]);
+   else
+   g2d_add_cmd(ctx, cmd, img-bo[0]);
+}
+
+/*
  * g2d_reset - reset fimg2d hardware.
  *
  * @ctx: a pointer to g2d_context structure.
@@ -276,13 +300,7 @@ g2d_solid_fill(struct g2d_context *ctx, struct g2d_image 
*img,
 
g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
g2d_add_cmd(ctx, DST_COLOR_MODE_REG, img-color_mode);
-
-   if (img-buf_type == G2D_IMGBUF_USERPTR)
-   g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
-   (unsigned long)img-user_ptr[0]);
-   else
-   g2d_add_cmd(ctx, DST_BASE_ADDR_REG, img-bo[0]);
-
+   g2d_add_base_addr(ctx, img, g2d_dst);
g2d_add_cmd(ctx, DST_STRIDE_REG, img-stride);
 
if (x + w  img-width)
@@ -339,22 +357,12 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
 
g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst-color_mode);
-   if (dst-buf_type == G2D_IMGBUF_USERPTR)
-   g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
-   (unsigned long)dst-user_ptr[0]);
-   else
-   g2d_add_cmd(ctx, DST_BASE_ADDR_REG, dst-bo[0]);
-
+   g2d_add_base_addr(ctx, dst, g2d_dst);
g2d_add_cmd(ctx, DST_STRIDE_REG, dst-stride);
 
g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src-color_mode);
-   if (src-buf_type == G2D_IMGBUF_USERPTR)
-   g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
-   (unsigned long)src-user_ptr[0]);
-   else
-   g2d_add_cmd(ctx, SRC_BASE_ADDR_REG, src-bo[0]);
-
+   g2d_add_base_addr(ctx, src, g2d_src);
g2d_add_cmd(ctx, SRC_STRIDE_REG, src-stride);
 
src_w = w;
@@ -442,12 +450,7 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
 
g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst-color_mode);
-   if (dst-buf_type == G2D_IMGBUF_USERPTR)
-   g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
-   (unsigned long)dst-user_ptr[0]);
-   else
-   g2d_add_cmd(ctx, DST_BASE_ADDR_REG, dst-bo[0]);
-
+   g2d_add_base_addr(ctx, dst, g2d_dst);
g2d_add_cmd(ctx, DST_STRIDE_REG, dst-stride);
 
g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
@@ -457,11 +460,7 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
if (src-repeat_mode == G2D_REPEAT_MODE_PAD)
g2d_add_cmd(ctx, SRC_PAD_VALUE_REG, dst-color);
 
-   if (src-buf_type == G2D_IMGBUF_USERPTR)
-   g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
-   (unsigned long)src-user_ptr[0]);
-   else
-   g2d_add_cmd(ctx, SRC_BASE_ADDR_REG, src-bo[0]);
+   g2d_add_base_addr(ctx, src, g2d_src);
 
g2d_add_cmd(ctx, SRC_STRIDE_REG, src-stride);
 
@@ -565,12 +564,7 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_NORMAL);
 
g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst-color_mode);
-   if (dst-buf_type == G2D_IMGBUF_USERPTR)
-   g2d_add_cmd(ctx, DST_BASE_ADDR_REG | G2D_BUF_USERPTR,
-   (unsigned long)dst-user_ptr[0]);
-   else
-  

[PATCH v2 04/15] tests/exynos: disable the G2D userptr/blend test

2015-02-16 Thread Tobias Jakobi
v2: Move the commit description into the patch itself.
Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 tests/exynos/exynos_fimg2d_test.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index aa140e5..55d2970 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -788,11 +788,19 @@ int main(int argc, char **argv)
 
getchar();
 
+  /* The blend test uses the userptr functionality of exynos-drm, which *
+   * is currently not safe to use. If the kernel hasn't been build with *
+   * exynos-iommu support, then the blend test is going to produce (kernel) *
+   * memory corruption, eventually leading to a system crash.   *
+   **
+   * Disable the test for now, until the kernel code has been sanitized.*/
+#if 0
ret  = test_case.blend(dev, src, bo, G2D_IMGBUF_USERPTR);
if (ret  0)
fprintf(stderr, failed to test blend operation.\n);
 
getchar();
+#endif
 
 err_free_src:
if (src)
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/15] tests/exynos: fix typos and change wording

2015-02-16 Thread Tobias Jakobi
No functional changes.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.c| 8 
 tests/exynos/exynos_fimg2d_test.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 037021a..8b1a0ff 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -146,13 +146,13 @@ static void g2d_reset(struct g2d_context *ctx)
 }
 
 /*
- * g2d_flush - summit all commands and values in user side command buffer
+ * g2d_flush - submit all commands and values in user side command buffer
  * to command queue aware of fimg2d dma.
  *
  * @ctx: a pointer to g2d_context structure.
  *
  * This function should be called after all commands and values to user
- * side command buffer is set to summit that buffer to kernel side driver.
+ * side command buffer are set. It submits that buffer to the kernel side 
driver.
  */
 static int g2d_flush(struct g2d_context *ctx)
 {
@@ -193,7 +193,7 @@ static int g2d_flush(struct g2d_context *ctx)
 /**
  * g2d_init - create a new g2d context and get hardware version.
  *
- * fd: a file descriptor to drm device driver opened.
+ * fd: a file descriptor to an opened drm device.
  */
 drm_public struct g2d_context *g2d_init(int fd)
 {
@@ -525,7 +525,7 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
 }
 
 /**
- * g2d_blend - blend image data in source and destion buffers
+ * g2d_blend - blend image data in source and destination buffers.
  *
  * @ctx: a pointer to g2d_context structure.
  * @src: a pointer to g2d_image structure including image and buffer
diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index 41fb869..aa140e5 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -39,7 +39,7 @@ static unsigned int screen_width, screen_height;
 /*
  * A structure to test fimg2d hw.
  *
- * @solid_fild: fill given color data to source buffer.
+ * @solid_fill: fill given color data to source buffer.
  * @copy: copy source to destination buffer.
  * @copy_with_scale: copy source to destination buffer scaling up or
  * down properly.
@@ -256,7 +256,7 @@ static int g2d_solid_fill_test(struct exynos_device *dev, 
struct exynos_bo *dst)
memset(img, 0, sizeof(struct g2d_image));
img.bo[0] = dst-handle;
 
-   printf(soild fill test.\n);
+   printf(solid fill test.\n);
 
srand(time(NULL));
img_w = screen_width;
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 07/15] exynos: honor the repeat mode in g2d_copy_with_scale

2015-02-16 Thread Tobias Jakobi
This is useful when the default repeat mode, which is 'repeat'
produces artifacts at the borders of the copied image.
Choose the 'pad' mode to make use of the color of the destination
image.

In my usage case the destination is the framebuffer, which is
solid filled with a background color. Scaling with 'pad' mode
would then just do the right thing and also produces nice
borders on the output.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 0d89b1d..b79081e 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -452,6 +452,11 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
 
g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src-color_mode);
+
+   g2d_add_cmd(ctx, SRC_REPEAT_MODE_REG, src-repeat_mode);
+   if (src-repeat_mode == G2D_REPEAT_MODE_PAD)
+   g2d_add_cmd(ctx, SRC_PAD_VALUE_REG, dst-color);
+
if (src-buf_type == G2D_IMGBUF_USERPTR)
g2d_add_cmd(ctx, SRC_BASE_ADDR_REG | G2D_BUF_USERPTR,
(unsigned long)src-user_ptr[0]);
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v2] libdrm: improvements to userspace exynos component

2015-02-16 Thread Tobias Jakobi
Hello,

here are some miscellaneous improvements (small features, bugfixes, spelling 
fixes, etc.) for the exynos component of libdrm. The general idea is to let 
userspace use the G2D engine functionality more 
efficiently.

If someone is interested in an application that actually makes use of this, the 
RetroArch frontend has a custom video backend:
https://github.com/libretro/RetroArch/blob/master/gfx/drivers/exynos_gfx.c


Please review and let me know what I can improve.

v2:
- Mention value of G2D scaling normalization factor (02/15).
- Moved patch (04/15) description from commit message to source itself, like 
suggested by Joonyoung Shim.

With best wishes,
Tobias


--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 13/15] exynos: fimg2d: fix comment for G2D_COEFF_MODE_GB_COLOR

2015-02-16 Thread Tobias Jakobi
The coefficient mode enables use of global color, not alpha.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/exynos/exynos_fimg2d.h b/exynos/exynos_fimg2d.h
index bd116cf..78cff47 100644
--- a/exynos/exynos_fimg2d.h
+++ b/exynos/exynos_fimg2d.h
@@ -166,7 +166,7 @@ enum e_g2d_coeff_mode {
G2D_COEFF_MODE_DST_COLOR,
/* Global Alpha : Set by ALPHA_REG(0x618) */
G2D_COEFF_MODE_GB_ALPHA,
-   /* Global Alpha : Set by ALPHA_REG(0x618) */
+   /* Global Color : Set by ALPHA_REG(0x618) */
G2D_COEFF_MODE_GB_COLOR,
/* (1-SRC alpha)/DST Alpha */
G2D_COEFF_MODE_DISJOINT_S,
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/15] exynos: replace G2D_DOUBLE_TO_FIXED macro with function

2015-02-16 Thread Tobias Jakobi
This also avoids the floating point conversion steps and just
uses pure integer arithmetic.
Since the G2D hardware scaling approach is a bit unintuitive,
document it in the function as well.

v2: Explicitly mention the normalization constant.
Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.c | 20 +++-
 exynos/fimg2d.h|  2 --
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index ce1ba1e..037021a 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -41,6 +41,16 @@
 
 #define MIN(a, b)  ((a)  (b) ? (a) : (b))
 
+static unsigned int g2d_get_scaling(unsigned int src, unsigned int dst)
+{
+   /* The G2D hw scaling factor is a normalized inverse of the scaling 
factor. *
+* For example: When source width is 100 and destination width is 200   
*
+* (scaling of 2x), then the hw factor is NC * 100 / 200.   
*
+* The normalization factor (NC) is 2^16 = 0x1. 
*/
+
+   return ((src  16) / dst);
+}
+
 static unsigned int g2d_get_blend_op(enum e_g2d_op op)
 {
union g2d_blend_func_val val;
@@ -428,7 +438,7 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
union g2d_rop4_val rop4;
union g2d_point_val pt;
unsigned int scale;
-   double scale_x = 0.0f, scale_y = 0.0f;
+   unsigned int scale_x, scale_y;
 
g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst-color_mode);
@@ -454,8 +464,8 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
scale = 0;
else {
scale = 1;
-   scale_x = (double)src_w / (double)dst_w;
-   scale_y = (double)src_h / (double)dst_h;
+   scale_x = g2d_get_scaling(src_w, dst_w);
+   scale_y = g2d_get_scaling(src_h, dst_h);
}
 
if (src_x + src_w  src-width)
@@ -487,8 +497,8 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct 
g2d_image *src,
 
if (scale) {
g2d_add_cmd(ctx, SRC_SCALE_CTRL_REG, G2D_SCALE_MODE_BILINEAR);
-   g2d_add_cmd(ctx, SRC_XSCALE_REG, G2D_DOUBLE_TO_FIXED(scale_x));
-   g2d_add_cmd(ctx, SRC_YSCALE_REG, G2D_DOUBLE_TO_FIXED(scale_y));
+   g2d_add_cmd(ctx, SRC_XSCALE_REG, scale_x);
+   g2d_add_cmd(ctx, SRC_YSCALE_REG, scale_y);
}
 
pt.val = 0;
diff --git a/exynos/fimg2d.h b/exynos/fimg2d.h
index 4785e2f..8e0321c 100644
--- a/exynos/fimg2d.h
+++ b/exynos/fimg2d.h
@@ -25,8 +25,6 @@
 #define G2D_MAX_CMD_LIST_NR64
 #define G2D_PLANE_MAX_NR   2
 
-#define G2D_DOUBLE_TO_FIXED(d) ((unsigned int)((d) * 65536.0))
-
 enum e_g2d_color_mode {
/* COLOR FORMAT */
G2D_COLOR_FMT_XRGB,
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 09/15] exynos: use structure initialization instead of memset

2015-02-16 Thread Tobias Jakobi
Keeps the code cleaner, since the structs have to be initialized
once anyway.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/exynos_fimg2d.c|  4 +---
 tests/exynos/exynos_fimg2d_test.c | 15 ---
 2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index c08974a..c6f964b 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -181,7 +181,7 @@ static void g2d_reset(struct g2d_context *ctx)
 static int g2d_flush(struct g2d_context *ctx)
 {
int ret;
-   struct drm_exynos_g2d_set_cmdlist cmdlist;
+   struct drm_exynos_g2d_set_cmdlist cmdlist = {0};
 
if (ctx-cmd_nr  == 0  ctx-cmd_buf_nr == 0)
return FALSE;
@@ -191,8 +191,6 @@ static int g2d_flush(struct g2d_context *ctx)
return -EINVAL;
}
 
-   memset(cmdlist, 0, sizeof(struct drm_exynos_g2d_set_cmdlist));
-
cmdlist.cmd = (uint64_t)(uintptr_t)ctx-cmd[0];
cmdlist.cmd_buf = (uint64_t)(uintptr_t)ctx-cmd_buf[0];
cmdlist.cmd_nr = ctx-cmd_nr;
diff --git a/tests/exynos/exynos_fimg2d_test.c 
b/tests/exynos/exynos_fimg2d_test.c
index 446a6c6..cffe11b 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -257,7 +257,7 @@ static void exynos_destroy_buffer(struct exynos_bo *bo)
 static int g2d_solid_fill_test(struct exynos_device *dev, struct exynos_bo 
*dst)
 {
struct g2d_context *ctx;
-   struct g2d_image img;
+   struct g2d_image img = {0};
unsigned int count, img_w, img_h;
int ret = 0;
 
@@ -265,7 +265,6 @@ static int g2d_solid_fill_test(struct exynos_device *dev, 
struct exynos_bo *dst)
if (!ctx)
return -EFAULT;
 
-   memset(img, 0, sizeof(struct g2d_image));
img.bo[0] = dst-handle;
 
printf(solid fill test.\n);
@@ -308,7 +307,7 @@ static int g2d_copy_test(struct exynos_device *dev, struct 
exynos_bo *src,
enum e_g2d_buf_type type)
 {
struct g2d_context *ctx;
-   struct g2d_image src_img, dst_img;
+   struct g2d_image src_img = {0}, dst_img = {0};
unsigned int count;
unsigned int src_x, src_y, dst_x, dst_y, img_w, img_h;
unsigned long userptr, size;
@@ -318,8 +317,6 @@ static int g2d_copy_test(struct exynos_device *dev, struct 
exynos_bo *src,
if (!ctx)
return -EFAULT;
 
-   memset(src_img, 0, sizeof(struct g2d_image));
-   memset(dst_img, 0, sizeof(struct g2d_image));
dst_img.bo[0] = dst-handle;
 
src_x = 0;
@@ -392,7 +389,7 @@ static int g2d_copy_with_scale_test(struct exynos_device 
*dev,
enum e_g2d_buf_type type)
 {
struct g2d_context *ctx;
-   struct g2d_image src_img, dst_img;
+   struct g2d_image src_img = {0}, dst_img = {0};
unsigned int count;
unsigned int src_x, src_y, dst_x, dst_y, img_w, img_h;
unsigned long userptr, size;
@@ -402,8 +399,6 @@ static int g2d_copy_with_scale_test(struct exynos_device 
*dev,
if (!ctx)
return -EFAULT;
 
-   memset(src_img, 0, sizeof(struct g2d_image));
-   memset(dst_img, 0, sizeof(struct g2d_image));
dst_img.bo[0] = dst-handle;
 
src_x = 0;
@@ -481,7 +476,7 @@ static int g2d_blend_test(struct exynos_device *dev,
enum e_g2d_buf_type type)
 {
struct g2d_context *ctx;
-   struct g2d_image src_img, dst_img;
+   struct g2d_image src_img = {0}, dst_img = {0};
unsigned int count;
unsigned int src_x, src_y, dst_x, dst_y, img_w, img_h;
unsigned long userptr, size;
@@ -491,8 +486,6 @@ static int g2d_blend_test(struct exynos_device *dev,
if (!ctx)
return -EFAULT;
 
-   memset(src_img, 0, sizeof(struct g2d_image));
-   memset(dst_img, 0, sizeof(struct g2d_image));
dst_img.bo[0] = dst-handle;
 
src_x = 0;
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/15] exynos: add fimg2d header to common includes

2015-02-16 Thread Tobias Jakobi
The reason for this change is to let userspace use the header.
Currently 'make install' does not install it.

Signed-off-by: Tobias Jakobi tjak...@math.uni-bielefeld.de
---
 exynos/Makefile.am | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/exynos/Makefile.am b/exynos/Makefile.am
index 1715a85..35bc71f 100644
--- a/exynos/Makefile.am
+++ b/exynos/Makefile.am
@@ -14,11 +14,10 @@ libdrm_exynos_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
 libdrm_exynos_la_SOURCES = \
exynos_drm.c \
exynos_fimg2d.c \
-   exynos_fimg2d.h \
fimg2d_reg.h
 
 libdrm_exynoscommonincludedir = ${includedir}/exynos
-libdrm_exynoscommoninclude_HEADERS = exynos_drm.h
+libdrm_exynoscommoninclude_HEADERS = exynos_drm.h exynos_fimg2d.h
 
 libdrm_exynosincludedir = ${includedir}/libdrm
 libdrm_exynosinclude_HEADERS = exynos_drmif.h
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] thermal: exynos: Fix NULL pointer exception during kernel booting

2015-02-16 Thread Lukasz Majewski
Hi Chanwoo,

 This patch fixes the NULL pointer exception during kernel booting.
 The thermal_zone _of_sensor_register() registers a sensor to DT
 thermal zone and then read the current temperature by '.get_temp'
 callback. The callback function of exynos thermal driver is
 exynos_get_temp() which must need the 'pdata' instance of exynos_tmu
 _platform_data structure.
 - exynos_get_temp() - code_to_temp() - Must need the 'pdata'
 instance
 
 But, exynos thermal driver is executed before getting the 'pdata'
 instance. To avoid the kernel panic, have to get the platform data by
 executing the exynos_map_dt_data() before calling
 thermal_zone_of_sensor_register() .

I've already prepared patch for this (unfortunately it isn't yet
applied to mainline):

[PATCH] thermal: exynos: fix: Check if data-tmu_read callback is
present before read

http://www.spinics.net/lists/linux-samsung-soc/msg42245.html

Does applying this patch help?

BTW: How can I reproduce this error? Could you point me the SHA1 and
repository?

 
 - kernel panic log
 [ 4211.324346] PC is at 0x0
 [ 4211.326867] LR is at exynos_get_temp+0x3c/0xe4
 [ 4211.331289] pc : [] lr : [ffc0004df460]
 [snip]
 [ 4211.940625] [  (null)]   (null)
 [ 4211.945315] [ffc0004de6d8] of_thermal_get_temp+0x1c/0x30
 [ 4211.951132] [ffc0004db86c] thermal_zone_get_temp+0x48/0x7c
 [ 4211.957118] [ffc0004dd278]
 thermal_zone_device_update+0x20/0x110 [ 4211.963627]
 [ffc0004de9c8] of_thermal_set_mode+0x44/0x68 [ 4211.969443]
 [ffc0004decb8] thermal_zone_of_sensor_register+0x15c/0x1d8
 [ 4211.976475] [ffc0004dfbe4] exynos_tmu_probe+0x6c/0x814
 [ 4211.982120] [ffc0003ef808] platform_drv_probe+0x48/0xb8
 [ 4211.987846] [ffc0003edb28] driver_probe_device+0x8c/0x244
 [ 4211.993747] [ffc0003eddcc] __driver_attach+0x98/0xa0
 [ 4211.999216] [ffc0003ebea0] bus_for_each_dev+0x54/0x98
 [ 4212.004771] [ffc0003ed66c] driver_attach+0x1c/0x28
 [ 4212.010066] [ffc0003ed2e8] bus_add_driver+0x150/0x208
 [ 4212.015622] [ffc0003ee6a4] driver_register+0x5c/0x11c
 [ 4212.021178] [ffc0003ef73c]
 __platform_driver_register+0x5c/0x68 [ 4212.027600]
 [ffc000b64eb8] exynos_tmu_driver_init+0x14/0x20 [ 4212.033678]
 [ffc828d4] do_one_initcall+0x88/0x1a0 [ 4212.039235]
 [ffc000b34b34] kernel_init_freeable+0x1bc/0x260 [ 4212.045311]
 [ffc0007e9fd4] kernel_init+0xc/0xd8
 
 Cc: Zhang Rui rui.zh...@intel.com
 Cc: Eduardo Valentin edubez...@gmail.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  drivers/thermal/samsung/exynos_tmu.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/thermal/samsung/exynos_tmu.c
 b/drivers/thermal/samsung/exynos_tmu.c index fbeedc0..b8846f1 100644
 --- a/drivers/thermal/samsung/exynos_tmu.c
 +++ b/drivers/thermal/samsung/exynos_tmu.c
 @@ -1147,17 +1147,17 @@ static int exynos_tmu_probe(struct
 platform_device *pdev) platform_set_drvdata(pdev, data);
   mutex_init(data-lock);
  
 + ret = exynos_map_dt_data(pdev);
 + if (ret)
 + return ret;
 + pdata = data-pdata;
 +
   data-tzd = thermal_zone_of_sensor_register(pdev-dev, 0,
 data, exynos_sensor_ops);
   if (IS_ERR(data-tzd)) {
   pr_err(thermal: tz: %p ERROR\n, data-tzd);
   return PTR_ERR(data-tzd);
   }
 - ret = exynos_map_dt_data(pdev);
 - if (ret)
 - goto err_sensor;
 -
 - pdata = data-pdata;
  
   INIT_WORK(data-irq_work, exynos_tmu_work);
  



-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] thermal: exynos: Clean-up code to use oneline entry for exynos compatible table

2015-02-16 Thread Lukasz Majewski
Hi Chanwoo,

 This patch cleanup the code to use oneline for entry of exynos
 compatible table.
 
 Cc: Zhang Rui rui.zh...@intel.com
 Cc: Eduardo Valentin edubez...@gmail.com
 Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  drivers/thermal/samsung/exynos_tmu.c | 38
 ++-- 1 file changed, 10
 insertions(+), 28 deletions(-)
 
 diff --git a/drivers/thermal/samsung/exynos_tmu.c
 b/drivers/thermal/samsung/exynos_tmu.c index b199fff..7e6baf5 100644
 --- a/drivers/thermal/samsung/exynos_tmu.c
 +++ b/drivers/thermal/samsung/exynos_tmu.c
 @@ -919,34 +919,16 @@ static irqreturn_t exynos_tmu_irq(int irq, void
 *id) }
  
  static const struct of_device_id exynos_tmu_match[] = {
 - {
 - .compatible = samsung,exynos3250-tmu,
 - },
 - {
 - .compatible = samsung,exynos4210-tmu,
 - },
 - {
 - .compatible = samsung,exynos4412-tmu,
 - },
 - {
 - .compatible = samsung,exynos5250-tmu,
 - },
 - {
 - .compatible = samsung,exynos5260-tmu,
 - },
 - {
 - .compatible = samsung,exynos5420-tmu,
 - },
 - {
 - .compatible = samsung,exynos5420-tmu-ext-triminfo,
 - },
 - {
 - .compatible = samsung,exynos5440-tmu,
 - },
 - {
 - .compatible = samsung,exynos7-tmu,
 - },
 - {},
 + { .compatible = samsung,exynos3250-tmu, },
 + { .compatible = samsung,exynos4210-tmu, },
 + { .compatible = samsung,exynos4412-tmu, },
 + { .compatible = samsung,exynos5250-tmu, },
 + { .compatible = samsung,exynos5260-tmu, },
 + { .compatible = samsung,exynos5420-tmu, },
 + { .compatible = samsung,exynos5420-tmu-ext-triminfo, },
 + { .compatible = samsung,exynos5440-tmu, },
 + { .compatible = samsung,exynos7-tmu, },
 + { /* sentinel */ },
  };
  MODULE_DEVICE_TABLE(of, exynos_tmu_match);
  

Acked-by: Lukasz Majewski l.majew...@samsung.com

Thanks for clean up!

-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/7] platform/chrome: Add user-space dev inferface support

2015-02-16 Thread Javier Martinez Canillas
Hello Olof,

On 02/02/2015 12:26 PM, Javier Martinez Canillas wrote:
 Hello,
 
 The mainline ChromeOS Embedded Controller (EC) driver is still missing some
 features that are present in the downstream ChromiumOS tree. These are:
 
   - Low Pin Count (LPC) interface
   - User-space device interface
   - Access to vboot context stored on a block device
   - Access to vboot context stored on EC's nvram
   - Power Delivery Device
   - Support for multiple EC in a system
 
 This is a fifth version of a series that adds support for the first two of
 the missing features: the EC LPC and EC character device interfaces that
 are used by user-space to access the ChromeOS EC. The support patches were
 taken from the downstream ChromiumOS 3.14 tree with the fixes and cleanups
 squashed to have a minimal patch-set.
 

Any comments on this series? The last version was posted a couple of weeks
ago but the series have been in the list for months. Lee has already acked
the mfd changes so you can merge all through your chrome-platform tree if
you want.

It wold be great if this series get in to have the EC user-space interface
supported and to minimize the delta with the Chromemium OS kernel since it
still has other features that needs to be upstreamed like multiple EC in a
system and access to vboot context stored in block device or EC's nvram.

Best regards,
Javier
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 0/6] cpufreq: use generic cpufreq drivers for exynos platforms

2015-02-16 Thread Lukasz Majewski
Hi Krzysztof, Thomas,

 2015-01-08 22:17 GMT+01:00 Kevin Hilman khil...@kernel.org:
  On Fri, Nov 21, 2014 at 5:31 AM, Thomas Abraham
  thomas...@samsung.com wrote:
  Changes since v11:
  - Rebased on top of git://linuxtv.org/snawrocki/samsung.git
  for-v3.19-exynos-clk
 
  This patch series removes the use of Exynos4210 and Exynos5250
  specific cpufreq drivers and enables the use of cpufreq-dt driver
  for these platforms. This series also enables cpufreq support for
  Exynos5420 using arm_big_little cpufreq driver.
 
  This series is based on the following branch.
  git://linuxtv.org/snawrocki/samsung.git for-v3.19-exynos-clk
 
  This series depends on the following patch which can be picked from
  git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git
  samsung/dt e540920cf21c (ARM: dts: add CPU nodes for Exynos4 SoCs).
 
  This patch series has been tested on Exynos4210/5250/5420 based
  boards. Tomasz Figa had plans to take this in the Samsung clock
  tree for v3.19
  (http://www.spinics.net/lists/linux-samsung-soc/msg37933.html).
  Sylwester, could you consider to merge this in your tree?
 
  CPUfreq for exynos is still not upstream.  What's the status of this
  series?  It's been ver a month since there's been any activity here
  (or any responses to the issues I reported.)
 
  On a related note, this series only does frequency scaling. Is there
  any work going on to also enable voltage scaling for the CPU rails
  as well?
 
 Hi Thomas,
 
 Do you plan to continue with this work? It would be very helpful.

+1 from me.

 
 I also wonder if Exynos 4412 could be re-added (without the boost if
 these bindings are not ready)?

I would prefer to have all platforms converted at once, since it might
happen that some parts of the work would get lost.

 
 Best regards,
 Krzysztof

-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] thermal: exynos: fix: Check if data-tmu_read callback is present before read

2015-02-16 Thread Lukasz Majewski
Hi Eduardo,

 The exynos_tmu_data() function should on entrance test not only for
 valid data pointer, but also for data-tmu_read one.
 It is important, since afterwards it is dereferenced to get
 temperature code.
 
 Signed-off-by: Lukasz Majewski l.majew...@samsung.com
 ---
  drivers/thermal/samsung/exynos_tmu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/thermal/samsung/exynos_tmu.c
 b/drivers/thermal/samsung/exynos_tmu.c index 3a19353..a86e0495e 100644
 --- a/drivers/thermal/samsung/exynos_tmu.c
 +++ b/drivers/thermal/samsung/exynos_tmu.c
 @@ -717,7 +717,7 @@ static int exynos_get_temp(void *p, long *temp)
  {
   struct exynos_tmu_data *data = p;
  
 - if (!data)
 + if (!data || !data-tmu_read)
   return -EINVAL;
  
   mutex_lock(data-lock);

This fix shall be added to v3.20.

-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] exynos: config: Enable thermal emulation for Exynos TMU (exynos_defconfig)

2015-02-16 Thread Lukasz Majewski
Hi Kukjin,

 On Wed, Jan 28, 2015 at 04:28:39PM +0100, Lukasz Majewski wrote:
  Enabling thermal emulation on Exynos SoCs. New sysfs attribute -
  emul_temp is created.
  
  Signed-off-by: Lukasz Majewski l.majew...@samsung.com
 
 I dont see problems with this patch:
 
 Acked-by: Eduardo Valentin edubez...@gmail.com

Could you add this change to -samsung tree?

 
  ---
   arch/arm/configs/exynos_defconfig | 1 +
   1 file changed, 1 insertion(+)
  
  diff --git a/arch/arm/configs/exynos_defconfig
  b/arch/arm/configs/exynos_defconfig index 3691a68..376dbf4 100644
  --- a/arch/arm/configs/exynos_defconfig
  +++ b/arch/arm/configs/exynos_defconfig
  @@ -88,6 +88,7 @@ CONFIG_HWMON=y
   CONFIG_SENSORS_LM90=y
   CONFIG_THERMAL=y
   CONFIG_EXYNOS_THERMAL=y
  +CONFIG_THERMAL_EMULATION=y
   CONFIG_WATCHDOG=y
   CONFIG_S3C2410_WATCHDOG=y
   CONFIG_MFD_CROS_EC=y
  -- 
  2.0.0.rc2
  

-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] exynos: config: Remove CONFIG_EXYNOS_THERMAL_CORE define (exynos_defconfig)

2015-02-16 Thread Lukasz Majewski
Hi Kukjin,

 On Wed, Jan 28, 2015 at 04:28:38PM +0100, Lukasz Majewski wrote:
  After Exynos TMU rework to use device tree for configuration this
  flag can be removed. It is not used anymore.
  
  Signed-off-by: Lukasz Majewski l.majew...@samsung.com
 
 Acked-by: Eduardo Valentin edubez...@gmail.com

Could you add this change to -samsung tree?

 
  ---
   arch/arm/configs/exynos_defconfig | 1 -
   1 file changed, 1 deletion(-)
  
  diff --git a/arch/arm/configs/exynos_defconfig
  b/arch/arm/configs/exynos_defconfig index 3d0c5d6..3691a68 100644
  --- a/arch/arm/configs/exynos_defconfig
  +++ b/arch/arm/configs/exynos_defconfig
  @@ -88,7 +88,6 @@ CONFIG_HWMON=y
   CONFIG_SENSORS_LM90=y
   CONFIG_THERMAL=y
   CONFIG_EXYNOS_THERMAL=y
  -CONFIG_EXYNOS_THERMAL_CORE=y
   CONFIG_WATCHDOG=y
   CONFIG_S3C2410_WATCHDOG=y
   CONFIG_MFD_CROS_EC=y
  -- 
  2.0.0.rc2
  



-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] exynos: config: Enable support for cpufreq on Exynos SoCs (exynos_defconfig)

2015-02-16 Thread Lukasz Majewski
Hi Kukjin,

 On Wed, Jan 28, 2015 at 04:28:40PM +0100, Lukasz Majewski wrote:
  This commit enables the cpufreq subsystem. Moreover, support for
  using CPU as a cooling device is provided.
  
  Signed-off-by: Lukasz Majewski l.majew...@samsung.com
 
 I dont see problems with this patch:
 
 Acked-by: Eduardo Valentin edubez...@gmail.com
 
 
 Again, it must go via the correct tree.

Could you add this change to -samsung tree?

 
  ---
   arch/arm/configs/exynos_defconfig | 2 ++
   1 file changed, 2 insertions(+)
  
  diff --git a/arch/arm/configs/exynos_defconfig
  b/arch/arm/configs/exynos_defconfig index 376dbf4..d6be7e8 100644
  --- a/arch/arm/configs/exynos_defconfig
  +++ b/arch/arm/configs/exynos_defconfig
  @@ -86,6 +86,8 @@ CONFIG_BATTERY_SBS=y
   CONFIG_CHARGER_TPS65090=y
   CONFIG_HWMON=y
   CONFIG_SENSORS_LM90=y
  +CONFIG_CPU_FREQ=y
  +CONFIG_CPU_THERMAL=y
   CONFIG_THERMAL=y
   CONFIG_EXYNOS_THERMAL=y
   CONFIG_THERMAL_EMULATION=y
  -- 
  2.0.0.rc2
  



-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html