aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-27 02:00:58 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-29 05:13:13 -0400
commit260489fa8a9735c76073ace95f03ffaf10cca884 (patch)
tree5cc56f69ba16de24886bb8fbab34f2404554ce31
parent7a715f46012f3552294154978aed59cba9804928 (diff)
sparc32: Make mmu_{get,release}_*() take a struct device pointer.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sparc/include/asm/dma.h22
-rw-r--r--arch/sparc/kernel/ioport.c17
-rw-r--r--arch/sparc/mm/io-unit.c16
-rw-r--r--arch/sparc/mm/iommu.c45
4 files changed, 47 insertions, 53 deletions
diff --git a/arch/sparc/include/asm/dma.h b/arch/sparc/include/asm/dma.h
index 493563446790..5955177ec752 100644
--- a/arch/sparc/include/asm/dma.h
+++ b/arch/sparc/include/asm/dma.h
@@ -100,16 +100,20 @@ BTFIXUPDEF_CALL(void, mmu_unlockarea, char *, unsigned long)
100#define mmu_lockarea(vaddr,len) BTFIXUP_CALL(mmu_lockarea)(vaddr,len) 100#define mmu_lockarea(vaddr,len) BTFIXUP_CALL(mmu_lockarea)(vaddr,len)
101#define mmu_unlockarea(vaddr,len) BTFIXUP_CALL(mmu_unlockarea)(vaddr,len) 101#define mmu_unlockarea(vaddr,len) BTFIXUP_CALL(mmu_unlockarea)(vaddr,len)
102 102
103struct page;
104struct device;
105struct scatterlist;
106
103/* These are implementations for sbus_map_sg/sbus_unmap_sg... collapse later */ 107/* These are implementations for sbus_map_sg/sbus_unmap_sg... collapse later */
104BTFIXUPDEF_CALL(__u32, mmu_get_scsi_one, char *, unsigned long, struct sbus_bus *sbus) 108BTFIXUPDEF_CALL(__u32, mmu_get_scsi_one, struct device *, char *, unsigned long)
105BTFIXUPDEF_CALL(void, mmu_get_scsi_sgl, struct scatterlist *, int, struct sbus_bus *sbus) 109BTFIXUPDEF_CALL(void, mmu_get_scsi_sgl, struct device *, struct scatterlist *, int)
106BTFIXUPDEF_CALL(void, mmu_release_scsi_one, __u32, unsigned long, struct sbus_bus *sbus) 110BTFIXUPDEF_CALL(void, mmu_release_scsi_one, struct device *, __u32, unsigned long)
107BTFIXUPDEF_CALL(void, mmu_release_scsi_sgl, struct scatterlist *, int, struct sbus_bus *sbus) 111BTFIXUPDEF_CALL(void, mmu_release_scsi_sgl, struct device *, struct scatterlist *, int)
108 112
109#define mmu_get_scsi_one(vaddr,len,sbus) BTFIXUP_CALL(mmu_get_scsi_one)(vaddr,len,sbus) 113#define mmu_get_scsi_one(dev,vaddr,len) BTFIXUP_CALL(mmu_get_scsi_one)(dev,vaddr,len)
110#define mmu_get_scsi_sgl(sg,sz,sbus) BTFIXUP_CALL(mmu_get_scsi_sgl)(sg,sz,sbus) 114#define mmu_get_scsi_sgl(dev,sg,sz) BTFIXUP_CALL(mmu_get_scsi_sgl)(dev,sg,sz)
111#define mmu_release_scsi_one(vaddr,len,sbus) BTFIXUP_CALL(mmu_release_scsi_one)(vaddr,len,sbus) 115#define mmu_release_scsi_one(dev,vaddr,len) BTFIXUP_CALL(mmu_release_scsi_one)(dev,vaddr,len)
112#define mmu_release_scsi_sgl(sg,sz,sbus) BTFIXUP_CALL(mmu_release_scsi_sgl)(sg,sz,sbus) 116#define mmu_release_scsi_sgl(dev,sg,sz) BTFIXUP_CALL(mmu_release_scsi_sgl)(dev,sg,sz)
113 117
114/* 118/*
115 * mmu_map/unmap are provided by iommu/iounit; Invalid to call on IIep. 119 * mmu_map/unmap are provided by iommu/iounit; Invalid to call on IIep.
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index aa73b3b71e85..11dccf945153 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -394,8 +394,6 @@ void sbus_free_consistent(struct device *dev, long n, void *p, u32 ba)
394 */ 394 */
395dma_addr_t sbus_map_single(struct device *dev, void *va, size_t len, int direction) 395dma_addr_t sbus_map_single(struct device *dev, void *va, size_t len, int direction)
396{ 396{
397 struct sbus_dev *sdev = to_sbus_device(dev);
398
399 /* XXX why are some lengths signed, others unsigned? */ 397 /* XXX why are some lengths signed, others unsigned? */
400 if (len <= 0) { 398 if (len <= 0) {
401 return 0; 399 return 0;
@@ -404,20 +402,17 @@ dma_addr_t sbus_map_single(struct device *dev, void *va, size_t len, int directi
404 if (len > 256*1024) { /* __get_free_pages() limit */ 402 if (len > 256*1024) { /* __get_free_pages() limit */
405 return 0; 403 return 0;
406 } 404 }
407 return mmu_get_scsi_one(va, len, sdev->bus); 405 return mmu_get_scsi_one(dev, va, len);
408} 406}
409 407
410void sbus_unmap_single(struct device *dev, dma_addr_t ba, size_t n, int direction) 408void sbus_unmap_single(struct device *dev, dma_addr_t ba, size_t n, int direction)
411{ 409{
412 struct sbus_dev *sdev = to_sbus_device(dev); 410 mmu_release_scsi_one(dev, ba, n);
413 mmu_release_scsi_one(ba, n, sdev->bus);
414} 411}
415 412
416int sbus_map_sg(struct device *dev, struct scatterlist *sg, int n, int direction) 413int sbus_map_sg(struct device *dev, struct scatterlist *sg, int n, int direction)
417{ 414{
418 struct sbus_dev *sdev = to_sbus_device(dev); 415 mmu_get_scsi_sgl(dev, sg, n);
419
420 mmu_get_scsi_sgl(sg, n, sdev->bus);
421 416
422 /* 417 /*
423 * XXX sparc64 can return a partial length here. sun4c should do this 418 * XXX sparc64 can return a partial length here. sun4c should do this
@@ -428,9 +423,7 @@ int sbus_map_sg(struct device *dev, struct scatterlist *sg, int n, int direction
428 423
429void sbus_unmap_sg(struct device *dev, struct scatterlist *sg, int n, int direction) 424void sbus_unmap_sg(struct device *dev, struct scatterlist *sg, int n, int direction)
430{ 425{
431 struct sbus_dev *sdev = to_sbus_device(dev); 426 mmu_release_scsi_sgl(dev, sg, n);
432
433 mmu_release_scsi_sgl(sg, n, sdev->bus);
434} 427}
435 428
436/* 429/*
@@ -438,7 +431,6 @@ void sbus_unmap_sg(struct device *dev, struct scatterlist *sg, int n, int direct
438void sbus_dma_sync_single_for_cpu(struct device *dev, dma_addr_t ba, size_t size, int direction) 431void sbus_dma_sync_single_for_cpu(struct device *dev, dma_addr_t ba, size_t size, int direction)
439{ 432{
440#if 0 433#if 0
441 struct sbus_dev *sdev = to_sbus_device(dev);
442 unsigned long va; 434 unsigned long va;
443 struct resource *res; 435 struct resource *res;
444 436
@@ -459,7 +451,6 @@ void sbus_dma_sync_single_for_cpu(struct device *dev, dma_addr_t ba, size_t size
459void sbus_dma_sync_single_for_device(struct device *dev, dma_addr_t ba, size_t size, int direction) 451void sbus_dma_sync_single_for_device(struct device *dev, dma_addr_t ba, size_t size, int direction)
460{ 452{
461#if 0 453#if 0
462 struct sbus_dev *sdev = to_sbus_device(dev);
463 unsigned long va; 454 unsigned long va;
464 struct resource *res; 455 struct resource *res;
465 456
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index 1093514a5773..4239655a6aaf 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -125,10 +125,10 @@ nexti: scan = find_next_zero_bit(iounit->bmap, limit, scan);
125 return vaddr; 125 return vaddr;
126} 126}
127 127
128static __u32 iounit_get_scsi_one(char *vaddr, unsigned long len, struct sbus_bus *sbus) 128static __u32 iounit_get_scsi_one(struct device *dev, char *vaddr, unsigned long len)
129{ 129{
130 struct iounit_struct *iounit = dev->archdata.iommu;
130 unsigned long ret, flags; 131 unsigned long ret, flags;
131 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
132 132
133 spin_lock_irqsave(&iounit->lock, flags); 133 spin_lock_irqsave(&iounit->lock, flags);
134 ret = iounit_get_area(iounit, (unsigned long)vaddr, len); 134 ret = iounit_get_area(iounit, (unsigned long)vaddr, len);
@@ -136,10 +136,10 @@ static __u32 iounit_get_scsi_one(char *vaddr, unsigned long len, struct sbus_bus
136 return ret; 136 return ret;
137} 137}
138 138
139static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 139static void iounit_get_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
140{ 140{
141 struct iounit_struct *iounit = dev->archdata.iommu;
141 unsigned long flags; 142 unsigned long flags;
142 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
143 143
144 /* FIXME: Cache some resolved pages - often several sg entries are to the same page */ 144 /* FIXME: Cache some resolved pages - often several sg entries are to the same page */
145 spin_lock_irqsave(&iounit->lock, flags); 145 spin_lock_irqsave(&iounit->lock, flags);
@@ -152,10 +152,10 @@ static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus
152 spin_unlock_irqrestore(&iounit->lock, flags); 152 spin_unlock_irqrestore(&iounit->lock, flags);
153} 153}
154 154
155static void iounit_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_bus *sbus) 155static void iounit_release_scsi_one(struct device *dev, __u32 vaddr, unsigned long len)
156{ 156{
157 struct iounit_struct *iounit = dev->archdata.iommu;
157 unsigned long flags; 158 unsigned long flags;
158 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
159 159
160 spin_lock_irqsave(&iounit->lock, flags); 160 spin_lock_irqsave(&iounit->lock, flags);
161 len = ((vaddr & ~PAGE_MASK) + len + (PAGE_SIZE-1)) >> PAGE_SHIFT; 161 len = ((vaddr & ~PAGE_MASK) + len + (PAGE_SIZE-1)) >> PAGE_SHIFT;
@@ -166,11 +166,11 @@ static void iounit_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_
166 spin_unlock_irqrestore(&iounit->lock, flags); 166 spin_unlock_irqrestore(&iounit->lock, flags);
167} 167}
168 168
169static void iounit_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 169static void iounit_release_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
170{ 170{
171 struct iounit_struct *iounit = dev->archdata.iommu;
171 unsigned long flags; 172 unsigned long flags;
172 unsigned long vaddr, len; 173 unsigned long vaddr, len;
173 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
174 174
175 spin_lock_irqsave(&iounit->lock, flags); 175 spin_lock_irqsave(&iounit->lock, flags);
176 while (sz != 0) { 176 while (sz != 0) {
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index a86c9f552fa1..8e9ab930f097 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -169,9 +169,9 @@ static void iommu_flush_iotlb(iopte_t *iopte, unsigned int niopte)
169 } 169 }
170} 170}
171 171
172static u32 iommu_get_one(struct page *page, int npages, struct sbus_bus *sbus) 172static u32 iommu_get_one(struct device *dev, struct page *page, int npages)
173{ 173{
174 struct iommu_struct *iommu = sbus->ofdev.dev.archdata.iommu; 174 struct iommu_struct *iommu = dev->archdata.iommu;
175 int ioptex; 175 int ioptex;
176 iopte_t *iopte, *iopte0; 176 iopte_t *iopte, *iopte0;
177 unsigned int busa, busa0; 177 unsigned int busa, busa0;
@@ -199,8 +199,7 @@ static u32 iommu_get_one(struct page *page, int npages, struct sbus_bus *sbus)
199 return busa0; 199 return busa0;
200} 200}
201 201
202static u32 iommu_get_scsi_one(char *vaddr, unsigned int len, 202static u32 iommu_get_scsi_one(struct device *dev, char *vaddr, unsigned int len)
203 struct sbus_bus *sbus)
204{ 203{
205 unsigned long off; 204 unsigned long off;
206 int npages; 205 int npages;
@@ -210,22 +209,22 @@ static u32 iommu_get_scsi_one(char *vaddr, unsigned int len,
210 off = (unsigned long)vaddr & ~PAGE_MASK; 209 off = (unsigned long)vaddr & ~PAGE_MASK;
211 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT; 210 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT;
212 page = virt_to_page((unsigned long)vaddr & PAGE_MASK); 211 page = virt_to_page((unsigned long)vaddr & PAGE_MASK);
213 busa = iommu_get_one(page, npages, sbus); 212 busa = iommu_get_one(dev, page, npages);
214 return busa + off; 213 return busa + off;
215} 214}
216 215
217static __u32 iommu_get_scsi_one_noflush(char *vaddr, unsigned long len, struct sbus_bus *sbus) 216static __u32 iommu_get_scsi_one_noflush(struct device *dev, char *vaddr, unsigned long len)
218{ 217{
219 return iommu_get_scsi_one(vaddr, len, sbus); 218 return iommu_get_scsi_one(dev, vaddr, len);
220} 219}
221 220
222static __u32 iommu_get_scsi_one_gflush(char *vaddr, unsigned long len, struct sbus_bus *sbus) 221static __u32 iommu_get_scsi_one_gflush(struct device *dev, char *vaddr, unsigned long len)
223{ 222{
224 flush_page_for_dma(0); 223 flush_page_for_dma(0);
225 return iommu_get_scsi_one(vaddr, len, sbus); 224 return iommu_get_scsi_one(dev, vaddr, len);
226} 225}
227 226
228static __u32 iommu_get_scsi_one_pflush(char *vaddr, unsigned long len, struct sbus_bus *sbus) 227static __u32 iommu_get_scsi_one_pflush(struct device *dev, char *vaddr, unsigned long len)
229{ 228{
230 unsigned long page = ((unsigned long) vaddr) & PAGE_MASK; 229 unsigned long page = ((unsigned long) vaddr) & PAGE_MASK;
231 230
@@ -233,23 +232,23 @@ static __u32 iommu_get_scsi_one_pflush(char *vaddr, unsigned long len, struct sb
233 flush_page_for_dma(page); 232 flush_page_for_dma(page);
234 page += PAGE_SIZE; 233 page += PAGE_SIZE;
235 } 234 }
236 return iommu_get_scsi_one(vaddr, len, sbus); 235 return iommu_get_scsi_one(dev, vaddr, len);
237} 236}
238 237
239static void iommu_get_scsi_sgl_noflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 238static void iommu_get_scsi_sgl_noflush(struct device *dev, struct scatterlist *sg, int sz)
240{ 239{
241 int n; 240 int n;
242 241
243 while (sz != 0) { 242 while (sz != 0) {
244 --sz; 243 --sz;
245 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 244 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
246 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; 245 sg->dvma_address = iommu_get_one(dev, sg_page(sg), n) + sg->offset;
247 sg->dvma_length = (__u32) sg->length; 246 sg->dvma_length = (__u32) sg->length;
248 sg = sg_next(sg); 247 sg = sg_next(sg);
249 } 248 }
250} 249}
251 250
252static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 251static void iommu_get_scsi_sgl_gflush(struct device *dev, struct scatterlist *sg, int sz)
253{ 252{
254 int n; 253 int n;
255 254
@@ -257,13 +256,13 @@ static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbu
257 while (sz != 0) { 256 while (sz != 0) {
258 --sz; 257 --sz;
259 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 258 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
260 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; 259 sg->dvma_address = iommu_get_one(dev, sg_page(sg), n) + sg->offset;
261 sg->dvma_length = (__u32) sg->length; 260 sg->dvma_length = (__u32) sg->length;
262 sg = sg_next(sg); 261 sg = sg_next(sg);
263 } 262 }
264} 263}
265 264
266static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 265static void iommu_get_scsi_sgl_pflush(struct device *dev, struct scatterlist *sg, int sz)
267{ 266{
268 unsigned long page, oldpage = 0; 267 unsigned long page, oldpage = 0;
269 int n, i; 268 int n, i;
@@ -288,15 +287,15 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu
288 } 287 }
289 } 288 }
290 289
291 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; 290 sg->dvma_address = iommu_get_one(dev, sg_page(sg), n) + sg->offset;
292 sg->dvma_length = (__u32) sg->length; 291 sg->dvma_length = (__u32) sg->length;
293 sg = sg_next(sg); 292 sg = sg_next(sg);
294 } 293 }
295} 294}
296 295
297static void iommu_release_one(u32 busa, int npages, struct sbus_bus *sbus) 296static void iommu_release_one(struct device *dev, u32 busa, int npages)
298{ 297{
299 struct iommu_struct *iommu = sbus->ofdev.dev.archdata.iommu; 298 struct iommu_struct *iommu = dev->archdata.iommu;
300 int ioptex; 299 int ioptex;
301 int i; 300 int i;
302 301
@@ -310,17 +309,17 @@ static void iommu_release_one(u32 busa, int npages, struct sbus_bus *sbus)
310 bit_map_clear(&iommu->usemap, ioptex, npages); 309 bit_map_clear(&iommu->usemap, ioptex, npages);
311} 310}
312 311
313static void iommu_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_bus *sbus) 312static void iommu_release_scsi_one(struct device *dev, __u32 vaddr, unsigned long len)
314{ 313{
315 unsigned long off; 314 unsigned long off;
316 int npages; 315 int npages;
317 316
318 off = vaddr & ~PAGE_MASK; 317 off = vaddr & ~PAGE_MASK;
319 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT; 318 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT;
320 iommu_release_one(vaddr & PAGE_MASK, npages, sbus); 319 iommu_release_one(dev, vaddr & PAGE_MASK, npages);
321} 320}
322 321
323static void iommu_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 322static void iommu_release_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
324{ 323{
325 int n; 324 int n;
326 325
@@ -328,7 +327,7 @@ static void iommu_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_b
328 --sz; 327 --sz;
329 328
330 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 329 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
331 iommu_release_one(sg->dvma_address & PAGE_MASK, n, sbus); 330 iommu_release_one(dev, sg->dvma_address & PAGE_MASK, n);
332 sg->dvma_address = 0x21212121; 331 sg->dvma_address = 0x21212121;
333 sg = sg_next(sg); 332 sg = sg_next(sg);
334 } 333 }