All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND][PATCH] ata: ahci: Add shutdown to freeze hardware resources of ahci
@ 2020-02-18  2:28 Prabhakar Kushwaha
  2020-02-18  4:41 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Prabhakar Kushwaha @ 2020-02-18  2:28 UTC (permalink / raw)
  To: stable, axboe; +Cc: gkulkarni, kamlakantp, prabhakar.pkin, Prabhakar Kushwaha

device_shutdown() called from reboot or power_shutdown expect
all devices to be shutdown. Same is true for even ahci pci driver.
As no ahci shutdown function is implemented, the ata subsystem
always remains alive with DMA & interrupt support. File system
related calls should not be honored after device_shutdown().

So defining ahci pci driver shutdown to freeze hardware (mask
interrupt, stop DMA engine and free DMA resources).

Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---

This problem has also been seen on older kernel. So sending to stable@vger.kernel.org 
Note: It is already applied to git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
with commit id: 10a663a1b151 ("ata: ahci: Add shutdown to freeze hardware resources of ahci")

 drivers/ata/ahci.c        |  7 +++++++
 drivers/ata/libata-core.c | 21 +++++++++++++++++++++
 include/linux/libata.h    |  1 +
 3 files changed, 29 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 4bfd1b14b390..11ea1aff40db 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -81,6 +81,7 @@ enum board_ids {
 
 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
 static void ahci_remove_one(struct pci_dev *dev);
+static void ahci_shutdown_one(struct pci_dev *dev);
 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 				 unsigned long deadline);
 static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
@@ -606,6 +607,7 @@ static struct pci_driver ahci_pci_driver = {
 	.id_table		= ahci_pci_tbl,
 	.probe			= ahci_init_one,
 	.remove			= ahci_remove_one,
+	.shutdown		= ahci_shutdown_one,
 	.driver = {
 		.pm		= &ahci_pci_pm_ops,
 	},
@@ -1877,6 +1879,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	return 0;
 }
 
+static void ahci_shutdown_one(struct pci_dev *pdev)
+{
+	ata_pci_shutdown_one(pdev);
+}
+
 static void ahci_remove_one(struct pci_dev *pdev)
 {
 	pm_runtime_get_noresume(&pdev->dev);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6f4ab5c5b52d..42c8728f6117 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6767,6 +6767,26 @@ void ata_pci_remove_one(struct pci_dev *pdev)
 	ata_host_detach(host);
 }
 
+void ata_pci_shutdown_one(struct pci_dev *pdev)
+{
+	struct ata_host *host = pci_get_drvdata(pdev);
+	int i;
+
+	for (i = 0; i < host->n_ports; i++) {
+		struct ata_port *ap = host->ports[i];
+
+		ap->pflags |= ATA_PFLAG_FROZEN;
+
+		/* Disable port interrupts */
+		if (ap->ops->freeze)
+			ap->ops->freeze(ap);
+
+		/* Stop the port DMA engines */
+		if (ap->ops->port_stop)
+			ap->ops->port_stop(ap);
+	}
+}
+
 /* move to PCI subsystem */
 int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
 {
@@ -7387,6 +7407,7 @@ EXPORT_SYMBOL_GPL(ata_timing_cycle2mode);
 
 #ifdef CONFIG_PCI
 EXPORT_SYMBOL_GPL(pci_test_config_bits);
+EXPORT_SYMBOL_GPL(ata_pci_shutdown_one);
 EXPORT_SYMBOL_GPL(ata_pci_remove_one);
 #ifdef CONFIG_PM
 EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 2dbde119721d..bff539918d82 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1221,6 +1221,7 @@ struct pci_bits {
 };
 
 extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
+extern void ata_pci_shutdown_one(struct pci_dev *pdev);
 extern void ata_pci_remove_one(struct pci_dev *pdev);
 
 #ifdef CONFIG_PM
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND][PATCH] ata: ahci: Add shutdown to freeze hardware resources of ahci
  2020-02-18  2:28 [RESEND][PATCH] ata: ahci: Add shutdown to freeze hardware resources of ahci Prabhakar Kushwaha
@ 2020-02-18  4:41 ` Greg KH
  2020-02-22  4:22   ` Prabhakar Kushwaha
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2020-02-18  4:41 UTC (permalink / raw)
  To: Prabhakar Kushwaha; +Cc: stable, axboe, gkulkarni, kamlakantp, prabhakar.pkin

