mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mansoor, Illyas" <illyas.mansoor@intel.com>
To: "linux-pm@lists.linux-foundation.org" 
	<linux-pm@lists.linux-foundation.org>
Cc: "Hunter, Adrian" <adrian.hunter@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>
Subject: mmc: sdhci-pci: why no .shutdown() implemented
Date: Mon, 12 Mar 2012 08:15:37 +0000	[thread overview]
Message-ID: <810586B7581CC8469141DADEBC3719120AECF8@BGSMSX102.gar.corp.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2105 bytes --]

Hi All,

I'm not sure if this is the right mailing list to discuss this question, but
anyways I'll ask:

On our platform we implemented a BUG in pci_set_power_state callback when the
shutdown
Is in progress, and we caught sdci-pci doing pci_set_power_state(D0) when
shutdown was
Already in progress.

My question, why doesn't sdhci-pci.c implement a .shutdown() callback and close
the device
After doing sys_sync()?

Is there some reason behind it not doing a graceful shutdown.

I think it could cause corruption, since there is no guarantee when the system
will power-off/reboot/halt

I just implemented a patch to fix this, if it's a good fix I'll submit.

diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index f5fe05c..e0818c9 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -23,6 +23,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/async.h>
+#include <linux/syscalls.h>

 #include <asm/scatterlist.h>
 #include <asm/io.h>
@@ -1342,6 +1343,34 @@ err:
        return ret;
 }

+static void sdhci_pci_shutdown(struct pci_dev *pdev)
+{
+       int i;
+       struct sdhci_pci_chip *chip;
+
+       printk(KERN_INFO "%s: Syncing filesystems ... ", __func__);
+       sys_sync();
+       printk("done.\n");
+
+       pm_runtime_get_sync(&pdev->dev);
+
+       chip = pci_get_drvdata(pdev);
+
+       if (chip) {
+               for (i = 0;i < chip->num_slots; i++)
+                       sdhci_pci_remove_slot(chip->slots[i]);
+
+               pci_set_drvdata(pdev, NULL);
+               kfree(chip);
+       }
+
+       pci_disable_device(pdev);
+
+       pm_runtime_put_noidle(&pdev->dev);
+       pm_runtime_forbid(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+}
+
 static void __devexit sdhci_pci_remove(struct pci_dev *pdev)
 {
        int i;
@@ -1473,6 +1502,7 @@ static struct pci_driver sdhci_driver = {
        .id_table =     pci_ids,
        .probe =        sdhci_pci_probe,
        .remove =       __devexit_p(sdhci_pci_remove),
+       .shutdown =     sdhci_pci_shutdown,


-Illyas

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 7212 bytes --]

             reply	other threads:[~2012-03-12  8:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12  8:15 Mansoor, Illyas [this message]
2012-03-12 13:25 ` Adrian Hunter
2012-03-12 14:30   ` Mansoor, Illyas
2012-03-13  5:51     ` Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=810586B7581CC8469141DADEBC3719120AECF8@BGSMSX102.gar.corp.intel.com \
    --to=illyas.mansoor@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®