From: Jens Axboe <jens.axboe@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: Jens Axboe <jens.axboe@oracle.com>
Subject: [PATCH 7/10] i386 sg: add support for chaining scatterlists
Date: Wed, 9 May 2007 09:59:21 +0200 [thread overview]
Message-ID: <11786975641488-git-send-email-jens.axboe@oracle.com> (raw)
In-Reply-To: <11786975641643-git-send-email-jens.axboe@oracle.com>
The core of the patch - allow the last sg element in a scatterlist
table to point to the start of a new table. This adds a pointer
to the sglist structure, and defines sg_chain_ptr() which the
generic code can use to look it up.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
include/asm-i386/scatterlist.h | 4 ++++
include/linux/scatterlist.h | 37 ++++++++++++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/include/asm-i386/scatterlist.h b/include/asm-i386/scatterlist.h
index d7e45a8..794b68c 100644
--- a/include/asm-i386/scatterlist.h
+++ b/include/asm-i386/scatterlist.h
@@ -8,8 +8,11 @@ struct scatterlist {
unsigned int offset;
dma_addr_t dma_address;
unsigned int length;
+ struct scatterlist *next;
};
+#define ARCH_HAS_SG_CHAIN
+
/* These macros should be used after a pci_map_sg call has been done
* to get bus addresses of each of the SG entries and their lengths.
* You should only work with the number of sg entries pci_map_sg
@@ -17,6 +20,7 @@ struct scatterlist {
*/
#define sg_dma_address(sg) ((sg)->dma_address)
#define sg_dma_len(sg) ((sg)->length)
+#define sg_chain_ptr(sg) ((sg)->next)
#define ISA_DMA_THRESHOLD (0x00ffffff)
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index c5bffde..e3fc307 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -20,13 +20,44 @@ static inline void sg_init_one(struct scatterlist *sg, const void *buf,
sg_set_buf(sg, buf, buflen);
}
-#define sg_next(sg) ((sg) + 1)
-#define sg_last(sg, nents) (&(sg[nents - 1]))
-
/*
* Loop over each sg element, following the pointer to a new list if necessary
*/
#define for_each_sg(sglist, sg, nr, __i) \
for (__i = 0, sg = (sglist); __i < nr; __i++, sg = sg_next(sg))
+#ifdef ARCH_HAS_SG_CHAIN
+#define sg_next(sg) (sg_chain_ptr((sg)) ? : (sg) + 1)
+/*
+ * Chain previous sglist to this one
+ */
+static inline void sg_chain(struct scatterlist *prv, unsigned int nents,
+ struct scatterlist *sgl)
+{
+ sg_chain_ptr(&prv[nents - 1]) = sgl;
+}
+
+/*
+ * We could improve this by passing in the maximum size of an sglist, so
+ * we could jump directly to the last table. That would eliminate this
+ * (potentially) lengthy scan.
+ */
+static inline struct scatterlist *sg_last(struct scatterlist *sgl,
+ unsigned int nents)
+{
+ struct scatterlist *sg, *ret = NULL;
+ int i;
+
+ for_each_sg(sgl, sg, nents, i)
+ ret = sg;
+
+ return ret;
+}
+#else
+#define sg_next(sg) ((sg) + 1)
+#define sg_chain(prv, nents, sgl) BUG()
+#define sg_chain_ptr(sg) NULL
+#define sg_last(sg, nents) (&(sg[nents - 1]))
+#endif
+
#endif /* _LINUX_SCATTERLIST_H */
--
1.5.2.rc1
next prev parent reply other threads:[~2007-05-09 8:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-09 7:59 [PATCH 0/10] Chaining sg lists for big IO commands v2 Jens Axboe
2007-05-09 7:59 ` [PATCH 1/10] crypto: don't pollute the global namespace with sg_next() Jens Axboe
2007-05-09 7:59 ` [PATCH 2/10] Add sg helpers for iterating over a scatterlist table Jens Axboe
2007-05-09 7:59 ` [PATCH 3/10] libata: convert to using sg helpers Jens Axboe
2007-05-09 7:59 ` [PATCH 4/10] block: " Jens Axboe
2007-05-09 7:59 ` [PATCH 5/10] scsi: " Jens Axboe
2007-05-09 7:59 ` [PATCH 6/10] i386 dma_map_sg: " Jens Axboe
2007-05-09 7:59 ` Jens Axboe [this message]
2007-05-09 10:03 ` [PATCH 7/10] i386 sg: add support for chaining scatterlists Herbert Xu
2007-05-09 10:19 ` Andrew Morton
2007-05-09 10:21 ` Herbert Xu
2007-05-09 10:30 ` Jens Axboe
2007-05-09 10:28 ` Jens Axboe
2007-05-09 7:59 ` [PATCH 8/10] scsi: simplify scsi_free_sgtable() Jens Axboe
2007-05-09 7:59 ` [PATCH 9/10] SCSI: support for allocating large scatterlists Jens Axboe
2007-05-09 7:59 ` [PATCH 10/10] ll_rw_blk: temporarily enable max_segments tweaking Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2007-05-16 8:31 [PATCH 0/19] Chaining sg lists for big IO commands v6 Jens Axboe
2007-05-16 8:31 ` [PATCH 7/10] i386 sg: add support for chaining scatterlists Jens Axboe
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=11786975641488-git-send-email-jens.axboe@oracle.com \
--to=jens.axboe@oracle.com \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox