All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sony-laptop: add new thermal control handle
@ 2016-06-23 18:21 Stefan Seidel
  2016-06-23 18:43 ` [PATCH v2] " Stefan Seidel
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Seidel @ 2016-06-23 18:21 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: platform-driver-x86

Hi,

this patch enables thermal control options on my VAIO Duo 11. I hope I  
have not made too many mistakes with it.

On at least the SVD11 there is an additional thermal control setting that
is found at a different handle address but otherwise behaves the same as
the other one.

Signed-off-by: Stefan Seidel <lkml@stefanseidel.info>
---
  drivers/platform/x86/sony-laptop.c | 29 ++++++++++++++++++-----------
  1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c  
b/drivers/platform/x86/sony-laptop.c
index 1dba359..550e8fa 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -148,7 +148,8 @@ static int sony_nc_battery_care_setup(struct  
platform_device *pd,
  		unsigned int handle);
  static void sony_nc_battery_care_cleanup(struct platform_device *pd);

-static int sony_nc_thermal_setup(struct platform_device *pd);
+static int sony_nc_thermal_setup(struct platform_device *pd,
+				 unsigned int handle);
  static void sony_nc_thermal_cleanup(struct platform_device *pd);

  static int sony_nc_lid_resume_setup(struct platform_device *pd,
@@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct  
acpi_device *device,
  						result);
  			break;
  		case 0x0122:
-			result = sony_nc_thermal_setup(pf_device);
+		case 0x015F:
+			result = sony_nc_thermal_setup(pf_device, handle);
  			if (result)
  				pr_err("couldn't set up thermal profile function (%d)\n",
  						result);
@@ -1446,9 +1448,6 @@ static void sony_nc_function_cleanup(struct  
platform_device *pd)
  {
  	unsigned int i, result, bitmask, handle;

-	if (!handles)
-		return;
-
  	/* get enabled events and disable them */
  	sony_nc_int_call(sony_nc_acpi_handle, "SN01", NULL, &bitmask);
  	sony_nc_int_call(sony_nc_acpi_handle, "SN03", &bitmask, &result);
@@ -1476,6 +1475,7 @@ static void sony_nc_function_cleanup(struct  
platform_device *pd)
  			sony_nc_lid_resume_cleanup(pd);
  			break;
  		case 0x0122:
+		case 0x015F:
  			sony_nc_thermal_cleanup(pd);
  			break;
  		case 0x0128:
@@ -1547,6 +1547,7 @@ static void sony_nc_function_resume(void)
  			sony_call_snc_handle(handle, 0x100, &result);
  			break;
  		case 0x0122:
+		case 0x015F:
  			sony_nc_thermal_resume();
  			break;
  		case 0x0124:
@@ -2150,14 +2151,16 @@ struct snc_thermal_ctrl {
  	unsigned int profiles;
  	struct device_attribute mode_attr;
  	struct device_attribute profiles_attr;
+	unsigned int handle;
  };
  static struct snc_thermal_ctrl *th_handle;

-#define THM_PROFILE_MAX 3
+#define THM_PROFILE_MAX 4
  static const char * const snc_thermal_profiles[] = {
  	"balanced",
  	"silent",
-	"performance"
+	"performance",
+	"cooling"
  };

  static int sony_nc_thermal_mode_set(unsigned short mode)
@@ -2173,7 +2176,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode)
  	if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX)
  		return -EINVAL;

-	if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result))
+	if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200,
+				 &result))
  		return -EIO;

  	th_handle->mode = mode;
@@ -2185,7 +2189,7 @@ static int sony_nc_thermal_mode_get(void)
  {
  	unsigned int result;

-	if (sony_call_snc_handle(0x0122, 0x0100, &result))
+	if (sony_call_snc_handle(th_handle->handle, 0x0100, &result))
  		return -EIO;

  	return result & 0xff;
@@ -2245,14 +2249,17 @@ static ssize_t  
sony_nc_thermal_mode_show(struct device *dev,
  	return count;
  }

-static int sony_nc_thermal_setup(struct platform_device *pd)
+static int sony_nc_thermal_setup(struct platform_device *pd,
+				 unsigned int handle)
  {
  	int ret = 0;
  	th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL);
  	if (!th_handle)
  		return -ENOMEM;

-	ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles);
+	th_handle->handle = handle;
+
+	ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles);
  	if (ret) {
  		pr_warn("couldn't to read the thermal profiles\n");
  		goto outkzalloc;
-- 
2.8.3

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

* [PATCH v2] sony-laptop: add new thermal control handle
  2016-06-23 18:21 [PATCH] sony-laptop: add new thermal control handle Stefan Seidel
@ 2016-06-23 18:43 ` Stefan Seidel
  2016-06-28  5:15   ` Mattia Dongili
  2016-07-01 19:30   ` Darren Hart
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Seidel @ 2016-06-23 18:43 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: platform-driver-x86

