All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers
@ 2022-01-10 10:39 Hans de Goede
  2022-01-10 10:39 ` [PATCH 2/3] platform/x86: x86-android-tablets: Add an init() callback to struct x86_dev_info Hans de Goede
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Hans de Goede @ 2022-01-10 10:39 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko
  Cc: Hans de Goede, Lubomir Rintel, platform-driver-x86

Some of the broken DSDTs on these devices often also include broken / wrong
_AEI (ACPI Event Interrupt) handlers, which can cause e.g. interrupt storms
by listening to a floating GPIO pin.

Add support for disabling these and disable them on the Asus ME176C and
TF103C tablets.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 23 ++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 3ba63ad91b28..d125d7a5189a 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -26,6 +26,7 @@
 #include <linux/string.h>
 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
 #include "../../gpio/gpiolib.h"
+#include "../../gpio/gpiolib-acpi.h"
 
 /*
  * Helper code to get Linux IRQ numbers given a description of the IRQ source
@@ -47,7 +48,7 @@ struct x86_acpi_irq_data {
 	int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */
 };
 
-static int x86_acpi_irq_helper_gpiochip_find(struct gpio_chip *gc, void *data)
+static int gpiochip_find_match_label(struct gpio_chip *gc, void *data)
 {
 	return gc->label && !strcmp(gc->label, data);
 }
@@ -73,7 +74,7 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
 		return irq;
 	case X86_ACPI_IRQ_TYPE_GPIOINT:
 		/* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
-		chip = gpiochip_find(data->chip, x86_acpi_irq_helper_gpiochip_find);
+		chip = gpiochip_find(data->chip, gpiochip_find_match_label);
 		if (!chip) {
 			pr_err("error cannot find GPIO chip %s\n", data->chip);
 			return -ENODEV;
@@ -143,6 +144,7 @@ struct x86_serdev_info {
 };
 
 struct x86_dev_info {
+	char *invalid_aei_gpiochip;
 	const char * const *modules;
 	struct gpiod_lookup_table **gpiod_lookup_tables;
 	const struct x86_i2c_client_info *i2c_client_info;
@@ -317,6 +319,7 @@ static const struct x86_dev_info asus_me176c_info __initconst = {
 	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
 	.gpiod_lookup_tables = asus_me176c_gpios,
 	.modules = bq24190_modules,
+	.invalid_aei_gpiochip = "INT33FC:02",
 };
 
 /* Asus TF103C tablets have an Android factory img with everything hardcoded */
@@ -417,6 +420,7 @@ static const struct x86_dev_info asus_tf103c_info __initconst = {
 	.pdev_count = ARRAY_SIZE(int3496_pdevs),
 	.gpiod_lookup_tables = asus_tf103c_gpios,
 	.modules = bq24190_modules,
+	.invalid_aei_gpiochip = "INT33FC:02",
 };
 
 /*
@@ -795,6 +799,7 @@ static __init int x86_android_tablet_init(void)
 {
 	const struct x86_dev_info *dev_info;
 	const struct dmi_system_id *id;
+	struct gpio_chip *chip;
 	int i, ret = 0;
 
 	id = dmi_first_match(x86_android_tablet_ids);
@@ -803,6 +808,20 @@ static __init int x86_android_tablet_init(void)
 
 	dev_info = id->driver_data;
 
+	/*
+	 * The broken DSDTs on these devices often also include broken
+	 * _AEI (ACPI Event Interrupt) handlers, disable these.
+	 */
+	if (dev_info->invalid_aei_gpiochip) {
+		chip = gpiochip_find(dev_info->invalid_aei_gpiochip,
+				     gpiochip_find_match_label);
+		if (!chip) {
+			pr_err("error cannot find GPIO chip %s\n", dev_info->invalid_aei_gpiochip);
+			return -ENODEV;
+		}
+		acpi_gpiochip_free_interrupts(chip);
+	}
+
 	/*
 	 * Since this runs from module_init() it cannot use -EPROBE_DEFER,
 	 * instead pre-load any modules which are listed as requirements.
-- 
2.33.1


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

* [PATCH 2/3] platform/x86: x86-android-tablets: Add an init() callback to struct x86_dev_info
  2022-01-10 10:39 [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
@ 2022-01-10 10:39 ` Hans de Goede
  2022-01-10 10:39 ` [PATCH 3/3] platform/x86: x86-android-tablets: Constify the gpiod_lookup_tables arrays Hans de Goede
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2022-01-10 10:39 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko
  Cc: Hans de Goede, Lubomir Rintel, platform-driver-x86

Add an init() callback to struct x86_dev_info, board descriptions can use
this to do some custom setup before registering the i2c_clients, platform-
devices and servdevs.

Also add an exit() callback to also allow for cleanup of the custom setup.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index d125d7a5189a..2329a5a6c182 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -153,6 +153,8 @@ struct x86_dev_info {
 	int i2c_client_count;
 	int pdev_count;
 	int serdev_count;
+	int (*init)(void);
+	void (*exit)(void);
 };
 
 /* Generic / shared bq24190 settings */
@@ -674,6 +676,7 @@ static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
 static struct serdev_device **serdevs;
 static struct gpiod_lookup_table **gpiod_lookup_tables;
+static void (*exit_handler)(void);
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
 					     int idx)
@@ -791,6 +794,9 @@ static void x86_android_tablet_cleanup(void)
 
 	kfree(i2c_clients);
 
+	if (exit_handler)
+		exit_handler();
+
 	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
 		gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
 }
@@ -833,6 +839,15 @@ static __init int x86_android_tablet_init(void)
 	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
 		gpiod_add_lookup_table(gpiod_lookup_tables[i]);
 
+	if (dev_info->init) {
+		ret = dev_info->init();
+		if (ret < 0) {
+			x86_android_tablet_cleanup();
+			return ret;
+		}
+		exit_handler = dev_info->exit;
+	}
+
 	i2c_clients = kcalloc(dev_info->i2c_client_count, sizeof(*i2c_clients), GFP_KERNEL);
 	if (!i2c_clients) {
 		x86_android_tablet_cleanup();
-- 
2.33.1


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

* [PATCH 3/3] platform/x86: x86-android-tablets: Constify the gpiod_lookup_tables arrays
  2022-01-10 10:39 [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
  2022-01-10 10:39 ` [PATCH 2/3] platform/x86: x86-android-tablets: Add an init() callback to struct x86_dev_info Hans de Goede
