]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
rockchip: block: blk-uclass: add bounce buffer flag to blk_desc
authorJohan Jonker <jbx6244@gmail.com>
Wed, 18 Oct 2023 14:01:10 +0000 (16:01 +0200)
committerKever Yang <kever.yang@rock-chips.com>
Tue, 24 Oct 2023 07:55:17 +0000 (15:55 +0800)
Currently bounce buffer support is enabled for all block devices
when available. Add a flag to blk_desc to enable only on demand.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/block/blk-uclass.c
drivers/scsi/scsi.c
include/blk.h

index 30ad5bbb002496476a17f262a2583fb141edee6d..77066da352a37b1dd831eedb4c0fe32a5ef6dc54 100644 (file)
@@ -441,7 +441,7 @@ long blk_read(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, void *buf)
                          start, blkcnt, desc->blksz, buf))
                return blkcnt;
 
-       if (IS_ENABLED(CONFIG_BOUNCE_BUFFER)) {
+       if (IS_ENABLED(CONFIG_BOUNCE_BUFFER) && desc->bb) {
                struct blk_bounce_buffer bbstate = { .dev = dev };
                int ret;
 
@@ -478,7 +478,7 @@ long blk_write(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
 
        blkcache_invalidate(desc->uclass_id, desc->devnum);
 
-       if (IS_ENABLED(CONFIG_BOUNCE_BUFFER)) {
+       if (IS_ENABLED(CONFIG_BOUNCE_BUFFER) && desc->bb) {
                struct blk_bounce_buffer bbstate = { .dev = dev };
                int ret;
 
index 7411660d465eb188b749a2d2b940bc77b5a995aa..779a34bd2f1ce8f022fea8f78fab078bf15bd4c8 100644 (file)
@@ -459,6 +459,9 @@ static void scsi_init_dev_desc_priv(struct blk_desc *dev_desc)
        dev_desc->product[0] = 0;
        dev_desc->revision[0] = 0;
        dev_desc->removable = false;
+#if IS_ENABLED(CONFIG_BOUNCE_BUFFER)
+       dev_desc->bb = true;
+#endif /* CONFIG_BOUNCE_BUFFER */
 }
 
 #if !defined(CONFIG_DM_SCSI)
@@ -606,6 +609,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
        bdesc->lun = lun;
        bdesc->removable = bd.removable;
        bdesc->type = bd.type;
+       bdesc->bb = bd.bb;
        memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor));
        memcpy(&bdesc->product, &bd.product, sizeof(bd.product));
        memcpy(&bdesc->revision, &bd.revision,  sizeof(bd.revision));
index 76bd5baf99594fd90aa67de4335d22540692fe28..7c7cf7f2b102a239976c04ef3bdc7d991bdc8231 100644 (file)
@@ -68,6 +68,7 @@ struct blk_desc {
        /* device can use 48bit addr (ATA/ATAPI v7) */
        bool    lba48;
        unsigned char   atapi;          /* Use ATAPI protocol */
+       unsigned char   bb;             /* Use bounce buffer */
        lbaint_t        lba;            /* number of blocks */
        unsigned long   blksz;          /* block size */
        int             log2blksz;      /* for convenience: log2(blksz) */