* [PATCH] ide/ide-cs: fix order of releasing resources
@ 2010-01-12 19:34 Wolfram Sang
2010-01-14 9:59 ` David Miller
2010-01-14 10:38 ` Dominik Brodowski
0 siblings, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2010-01-12 19:34 UTC (permalink / raw)
To: linux-ide
Cc: linux-pcmcia, Wolfram Sang, Dominik Brodowski,
Bartlomiej Zolnierkiewicz, David S. Miller
ide_detach() called first ide_release() and then release_region(). This
produced the following warnings:
Trying to free nonexistent resource <000000000000c10e-000000000000c10e>
Trying to free nonexistent resource <000000000000c100-000000000000c107>
This is true, because the callchain inside ide_release() is:
ide_release -> pcmcia_disable_device -> pcmcia_release_io
So, the whole io-block is already gone for release_region(). To fix
this, just swap the order of releasing (and remove the now obsolete
shadowing).
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
---
drivers/ide/ide-cs.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index dd63963..43ed330 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -122,18 +122,14 @@ static void ide_detach(struct pcmcia_device *link)
{
ide_info_t *info = link->priv;
ide_hwif_t *hwif = info->host->ports[0];
- unsigned long data_addr, ctl_addr;
dev_dbg(&link->dev, "ide_detach(0x%p)\n", link);
- data_addr = hwif->io_ports.data_addr;
- ctl_addr = hwif->io_ports.ctl_addr;
+ release_region(hwif->io_ports.ctl_addr, 1);
+ release_region(hwif->io_ports.data_addr, 8);
ide_release(link);
- release_region(ctl_addr, 1);
- release_region(data_addr, 8);
-
kfree(info);
} /* ide_detach */
--
1.6.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] ide/ide-cs: fix order of releasing resources
2010-01-12 19:34 [PATCH] ide/ide-cs: fix order of releasing resources Wolfram Sang
@ 2010-01-14 9:59 ` David Miller
2010-01-14 15:50 ` Bartlomiej Zolnierkiewicz
2010-01-14 10:38 ` Dominik Brodowski
1 sibling, 1 reply; 8+ messages in thread
From: David Miller @ 2010-01-14 9:59 UTC (permalink / raw)
To: w.sang; +Cc: linux-ide, linux-pcmcia, linux, bzolnier
From: Wolfram Sang <w.sang@pengutronix.de>
Date: Tue, 12 Jan 2010 20:34:54 +0100
> ide_detach() called first ide_release() and then release_region(). This
> produced the following warnings:
>
> Trying to free nonexistent resource <000000000000c10e-000000000000c10e>
> Trying to free nonexistent resource <000000000000c100-000000000000c107>
>
> This is true, because the callchain inside ide_release() is:
>
> ide_release -> pcmcia_disable_device -> pcmcia_release_io
>
> So, the whole io-block is already gone for release_region(). To fix
> this, just swap the order of releasing (and remove the now obsolete
> shadowing).
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Applied, thanks a lot!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ide/ide-cs: fix order of releasing resources
2010-01-12 19:34 [PATCH] ide/ide-cs: fix order of releasing resources Wolfram Sang
2010-01-14 9:59 ` David Miller
@ 2010-01-14 10:38 ` Dominik Brodowski
1 sibling, 0 replies; 8+ messages in thread
From: Dominik Brodowski @ 2010-01-14 10:38 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-ide, linux-pcmcia, Bartlomiej Zolnierkiewicz,
David S. Miller
On Tue, Jan 12, 2010 at 08:34:54PM +0100, Wolfram Sang wrote:
> ide_detach() called first ide_release() and then release_region(). This
> produced the following warnings:
>
> Trying to free nonexistent resource <000000000000c10e-000000000000c10e>
> Trying to free nonexistent resource <000000000000c100-000000000000c107>
>
> This is true, because the callchain inside ide_release() is:
>
> ide_release -> pcmcia_disable_device -> pcmcia_release_io
>
> So, the whole io-block is already gone for release_region(). To fix
> this, just swap the order of releasing (and remove the now obsolete
> shadowing).
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Dominik Brodowski <linux@dominikbrodowski.net>
Best,
Dominik
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ide/ide-cs: fix order of releasing resources
2010-01-14 9:59 ` David Miller
@ 2010-01-14 15:50 ` Bartlomiej Zolnierkiewicz
2010-01-15 9:31 ` David Miller
0 siblings, 1 reply; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2010-01-14 15:50 UTC (permalink / raw)
To: David Miller; +Cc: w.sang, linux-ide, linux-pcmcia, linux
On Thursday 14 January 2010 10:59:38 am David Miller wrote:
> From: Wolfram Sang <w.sang@pengutronix.de>
> Date: Tue, 12 Jan 2010 20:34:54 +0100
>
> > ide_detach() called first ide_release() and then release_region(). This
> > produced the following warnings:
> >
> > Trying to free nonexistent resource <000000000000c10e-000000000000c10e>
> > Trying to free nonexistent resource <000000000000c100-000000000000c107>
> >
> > This is true, because the callchain inside ide_release() is:
> >
> > ide_release -> pcmcia_disable_device -> pcmcia_release_io
> >
> > So, the whole io-block is already gone for release_region(). To fix
> > this, just swap the order of releasing (and remove the now obsolete
> > shadowing).
> >
> > Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
>
> Applied, thanks a lot!
Port resources should not be freed before ide_host_remove() call in
ide_release() returns as port and/or devices may still be in use.
FWIW the following modified version of the patch is now in my atang tree:
From: Wolfram Sang <w.sang@pengutronix.de>
Subject: [PATCH] ide/ide-cs: fix order of releasing resources
ide_detach() called first ide_release() and then release_region(). This
produced the following warnings:
Trying to free nonexistent resource <000000000000c10e-000000000000c10e>
Trying to free nonexistent resource <000000000000c100-000000000000c107>
This is true, because the callchain inside ide_release() is:
ide_release -> pcmcia_disable_device -> pcmcia_release_io
So, the whole io-block is already gone for release_region(). To fix
this, just swap the order of releasing (and remove the now obsolete
shadowing).
bzolnier:
- release resources in ide_release() to fix ordering of events
- remove stale FIXME note while at it
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-cs.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
Index: b/drivers/ide/ide-cs.c
===================================================================
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -131,19 +131,11 @@ static int ide_probe(struct pcmcia_devic
static void ide_detach(struct pcmcia_device *link)
{
ide_info_t *info = link->priv;
- ide_hwif_t *hwif = info->host->ports[0];
- unsigned long data_addr, ctl_addr;
DEBUG(0, "ide_detach(0x%p)\n", link);
- data_addr = hwif->io_ports.data_addr;
- ctl_addr = hwif->io_ports.ctl_addr;
-
ide_release(link);
- release_region(ctl_addr, 1);
- release_region(data_addr, 8);
-
kfree(info);
} /* ide_detach */
@@ -365,12 +357,19 @@ static void ide_release(struct pcmcia_de
DEBUG(0, "ide_release(0x%p)\n", link);
- if (info->ndev)
- /* FIXME: if this fails we need to queue the cleanup somehow
- -- need to investigate the required PCMCIA magic */
+ if (info->ndev) {
+ ide_hwif_t *hwif = host->ports[0];
+ unsigned long data_addr, ctl_addr;
+
+ data_addr = hwif->io_ports.data_addr;
+ ctl_addr = hwif->io_ports.ctl_addr;
+
ide_host_remove(host);
+ info->ndev = 0;
- info->ndev = 0;
+ release_region(ctl_addr, 1);
+ release_region(data_addr, 8);
+ }
pcmcia_disable_device(link);
} /* ide_release */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ide/ide-cs: fix order of releasing resources
2010-01-14 15:50 ` Bartlomiej Zolnierkiewicz
@ 2010-01-15 9:31 ` David Miller
2010-01-15 9:43 ` Wolfram Sang
2010-01-16 18:51 ` Wolfram Sang
0 siblings, 2 replies; 8+ messages in thread
From: David Miller @ 2010-01-15 9:31 UTC (permalink / raw)
To: bzolnier; +Cc: w.sang, linux-ide, linux-pcmcia, linux
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Date: Thu, 14 Jan 2010 16:50:17 +0100
> bzolnier:
> - release resources in ide_release() to fix ordering of events
> - remove stale FIXME note while at it
Ok this does look better, Wolfram can you test this?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ide/ide-cs: fix order of releasing resources
2010-01-15 9:31 ` David Miller
@ 2010-01-15 9:43 ` Wolfram Sang
2010-01-16 18:51 ` Wolfram Sang
1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2010-01-15 9:43 UTC (permalink / raw)
To: David Miller; +Cc: bzolnier, linux-ide, linux-pcmcia, linux
[-- Attachment #1: Type: text/plain, Size: 423 bytes --]
> > bzolnier:
> > - release resources in ide_release() to fix ordering of events
> > - remove stale FIXME note while at it
>
> Ok this does look better, Wolfram can you test this?
ACK, looks better. I will test it, might not happen before Sunday, though.
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ide/ide-cs: fix order of releasing resources
2010-01-15 9:31 ` David Miller
2010-01-15 9:43 ` Wolfram Sang
@ 2010-01-16 18:51 ` Wolfram Sang
2010-01-18 2:59 ` David Miller
1 sibling, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2010-01-16 18:51 UTC (permalink / raw)
To: David Miller; +Cc: bzolnier, linux-ide, linux-pcmcia, linux
[-- Attachment #1: Type: text/plain, Size: 367 bytes --]
> > bzolnier:
> > - release resources in ide_release() to fix ordering of events
> > - remove stale FIXME note while at it
>
> Ok this does look better, Wolfram can you test this?
Works as expected.
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ide/ide-cs: fix order of releasing resources
2010-01-16 18:51 ` Wolfram Sang
@ 2010-01-18 2:59 ` David Miller
0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2010-01-18 2:59 UTC (permalink / raw)
To: w.sang; +Cc: bzolnier, linux-ide, linux-pcmcia, linux
From: Wolfram Sang <w.sang@pengutronix.de>
Date: Sat, 16 Jan 2010 19:51:24 +0100
>> > bzolnier:
>> > - release resources in ide_release() to fix ordering of events
>> > - remove stale FIXME note while at it
>>
>> Ok this does look better, Wolfram can you test this?
>
> Works as expected.
Great, thanks for testing.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-01-18 2:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-12 19:34 [PATCH] ide/ide-cs: fix order of releasing resources Wolfram Sang
2010-01-14 9:59 ` David Miller
2010-01-14 15:50 ` Bartlomiej Zolnierkiewicz
2010-01-15 9:31 ` David Miller
2010-01-15 9:43 ` Wolfram Sang
2010-01-16 18:51 ` Wolfram Sang
2010-01-18 2:59 ` David Miller
2010-01-14 10:38 ` Dominik Brodowski
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.