@ 2022-01-10 10:39 ` Hans de Goede
  2022-01-11  9:43 ` [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
  2022-01-11 10:06 ` Lubomir Rintel
  3 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2022-01-10 10:39 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko
  Cc: Hans de Goede, Lubomir Rintel, platform-driver-x86

The individual gpiod_lookup_table structs cannot be const because they
contain a list-head which gets used when registering them.

But the array of pointers to the gpiod_lookup_table-s used by a board
can be const, constify these.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 2329a5a6c182..e551670143d7 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -146,7 +146,7 @@ struct x86_serdev_info {
 struct x86_dev_info {
 	char *invalid_aei_gpiochip;
 	const char * const *modules;
-	struct gpiod_lookup_table **gpiod_lookup_tables;
+	struct gpiod_lookup_table * const *gpiod_lookup_tables;
 	const struct x86_i2c_client_info *i2c_client_info;
 	const struct platform_device_info *pdev_info;
 	const struct x86_serdev_info *serdev_info;
@@ -306,7 +306,7 @@ static struct gpiod_lookup_table asus_me176c_goodix_gpios = {
 	},
 };
 
-static struct gpiod_lookup_table *asus_me176c_gpios[] = {
+static struct gpiod_lookup_table * const asus_me176c_gpios[] = {
 	&int3496_gpo2_pin22_gpios,
 	&asus_me176c_goodix_gpios,
 	NULL
@@ -410,7 +410,7 @@ static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst =
 	},
 };
 
-static struct gpiod_lookup_table *asus_tf103c_gpios[] = {
+static struct gpiod_lookup_table * const asus_tf103c_gpios[] = {
 	&int3496_gpo2_pin22_gpios,
 	NULL
 };
@@ -565,7 +565,7 @@ static struct gpiod_lookup_table whitelabel_tm800a550l_goodix_gpios = {
 	},
 };
 
-static struct gpiod_lookup_table *whitelabel_tm800a550l_gpios[] = {
+static struct gpiod_lookup_table * const whitelabel_tm800a550l_gpios[] = {
 	&whitelabel_tm800a550l_goodix_gpios,
 	NULL
 };
@@ -675,7 +675,7 @@ static int serdev_count;
 static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
 static struct serdev_device **serdevs;
-static struct gpiod_lookup_table **gpiod_lookup_tables;
+static struct gpiod_lookup_table * const *gpiod_lookup_tables;
 static void (*exit_handler)(void);
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
-- 
2.33.1


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

* Re: [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers
  2022-01-10 10:39 [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
  2022-01-10 10:39 ` [PATCH 2/3] platform/x86: x86-android-tablets: Add an init() callback to struct x86_dev_info Hans de Goede
  2022-01-10 10:39 ` [PATCH 3/3] platform/x86: x86-android-tablets: Constify the gpiod_lookup_tables arrays Hans de Goede
@ 2022-01-11  9:43 ` Hans de Goede
  2022-01-11 10:06 ` Lubomir Rintel
  3 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2022-01-11  9:43 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko; +Cc: Lubomir Rintel, platform-driver-x86

Hi,

On 1/10/22 11:39, Hans de Goede wrote:
> Some of the broken DSDTs on these devices often also include broken / wrong
> _AEI (ACPI Event Interrupt) handlers, which can cause e.g. interrupt storms
> by listening to a floating GPIO pin.
> 
> Add support for disabling these and disable them on the Asus ME176C and
> TF103C tablets.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

I've added this series to my review-hans branch now, I will rebase this
on top of 5.17-rc1 once it out and then push it to for-next.

Regards,

Hans

> ---
>  drivers/platform/x86/x86-android-tablets.c | 23 ++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
> index 3ba63ad91b28..d125d7a5189a 100644
> --- a/drivers/platform/x86/x86-android-tablets.c
> +++ b/drivers/platform/x86/x86-android-tablets.c
> @@ -26,6 +26,7 @@
>  #include <linux/string.h>
>  /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
>  #include "../../gpio/gpiolib.h"
> +#include "../../gpio/gpiolib-acpi.h"
>  
>  /*
>   * Helper code to get Linux IRQ numbers given a description of the IRQ source
> @@ -47,7 +48,7 @@ struct x86_acpi_irq_data {
>  	int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */
>  };
>  
> -static int x86_acpi_irq_helper_gpiochip_find(struct gpio_chip *gc, void *data)
> +static int gpiochip_find_match_label(struct gpio_chip *gc, void *data)
>  {
>  	return gc->label && !strcmp(gc->label, data);
>  }
> @@ -73,7 +74,7 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
>  		return irq;
>  	case X86_ACPI_IRQ_TYPE_GPIOINT:
>  		/* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
> -		chip = gpiochip_find(data->chip, x86_acpi_irq_helper_gpiochip_find);
> +		chip = gpiochip_find(data->chip, gpiochip_find_match_label);
>  		if (!chip) {
>  			pr_err("error cannot find GPIO chip %s\n", data->chip);
>  			return -ENODEV;
> @@ -143,6 +144,7 @@ struct x86_serdev_info {
>  };
>  
>  struct x86_dev_info {
> +	char *invalid_aei_gpiochip;
>  	const char * const *modules;
>  	struct gpiod_lookup_table **gpiod_lookup_tables;
>  	const struct x86_i2c_client_info *i2c_client_info;
> @@ -317,6 +319,7 @@ static const struct x86_dev_info asus_me176c_info __initconst = {
>  	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
>  	.gpiod_lookup_tables = asus_me176c_gpios,
>  	.modules = bq24190_modules,
> +	.invalid_aei_gpiochip = "INT33FC:02",
>  };
>  
>  /* Asus TF103C tablets have an Android factory img with everything hardcoded */
> @@ -417,6 +420,7 @@ static const struct x86_dev_info asus_tf103c_info __initconst = {
>  	.pdev_count = ARRAY_SIZE(int3496_pdevs),
>  	.gpiod_lookup_tables = asus_tf103c_gpios,
>  	.modules = bq24190_modules,
> +	.invalid_aei_gpiochip = "INT33FC:02",
>  };
>  
>  /*
> @@ -795,6 +799,7 @@ static __init int x86_android_tablet_init(void)
>  {
>  	const struct x86_dev_info *dev_info;
>  	const struct dmi_system_id *id;
> +	struct gpio_chip *chip;
>  	int i, ret = 0;
>  
>  	id = dmi_first_match(x86_android_tablet_ids);
> @@ -803,6 +808,20 @@ static __init int x86_android_tablet_init(void)
>  
>  	dev_info = id->driver_data;
>  
> +	/*
> +	 * The broken DSDTs on these devices often also include broken
> +	 * _AEI (ACPI Event Interrupt) handlers, disable these.
> +	 */
> +	if (dev_info->invalid_aei_gpiochip) {
> +		chip = gpiochip_find(dev_info->invalid_aei_gpiochip,
> +				     gpiochip_find_match_label);
> +		if (!chip) {
> +			pr_err("error cannot find GPIO chip %s\n", dev_info->invalid_aei_gpiochip);
> +			return -ENODEV;
> +		}
> +		acpi_gpiochip_free_interrupts(chip);
> +	}
> +
>  	/*
>  	 * Since this runs from module_init() it cannot use -EPROBE_DEFER,
>  	 * instead pre-load any modules which are listed as requirements.
> 


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

* Re: [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers
  2022-01-10 10:39 [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
                   ` (2 preceding siblings ...)
  2022-01-11  9:43 ` [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
@ 2022-01-11 10:06 ` Lubomir Rintel
  2022-01-11 10:09   ` Hans de Goede
  3 siblings, 1 reply; 6+ messages in thread
From: Lubomir Rintel @ 2022-01-11 10:06 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Mark Gross, Andy Shevchenko, platform-driver-x86

On Mon, Jan 10, 2022 at 11:39:50AM +0100, Hans de Goede wrote:
> Some of the broken DSDTs on these devices often also include broken / wrong
> _AEI (ACPI Event Interrupt) handlers, which can cause e.g. interrupt storms
> by listening to a floating GPIO pin.
> 
> Add support for disabling these and disable them on the Asus ME176C and
> TF103C tablets.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

The whole series looks good to me. Feel free to slap on:

Reviewed-By: Lubomir Rintel <lkundrak@V3.sk>

Regards
Lubo

> ---
>  drivers/platform/x86/x86-android-tablets.c | 23 ++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
> index 3ba63ad91b28..d125d7a5189a 100644
> --- a/drivers/platform/x86/x86-android-tablets.c
> +++ b/drivers/platform/x86/x86-android-tablets.c
> @@ -26,6 +26,7 @@
>  #include <linux/string.h>
>  /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
>  #include "../../gpio/gpiolib.h"
> +#include "../../gpio/gpiolib-acpi.h"
>  
>  /*
>   * Helper code to get Linux IRQ numbers given a description of the IRQ source
> @@ -47,7 +48,7 @@ struct x86_acpi_irq_data {
>  	int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */
>  };
>  
> -static int x86_acpi_irq_helper_gpiochip_find(struct gpio_chip *gc, void *data)
> +static int gpiochip_find_match_label(struct gpio_chip *gc, void *data)
>  {
>  	return gc->label && !strcmp(gc->label, data);
>  }
> @@ -73,7 +74,7 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
>  		return irq;
>  	case X86_ACPI_IRQ_TYPE_GPIOINT:
>  		/* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
> -		chip = gpiochip_find(data->chip, x86_acpi_irq_helper_gpiochip_find);
> +		chip = gpiochip_find(data->chip, gpiochip_find_match_label);
>  		if (!chip) {
>  			pr_err("error cannot find GPIO chip %s\n", data->chip);
>  			return -ENODEV;
> @@ -143,6 +144,7 @@ struct x86_serdev_info {
>  };
>  
>  struct x86_dev_info {
> +	char *invalid_aei_gpiochip;
>  	const char * const *modules;
>  	struct gpiod_lookup_table **gpiod_lookup_tables;
>  	const struct x86_i2c_client_info *i2c_client_info;
> @@ -317,6 +319,7 @@ static const struct x86_dev_info asus_me176c_info __initconst = {
>  	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
>  	.gpiod_lookup_tables = asus_me176c_gpios,
>  	.modules = bq24190_modules,
> +	.invalid_aei_gpiochip = "INT33FC:02",
>  };
>  
>  /* Asus TF103C tablets have an Android factory img with everything hardcoded */
> @@ -417,6 +420,7 @@ static const struct x86_dev_info asus_tf103c_info __initconst = {
>  	.pdev_count = ARRAY_SIZE(int3496_pdevs),
>  	.gpiod_lookup_tables = asus_tf103c_gpios,
>  	.modules = bq24190_modules,
> +	.invalid_aei_gpiochip = "INT33FC:02",
>  };
>  
>  /*
> @@ -795,6 +799,7 @@ static __init int x86_android_tablet_init(void)
>  {
>  	const struct x86_dev_info *dev_info;
>  	const struct dmi_system_id *id;
> +	struct gpio_chip *chip;
>  	int i, ret = 0;
>  
>  	id = dmi_first_match(x86_android_tablet_ids);
> @@ -803,6 +808,20 @@ static __init int x86_android_tablet_init(void)
>  
>  	dev_info = id->driver_data;
>  
> +	/*
> +	 * The broken DSDTs on these devices often also include broken
> +	 * _AEI (ACPI Event Interrupt) handlers, disable these.
> +	 */
> +	if (dev_info->invalid_aei_gpiochip) {
> +		chip = gpiochip_find(dev_info->invalid_aei_gpiochip,
> +				     gpiochip_find_match_label);
> +		if (!chip) {
> +			pr_err("error cannot find GPIO chip %s\n", dev_info->invalid_aei_gpiochip);
> +			return -ENODEV;
> +		}
> +		acpi_gpiochip_free_interrupts(chip);
> +	}
> +
>  	/*
>  	 * Since this runs from module_init() it cannot use -EPROBE_DEFER,
>  	 * instead pre-load any modules which are listed as requirements.
> -- 
> 2.33.1
> 

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

* Re: [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers
  2022-01-11 10:06 ` Lubomir Rintel
@ 2022-01-11 10:09   ` Hans de Goede
  0 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2022-01-11 10:09 UTC (permalink / raw)
  To: Lubomir Rintel; +Cc: Mark Gross, Andy Shevchenko, platform-driver-x86

Hi,

On 1/11/22 11:06, Lubomir Rintel wrote:
> On Mon, Jan 10, 2022 at 11:39:50AM +0100, Hans de Goede wrote:
>> Some of the broken DSDTs on these devices often also include broken / wrong
>> _AEI (ACPI Event Interrupt) handlers, which can cause e.g. interrupt storms
>> by listening to a floating GPIO pin.
>>
>> Add support for disabling these and disable them on the Asus ME176C and
>> TF103C tablets.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> The whole series looks good to me. Feel free to slap on:
> 
> Reviewed-By: Lubomir Rintel <lkundrak@V3.sk>

Thanks, I've added the tag to the patches in my review-hans branch.

Regards,

Hans



>> ---
>>  drivers/platform/x86/x86-android-tablets.c | 23 ++++++++++++++++++++--
>>  1 file changed, 21 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
>> index 3ba63ad91b28..d125d7a5189a 100644
>> --- a/drivers/platform/x86/x86-android-tablets.c
>> +++ b/drivers/platform/x86/x86-android-tablets.c
>> @@ -26,6 +26,7 @@
>>  #include <linux/string.h>
>>  /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
>>  #include "../../gpio/gpiolib.h"
>> +#include "../../gpio/gpiolib-acpi.h"
>>  
>>  /*
>>   * Helper code to get Linux IRQ numbers given a description of the IRQ source
>> @@ -47,7 +48,7 @@ struct x86_acpi_irq_data {
>>  	int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */
>>  };
>>  
>> -static int x86_acpi_irq_helper_gpiochip_find(struct gpio_chip *gc, void *data)
>> +static int gpiochip_find_match_label(struct gpio_chip *gc, void *data)
>>  {
>>  	return gc->label && !strcmp(gc->label, data);
>>  }
>> @@ -73,7 +74,7 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
>>  		return irq;
>>  	case X86_ACPI_IRQ_TYPE_GPIOINT:
>>  		/* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
>> -		chip = gpiochip_find(data->chip, x86_acpi_irq_helper_gpiochip_find);
>> +		chip = gpiochip_find(data->chip, gpiochip_find_match_label);
>>  		if (!chip) {
>>  			pr_err("error cannot find GPIO chip %s\n", data->chip);
>>  			return -ENODEV;
>> @@ -143,6 +144,7 @@ struct x86_serdev_info {
>>  };
>>  
>>  struct x86_dev_info {
>> +	char *invalid_aei_gpiochip;
>>  	const char * const *modules;
>>  	struct gpiod_lookup_table **gpiod_lookup_tables;
>>  	const struct x86_i2c_client_info *i2c_client_info;
>> @@ -317,6 +319,7 @@ static const struct x86_dev_info asus_me176c_info __initconst = {
>>  	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
>>  	.gpiod_lookup_tables = asus_me176c_gpios,
>>  	.modules = bq24190_modules,
>> +	.invalid_aei_gpiochip = "INT33FC:02",
>>  };
>>  
>>  /* Asus TF103C tablets have an Android factory img with everything hardcoded */
>> @@ -417,6 +420,7 @@ static const struct x86_dev_info asus_tf103c_info __initconst = {
>>  	.pdev_count = ARRAY_SIZE(int3496_pdevs),
>>  	.gpiod_lookup_tables = asus_tf103c_gpios,
>>  	.modules = bq24190_modules,
>> +	.invalid_aei_gpiochip = "INT33FC:02",
>>  };
>>  
>>  /*
>> @@ -795,6 +799,7 @@ static __init int x86_android_tablet_init(void)
>>  {
>>  	const struct x86_dev_info *dev_info;
>>  	const struct dmi_system_id *id;
>> +	struct gpio_chip *chip;
>>  	int i, ret = 0;
>>  
>>  	id = dmi_first_match(x86_android_tablet_ids);
>> @@ -803,6 +808,20 @@ static __init int x86_android_tablet_init(void)
>>  
>>  	dev_info = id->driver_data;
>>  
>> +	/*
>> +	 * The broken DSDTs on these devices often also include broken
>> +	 * _AEI (ACPI Event Interrupt) handlers, disable these.
>> +	 */
>> +	if (dev_info->invalid_aei_gpiochip) {
>> +		chip = gpiochip_find(dev_info->invalid_aei_gpiochip,
>> +				     gpiochip_find_match_label);
>> +		if (!chip) {
>> +			pr_err("error cannot find GPIO chip %s\n", dev_info->invalid_aei_gpiochip);
>> +			return -ENODEV;
>> +		}
>> +		acpi_gpiochip_free_interrupts(chip);
>> +	}
>> +
>>  	/*
>>  	 * Since this runs from module_init() it cannot use -EPROBE_DEFER,
>>  	 * instead pre-load any modules which are listed as requirements.
>> -- 
>> 2.33.1
>>
> 


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

end of thread, other threads:[~2022-01-11 10:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 10:39 [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
2022-01-10 10:39 ` [PATCH 2/3] platform/x86: x86-android-tablets: Add an init() callback to struct x86_dev_info Hans de Goede
2022-01-10 10:39 ` [PATCH 3/3] platform/x86: x86-android-tablets: Constify the gpiod_lookup_tables arrays Hans de Goede
2022-01-11  9:43 ` [PATCH 1/3] platform/x86: x86-android-tablets: Add support for disabling ACPI _AEI handlers Hans de Goede
2022-01-11 10:06 ` Lubomir Rintel
2022-01-11 10:09   ` Hans de Goede

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.