From: David Miller <davem@davemloft.net>
To: jens.axboe@oracle.com
Cc: fujita.tomonori@lab.ntt.co.jp, linux-kernel@vger.kernel.org,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH] SPARC64: fix iommu sg chaining
Date: Wed, 17 Oct 2007 04:10:04 -0700 (PDT) [thread overview]
Message-ID: <20071017.041004.21594558.davem@davemloft.net> (raw)
In-Reply-To: <20071017110142.GU5043@kernel.dk>
From: Jens Axboe <jens.axboe@oracle.com>
Date: Wed, 17 Oct 2007 13:01:42 +0200
> Actually, just clearing AFTER sg_next() would be fine, since we know
> that is not a link entry. Duh...
Yes and I'm running a kernel successfully with this fix.
Jens, please also add the following on top of Fujita-san's most recent
sparc64 patch and we should be good to go.
>From 0f6e2c3085ec57df78b249a8722323692f33a1b2 Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@sunset.davemloft.net>
Date: Wed, 17 Oct 2007 04:08:48 -0700
Subject: [PATCH] [SPARC64]: Fix loop terminating conditions in fill_sg().
Signed-off-by: David S. Miller <davem@davemloft.net>
---
arch/sparc64/kernel/iommu.c | 12 +++++++-----
arch/sparc64/kernel/pci_sun4v.c | 15 ++++++++-------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c
index 5d4e96d..29af777 100644
--- a/arch/sparc64/kernel/iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -475,12 +475,11 @@ static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr,
#define SG_ENT_PHYS_ADDRESS(SG) \
(__pa(page_address((SG)->page)) + (SG)->offset)
-static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
- int nused, int nelems,
- unsigned long iopte_protection)
+static void fill_sg(iopte_t *iopte, struct scatterlist *sg,
+ int nused, int nelems,
+ unsigned long iopte_protection)
{
struct scatterlist *dma_sg = sg;
- struct scatterlist *sg_end = sg_last(sg, nelems);
int i;
for (i = 0; i < nused; i++) {
@@ -516,6 +515,7 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
break;
}
sg = sg_next(sg);
+ nelems--;
}
pteval = iopte_protection | (pteval & IOPTE_PAGE);
@@ -529,18 +529,20 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
pteval = (pteval & IOPTE_PAGE) + len;
sg = sg_next(sg);
+ nelems--;
/* Skip over any tail mappings we've fully mapped,
* adjusting pteval along the way. Stop when we
* detect a page crossing event.
*/
- while (sg != sg_end &&
+ while (nelems &&
(pteval << (64 - IO_PAGE_SHIFT)) != 0UL &&
(pteval == SG_ENT_PHYS_ADDRESS(sg)) &&
((pteval ^
(SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) {
pteval += sg->length;
sg = sg_next(sg);
+ nelems--;
}
if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL)
pteval = ~0UL;
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 119f8ef..fe46ace 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -368,12 +368,11 @@ static void dma_4v_unmap_single(struct device *dev, dma_addr_t bus_addr,
#define SG_ENT_PHYS_ADDRESS(SG) \
(__pa(page_address((SG)->page)) + (SG)->offset)
-static inline long fill_sg(long entry, struct device *dev,
- struct scatterlist *sg,
- int nused, int nelems, unsigned long prot)
+static long fill_sg(long entry, struct device *dev,
+ struct scatterlist *sg,
+ int nused, int nelems, unsigned long prot)
{
struct scatterlist *dma_sg = sg;
- struct scatterlist *sg_end = sg_last(sg, nelems);
unsigned long flags;
int i;
@@ -414,6 +413,7 @@ static inline long fill_sg(long entry, struct device *dev,
break;
}
sg = sg_next(sg);
+ nelems--;
}
pteval = (pteval & IOPTE_PAGE);
@@ -432,19 +432,20 @@ static inline long fill_sg(long entry, struct device *dev,
pteval = (pteval & IOPTE_PAGE) + len;
sg = sg_next(sg);
+ nelems--;
/* Skip over any tail mappings we've fully mapped,
* adjusting pteval along the way. Stop when we
* detect a page crossing event.
*/
- while ((pteval << (64 - IO_PAGE_SHIFT)) != 0UL &&
+ while (nelems &&
+ (pteval << (64 - IO_PAGE_SHIFT)) != 0UL &&
(pteval == SG_ENT_PHYS_ADDRESS(sg)) &&
((pteval ^
(SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) {
pteval += sg->length;
- if (sg == sg_end)
- break;
sg = sg_next(sg);
+ nelems--;
}
if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL)
pteval = ~0UL;
--
1.5.3.4
next prev parent reply other threads:[~2007-10-17 11:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-17 5:07 [PATCH] SPARC64: fix iommu sg chaining FUJITA Tomonori
2007-10-17 7:21 ` Jens Axboe
2007-10-17 8:33 ` David Miller
2007-10-17 8:42 ` David Miller
2007-10-17 8:45 ` Jens Axboe
2007-10-17 9:13 ` David Miller
2007-10-17 9:16 ` Jens Axboe
2007-10-17 9:24 ` FUJITA Tomonori
2007-10-17 9:27 ` Jens Axboe
2007-10-17 9:45 ` David Miller
2007-10-17 11:08 ` FUJITA Tomonori
2007-10-17 11:13 ` Jens Axboe
2007-10-17 11:16 ` Jens Axboe
2007-10-17 10:54 ` David Miller
2007-10-17 10:58 ` Jens Axboe
2007-10-17 11:01 ` Jens Axboe
2007-10-17 11:10 ` David Miller [this message]
2007-10-17 11:11 ` Jens Axboe
2007-10-17 11:18 ` David Miller
2007-10-17 11:27 ` Jens Axboe
2007-10-17 11:37 ` FUJITA Tomonori
2007-10-17 11:41 ` Jens Axboe
2007-10-17 11:57 ` FUJITA Tomonori
2007-10-17 12:05 ` FUJITA Tomonori
2007-10-17 14:36 ` Jens Axboe
2007-10-17 23:01 ` FUJITA Tomonori
2007-10-17 11:04 ` David Miller
2007-10-17 11:04 ` Jens Axboe
2007-10-17 11:04 ` FUJITA Tomonori
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=20071017.041004.21594558.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox