grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: ValdikSS via Grub-devel <grub-devel@gnu.org>
To: grub-devel@gnu.org
Cc: ValdikSS <iam@valdikss.org.ru>
Subject: [PATCH v3 1/2] disk: read up to 63 sectors in LBA mode
Date: Tue, 10 Oct 2023 21:28:44 +0300	[thread overview]
Message-ID: <20231010182906.18846-2-iam@valdikss.org.ru> (raw)
In-Reply-To: <20231010182906.18846-1-iam@valdikss.org.ru>

Current code impose limitations on the amount of sectors read
in a single call according to CHS layout of the disk, even in LBA
read mode.

There's no need to obey CHS layout restrictions for LBA reads
on LBA disks, it only slows down booting process.

See: https://lore.kernel.org/grub-devel/d42a11fa-2a59-b5e7-08b1-d2c60444bb99@valdikss.org.ru/

Signed-off-by: ValdikSS <iam@valdikss.org.ru>
---
 grub-core/disk/i386/pc/biosdisk.c | 5 ++++-
 include/grub/disk.h               | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c
index f9362d17c..1d6788950 100644
--- a/grub-core/disk/i386/pc/biosdisk.c
+++ b/grub-core/disk/i386/pc/biosdisk.c
@@ -471,7 +471,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
       struct grub_biosdisk_dap *dap;
 
       dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
-					  + (data->sectors
+					  + (GRUB_DISK_MAX_LBA_SECTORS
 					     << disk->log_sector_size));
       dap->length = sizeof (*dap);
       dap->reserved = 0;
@@ -561,6 +561,9 @@ get_safe_sectors (grub_disk_t disk, grub_disk_addr_t sector)
   struct grub_biosdisk_data *data = disk->data;
   grub_uint32_t sectors = data->sectors;
 
+  if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
+    sectors = GRUB_DISK_MAX_LBA_SECTORS;
+
   /* OFFSET = SECTOR % SECTORS */
   grub_divmod64 (sector, sectors, &offset);
 
diff --git a/include/grub/disk.h b/include/grub/disk.h
index a4b5d13f3..be032a72c 100644
--- a/include/grub/disk.h
+++ b/include/grub/disk.h
@@ -190,6 +190,9 @@ typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
 
 #define GRUB_DISK_MAX_MAX_AGGLOMERATE ((1 << (30 - GRUB_DISK_CACHE_BITS - GRUB_DISK_SECTOR_BITS)) - 1)
 
+/* Maximum number of sectors to read in LBA mode at once */
+#define GRUB_DISK_MAX_LBA_SECTORS 63
+
 /* Return value of grub_disk_native_sectors() in case disk size is unknown. */
 #define GRUB_DISK_SIZE_UNKNOWN	 0xffffffffffffffffULL
 
-- 
2.41.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

  reply	other threads:[~2023-10-10 18:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 18:28 [PATCH v3 0/2] disk: use maximum number of sectors for LBA ValdikSS via Grub-devel
2023-10-10 18:28 ` ValdikSS via Grub-devel [this message]
2023-10-10 18:28 ` [PATCH v3 2/2] disk: increase sector size up to 127 for LBA reads ValdikSS via Grub-devel
2024-01-29 18:16   ` Daniel Kiper
2024-01-30 19:34     ` ValdikSS via Grub-devel
2024-01-30 19:37       ` ValdikSS via Grub-devel
2024-02-08 16:21       ` Daniel Kiper
2024-02-09  2:01   ` Vladimir 'phcoder' Serbinenko
2024-02-09 17:58     ` ValdikSS via Grub-devel
2023-10-12 12:30 ` [PATCH v3 0/2] disk: use maximum number of sectors for LBA Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231010182906.18846-2-iam@valdikss.org.ru \
    --to=grub-devel@gnu.org \
    --cc=iam@valdikss.org.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).