From 2b5336a24a542311fa11f5cb39cbdf47a6bbd1ec Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 29 Jan 2012 19:00:30 +0100 Subject: [PATCH] * include/grub/ata.h (grub_ata): Add a new element maxbuffer. * grub-core/disk/ata.c (grub_ata_readwrite): Limit to ata->maxbuffer. * grub-core/disk/pata.c (grub_pata_open): Set ata->maxbuffer. * grub-core/disk/ahci.c (grub_ahci_open): Likewise. --- ChangeLog | 7 +++++++ grub-core/disk/ahci.c | 1 + grub-core/disk/ata.c | 7 +++++-- grub-core/disk/pata.c | 1 + include/grub/ata.h | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d270c87df..7a0af5e7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-01-29 Vladimir Serbinenko + + * include/grub/ata.h (grub_ata): Add a new element maxbuffer. + * grub-core/disk/ata.c (grub_ata_readwrite): Limit to ata->maxbuffer. + * grub-core/disk/pata.c (grub_pata_open): Set ata->maxbuffer. + * grub-core/disk/ahci.c (grub_ahci_open): Likewise. + 2012-01-29 Vladimir Serbinenko * include/grub/zfs/dnode.h (DN_MIN_INDBLKSHIFT): Removed. diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index a5a14d414..8c4fc2bfb 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -693,6 +693,7 @@ grub_ahci_open (int id, int devnum, struct grub_ata *ata) ata->data = dev; ata->dma = 1; + ata->maxbuffer = GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH; ata->present = &dev->present; return GRUB_ERR_NONE; diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c index 50559a815..6d2ec0c78 100644 --- a/grub-core/disk/ata.c +++ b/grub-core/disk/ata.c @@ -278,6 +278,7 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector, grub_ata_addressing_t addressing = ata->addr; grub_size_t batch; int cmd, cmd_write; + grub_size_t nsectors = 0; grub_dprintf("ata", "grub_ata_readwrite (size=%llu, rw=%d)\n", (unsigned long long) size, rw); @@ -314,9 +315,11 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector, cmd = GRUB_ATA_CMD_READ_SECTORS; cmd_write = GRUB_ATA_CMD_WRITE_SECTORS; } - } + } + + if (batch > (ata->maxbuffer >> ata->log_sector_size)) + batch = (ata->maxbuffer >> ata->log_sector_size); - grub_size_t nsectors = 0; while (nsectors < size) { struct grub_disk_ata_pass_through_parms parms; diff --git a/grub-core/disk/pata.c b/grub-core/disk/pata.c index ff76cc1fb..089059d10 100644 --- a/grub-core/disk/pata.c +++ b/grub-core/disk/pata.c @@ -484,6 +484,7 @@ grub_pata_open (int id, int devnum, struct grub_ata *ata) ata->data = devfnd; ata->dma = 0; + ata->maxbuffer = 256 * 512; ata->present = &devfnd->present; return GRUB_ERR_NONE; diff --git a/include/grub/ata.h b/include/grub/ata.h index 1a19f27aa..efba7b71d 100644 --- a/include/grub/ata.h +++ b/include/grub/ata.h @@ -182,6 +182,8 @@ struct grub_ata int dma; + grub_size_t maxbuffer; + int *present; void *data;