Hi,

sorry about the wrong first patch, I had missed an unwanted hunk.

On at least the SVD11 there is an additional thermal control setting that
is found at a different handle address but otherwise behaves the same as
the other one.

Signed-off-by: Stefan Seidel <lkml@stefanseidel.info>
---
  drivers/platform/x86/sony-laptop.c | 26 ++++++++++++++++++--------
  1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c  
b/drivers/platform/x86/sony-laptop.c
index 1dba359..6c9deb3 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -148,7 +148,8 @@ static int sony_nc_battery_care_setup(struct  
platform_device *pd,
  		unsigned int handle);
  static void sony_nc_battery_care_cleanup(struct platform_device *pd);

-static int sony_nc_thermal_setup(struct platform_device *pd);
+static int sony_nc_thermal_setup(struct platform_device *pd,
+				  unsigned int handle);
  static void sony_nc_thermal_cleanup(struct platform_device *pd);

  static int sony_nc_lid_resume_setup(struct platform_device *pd,
@@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct  
acpi_device *device,
  						result);
  			break;
  		case 0x0122:
-			result = sony_nc_thermal_setup(pf_device);
+		case 0x015F:
+			result = sony_nc_thermal_setup(pf_device, handle);
  			if (result)
  				pr_err("couldn't set up thermal profile function (%d)\n",
  						result);
@@ -1476,6 +1478,7 @@ static void sony_nc_function_cleanup(struct  
platform_device *pd)
  			sony_nc_lid_resume_cleanup(pd);
  			break;
  		case 0x0122:
+		case 0x015F:
  			sony_nc_thermal_cleanup(pd);
  			break;
  		case 0x0128:
@@ -1547,6 +1550,7 @@ static void sony_nc_function_resume(void)
  			sony_call_snc_handle(handle, 0x100, &result);
  			break;
  		case 0x0122:
+		case 0x015F:
  			sony_nc_thermal_resume();
  			break;
  		case 0x0124:
@@ -2150,14 +2154,16 @@ struct snc_thermal_ctrl {
  	unsigned int profiles;
  	struct device_attribute mode_attr;
  	struct device_attribute profiles_attr;
+	unsigned int handle;
  };
  static struct snc_thermal_ctrl *th_handle;

-#define THM_PROFILE_MAX 3
+#define THM_PROFILE_MAX 4
  static const char * const snc_thermal_profiles[] = {
  	"balanced",
  	"silent",
-	"performance"
+	"performance",
+	"cooling"
  };

  static int sony_nc_thermal_mode_set(unsigned short mode)
@@ -2173,7 +2179,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode)
  	if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX)
  		return -EINVAL;

-	if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result))
+	if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200,
+				 &result))
  		return -EIO;

  	th_handle->mode = mode;
