Hi,
I've finally spend the time to mend the patch for control of
the HD led blinking at runtime. This is a patch against
2.6.15
The sysfs entry is attached to the PCI device and to the
MACIO device if available. I think that was what Ben was
asking for:
lauren-ph:/sys# find . | grep blink
./module/ide_core/parameters/noblink
./devices/pci0001:10/0001:10:17.0/blinking_led
./devices/pci0001:10/0001:10:17.0/0.80000000:mac-io/0.0001f000:ata-4/blinking_led
To activate blinking:
echo 1 > ./devices/pci0001:10/0001:10:17.0/blinking_led
To deactivate it:
echo 0 > ./devices/pci0001:10/0001:10:17.0/blinking_led
There is also a boot time parameter idecore:noblink to
deactivate the blinking at this stage.
signed-off-by: Cedric Pradalier <redacted>
---
(id
#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
+MODULE_AUTHOR("Paul Mackerras & Ben. Herrenschmidt");
+MODULE_DESCRIPTION("Support for IDE interfaces on
PowerMacs"); +MODULE_LICENSE("GPL");
+
+static int blinking_led = 1;
+module_param_named(noblink,blinking_led, invbool, 0666);
+MODULE_PARM_DESC(noblink,"Enable/Disable blinking led
[Default: enabled]"); +
+
/* Set to 50ms minimum led-on time (also used to limit
frequency
* of requests sent to the PMU
*/
@@ -437,8 +451,7 @@ static spinlock_t pmu_blink_lock; static unsigned long pmu_blink_stoptime; static int pmu_blink_ledstate; static struct timer_list pmu_blink_timer;-static int pmu_ide_blink_enabled;-+static int pmu_ide_blink_enabled = 0; static void pmu_hd_blink_timeout(unsigned long data)
@@ -468,6 +481,8 @@ static void pmu_hd_kick_blink(void *data, int rw) { unsigned long flags;+ if (!blinking_led)+ return; pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME; wmb();
macio_dev * #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
dev_set_drvdata(&mdev->ofdev.dev, hwif);
+ printk(KERN_INFO "pmac: using macio interface");
rc = pmac_ide_setup_device(pmif, hwif);
if (rc != 0) {
/* The inteface is released to the common
IDE layer */ @@ -1584,6 +1627,7 @@ pmac_ide_pci_attach
(struct pci_dev *pdev
pci_set_drvdata(pdev, hwif);
+ printk(KERN_INFO "pmac: using PCI interface");
rc = pmac_ide_setup_device(pmif, hwif);
if (rc != 0) {
/* The inteface is released to the common
IDE layer */
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2006-01-22 02:49:53
On Sun, 2006-01-22 at 12:19 +1000, Cedric Pradalier wrote:
Hi,
I've finally spend the time to mend the patch for control of
the HD led blinking at runtime. This is a patch against
2.6.15
The sysfs entry is attached to the PCI device and to the
MACIO device if available. I think that was what Ben was
asking for:
Heh, nice :) Almost ! It would be better if it was attached to the sysfs
node of the ide interface, you can find it in the HWIF array after
probe, but I won't be too much of a pain about that for now :)
Ben.
According to Benjamin Herrenschmidt, on Sun, 22 Jan 2006
13:49:53 +1100,
On Sun, 2006-01-22 at 12:19 +1000, Cedric Pradalier wrote:
quoted
Hi,
I've finally spend the time to mend the patch for control of
the HD led blinking at runtime. This is a patch against
2.6.15
The sysfs entry is attached to the PCI device and to the
MACIO device if available. I think that was what Ben was
asking for:
Heh, nice :) Almost ! It would be better if it was attached to the sysfs
node of the ide interface, you can find it in the HWIF array after
probe, but I won't be too much of a pain about that for now :)
Yep, now I remember, that was what you where asking for.
Can you give me an idea of the sysfs path you're expecting?
Is it in
bus/ide/...,
bus/pci/drivers/ide-pmac,
bus/pci/drivers/ide-disk
devices/pci0001:10/0001:10:17.0/0.80000000:mac-io/0.0001f000:ata-4/ide0
I would guess on the latter.
For now I'm using the pmif->mdev->ofdev.dev as attachment
device, which brings me into 0.0001f000:ata-4
What in pmif can brings me to the ide0? pmif->node? Or one
of its siblings?
In ide_hwif_t, I'm using the pci_dev. Where in the pci_dev
can I find ide0? or is it somewhere else in ide_hwif_t?
For the HWIF array, I guess you're talking about ide_hwifs.
How do I identify the interface itself there?
Hmm, plenty of questions. I hope at least one is relevant
for this problem...
Thanks
--
Cedric
According to Benjamin Herrenschmidt, on Sun, 22 Jan 2006
13:49:53 +1100,
On Sun, 2006-01-22 at 12:19 +1000, Cedric Pradalier wrote:
quoted
Hi,
I've finally spend the time to mend the patch for control of
the HD led blinking at runtime. This is a patch against
2.6.15
The sysfs entry is attached to the PCI device and to the
MACIO device if available. I think that was what Ben was
asking for:
Heh, nice :) Almost ! It would be better if it was attached to the sysfs
node of the ide interface, you can find it in the HWIF array after
probe, but I won't be too much of a pain about that for now :)
Ben.
OK, I think now I got it.
pradalie@lauren-ph:~$ find /sys/ | grep blink
/sys/devices/pci0001:10/0001:10:17.0/0.80000000:mac-io/0.0001f000:ata-4/ide0/blinking_led
The key I could not understand was that hwif->gendev is
only initialised in the probe. So I had to move the
device creation after that.
Currently, it is blinking by default. Should it be that
way? I guess so, since it is activated by a kernel config
option. It is easy to change if required.
Anyway, here is the updated patch.
signed-off-by: Cedric Pradalier <redacted>
---
@@ -427,6 +432,15 @@ static void pmac_ide_kauai_selectproc(id#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+MODULE_AUTHOR("Paul Mackerras & Ben. Herrenschmidt");+MODULE_DESCRIPTION("Support for IDE interfaces on PowerMacs");+MODULE_LICENSE("GPL");++staticintblinking_led=1;+module_param_named(noblink,blinking_led,invbool,0666);+MODULE_PARM_DESC(noblink,"Enable/Disable blinking led [Default: enabled]");++/* Set to 50ms minimum led-on time (also used to limit frequency*ofrequestssenttothePMU*/
@@ -1401,6 +1439,12 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p/* We probe the hwif now */probe_hwif_init(hwif);+#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+/* We wait till here to have the gendev initialized in hwif */+device_create_file(&hwif->gendev,&dev_attr_blinking_led);+#endif++return0;}
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2006-01-23 13:47:16
The key I could not understand was that hwif->gendev is
only initialised in the probe. So I had to move the
device creation after that.
Currently, it is blinking by default. Should it be that
way? I guess so, since it is activated by a kernel config
option. It is easy to change if required.
Yes. In fact, by enabled default for ATA disks and by disabled for ATAPI
would make sense...
Also, we should think a bit about the file name... "blinking_led" isn't
terrific for something that will end up in a non-ppc specific location.
Or maybe on the contrary it's good ... what about "activity_led"
rather ?
quoted hunk
Anyway, here is the updated patch.
signed-off-by: Cedric Pradalier <redacted>
---
@@ -427,6 +432,15 @@ static void pmac_ide_kauai_selectproc(id#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+MODULE_AUTHOR("Paul Mackerras & Ben. Herrenschmidt");+MODULE_DESCRIPTION("Support for IDE interfaces on PowerMacs");+MODULE_LICENSE("GPL");++staticintblinking_led=1;+module_param_named(noblink,blinking_led,invbool,0666);+MODULE_PARM_DESC(noblink,"Enable/Disable blinking led [Default: enabled]");++/* Set to 50ms minimum led-on time (also used to limit frequency*ofrequestssenttothePMU*/
@@ -1401,6 +1439,12 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p/* We probe the hwif now */probe_hwif_init(hwif);+#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+/* We wait till here to have the gendev initialized in hwif */+device_create_file(&hwif->gendev,&dev_attr_blinking_led);+#endif++return0;}
According to Benjamin Herrenschmidt, on Tue, 24 Jan 2006
00:47:16 +1100,
quoted
The key I could not understand was that hwif->gendev is
only initialised in the probe. So I had to move the
device creation after that.
Currently, it is blinking by default. Should it be that
way? I guess so, since it is activated by a kernel config
option. It is easy to change if required.
Yes. In fact, by enabled default for ATA disks and by disabled for ATAPI
would make sense...
How do I tell the difference?. There is a 'kind' in pmif,
and also a atapi_dma flag in hwif. Which is more sensible?
Also, we should think a bit about the file name... "blinking_led" isn't
terrific for something that will end up in a non-ppc specific location.
Or maybe on the contrary it's good ... what about "activity_led"
rather ?
I'm open to any suggestion. I'll wait a bit to see if
someone else has a comment, then I'll change to
"activity_led".
--
Cedric
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2006-01-23 23:10:26
On Tue, 2006-01-24 at 07:31 +1000, Cedric Pradalier wrote:
According to Benjamin Herrenschmidt, on Tue, 24 Jan 2006
00:47:16 +1100,
quoted
quoted
The key I could not understand was that hwif->gendev is
only initialised in the probe. So I had to move the
device creation after that.
Currently, it is blinking by default. Should it be that
way? I guess so, since it is activated by a kernel config
option. It is easy to change if required.
Yes. In fact, by enabled default for ATA disks and by disabled for ATAPI
would make sense...
How do I tell the difference?. There is a 'kind' in pmif,
and also a atapi_dma flag in hwif. Which is more sensible?
You need to check drive->media ... Which is a bit annoying since it mans
it's per drive, not per-HWIF... you may want to move your sysfs entry
down one more level :) (Each HWIF has an array of 2 drives, though check
drive->present before expecting a useful struct device there)
quoted
Also, we should think a bit about the file name... "blinking_led" isn't
terrific for something that will end up in a non-ppc specific location.
Or maybe on the contrary it's good ... what about "activity_led"
rather ?
I'm open to any suggestion. I'll wait a bit to see if
someone else has a comment, then I'll change to
"activity_led".
--
Cedric
According to Benjamin Herrenschmidt, on Tue, 24 Jan 2006
10:10:26 +1100,
On Tue, 2006-01-24 at 07:31 +1000, Cedric Pradalier wrote:
quoted
quoted
Yes. In fact, by enabled default for ATA disks and by disabled for ATAPI
would make sense...
How do I tell the difference?. There is a 'kind' in pmif,
and also a atapi_dma flag in hwif. Which is more sensible?
You need to check drive->media ... Which is a bit annoying since it mans
it's per drive, not per-HWIF... you may want to move your sysfs entry
down one more level :) (Each HWIF has an array of 2 drives, though check
drive->present before expecting a useful struct device there)
Well in this case, I'll let this part waiting for now.
I don't think there will be enough real users of this minor
thing to justify putting any more efforts for now.
I think the practical solution is to disable the led by
default. The few user who will want it will be able to add
either ide_core.blink to their boot parameter or make a
small init.d script to put 1 into the sysfs entry.
That's the way I've implemented it, and I've changed the
name into activity_led.
pradalier@localhost:~$ find /sys/ -name activity_led
/sys/devices/pci0001:10/0001:10:17.0/0.80000000:mac-io/0.0001f000:ata-4/ide0/activity_led
This is the updated version of the patch. I, for one, will
consider it stable now.
signed-off-by: Cedric Pradalier <redacted>
---
@@ -427,6 +432,15 @@ static void pmac_ide_kauai_selectproc(id#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+MODULE_AUTHOR("Paul Mackerras & Ben. Herrenschmidt");+MODULE_DESCRIPTION("Support for IDE interfaces on PowerMacs");+MODULE_LICENSE("GPL");++staticintactivity_led=0;+module_param_named(blink,activity_led,bool,0666);+MODULE_PARM_DESC(blink,"Enable/Disable activity led [Default: disabled]");++/* Set to 50ms minimum led-on time (also used to limit frequency*ofrequestssenttothePMU*/
@@ -1401,6 +1439,12 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p/* We probe the hwif now */probe_hwif_init(hwif);+#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+/* We wait till here to have the gendev initialized in hwif */+device_create_file(&hwif->gendev,&dev_attr_activity_led);+#endif++return0;}
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2006-01-24 23:14:51
On Tue, 2006-01-24 at 22:25 +1000, Cedric Pradalier wrote:
According to Benjamin Herrenschmidt, on Tue, 24 Jan 2006
10:10:26 +1100,
quoted
On Tue, 2006-01-24 at 07:31 +1000, Cedric Pradalier wrote:
quoted
quoted
Yes. In fact, by enabled default for ATA disks and by disabled for ATAPI
would make sense...
How do I tell the difference?. There is a 'kind' in pmif,
and also a atapi_dma flag in hwif. Which is more sensible?
You need to check drive->media ... Which is a bit annoying since it mans
it's per drive, not per-HWIF... you may want to move your sysfs entry
down one more level :) (Each HWIF has an array of 2 drives, though check
drive->present before expecting a useful struct device there)
Well in this case, I'll let this part waiting for now.
I don't think there will be enough real users of this minor
thing to justify putting any more efforts for now.
I think the practical solution is to disable the led by
default. The few user who will want it will be able to add
either ide_core.blink to their boot parameter or make a
small init.d script to put 1 into the sysfs entry.
That's the way I've implemented it, and I've changed the
name into activity_led.
I'll have a look into making it work he way I want :) Then I'll submit
it.
Thanks,
Ben.
quoted hunk
pradalier@localhost:~$ find /sys/ -name activity_led
/sys/devices/pci0001:10/0001:10:17.0/0.80000000:mac-io/0.0001f000:ata-4/ide0/activity_led
This is the updated version of the patch. I, for one, will
consider it stable now.
signed-off-by: Cedric Pradalier <redacted>
---
@@ -427,6 +432,15 @@ static void pmac_ide_kauai_selectproc(id#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+MODULE_AUTHOR("Paul Mackerras & Ben. Herrenschmidt");+MODULE_DESCRIPTION("Support for IDE interfaces on PowerMacs");+MODULE_LICENSE("GPL");++staticintactivity_led=0;+module_param_named(blink,activity_led,bool,0666);+MODULE_PARM_DESC(blink,"Enable/Disable activity led [Default: disabled]");++/* Set to 50ms minimum led-on time (also used to limit frequency*ofrequestssenttothePMU*/
@@ -1401,6 +1439,12 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p/* We probe the hwif now */probe_hwif_init(hwif);+#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+/* We wait till here to have the gendev initialized in hwif */+device_create_file(&hwif->gendev,&dev_attr_activity_led);+#endif++return0;}
According to Andreas Schwab, on Wed, 25 Jan 2006 12:06:44
+0100,
Cedric Pradalier [off-list ref] writes:
quoted
@@ -427,6 +432,15 @@ static void pmac_ide_kauai_selectproc(id #ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK+MODULE_AUTHOR("Paul Mackerras & Ben. Herrenschmidt");+MODULE_DESCRIPTION("Support for IDE interfaces on PowerMacs");+MODULE_LICENSE("GPL");++static int activity_led = 0;
No need to zero-initialize a static variable.
On the other hand, the cost is minor for an increased
readability and a behavior which does not rely on any
assumption on the compiler (or even the C specification).
I tend to favor readability first in my coding.
Cheers
--
Cedric