nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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