swim3: support highmem
authorChristoph Hellwig <hch@lst.de>
Tue, 6 Apr 2021 06:18:39 +0000 (08:18 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 6 Apr 2021 15:30:09 +0000 (09:30 -0600)
swim3 only uses the virtual address of a bio to stash it into the data
transfer using virt_to_bus.  But the ppc32 virt_to_bus just uses the
physical address with an offset.  Replace virt_to_bus with a local hack
that performs the equivalent transformation and stop asking for block
layer bounce buffering.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210406061839.811588-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/swim3.c

index c2d922d125e281afc251443b418f664c366cf156..a515d0c1d2cb8e8e60fccf8efbc72449b5cc6648 100644 (file)
@@ -234,7 +234,6 @@ static unsigned short write_postamble[] = {
 };
 
 static void seek_track(struct floppy_state *fs, int n);
-static void init_dma(struct dbdma_cmd *cp, int cmd, void *buf, int count);
 static void act(struct floppy_state *fs);
 static void scan_timeout(struct timer_list *t);
 static void seek_timeout(struct timer_list *t);
@@ -404,12 +403,28 @@ static inline void seek_track(struct floppy_state *fs, int n)
        fs->settle_time = 0;
 }
 
+/*
+ * XXX: this is a horrible hack, but at least allows ppc32 to get
+ * out of defining virt_to_bus, and this driver out of using the
+ * deprecated block layer bounce buffering for highmem addresses
+ * for no good reason.
+ */
+static unsigned long swim3_phys_to_bus(phys_addr_t paddr)
+{
+       return paddr + PCI_DRAM_OFFSET;
+}
+
+static phys_addr_t swim3_bio_phys(struct bio *bio)
+{
+       return page_to_phys(bio_page(bio)) + bio_offset(bio);
+}
+
 static inline void init_dma(struct dbdma_cmd *cp, int cmd,
-                           void *buf, int count)
+                           phys_addr_t paddr, int count)
 {
        cp->req_count = cpu_to_le16(count);
        cp->command = cpu_to_le16(cmd);
-       cp->phy_addr = cpu_to_le32(virt_to_bus(buf));
+       cp->phy_addr = cpu_to_le32(swim3_phys_to_bus(paddr));
        cp->xfer_status = 0;
 }
 
@@ -441,16 +456,18 @@ static inline void setup_transfer(struct floppy_state *fs)
        out_8(&sw->sector, fs->req_sector);
        out_8(&sw->nsect, n);
        out_8(&sw->gap3, 0);
-       out_le32(&dr->cmdptr, virt_to_bus(cp));
+       out_le32(&dr->cmdptr, swim3_phys_to_bus(virt_to_phys(cp)));
        if (rq_data_dir(req) == WRITE) {
                /* Set up 3 dma commands: write preamble, data, postamble */
-               init_dma(cp, OUTPUT_MORE, write_preamble, sizeof(write_preamble));
+               init_dma(cp, OUTPUT_MORE, virt_to_phys(write_preamble),
+                        sizeof(write_preamble));
                ++cp;
-               init_dma(cp, OUTPUT_MORE, bio_data(req->bio), 512);
+               init_dma(cp, OUTPUT_MORE, swim3_bio_phys(req->bio), 512);
                ++cp;
-               init_dma(cp, OUTPUT_LAST, write_postamble, sizeof(write_postamble));
+               init_dma(cp, OUTPUT_LAST, virt_to_phys(write_postamble),
+                       sizeof(write_postamble));
        } else {
-               init_dma(cp, INPUT_LAST, bio_data(req->bio), n * 512);
+               init_dma(cp, INPUT_LAST, swim3_bio_phys(req->bio), n * 512);
        }
        ++cp;
        out_le16(&cp->command, DBDMA_STOP);
@@ -1201,7 +1218,6 @@ static int swim3_attach(struct macio_dev *mdev,
                disk->queue = NULL;
                goto out_put_disk;
        }
-       blk_queue_bounce_limit(disk->queue, BLK_BOUNCE_HIGH);
        disk->queue->queuedata = fs;
 
        rc = swim3_add_device(mdev, floppy_count);