From: FUJITA Tomonori <tomof@acm.org>
To: James.Bottomley@HansenPartnership.com
Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
Jens.Axboe@oracle.com, fujita.tomonori@lab.ntt.co.jp,
jeff@garzik.orgfujita.tomonori@lab.ntt.co.jp
Subject: Re: [PATCH] libata: eliminate the home grown dma padding in favour of that provided by the block layer
Date: Thu, 3 Jan 2008 16:58:49 +0900 [thread overview]
Message-ID: <20080103170148K.tomof@acm.org> (raw)
In-Reply-To: <1199138168.3110.12.camel@localhost.localdomain>
On Mon, 31 Dec 2007 15:56:08 -0600
James Bottomley <James.Bottomley@HansenPartnership.com> wrote:
> ATA requires that all DMA transfers begin and end on word boundaries.
> Because of this, a large amount of machinery grew up in ide to adjust
> scatterlists on this basis. However, as of 2.5, the block layer has a
> dma_alignment variable which ensures both the beginning and length of a
> DMA transfer are aligned on the dma_alignment boundary. Although the
> block layer does adjust the beginning of the transfer to ensure this
> happens, it doesn't actually adjust the length, it merely makes sure
> that space is allocated for transfers beyond the declared length. The
> upshot of this is that scatterlists may be padded to any size between
> the actual length and the length adjusted to the dma_alignment safely
> knowing that memory is allocated in this region.
Great!
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index 124033c..2f40d57 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -282,7 +282,7 @@ enum {
>
> /* size of buffer to pad xfers ending on unaligned boundaries */
> ATA_DMA_PAD_SZ = 4,
> - ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,
> + ATA_DMA_PAD_MASK = ATA_DMA_PAD_SZ - 1,
>
> /* ering size */
> ATA_ERING_SIZE = 32,
> @@ -446,12 +446,9 @@ struct ata_queued_cmd {
> unsigned long flags; /* ATA_QCFLAG_xxx */
> unsigned int tag;
> unsigned int n_elem;
> - unsigned int n_iter;
> - unsigned int orig_n_elem;
>
> int dma_dir;
>
> - unsigned int pad_len;
> unsigned int sect_size;
>
> unsigned int nbytes;
> @@ -461,7 +458,6 @@ struct ata_queued_cmd {
> unsigned int cursg_ofs;
>
> struct scatterlist sgent;
> - struct scatterlist pad_sgent;
> void *buf_virt;
>
> /* DO NOT iterate over __sg manually, use ata_for_each_sg() */
> @@ -606,9 +602,6 @@ struct ata_port {
> struct ata_prd *prd; /* our SG list */
> dma_addr_t prd_dma; /* and its DMA mapping */
>
> - void *pad; /* array of DMA pad buffers */
> - dma_addr_t pad_dma;
> -
> struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */
>
> u8 ctl; /* cache of ATA control register */
> @@ -1080,24 +1073,15 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
> static inline struct scatterlist *
> ata_qc_first_sg(struct ata_queued_cmd *qc)
> {
> - qc->n_iter = 0;
> if (qc->n_elem)
> return qc->__sg;
> - if (qc->pad_len)
> - return &qc->pad_sgent;
> return NULL;
> }
>
> static inline struct scatterlist *
> ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
> {
> - if (sg == &qc->pad_sgent)
> - return NULL;
> - if (++qc->n_iter < qc->n_elem)
> - return sg_next(sg);
> - if (qc->pad_len)
> - return &qc->pad_sgent;
> - return NULL;
> + return sg_next(sg);
> }
>
> #define ata_for_each_sg(sg, qc) \
How about removing ata_qc_first_sg and ata_qc_next_sg completely?
Now we can just replace ata_qc_next_sg with sg_next. qc->__sg seems to
be always initialized to NULL so we can remove ata_qc_first_sg too.
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 4f6404c..2774882 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1054,25 +1054,8 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
const char *name);
#endif
-/*
- * qc helpers
- */
-static inline struct scatterlist *
-ata_qc_first_sg(struct ata_queued_cmd *qc)
-{
- if (qc->n_elem)
- return qc->__sg;
- return NULL;
-}
-
-static inline struct scatterlist *
-ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
-{
- return sg_next(sg);
-}
-
#define ata_for_each_sg(sg, qc) \
- for (sg = ata_qc_first_sg(qc); sg; sg = ata_qc_next_sg(sg, qc))
+ for (sg = qc->__sg; sg; sg = sg_next(sg))
static inline unsigned int ata_tag_valid(unsigned int tag)
{
next prev parent reply other threads:[~2008-01-03 7:58 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-31 21:56 [PATCH] libata: eliminate the home grown dma padding in favour of that provided by the block layer James Bottomley
2007-12-31 22:56 ` Jeff Garzik
2008-01-03 7:58 ` FUJITA Tomonori [this message]
2008-01-03 15:12 ` James Bottomley
2008-01-09 2:10 ` Tejun Heo
2008-01-09 4:24 ` James Bottomley
2008-01-09 5:13 ` Tejun Heo
2008-01-09 15:13 ` James Bottomley
2008-01-18 23:14 ` [PATCH RESEND] " James Bottomley
2008-02-01 19:40 ` [PATCH RESEND number 2] " James Bottomley
2008-02-01 20:02 ` Jeff Garzik
2008-02-01 21:09 ` James Bottomley
2008-02-03 3:04 ` Tejun Heo
2008-02-03 4:32 ` James Bottomley
2008-02-03 7:37 ` Tejun Heo
2008-02-03 14:38 ` James Bottomley
2008-02-03 15:14 ` Tejun Heo
2008-02-03 16:12 ` James Bottomley
2008-02-03 16:38 ` Jeff Garzik
2008-02-03 17:12 ` James Bottomley
2008-02-04 1:21 ` Tejun Heo
2008-02-04 1:28 ` Tejun Heo
2008-02-04 9:25 ` Tejun Heo
2008-02-04 14:43 ` Tejun Heo
2008-02-04 16:23 ` James Bottomley
2008-02-05 0:06 ` Tejun Heo
2008-02-05 0:32 ` James Bottomley
2008-02-05 0:43 ` Tejun Heo
2008-02-05 0:53 ` James Bottomley
2008-02-05 1:07 ` Tejun Heo
2008-02-05 5:03 ` James Bottomley
2008-02-05 5:22 ` Tejun Heo
2008-02-04 15:43 ` James Bottomley
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=20080103170148K.tomof@acm.org \
--to=tomof@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Jens.Axboe@oracle.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jeff@garzik.orgfujita.tomonori \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.