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

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