1 Mar 2008 01:26
Re: [RFC PATCH] libata: PIO via bounce buffer
Jeff Garzik <jeff <at> garzik.org>
2008-03-01 00:26:40 GMT
2008-03-01 00:26:40 GMT
Alan Cox wrote:
> First cut at the problem. Given the lack of certainty about worst case
> buffer size (1 page I suspect) this uses kmalloc. We could hang a buffer
> off the device (or I think in fact the port as we never do overlapped PIO)
> +static void ata_bounce_pio_xfer(struct ata_device *dev, struct page *page,
> + unsigned int offset, int count, int do_write)
> +{
> + struct ata_port *ap = dev->link->ap;
> + unsigned long flags;
> + unsigned char *zebedee;
> + unsigned char *buf;
> +
> + BUG_ON(offset + count > PAGE_SIZE);
> +
> + zebedee = kmalloc(count, GFP_ATOMIC);
> + if (likely(zebedee)) {
> + if (do_write) {
> + local_irq_save(flags);
> + buf = kmap_atomic(page, KM_IRQ0);
> + memcpy(zebedee, buf + offset, count);
> + kunmap_atomic(buf, KM_IRQ0);
> + local_irq_restore(flags);
> + }
> + /* do the actual data transfer */
> + ap->ops->data_xfer(dev, zebedee, count, do_write);
> + if (!do_write) {
> + /* Read so bounce data upwards */
> + local_irq_save(flags);
> + buf = kmap_atomic(page, KM_IRQ0);
(Continue reading)
RSS Feed