sata_mv: use hpriv->base instead of the host->iomap
PATCH 1/2 sata_mv: use hpriv->base instead of the host->iomap
this fixes crash bug as the iomap table is not valid for integrated controllers.
--- drivers/ata/sata_mv.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/ata/sata_mv.c +1 -1
@@ -870,7 +870,7 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio,struct mv_host_priv *hpriv = ap->host->private_data;int hard_port =mv_hardport_from_port (ap->port_no);void __iomem *hc_mmio =mv_hc_base_from_port ( - ap->host->iomap[MV_PRIMARY_BAR ], hard_port); +mv_host_base (ap->host), hard_port);u32 hc_irq_cause, ipending;/* clear EDMA event indicators, if any */
Signature · 1 line
1.5.2.5
PATCH 2/2 sata_mv: remove iounmap in mv_platform_remove
this will fix crash bug when doing rmmod to the driver, this is because the port_stop function get called later and it could access the device's registers.
--- drivers/ata/sata_mv.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/ata/sata_mv.c +0 -3
@@ -2983,11 +2983,8 @@ static int __devexit mv_platform_remove(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct ata_host *host =dev_get_drvdata (dev); -struct mv_host_priv *hpriv = host->private_data; -void __iomem *base = hpriv->base;ata_host_detach (host); -iounmap (base);return 0 ; }
Signature · 1 line
1.5.2.5
Re: [PATCH 2/2] sata_mv: remove iounmap in mv_platform_remove
Quoted 13 lines · Saeed Bishara
this will fix crash bug when doing rmmod to the driver, this is because the
port_stopfunction get called later and it could access the device's registers.Signed-off-by Saeed Bishara <[email protected]>--- drivers/ata/sata_mv.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)drivers/ata/sata_mv.c +0
-0
drivers/ata/sata_mv.c static int __devexit mv_platform_remove(struct platform_device *pdev) · line 2989
Quoted 10 lines
drivers/ata/sata_mv.c +0
-3@@ -2983,11 +2983,8 @@ static int __devexit mv_platform_remove(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct ata_host *host =dev_get_drvdata (dev); -struct mv_host_priv *hpriv = host->private_data; -void __iomem *base = hpriv->base;ata_host_detach (host); -iounmap (base);return 0 ; }
..
Where does the iounmap() now get done instead of that place?
Signature · 3 lines
Mark Lord Real-Time Remedies Inc. [email protected]
Re: [PATCH 2/2] sata_mv: remove iounmap in mv_platform_remove
Quoted 6 lines
Quoted 3 lines
this will fix crash bug when doing rmmod to the driver, this is because the
port_stopfunction get called later and it could access the device's registers.Where does the
iounmap()now get done instead of that place?
nowhere, the /proc/iomem still shows that sata_mv uses io mempry after the rrmod, but when I re-load the driver, I can see it reuses the same io address range. so it doesn't waste io mem resources.
saeed
Re: [PATCH 2/2] sata_mv: remove iounmap in mv_platform_remove
Quoted 9 lines · saeed bishara
Quoted 6 lines
Quoted 3 lines
this will fix crash bug when doing rmmod to the driver, this is because the
port_stopfunction get called later and it could access the device's registers.Where does the
iounmap()now get done instead of that place?nowhere, the
/proc/iomemstill shows thatsata_mvuses io mempry after the rrmod, but when I re-load the driver, I can see it reuses the same io address range. so it doesn't waste io mem resources.
..
Mmm.. sounds like a bug to me. Possibly two bugs:
1. the ioremap() should fail if the range is already mapped, and
2. we should free the resources on module unload.
I suppose this would be mostly automatic if the code simply were to use devm_ioremap() instead of ioremap().
Cheers
Re: [PATCH 2/2] sata_mv: remove iounmap in mv_platform_remove
Quoted 8 lines
Mmm.. sounds like a bug to me. Possibly two bugs:
1. the
ioremap()should fail if the range is already mapped, and
2. we should free the resources on module unload.I suppose this would be mostly automatic if the code simply were to use
devm_ioremap()instead ofioremap().
my understanding for the /proc/iomem was totaly wrong..
the ioremap() actually allocated different address each time, I don't know if should fail if the range is already mapped, but maybe the name (remap) hints that it is shouldn't.
anyway, I replaced ioremap with devm_ioremap and it looks fine. I'll send the new patch in different email.
saeed
Re: [PATCH 2/2] sata_mv: remove iounmap in mv_platform_remove
Quoted 9 lines · saeed bishara
Quoted 7 lines
Mmm.. sounds like a bug to me. Possibly two bugs:
1. the
ioremap()should fail if the range is already mapped, and
2. we should free the resources on module unload.I suppose this would be mostly automatic if the code simply were to use
devm_ioremap()instead ofioremap().my understanding for the
/proc/iomemwas totaly wrong.. theioremap()actually allocated different address each time,
..
Good. That makes a lot more sense.
Quoted 4 lines
I don't know if should fail if the range is already mapped, but maybe the name (remap) hints that it is shouldn't. anyway, I replaced ioremap with
devm_ioremapand it looks fine. I'll send the new patch in different email.
..
I think that the code should first call devm_request_region()
to reserve the ioports -- this will then fail if the ports are in-use. After success there, it should then call devm_ioremap(),
which gives a virtual address back (the "remap" part) for use within the kernel.
Cheers
Re: [PATCH 2/2] sata_mv: remove iounmap in mv_platform_remove
In reply to Mark LordQuoted 11 lines · Mark Lord
drivers/ata/sata_mv.c static int __devexit mv_platform_remove(struct platform_device *pdev) · line 2989
Quoted 8 lines
drivers/ata/sata_mv.c +0
-3struct device *dev = &pdev->dev;struct ata_host *host =dev_get_drvdata (dev); -struct mv_host_priv *hpriv = host->private_data; -void __iomem *base = hpriv->base;ata_host_detach (host); -iounmap (base);return 0 ; }..
Where does the
iounmap()now get done instead of that place?
You commented on the 2nd patch but can you please review/ack the 1st one so this can go in. Thanks.
Signature · 2 lines
Martin Michlmayr http://www.cyrius.com/
Quoted 12 lines · Saeed Bishara
this fixes crash bug as the iomap table is not valid for integrated controllers.
Signed-off-by Saeed Bishara <[email protected]>--- drivers/ata/sata_mv.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/ata/sata_mv.c +0
-0
drivers/ata/sata_mv.c static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, · line 876
Quoted 8 lines
drivers/ata/sata_mv.c +1
-1@@ -870,7 +870,7 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio,struct mv_host_priv *hpriv = ap->host->private_data;int hard_port =mv_hardport_from_port (ap->port_no);void __iomem *hc_mmio =mv_hc_base_from_port ( - ap->host->iomap[MV_PRIMARY_BAR ], hard_port); +mv_host_base (ap->host), hard_port);u32 hc_irq_cause, ipending;/* clear EDMA event indicators, if any */
..
This one looks fine.
Cheers
Jeff Garzik
AppliedQuoted 12 lines · Saeed Bishara
this fixes crash bug as the iomap table is not valid for integrated controllers.
Signed-off-by Saeed Bishara <[email protected]>--- drivers/ata/sata_mv.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/ata/sata_mv.c +0
-0
drivers/ata/sata_mv.c static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio, · line 874
Quoted 6 lines
drivers/ata/sata_mv.c +1
-1@@ -870,7 +870,7 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio,struct mv_host_priv *hpriv = ap->host->private_data;int hard_port =mv_hardport_from_port (ap->port_no);void __iomem *hc_mmio =mv_hc_base_from_port ( - ap->host->iomap[MV_PRIMARY_BAR ], hard_port); +mv_host_base (ap->host), hard_port);u32 hc_irq_cause, ipending;
applied