@@ -2185,7 +2192,7 @@ static int sony_nc_thermal_mode_get(void)
  {
  	unsigned int result;

-	if (sony_call_snc_handle(0x0122, 0x0100, &result))
+	if (sony_call_snc_handle(th_handle->handle, 0x0100, &result))
  		return -EIO;

  	return result & 0xff;
@@ -2245,14 +2252,17 @@ static ssize_t  
sony_nc_thermal_mode_show(struct device *dev,
  	return count;
  }

-static int sony_nc_thermal_setup(struct platform_device *pd)
+static int sony_nc_thermal_setup(struct platform_device *pd,
+				 unsigned int handle)
  {
  	int ret = 0;
  	th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL);
  	if (!th_handle)
  		return -ENOMEM;

-	ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles);
+	th_handle->handle = handle;
+
+	ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles);
  	if (ret) {
  		pr_warn("couldn't to read the thermal profiles\n");
  		goto outkzalloc;
-- 
2.8.3

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

* Re: [PATCH v2] sony-laptop: add new thermal control handle
  2016-06-23 18:43 ` [PATCH v2] " Stefan Seidel
@ 2016-06-28  5:15   ` Mattia Dongili
  2016-07-01 19:30   ` Darren Hart
  1 sibling, 0 replies; 4+ messages in thread
From: Mattia Dongili @ 2016-06-28  5:15 UTC (permalink / raw)
  To: Stefan Seidel; +Cc: platform-driver-x86

On Thu, Jun 23, 2016 at 08:43:22PM +0200, Stefan Seidel wrote:
> Hi,
> 
> sorry about the wrong first patch, I had missed an unwanted hunk.
> 
> On at least the SVD11 there is an additional thermal control setting that
> is found at a different handle address but otherwise behaves the same as
> the other one.

Hi Stefan,

this patch looks ok.
I'm tempted to say that the "cooling" option should be limited to models
that support it, though IIRC (and the comment seems to confirm), it's
already the case that not all models support the current 3 options.

I cannot test this code myself not having a Duo.
For reference, could you send me (even privately) the DSDT from your Duo
model?

Thanks.

Reviewed-by: Mattia Dongili <malattia@linux.it>

> Signed-off-by: Stefan Seidel <lkml@stefanseidel.info>
> ---
>  drivers/platform/x86/sony-laptop.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/sony-laptop.c
> b/drivers/platform/x86/sony-laptop.c
> index 1dba359..6c9deb3 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -148,7 +148,8 @@ static int sony_nc_battery_care_setup(struct
> platform_device *pd,
>  		unsigned int handle);
>  static void sony_nc_battery_care_cleanup(struct platform_device *pd);
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd);
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				  unsigned int handle);
>  static void sony_nc_thermal_cleanup(struct platform_device *pd);
> 
>  static int sony_nc_lid_resume_setup(struct platform_device *pd,
> @@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct acpi_device
> *device,
>  						result);
>  			break;
>  		case 0x0122:
> -			result = sony_nc_thermal_setup(pf_device);
> +		case 0x015F:
> +			result = sony_nc_thermal_setup(pf_device, handle);
>  			if (result)
>  				pr_err("couldn't set up thermal profile function (%d)\n",
>  						result);
> @@ -1476,6 +1478,7 @@ static void sony_nc_function_cleanup(struct
> platform_device *pd)
>  			sony_nc_lid_resume_cleanup(pd);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_cleanup(pd);
>  			break;
>  		case 0x0128:
> @@ -1547,6 +1550,7 @@ static void sony_nc_function_resume(void)
>  			sony_call_snc_handle(handle, 0x100, &result);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_resume();
>  			break;
>  		case 0x0124:
> @@ -2150,14 +2154,16 @@ struct snc_thermal_ctrl {
>  	unsigned int profiles;
>  	struct device_attribute mode_attr;
>  	struct device_attribute profiles_attr;
> +	unsigned int handle;
>  };
>  static struct snc_thermal_ctrl *th_handle;
> 
> -#define THM_PROFILE_MAX 3
> +#define THM_PROFILE_MAX 4
>  static const char * const snc_thermal_profiles[] = {
>  	"balanced",
>  	"silent",
> -	"performance"
> +	"performance",
> +	"cooling"
>  };
> 
>  static int sony_nc_thermal_mode_set(unsigned short mode)
> @@ -2173,7 +2179,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode)
>  	if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX)
>  		return -EINVAL;
> 
> -	if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result))
> +	if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200,
> +				 &result))
>  		return -EIO;
> 
>  	th_handle->mode = mode;
> @@ -2185,7 +2192,7 @@ static int sony_nc_thermal_mode_get(void)
>  {
>  	unsigned int result;
> 
> -	if (sony_call_snc_handle(0x0122, 0x0100, &result))
> +	if (sony_call_snc_handle(th_handle->handle, 0x0100, &result))
>  		return -EIO;
> 
>  	return result & 0xff;
> @@ -2245,14 +2252,17 @@ static ssize_t sony_nc_thermal_mode_show(struct
> device *dev,
>  	return count;
>  }
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd)
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				 unsigned int handle)
>  {
>  	int ret = 0;
>  	th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL);
>  	if (!th_handle)
>  		return -ENOMEM;
> 
> -	ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles);
> +	th_handle->handle = handle;
> +
> +	ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles);
>  	if (ret) {
>  		pr_warn("couldn't to read the thermal profiles\n");
>  		goto outkzalloc;
> -- 
> 2.8.3
> 
> 
-- 
mattia
:wq!

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

* Re: [PATCH v2] sony-laptop: add new thermal control handle
  2016-06-23 18:43 ` [PATCH v2] " Stefan Seidel
  2016-06-28  5:15   ` Mattia Dongili
@ 2016-07-01 19:30   ` Darren Hart
  1 sibling, 0 replies; 4+ messages in thread
From: Darren Hart @ 2016-07-01 19:30 UTC (permalink / raw)
  To: Stefan Seidel; +Cc: Mattia Dongili, platform-driver-x86

On Thu, Jun 23, 2016 at 08:43:22PM +0200, Stefan Seidel wrote:
> Hi,
> 
> sorry about the wrong first patch, I had missed an unwanted hunk.
> 

Hi Stefan, please provide commentary like the above in a cover letter (PATCH
0/N), so the patch itself can be applied directly.

> On at least the SVD11 there is an additional thermal control setting that
> is found at a different handle address but otherwise behaves the same as
> the other one.
> 
> Signed-off-by: Stefan Seidel <lkml@stefanseidel.info>


Please include all maintainers and lists reported by get_maintainers.pl on Cc.

The patch comes in corrupted and does not apply. It appears to be line wrapped.
checkpatch --fix-inplace was unable to correct it. Please check your mail client
settings, send the patch to yourself and verify you can apply it, then resend.

> ---
>  drivers/platform/x86/sony-laptop.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/sony-laptop.c
> b/drivers/platform/x86/sony-laptop.c
> index 1dba359..6c9deb3 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -148,7 +148,8 @@ static int sony_nc_battery_care_setup(struct
> platform_device *pd,
>  		unsigned int handle);
>  static void sony_nc_battery_care_cleanup(struct platform_device *pd);
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd);
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				  unsigned int handle);
>  static void sony_nc_thermal_cleanup(struct platform_device *pd);
> 
>  static int sony_nc_lid_resume_setup(struct platform_device *pd,
> @@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct acpi_device
> *device,
>  						result);
>  			break;
>  		case 0x0122:
> -			result = sony_nc_thermal_setup(pf_device);
> +		case 0x015F:
> +			result = sony_nc_thermal_setup(pf_device, handle);
>  			if (result)
>  				pr_err("couldn't set up thermal profile function (%d)\n",
>  						result);
> @@ -1476,6 +1478,7 @@ static void sony_nc_function_cleanup(struct
> platform_device *pd)
>  			sony_nc_lid_resume_cleanup(pd);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_cleanup(pd);
>  			break;
>  		case 0x0128:
> @@ -1547,6 +1550,7 @@ static void sony_nc_function_resume(void)
>  			sony_call_snc_handle(handle, 0x100, &result);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_resume();
>  			break;
>  		case 0x0124:
> @@ -2150,14 +2154,16 @@ struct snc_thermal_ctrl {
>  	unsigned int profiles;
>  	struct device_attribute mode_attr;
>  	struct device_attribute profiles_attr;
> +	unsigned int handle;
>  };
>  static struct snc_thermal_ctrl *th_handle;
> 
> -#define THM_PROFILE_MAX 3
> +#define THM_PROFILE_MAX 4

