dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0054-grub-core-disk-ahci.c-Properly-handle-transactions-w.patch

0dc71c
From 5e8c619b17cdf70b30d37412738b149d80874c28 Mon Sep 17 00:00:00 2001
0dc71c
From: Vladimir Serbinenko <phcoder@gmail.com>
0dc71c
Date: Wed, 29 Jan 2014 23:49:51 +0100
0dc71c
Subject: [PATCH 054/143] 	* grub-core/disk/ahci.c: Properly handle
0dc71c
 transactions with no 	transferred data.
0dc71c
0dc71c
---
0dc71c
 ChangeLog             | 5 +++++
0dc71c
 grub-core/disk/ahci.c | 7 +++++--
0dc71c
 2 files changed, 10 insertions(+), 2 deletions(-)
0dc71c
0dc71c
diff --git a/ChangeLog b/ChangeLog
0dc71c
index 15300b0..bc1ab23 100644
0dc71c
--- a/ChangeLog
0dc71c
+++ b/ChangeLog
0dc71c
@@ -1,5 +1,10 @@
0dc71c
 2014-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
0dc71c
 
0dc71c
+	* grub-core/disk/ahci.c: Properly handle transactions with no
0dc71c
+	transferred data.
0dc71c
+
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
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
0dc71c
index 643e691..fdd40c6 100644
0dc71c
--- a/grub-core/disk/ahci.c
0dc71c
+++ b/grub-core/disk/ahci.c
0dc71c
@@ -932,7 +932,10 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
0dc71c
   if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH)
0dc71c
     return grub_error (GRUB_ERR_BUG, "too big data buffer");
0dc71c
 
0dc71c
-  bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
0dc71c
+  if (parms->size)
0dc71c
+    bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
0dc71c
+  else
0dc71c
+    bufc = grub_memalign_dma32 (1024, 512);
0dc71c
 
0dc71c
   grub_dprintf ("ahci", "AHCI tfd = %x, CL=%p\n",
0dc71c
 		dev->hba->ports[dev->port].task_file_data,
0dc71c
@@ -942,7 +945,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
0dc71c
     = (5 << GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT)
0dc71c
     //    | GRUB_AHCI_CONFIG_CLEAR_R_OK
0dc71c
     | (0 << GRUB_AHCI_CONFIG_PMP_SHIFT)
0dc71c
-    | (1 << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
0dc71c
+    | ((parms->size ? 1 : 0) << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
0dc71c
     | (parms->cmdsize ? GRUB_AHCI_CONFIG_ATAPI : 0)
0dc71c
     | (parms->write ? GRUB_AHCI_CONFIG_WRITE : GRUB_AHCI_CONFIG_READ)
0dc71c
     | (parms->taskfile.cmd == 8 ? (1 << 8) : 0);
0dc71c
-- 
0dc71c
1.9.3
0dc71c