nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0053-grub-core-disk-ahci.c-Add-safety-cleanups.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Vladimir Serbinenko <phcoder@gmail.com>
4fe85b
Date: Wed, 29 Jan 2014 23:46:17 +0100
4fe85b
Subject: [PATCH] * grub-core/disk/ahci.c: Add safety cleanups.
4fe85b
4fe85b
---
4fe85b
 grub-core/disk/ahci.c | 10 ++++++++++
4fe85b
 ChangeLog             |  4 ++++
4fe85b
 2 files changed, 14 insertions(+)
4fe85b
4fe85b
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
4fe85b
index d63fd09fdc6..643e691ef80 100644
4fe85b
--- a/grub-core/disk/ahci.c
4fe85b
+++ b/grub-core/disk/ahci.c
4fe85b
@@ -454,6 +454,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
4fe85b
 	adevs[i]->hba->ports[adevs[i]->port].fis_base = grub_dma_get_phys (adevs[i]->rfis);
4fe85b
 	adevs[i]->hba->ports[adevs[i]->port].command_list_base
4fe85b
 	  = grub_dma_get_phys (adevs[i]->command_list_chunk);
4fe85b
+	adevs[i]->hba->ports[adevs[i]->port].command_issue = 0;
4fe85b
 	adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_FRE;
4fe85b
       }
4fe85b
 
4fe85b
@@ -600,6 +601,9 @@ grub_ahci_pciinit (grub_pci_device_t dev,
4fe85b
 	failed_adevs[i] = adevs[i];
4fe85b
 	adevs[i] = 0;
4fe85b
       }
4fe85b
+
4fe85b
+  grub_dprintf ("ahci", "cleaning up failed devs\n");
4fe85b
+
4fe85b
   for (i = 0; i < nports; i++)
4fe85b
     if (failed_adevs[i] && (fr_running & (1 << i)))
4fe85b
       failed_adevs[i]->hba->ports[failed_adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
4fe85b
@@ -855,6 +859,12 @@ grub_ahci_reset_port (struct grub_ahci_device *dev, int force)
4fe85b
     {
4fe85b
       struct grub_disk_ata_pass_through_parms parms2;
4fe85b
       dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
4fe85b
+      dev->hba->ports[dev->port].command_issue = 0;
4fe85b
+      dev->command_list[0].config = 0;
4fe85b
+      dev->command_table[0].prdt[0].unused = 0;
4fe85b
+      dev->command_table[0].prdt[0].size = 0;
4fe85b
+      dev->command_table[0].prdt[0].data_base = 0;
4fe85b
+
4fe85b
       endtime = grub_get_time_ms () + 1000;
4fe85b
       while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
4fe85b
 	if (grub_get_time_ms () > endtime)
4fe85b
diff --git a/ChangeLog b/ChangeLog
4fe85b
index 9bb18177793..15300b020c6 100644
4fe85b
--- a/ChangeLog
4fe85b
+++ b/ChangeLog
4fe85b
@@ -1,3 +1,7 @@
4fe85b
+2014-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
4fe85b
+
4fe85b
+	* grub-core/disk/ahci.c: Add safety cleanups.
4fe85b
+
4fe85b
 2014-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
4fe85b
 
4fe85b
 	* grub-core/disk/ahci.c: Allocate and clean space for all possible 32