You mention the new control behaves the same, but here you are adding a profile,
and blow you add "cooling"... this seems like an additional change which needs
to be documented in the commit message at the very least.

>  static const char * const snc_thermal_profiles[] = {
>  	"balanced",
>  	"silent",
> -	"performance"
> +	"performance",
> +	"cooling"
>  };
> 
>  static int sony_nc_thermal_mode_set(unsigned short mode)
> @@ -2173,7 +2179,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode)
>  	if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX)
>  		return -EINVAL;
> 
> -	if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result))
> +	if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200,
> +				 &result))
>  		return -EIO;
> 
>  	th_handle->mode = mode;
> @@ -2185,7 +2192,7 @@ static int sony_nc_thermal_mode_get(void)
>  {
>  	unsigned int result;
> 
> -	if (sony_call_snc_handle(0x0122, 0x0100, &result))
> +	if (sony_call_snc_handle(th_handle->handle, 0x0100, &result))
>  		return -EIO;
> 
>  	return result & 0xff;
> @@ -2245,14 +2252,17 @@ static ssize_t sony_nc_thermal_mode_show(struct
> device *dev,
>  	return count;
>  }
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd)
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				 unsigned int handle)
>  {
>  	int ret = 0;
>  	th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL);
>  	if (!th_handle)
>  		return -ENOMEM;
> 
> -	ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles);
> +	th_handle->handle = handle;
> +
> +	ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles);
>  	if (ret) {
>  		pr_warn("couldn't to read the thermal profiles\n");
>  		goto outkzalloc;
> -- 
> 2.8.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Darren Hart
Intel Open Source Technology Center

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

end of thread, other threads:[~2016-07-01 19:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-23 18:21 [PATCH] sony-laptop: add new thermal control handle Stefan Seidel
2016-06-23 18:43 ` [PATCH v2] " Stefan Seidel
2016-06-28  5:15   ` Mattia Dongili
2016-07-01 19:30   ` Darren Hart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.