Skip to contentSkip to conversation

MMC: s3cmci: ensure host stopped on machine shutdown

PATCH Ben Dooks 2 participants 5 messages Jul 17, 2008 MMC, SD and SDIO

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

Ensure that the s3cmci host controller is turned off when the machine is shutdown, otherwise we end up leaving the card powered and processing insertion and removal events after the system prints "System halted."

drivers/mmc/host/s3cmci.c +16 -4
Index: linux-2.6.26-quilt3/drivers/mmc/host/s3cmci.c
===================================================================
@@ -1331,21 +1331,30 @@ static int __devinit s3cmci_probe(struct
 	return ret;
 }
 
+static void s3cmci_shutdown(struct platform_device *pdev)
+{
+	struct mmc_host	*mmc = platform_get_drvdata(pdev);
+	struct s3cmci_host *host = mmc_priv(mmc);
+
+	if (host->irq_cd >= 0)
+		free_irq(host->irq_cd, host);
+
+	mmc_remove_host(mmc);
+	clk_disable(host->clk);
+}
+
 static int __devexit s3cmci_remove(struct platform_device *pdev)
 {
 	struct mmc_host		*mmc  = platform_get_drvdata(pdev);
 	struct s3cmci_host	*host = mmc_priv(mmc);
 
-	mmc_remove_host(mmc);
+	s3cmci_shutdown(pdev);
 
-	clk_disable(host->clk);
 	clk_put(host->clk);
 
 	tasklet_disable(&host->pio_tasklet);
 	s3c2410_dma_free(S3CMCI_DMA, &s3cmci_dma_client);
 
-	if (host->irq_cd >= 0)
-		free_irq(host->irq_cd, host);
 	free_irq(host->irq, host);
 
 	iounmap(host->base);
@@ -1397,6 +1406,7 @@ static struct platform_driver s3cmci_241
 	.driver.owner	= THIS_MODULE,
 	.probe		= s3cmci_2410_probe,
 	.remove		= __devexit_p(s3cmci_remove),
+	.shutdown	= s3cmci_shutdown,
 	.suspend	= s3cmci_suspend,
 	.resume		= s3cmci_resume,
 };
@@ -1406,6 +1416,7 @@ static struct platform_driver s3cmci_241
 	.driver.owner	= THIS_MODULE,
 	.probe		= s3cmci_2412_probe,
 	.remove		= __devexit_p(s3cmci_remove),
+	.shutdown	= s3cmci_shutdown,
 	.suspend	= s3cmci_suspend,
 	.resume		= s3cmci_resume,
 };
@@ -1415,6 +1426,7 @@ static struct platform_driver s3cmci_244
 	.driver.owner	= THIS_MODULE,
 	.probe		= s3cmci_2440_probe,
 	.remove		= __devexit_p(s3cmci_remove),
+	.shutdown	= s3cmci_shutdown,
 	.suspend	= s3cmci_suspend,
 	.resume		= s3cmci_resume,
 };
Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
#1 lore raw
Quoted 17 lines · On Thu, 17 Jul 2008 15:32:54 +0100 Ben Dooks <[email protected]> wrote:

Ensure that the s3cmci host controller is turned off when the machine is shutdown, otherwise we end up leaving the card powered and processing insertion and removal events after the system prints "System halted."

Index: linux-2.6.26-quilt3/drivers/mmc/host/s3cmci.c
===================================================================

drivers/mmc/host/s3cmci.c +2 -0
@@ -1331,21 +1331,30 @@ static int __devinit s3cmci_probe(struct
 	return ret;
 }
 
+static void s3cmci_shutdown(struct platform_device *pdev)
+{

drivers/mmc/host/s3cmci.c static int __devinit s3cmci_probe(struct · line 1345

Quoted 10 lines
drivers/mmc/host/s3cmci.c +10 -0
+	struct mmc_host	*mmc = platform_get_drvdata(pdev);
+	struct s3cmci_host *host = mmc_priv(mmc);
+
+	if (host->irq_cd >= 0)
+		free_irq(host->irq_cd, host);
+
+	mmc_remove_host(mmc);
+	clk_disable(host->clk);
+}
+

The core can send requests your way until mmc_remove_host() returns so you can't remove the interrupt before then.

Rgds

Signature · 9 lines
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.
author
#2 lore raw
Quoted 18 lines · Pierre Ossman
Quoted 15 lines · On Thu, 17 Jul 2008 15:32:54 +0100 Ben Dooks <[email protected]> wrote:

Ensure that the s3cmci host controller is turned off when the machine is shutdown, otherwise we end up leaving the card powered and processing insertion and removal events after the system prints "System halted."

Index: linux-2.6.26-quilt3/drivers/mmc/host/s3cmci.c
===================================================================

drivers/mmc/host/s3cmci.c +0 -0
@@ -1331,21 +1331,30 @@ static int __devinit s3cmci_probe(struct
 	return ret;
 }
 
Quoted 15 lines

drivers/mmc/host/s3cmci.c static int __devinit s3cmci_probe(struct · line 1345

Quoted 12 lines
drivers/mmc/host/s3cmci.c +12 -0
+static void s3cmci_shutdown(struct platform_device *pdev)
+{
+	struct mmc_host	*mmc = platform_get_drvdata(pdev);
+	struct s3cmci_host *host = mmc_priv(mmc);
+
+	if (host->irq_cd >= 0)
+		free_irq(host->irq_cd, host);
+
+	mmc_remove_host(mmc);
+	clk_disable(host->clk);
+}
+

The core can send requests your way until mmc_remove_host() returns so you can't remove the interrupt before then.

I'm only removing the card-detect interrupt, the main host one is not being disabled here.

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
#3 lore raw
Quoted 8 lines · On Thu, 17 Jul 2008 16:50:37 +0100 Ben Dooks <[email protected]> wrote:
Quoted 3 lines · Pierre Ossman

The core can send requests your way until mmc_remove_host() returns so you can't remove the interrupt before then.

I'm only removing the card-detect interrupt, the main host one is not being disabled here.

Ah, I see. Then it should be just fine. I'll have it queued up.

Rgds

Signature · 9 lines
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.
author
#4 lore raw
Quoted 5 lines · Pierre Ossman
Quoted 2 lines · On Thu, 17 Jul 2008 16:50:37 +0100 Ben Dooks <[email protected]> wrote:
Quoted 1 line · Pierre Ossman
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

The core can send requests your way until mmc_remove_host() returns so you can't remove the interrupt before then.

I'm only removing the card-detect interrupt, the main host one is not being disabled here.

Ah, I see. Then it should be just fine. I'll have it queued up.

It does depend on the previous patch to fix the section mismatch reports.

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'