ACPI: dock: Don't eval _STA on every show_docked sysfs read
PATCH 1/1 ACPI: dock: Don't eval _STA on every show_docked sysfs read
Some devices trigger a DEVICE_CHECK on every evalutation of _STA. This can also be seen in commit 8b59560a3baf2e7c24e0fb92ea5d09eca92805db (ACPI: dock: avoid check _STA method). If an undock is processed, the dock driver sends a uevent and userspace might read the show_docked property in sysfs. This causes an evaluation of _STA of the particular device which causes the dock driver to immediately dock again.
In any case, evaluation of _STA (show_docked) does not necessarily mean that we are docked, so check with the internal device structure.
http://bugzilla.kernel.org/show_bug.cgi?id=12360
---
drivers/acpi/dock.c +5 -1
@@ -855,10 +855,14 @@ fdd_out:static ssize_t show_docked (struct device *dev,struct device_attribute *attr,char *buf) { +struct acpi_device *tmp; +struct dock_station *dock_station = *((struct dock_station **) dev->platform_data); -return snprintf (buf,PAGE_SIZE ,"%d\n" ,dock_present (dock_station)); +if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) +return snprintf (buf,PAGE_SIZE ,"1\n" ); +return snprintf (buf,PAGE_SIZE ,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
Quoted 1 line · On Tue, 20 Jan 2009 12:18:24 +0100 Holger Macht <[email protected]> wrote:
The patch applied OK to 2.6.28 but not to any earlier kernel. If we decide that it should be backported to 2.6.27 or earlier, a new patch might be needed for that.
Quoted 24 lines
Some devices trigger a
DEVICE_CHECKon every evalutation of_STA. This can also be seen in commit8b59560a3baf2e7c24e0fb92ea5d09eca92805db(ACPI: dock: avoid check_STAmethod). If an undock is processed, the dock driver sends a uevent and userspace might read theshow_dockedproperty in sysfs. This causes an evaluation of_STAof the particular device which causes the dock driver to immediately dock again.In any case, evaluation of
_STA(show_docked) does not necessarily mean that we are docked, so check with the internal device structure.http://bugzilla.kernel.org/show_bug.cgi?id=12360
Signed-off-by Holger Macht <[email protected]>---
drivers/acpi/dock.c +1
-0@@ -855,10 +855,14 @@ fdd_out:static ssize_t show_docked (struct device *dev,struct device_attribute *attr,char *buf) { +struct acpi_device *tmp;
drivers/acpi/dock.c fdd_out: · line 867
Quoted 10 lines
drivers/acpi/dock.c +4
-1+struct dock_station *dock_station = *((struct dock_station **) dev->platform_data); -return snprintf (buf,PAGE_SIZE ,"%d\n" ,dock_present (dock_station)); +if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) +return snprintf (buf,PAGE_SIZE ,"1\n" ); +return snprintf (buf,PAGE_SIZE ,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
That seems a little overwrought. Won't plain old strcpy suffice?
drivers/acpi/dock.c renamed from drivers/acpi/dock.c~acpi-dock-dont-eval-_sta-on-every-show_docked-sysfs-read-simplification +2 -2
@@ -861,8 +861,8 @@ static ssize_t show_docked(struct device dev->platform_data);if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) -return snprintf (buf,PAGE_SIZE ,"1\n" ); -return snprintf (buf,PAGE_SIZE ,"0\n" ); +return strcpy (buf,"1\n" ); +return strcpy (buf,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
_
Hi,
sorry for the delay...
Quoted 8 lines · Andrew Morton
Quoted 1 line · On Tue, 20 Jan 2009 12:18:24 +0100 Holger Macht <[email protected]> wrote:
The patch applied OK to 2.6.28 but not to any earlier kernel. If we decide that it should be backported to 2.6.27 or earlier, a new patch might be needed for that.
Patch that applies to stable kernel from today is attached.
Thanks,
Holger
Some devices trigger a DEVICE_CHECK on every evalutation of _STA. This can also be seen in commit 8b59560a3baf2e7c24e0fb92ea5d09eca92805db (acpi: dock: avoid check _STA method). If an undock is processed, the dock driver sends a uevent and userspace might read the show_docked property in sysfs. This causes an evaluation of _STA of the particular device which causes the dock driver to immediately dock again.
In any case, evaluation of _STA (show_docked) does not necessarily mean that we are docked, so check with the internal device structure.
http://bugzilla.kernel.org/show_bug.cgi?id=12360
---
drivers/acpi/dock.c +7 -1
@@ -691,8 +691,14 @@ fdd_out:static ssize_t show_docked (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%d\n" ,dock_present (dock_station)); +struct acpi_device *tmp; + +struct dock_station *dock_station = *((struct dock_station **) + dev->platform_data); +if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) +return snprintf (buf,PAGE_SIZE ,"1\n" ); +return snprintf (buf,PAGE_SIZE ,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
Quoted 8 lines · On Fri, 06 Feb 2009 17:47:56 +0100 Holger Macht <[email protected]> wrote:
Hi,
sorry for the delay...
Quoted 3 lines · Andrew Morton
On Tue, 20 Jan 2009 12:18:24 +0100
Holger Macht <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
The patch applied OK to 2.6.28 but not to any earlier kernel. If we decide that it should be backported to 2.6.27 or earlier, a new patch might be needed for that.
Patch that applies to stable kernel from today is attached.
ok, thanks.
But this won't be going into -stable until the mainline version gets merged.
Len, where are we up to with that?
Thanks.
Len Brown
reviewer--
Len Brown, Intel Open Source Technology Center
Quoted 60 lines · Andrew Morton
Quoted 1 line · On Tue, 20 Jan 2009 12:18:24 +0100 Holger Macht <[email protected]> wrote:
The patch applied OK to 2.6.28 but not to any earlier kernel. If we decide that it should be backported to 2.6.27 or earlier, a new patch might be needed for that.
Quoted 24 lines
Some devices trigger a
DEVICE_CHECKon every evalutation of_STA. This can also be seen in commit8b59560a3baf2e7c24e0fb92ea5d09eca92805db(ACPI: dock: avoid check_STAmethod). If an undock is processed, the dock driver sends a uevent and userspace might read theshow_dockedproperty in sysfs. This causes an evaluation of_STAof the particular device which causes the dock driver to immediately dock again.In any case, evaluation of
_STA(show_docked) does not necessarily mean that we are docked, so check with the internal device structure.http://bugzilla.kernel.org/show_bug.cgi?id=12360
Signed-off-by Holger Macht <[email protected]>---
drivers/acpi/dock.c +1
-0@@ -855,10 +855,14 @@ fdd_out:static ssize_t show_docked (struct device *dev,struct device_attribute *attr,char *buf) { +struct acpi_device *tmp;drivers/acpi/dock.c fdd_out: · line 867
Quoted 10 lines
drivers/acpi/dock.c +4
-1+struct dock_station *dock_station = *((struct dock_station **) dev->platform_data); -return snprintf (buf,PAGE_SIZE ,"%d\n" ,dock_present (dock_station)); +if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) +return snprintf (buf,PAGE_SIZE ,"1\n" ); +return snprintf (buf,PAGE_SIZE ,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);That seems a little overwrought. Won't plain old strcpy suffice?
drivers/acpi/dock.c renamed from drivers/acpi/dock.c~acpi-dock-dont-eval-_sta-on-every-show_docked-sysfs-read-simplification +2
-2@@ -861,8 +861,8 @@ static ssize_t show_docked(struct device dev->platform_data);if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) -return snprintf (buf,PAGE_SIZE ,"1\n" ); -return snprintf (buf,PAGE_SIZE ,"0\n" ); +return strcpy (buf,"1\n" ); +return strcpy (buf,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
Quoted 2 lines
_
sure, strcpy is fine b/c the src and dest are known to not be in danger of overlow. applied to acpi misc branch.
thanks,
-Len
Quoted 67 lines · On Fri, 06 Feb 2009 22:11:15 -0500 (EST) Len Brown <[email protected]> wrote:
--
Len Brown, Intel Open Source Technology CenterQuoted 60 lines · Andrew Morton
Quoted 1 line · On Tue, 20 Jan 2009 12:18:24 +0100 Holger Macht <[email protected]> wrote:
The patch applied OK to 2.6.28 but not to any earlier kernel. If we decide that it should be backported to 2.6.27 or earlier, a new patch might be needed for that.
Quoted 24 lines
Some devices trigger a
DEVICE_CHECKon every evalutation of_STA. This can also be seen in commit8b59560a3baf2e7c24e0fb92ea5d09eca92805db(ACPI: dock: avoid check_STAmethod). If an undock is processed, the dock driver sends a uevent and userspace might read theshow_dockedproperty in sysfs. This causes an evaluation of_STAof the particular device which causes the dock driver to immediately dock again.In any case, evaluation of
_STA(show_docked) does not necessarily mean that we are docked, so check with the internal device structure.http://bugzilla.kernel.org/show_bug.cgi?id=12360
Signed-off-by Holger Macht <[email protected]>---
drivers/acpi/dock.c +1
-0@@ -855,10 +855,14 @@ fdd_out:static ssize_t show_docked (struct device *dev,struct device_attribute *attr,char *buf) { +struct acpi_device *tmp;drivers/acpi/dock.c fdd_out: · line 867
Quoted 10 lines
drivers/acpi/dock.c +4
-1+struct dock_station *dock_station = *((struct dock_station **) dev->platform_data); -return snprintf (buf,PAGE_SIZE ,"%d\n" ,dock_present (dock_station)); +if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) +return snprintf (buf,PAGE_SIZE ,"1\n" ); +return snprintf (buf,PAGE_SIZE ,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);That seems a little overwrought. Won't plain old strcpy suffice?
drivers/acpi/dock.c renamed from drivers/acpi/dock.c~acpi-dock-dont-eval-_sta-on-every-show_docked-sysfs-read-simplification +2
-2@@ -861,8 +861,8 @@ static ssize_t show_docked(struct device dev->platform_data);if (ACPI_SUCCESS (acpi_bus_get_device (dock_station->handle, &tmp))) -return snprintf (buf,PAGE_SIZE ,"1\n" ); -return snprintf (buf,PAGE_SIZE ,"0\n" ); +return strcpy (buf,"1\n" ); +return strcpy (buf,"0\n" ); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
Quoted 5 lines
Quoted 2 lines
_
sure, strcpy is fine b/c the src and dest are known to not be in danger of overlow. applied to acpi misc branch.
argh, sorry, don't apply the strcpy() version - it's buggy. It returns the address of the string (and a compile warning) rather than the amount-of-data-available.