diff mbox

asus_atk0110 not working on Asus P7P55D PRO

Message ID 20090920162306.GA18214@dreamland.darkstar.lan (mailing list archive)
State RFC, archived
Headers show

Commit Message

Luca Tettamanti Sept. 20, 2009, 4:23 p.m. UTC
Il Wed, Sep 16, 2009 at 11:28:39PM -0600, Robert Hancock ha scritto: 
> Just built a new system with an Asus P7P55D PRO motherboard. The
> ATK0110 driver doesn't seem to be able to retrieve any hardware
> monitoring parameters successfully, sensors gives:
> 
> atk0110-acpi-0
> Adapter: ACPI interface
> ERROR: Can't get value of subfeature in0_input: I/O error
> Vcore Voltage:      +0.00 V  (min =  +0.80 V, max =  +1.60 V)
> ERROR: Can't get value of subfeature in1_input: I/O error
> +3.3V Voltage:      +0.00 V  (min =  +2.97 V, max =  +3.63 V)
> ERROR: Can't get value of subfeature in2_input: I/O error
> +5V Voltage:        +0.00 V  (min =  +4.50 V, max =  +5.50 V)
> 
> etc. and dmesg spits out a bunch of these:
> 
> ATK0110 ATK0110:00: atk_read_value_new: ACPI exception: AE_BUFFER_OVERFLOW
> 
> I'm guessing this board uses a different format than what the driver
> is expecting. I'm attaching the gzipped decompiled DSDT from the
> board, hopefully it's useful to somebody..

Please try the following patch, it should detect the proper buffer size.


Luca

Comments

Robert Hancock Sept. 20, 2009, 5:47 p.m. UTC | #1
On Sun, Sep 20, 2009 at 10:23 AM, Luca Tettamanti <kronos.it@gmail.com> wrote:
> Il Wed, Sep 16, 2009 at 11:28:39PM -0600, Robert Hancock ha scritto:
>> Just built a new system with an Asus P7P55D PRO motherboard. The
>> ATK0110 driver doesn't seem to be able to retrieve any hardware
>> monitoring parameters successfully, sensors gives:
>>
>> atk0110-acpi-0
>> Adapter: ACPI interface
>> ERROR: Can't get value of subfeature in0_input: I/O error
>> Vcore Voltage:      +0.00 V  (min =  +0.80 V, max =  +1.60 V)
>> ERROR: Can't get value of subfeature in1_input: I/O error
>> +3.3V Voltage:      +0.00 V  (min =  +2.97 V, max =  +3.63 V)
>> ERROR: Can't get value of subfeature in2_input: I/O error
>> +5V Voltage:        +0.00 V  (min =  +4.50 V, max =  +5.50 V)
>>
>> etc. and dmesg spits out a bunch of these:
>>
>> ATK0110 ATK0110:00: atk_read_value_new: ACPI exception: AE_BUFFER_OVERFLOW
>>
>> I'm guessing this board uses a different format than what the driver
>> is expecting. I'm attaching the gzipped decompiled DSDT from the
>> board, hopefully it's useful to somebody..
>
> Please try the following patch, it should detect the proper buffer size.
>

Obviously something not quite right:

BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffff81301b1f>] acpi_ut_copy_isimple_to_esimple+0x3e/0x16e
PGD 11d5c8067 PUD 11d680067 PMD 0
Oops: 0002 [#1] SMP
last sysfs file:
/sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:03/ATK0110:00/hwmon/hwmon0/in0_input
CPU 3
Modules linked in: ipv6 cpufreq_ondemand acpi_cpufreq freq_table fuse
dm_multipath uinput snd_ice1724 snd_rawmidi snd_seq_device
snd_hda_codec_via snd_ice17xx_ak4xxx snd_ac97_codec snd_hda_intel
snd_hda_codec ac97_bus snd_ak4xxx_adda snd_ak4114 snd_hwdep snd_pcm
snd_pt2258 snd_i2c snd_timer gspca_spca561 snd gspca_main videodev
ata_generic r8169 v4l1_compat firewire_ohci pata_acpi usb_storage
firewire_core i2c_i801 snd_page_alloc soundcore mii
v4l2_compat_ioctl32 asus_atk0110 wmi joydev pata_jmicron i2c_core
pcspkr serio_raw hwmon crc_itu_t [last unloaded: scsi_wait_scan]
Pid: 2475, comm: sensors-applet Not tainted 2.6.31-rc0 #6 System Product Name
RIP: 0010:[<ffffffff81301b1f>]  [<ffffffff81301b1f>]
acpi_ut_copy_isimple_to_esimple+0x3e/0x16e
RSP: 0018:ffff88011f2d1c48  EFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000006
RDX: 0000000000000018 RSI: ffff88011f2d1dc8 RDI: 0000000000000000
RBP: ffff88011f2d1c68 R08: ffff88013ba9a2d0 R09: ffff88013ba9a2d0
R10: 00000000c261101f R11: 00000000c261101f R12: ffff88013ba70a40
R13: ffff88011f2d1dd8 R14: ffff88013b2d3fc0 R15: ffff88011f2d1dc8
FS:  00007f7cdbea1800(0000) GS:ffff880028260000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000011f398000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process sensors-applet (pid: 2475, threadinfo ffff88011f2d0000, task
ffff88011f2c8000)
Stack:
 0000000000004001 00000000c261101f ffff88011f2d1cc8 ffff88011f2d1dc8
<0> ffff88011f2d1ca8 ffffffff81301ce3 ffff88013b2d3fc0 00000000c261101f
<0> 0000000000000000 00000000c261101f 0000000000000000 0000000000000000
Call Trace:
 [<ffffffff81301ce3>] acpi_ut_copy_iobject_to_eobject+0x94/0xb3
 [<ffffffff812f6911>] acpi_evaluate_object+0x1b5/0x21a
 [<ffffffff812f69b1>] acpi_evaluate_object_typed+0x3b/0xfa
 [<ffffffffa00405d6>] atk_input_show+0x1a0/0x2bb [asus_atk0110]
 [<ffffffff81011f82>] ? system_call_fastpath+0x16/0x1b
Code: 28 00 00 00 48 89 45 e8 31 c0 48 89 f3 49 89 f8 48 89 ce 48 c7
01 00 00 00 00 48 85 ff 0f 84 1d 01 00 00 b9 06 00 00 00 48 89 df <f3>
ab 41 0f b6 40 09 89 03 41 8a 78 09 40 80 ff 03 74 56 77 12
RIP  [<ffffffff81301b1f>] acpi_ut_copy_isimple_to_esimple+0x3e/0x16e
 RSP <ffff88011f2d1c48>
CR2: 0000000000000000
---[ end trace d7191dbc499ceceb ]---

Based on the disassembly I think this memset is what failed in
drivers/acpi/acpica/utcopy.c, in the acpi_ut_copy_isimple_to_esimple
function:

	/* Always clear the external object */

	ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index fe4fa29..4f6f5ec 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -75,6 +75,13 @@  enum atk_pack_member {
 #define _HWMON_OLD_PACK_ENABLE	4
 
 
+struct atk_acpi_out_buffer {
+	union acpi_object buf;
+	u32 flags;
+	u32 value;
+	u8 data[];
+};
+
 struct atk_data {
 	struct device *hwmon_dev;
 	acpi_handle atk_handle;
@@ -94,6 +101,10 @@  struct atk_data {
 	int temperature_count;
 	int fan_count;
 	struct list_head sensor_list;
+	
+	struct atk_acpi_out_buffer *buffer;
+	size_t buffer_size;
+	struct mutex buffer_lock;
 };
 
 
@@ -129,11 +140,6 @@  struct atk_sensor_data {
 	char const *acpi_name;
 };
 
-struct atk_acpi_buffer_u64 {
-	union acpi_object buf;
-	u64 value;
-};
-
 static int atk_add(struct acpi_device *device);
 static int atk_remove(struct acpi_device *device, int type);
 static void atk_print_sensor(struct atk_data *data, union acpi_object *obj);
@@ -446,8 +452,9 @@  static int atk_read_value_new(struct atk_sensor_data *sensor, u64 *value)
 	struct acpi_object_list params;
 	struct acpi_buffer ret;
 	union acpi_object id;
-	struct atk_acpi_buffer_u64 tmp;
+	union acpi_object buf;
 	acpi_status status;
+	int err = 0;
 
 	id.type = ACPI_TYPE_INTEGER;
 	id.integer.value = sensor->id;
@@ -455,36 +462,35 @@  static int atk_read_value_new(struct atk_sensor_data *sensor, u64 *value)
 	params.count = 1;
 	params.pointer = &id;
 
-	tmp.buf.type = ACPI_TYPE_BUFFER;
-	tmp.buf.buffer.pointer = (u8 *)&tmp.value;
-	tmp.buf.buffer.length = sizeof(u64);
-	ret.length = sizeof(tmp);
-	ret.pointer = &tmp;
+	mutex_lock(&data->buffer_lock);
+
+	ret.length = data->buffer_size;
+	ret.pointer = &buf;
 
 	status = acpi_evaluate_object_typed(data->read_handle, NULL, &params,
 			&ret, ACPI_TYPE_BUFFER);
 	if (status != AE_OK) {
 		dev_warn(dev, "%s: ACPI exception: %s\n", __func__,
 				acpi_format_exception(status));
-		return -EIO;
+		err = -EIO;
+		goto out;
 	}
 
-	/* Return buffer format:
-	 * [0-3] "value" is valid flag
-	 * [4-7] value
-	 */
-	if (!(tmp.value & 0xffffffff)) {
+	if (!data->buffer->flags) {
 		/* The reading is not valid, possible causes:
 		 * - sensor failure
 		 * - enumeration was FUBAR (and we didn't notice)
 		 */
-		dev_info(dev, "Failure: %#llx\n", tmp.value);
-		return -EIO;
+		dev_info(dev, "Failure: %#x\n", data->buffer->flags);
+	
+		err = -EIO;
+		goto out;
 	}
 
-	*value = (tmp.value & 0xffffffff00000000ULL) >> 32;
-
-	return 0;
+	*value = data->buffer->value;
+out:
+	mutex_unlock(&data->buffer_lock);
+	return err;
 }
 
 static int atk_read_value(struct atk_sensor_data *sensor, u64 *value)
@@ -721,11 +727,40 @@  static int atk_enumerate_new_hwmon(struct atk_data *data)
 	struct acpi_object_list params;
 	union acpi_object id;
 	union acpi_object *pack;
+	union acpi_object *asbf;
 	int err;
 	int i;
 
 	dev_dbg(dev, "Enumerating hwmon sensors\n");
 
+	/* Probe ASBF */
+	buf.length = ACPI_ALLOCATE_BUFFER;
+	ret = acpi_evaluate_object_typed(data->atk_handle, "ASBF", NULL, &buf,
+			ACPI_TYPE_BUFFER);
+	if (ret != AE_OK) {
+		dev_warn(dev, "Failed to evaluate ASBF: %s\n",
+				acpi_format_exception(ret));
+		return -ENODEV;
+	}
+	asbf = buf.pointer;
+	data->buffer_size = asbf->buffer.length;
+	ACPI_FREE(buf.pointer);
+	buf.pointer = NULL;
+	
+	dev_dbg(dev, "ASBF buffer size: %zu\n", data->buffer_size);
+	/* Sanity check */
+	if (data->buffer_size < 8 || data->buffer_size > 512) {
+		dev_warn(dev, "Invalid ASBF buffer size: %zu\n",
+				data->buffer_size);
+		return -EINVAL;
+	}
+	data->buffer_size += sizeof(union acpi_object);
+
+	data->buffer = kzalloc(data->buffer_size, GFP_KERNEL);
+	if (!data->buffer)
+		return -ENOMEM;
+	mutex_init(&data->buffer_lock);
+
 	id.type = ACPI_TYPE_INTEGER;
 	id.integer.value = ATK_MUX_HWMON;
 	params.count = 1;
@@ -737,7 +772,8 @@  static int atk_enumerate_new_hwmon(struct atk_data *data)
 	if (ret != AE_OK) {
 		dev_warn(dev, METHOD_ENUMERATE ": ACPI exception: %s\n",
 				acpi_format_exception(ret));
-		return -ENODEV;
+		err = -ENODEV;
+		goto out;
 	}
 
 	/* Result must be a package */
@@ -759,6 +795,8 @@  static int atk_enumerate_new_hwmon(struct atk_data *data)
 	err = data->voltage_count + data->temperature_count + data->fan_count;
 
 out:
+	if (err < 0)
+		kfree(data->buffer);
 	ACPI_FREE(buf.pointer);
 	return err;
 }
@@ -988,6 +1026,7 @@  static int atk_remove(struct acpi_device *device, int type)
 	atk_free_sensors(data);
 	hwmon_device_unregister(data->hwmon_dev);
 
+	kfree(data->buffer);
 	kfree(data);
 
 	return 0;