On Mon, Feb 17, 2020 at 06:28:02PM -0800, Prabhakar Kushwaha wrote:
> device_shutdown() called from reboot or power_shutdown expect
> all devices to be shutdown. Same is true for even ahci pci driver.
> As no ahci shutdown function is implemented, the ata subsystem
> always remains alive with DMA & interrupt support. File system
> related calls should not be honored after device_shutdown().
> 
> So defining ahci pci driver shutdown to freeze hardware (mask
> interrupt, stop DMA engine and free DMA resources).
> 
> Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
> 
> This problem has also been seen on older kernel. So sending to stable@vger.kernel.org 
> Note: It is already applied to git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> with commit id: 10a663a1b151 ("ata: ahci: Add shutdown to freeze hardware resources of ahci")

So what kernel(s) do you wish to have this commit backported to?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND][PATCH] ata: ahci: Add shutdown to freeze hardware resources of ahci
  2020-02-18  4:41 ` Greg KH
@ 2020-02-22  4:22   ` Prabhakar Kushwaha
  2020-02-27 12:50     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Prabhakar Kushwaha @ 2020-02-22  4:22 UTC (permalink / raw)
  To: Greg KH
  Cc: Prabhakar Kushwaha, stable, Jens Axboe,
	Ganapatrao Prabhakerrao Kulkarni, Kamlakant Patel

On Tue, Feb 18, 2020 at 10:11 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, Feb 17, 2020 at 06:28:02PM -0800, Prabhakar Kushwaha wrote:
> > device_shutdown() called from reboot or power_shutdown expect
> > all devices to be shutdown. Same is true for even ahci pci driver.
> > As no ahci shutdown function is implemented, the ata subsystem
> > always remains alive with DMA & interrupt support. File system
> > related calls should not be honored after device_shutdown().
> >
> > So defining ahci pci driver shutdown to freeze hardware (mask
> > interrupt, stop DMA engine and free DMA resources).
> >
> > Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
> > Signed-off-by: Jens Axboe <axboe@kernel.dk>
> > ---
> >
> > This problem has also been seen on older kernel. So sending to stable@vger.kernel.org
> > Note: It is already applied to git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > with commit id: 10a663a1b151 ("ata: ahci: Add shutdown to freeze hardware resources of ahci")
>
> So what kernel(s) do you wish to have this commit backported to?
>

Sorry for the late reply.  This patch should be back-ported to
following kernels versions
4.9, 4.14, 4.19, 5.4 and 5.5

--pk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND][PATCH] ata: ahci: Add shutdown to freeze hardware resources of ahci
  2020-02-22  4:22   ` Prabhakar Kushwaha
@ 2020-02-27 12:50     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2020-02-27 12:50 UTC (permalink / raw)
  To: Prabhakar Kushwaha
  Cc: Prabhakar Kushwaha, stable, Jens Axboe,
	Ganapatrao Prabhakerrao Kulkarni, Kamlakant Patel

On Sat, Feb 22, 2020 at 09:52:27AM +0530, Prabhakar Kushwaha wrote:
> On Tue, Feb 18, 2020 at 10:11 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Feb 17, 2020 at 06:28:02PM -0800, Prabhakar Kushwaha wrote:
> > > device_shutdown() called from reboot or power_shutdown expect
> > > all devices to be shutdown. Same is true for even ahci pci driver.
> > > As no ahci shutdown function is implemented, the ata subsystem
> > > always remains alive with DMA & interrupt support. File system
> > > related calls should not be honored after device_shutdown().
> > >
> > > So defining ahci pci driver shutdown to freeze hardware (mask
> > > interrupt, stop DMA engine and free DMA resources).
> > >
> > > Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
> > > Signed-off-by: Jens Axboe <axboe@kernel.dk>
> > > ---
> > >
> > > This problem has also been seen on older kernel. So sending to stable@vger.kernel.org
> > > Note: It is already applied to git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > > with commit id: 10a663a1b151 ("ata: ahci: Add shutdown to freeze hardware resources of ahci")
> >
> > So what kernel(s) do you wish to have this commit backported to?
> >
> 
> Sorry for the late reply.  This patch should be back-ported to
> following kernels versions
> 4.9, 4.14, 4.19, 5.4 and 5.5

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-27 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18  2:28 [RESEND][PATCH] ata: ahci: Add shutdown to freeze hardware resources of ahci Prabhakar Kushwaha
2020-02-18  4:41 ` Greg KH
2020-02-22  4:22   ` Prabhakar Kushwaha
2020-02-27 12:50     ` Greg KH

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.