* [PATCH RESEND] libata: implement drain buffers
@ 2008-02-01 19:53 James Bottomley
2008-02-01 20:02 ` Jeff Garzik
0 siblings, 1 reply; 3+ messages in thread
From: James Bottomley @ 2008-02-01 19:53 UTC (permalink / raw)
To: Jeff Garzik, Tejun Heo; +Cc: linux-ide
From: James Bottomley <James.Bottomley@HansenPartnership.com>
Date: Thu, 10 Jan 2008 11:42:50 -0600
Subject: libata: implement drain buffers
This just updates the libata slave configure routine to take advantage
of the block layer drain buffers.
I suspect I should also be checking for AHCI as well as ATA_DEV_ATAPI,
but I couldn't see how to do that easily.
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
drivers/ata/libata-scsi.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8ffff44..a28351c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -826,8 +826,8 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
sdev->max_device_blocked = 1;
}
-static void ata_scsi_dev_config(struct scsi_device *sdev,
- struct ata_device *dev)
+static int ata_scsi_dev_config(struct scsi_device *sdev,
+ struct ata_device *dev)
{
/* configure max sectors */
blk_queue_max_sectors(sdev->request_queue, dev->max_sectors);
@@ -839,6 +839,16 @@ static void ata_scsi_dev_config(struct scsi_device *sdev,
sdev->manage_start_stop = 1;
}
+ if (dev->class == ATA_DEV_ATAPI) {
+ struct request_queue *q = sdev->request_queue;
+ void *buf = kmalloc(ATAPI_MAX_DRAIN, GFP_KERNEL);
+ if (!buf) {
+ sdev_printk(KERN_ERR, sdev, "drain buffer allocation failed\n");
+ return -ENOMEM;
+ }
+ blk_queue_dma_drain(q, buf, ATAPI_MAX_DRAIN);
+ }
+
if (dev->flags & ATA_DFLAG_AN)
set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events);
@@ -849,6 +859,8 @@ static void ata_scsi_dev_config(struct scsi_device *sdev,
depth = min(ATA_MAX_QUEUE - 1, depth);
scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth);
}
+
+ return 0;
}
/**
@@ -867,13 +879,14 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
{
struct ata_port *ap = ata_shost_to_port(sdev->host);
struct ata_device *dev = __ata_scsi_find_dev(ap, sdev);
+ int rc = 0;
ata_scsi_sdev_config(sdev);
if (dev)
- ata_scsi_dev_config(sdev, dev);
+ rc = ata_scsi_dev_config(sdev, dev);
- return 0;
+ return rc;
}
/**
@@ -895,6 +908,7 @@ void ata_scsi_slave_destroy(struct scsi_device *sdev)
struct ata_port *ap = ata_shost_to_port(sdev->host);
unsigned long flags;
struct ata_device *dev;
+ struct request_queue *q = sdev->request_queue;
if (!ap->ops->error_handler)
return;
@@ -908,6 +922,10 @@ void ata_scsi_slave_destroy(struct scsi_device *sdev)
ata_port_schedule_eh(ap);
}
spin_unlock_irqrestore(ap->lock, flags);
+
+ kfree(q->dma_drain_buffer);
+ q->dma_drain_buffer = NULL;
+ q->dma_drain_size = 0;
}
/**
--
1.5.3.8
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] libata: implement drain buffers
2008-02-01 19:53 [PATCH RESEND] libata: implement drain buffers James Bottomley
@ 2008-02-01 20:02 ` Jeff Garzik
2008-02-01 21:08 ` James Bottomley
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2008-02-01 20:02 UTC (permalink / raw)
To: James Bottomley; +Cc: Tejun Heo, linux-ide
James Bottomley wrote:
> From: James Bottomley <James.Bottomley@HansenPartnership.com>
> Date: Thu, 10 Jan 2008 11:42:50 -0600
> Subject: libata: implement drain buffers
>
> This just updates the libata slave configure routine to take advantage
> of the block layer drain buffers.
>
> I suspect I should also be checking for AHCI as well as ATA_DEV_ATAPI,
> but I couldn't see how to do that easily.
>
> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> ---
> drivers/ata/libata-scsi.c | 26 ++++++++++++++++++++++----
> 1 files changed, 22 insertions(+), 4 deletions(-)
Tejun's persistent comment/objection with these works is that you need
two sizes, for ATAPI, the raw size and the buffered size.
Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] libata: implement drain buffers
2008-02-01 20:02 ` Jeff Garzik
@ 2008-02-01 21:08 ` James Bottomley
0 siblings, 0 replies; 3+ messages in thread
From: James Bottomley @ 2008-02-01 21:08 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Tejun Heo, linux-ide
On Fri, 2008-02-01 at 15:02 -0500, Jeff Garzik wrote:
> James Bottomley wrote:
> > From: James Bottomley <James.Bottomley@HansenPartnership.com>
> > Date: Thu, 10 Jan 2008 11:42:50 -0600
> > Subject: libata: implement drain buffers
> >
> > This just updates the libata slave configure routine to take advantage
> > of the block layer drain buffers.
> >
> > I suspect I should also be checking for AHCI as well as ATA_DEV_ATAPI,
> > but I couldn't see how to do that easily.
> >
> > Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> > ---
> > drivers/ata/libata-scsi.c | 26 ++++++++++++++++++++++----
> > 1 files changed, 22 insertions(+), 4 deletions(-)
>
> Tejun's persistent comment/objection with these works is that you need
> two sizes, for ATAPI, the raw size and the buffered size.
This should be independent of the drain patch. All this one does is
eliminate the unnecessary extra segment for alignment. DMA drain for
ATAPI is something separate (and it's also something that isn't upstream
in any form).
James
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-01 21:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-01 19:53 [PATCH RESEND] libata: implement drain buffers James Bottomley
2008-02-01 20:02 ` Jeff Garzik
2008-02-01 21:08 ` James Bottomley
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 NNTP newsgroup(s).