Skip to content

Commit e19d4eb

Browse files
committed
alpha: add full ioread64/iowrite64 implementation
The previous patch introduced ioread64/iowrite64 declarations, but this means we no longer get the io-64-nonatomic variant, and run into a long error when someone actually wants to use these: ERROR: modpost: "ioread64" [drivers/net/ethernet/freescale/enetc/fsl-enetc.ko] undefined! Add the (hopefully) correct implementation for each machine type, based on the 32-bit accessor. Since the 32-bit return type does not work for ioread64(), change the internal implementation to use the correct width consistently, but leave the external interface to match the asm-generic/iomap.h header that uses 32-bit or 64-bit return values. Reported-by: Guenter Roeck <[email protected]> Tested-by: Guenter Roeck <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Fixes: 7e772da ("alpha: Use generic <asm-generic/io.h>") Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 28a679e commit e19d4eb

File tree

13 files changed

+175
-23
lines changed

13 files changed

+175
-23
lines changed

arch/alpha/include/asm/core_apecs.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ struct el_apecs_procdata
384384
} \
385385
} while (0)
386386

387-
__EXTERN_INLINE unsigned int apecs_ioread8(const void __iomem *xaddr)
387+
__EXTERN_INLINE u8 apecs_ioread8(const void __iomem *xaddr)
388388
{
389389
unsigned long addr = (unsigned long) xaddr;
390390
unsigned long result, base_and_type;
@@ -420,7 +420,7 @@ __EXTERN_INLINE void apecs_iowrite8(u8 b, void __iomem *xaddr)
420420
*(vuip) ((addr << 5) + base_and_type) = w;
421421
}
422422

423-
__EXTERN_INLINE unsigned int apecs_ioread16(const void __iomem *xaddr)
423+
__EXTERN_INLINE u16 apecs_ioread16(const void __iomem *xaddr)
424424
{
425425
unsigned long addr = (unsigned long) xaddr;
426426
unsigned long result, base_and_type;
@@ -456,7 +456,7 @@ __EXTERN_INLINE void apecs_iowrite16(u16 b, void __iomem *xaddr)
456456
*(vuip) ((addr << 5) + base_and_type) = w;
457457
}
458458

459-
__EXTERN_INLINE unsigned int apecs_ioread32(const void __iomem *xaddr)
459+
__EXTERN_INLINE u32 apecs_ioread32(const void __iomem *xaddr)
460460
{
461461
unsigned long addr = (unsigned long) xaddr;
462462
if (addr < APECS_DENSE_MEM)
@@ -472,6 +472,22 @@ __EXTERN_INLINE void apecs_iowrite32(u32 b, void __iomem *xaddr)
472472
*(vuip)addr = b;
473473
}
474474

475+
__EXTERN_INLINE u64 apecs_ioread64(const void __iomem *xaddr)
476+
{
477+
unsigned long addr = (unsigned long) xaddr;
478+
if (addr < APECS_DENSE_MEM)
479+
addr = ((addr - APECS_IO) << 5) + APECS_IO + 0x18;
480+
return *(vulp)addr;
481+
}
482+
483+
__EXTERN_INLINE void apecs_iowrite64(u64 b, void __iomem *xaddr)
484+
{
485+
unsigned long addr = (unsigned long) xaddr;
486+
if (addr < APECS_DENSE_MEM)
487+
addr = ((addr - APECS_IO) << 5) + APECS_IO + 0x18;
488+
*(vulp)addr = b;
489+
}
490+
475491
__EXTERN_INLINE void __iomem *apecs_ioportmap(unsigned long addr)
476492
{
477493
return (void __iomem *)(addr + APECS_IO);

arch/alpha/include/asm/core_cia.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ struct el_CIA_sysdata_mcheck {
342342
#define vuip volatile unsigned int __force *
343343
#define vulp volatile unsigned long __force *
344344

345-
__EXTERN_INLINE unsigned int cia_ioread8(const void __iomem *xaddr)
345+
__EXTERN_INLINE u8 cia_ioread8(const void __iomem *xaddr)
346346
{
347347
unsigned long addr = (unsigned long) xaddr;
348348
unsigned long result, base_and_type;
@@ -374,7 +374,7 @@ __EXTERN_INLINE void cia_iowrite8(u8 b, void __iomem *xaddr)
374374
*(vuip) ((addr << 5) + base_and_type) = w;
375375
}
376376

377-
__EXTERN_INLINE unsigned int cia_ioread16(const void __iomem *xaddr)
377+
__EXTERN_INLINE u16 cia_ioread16(const void __iomem *xaddr)
378378
{
379379
unsigned long addr = (unsigned long) xaddr;
380380
unsigned long result, base_and_type;
@@ -404,7 +404,7 @@ __EXTERN_INLINE void cia_iowrite16(u16 b, void __iomem *xaddr)
404404
*(vuip) ((addr << 5) + base_and_type) = w;
405405
}
406406

407-
__EXTERN_INLINE unsigned int cia_ioread32(const void __iomem *xaddr)
407+
__EXTERN_INLINE u32 cia_ioread32(const void __iomem *xaddr)
408408
{
409409
unsigned long addr = (unsigned long) xaddr;
410410
if (addr < CIA_DENSE_MEM)
@@ -420,6 +420,22 @@ __EXTERN_INLINE void cia_iowrite32(u32 b, void __iomem *xaddr)
420420
*(vuip)addr = b;
421421
}
422422

423+
__EXTERN_INLINE u64 cia_ioread64(const void __iomem *xaddr)
424+
{
425+
unsigned long addr = (unsigned long) xaddr;
426+
if (addr < CIA_DENSE_MEM)
427+
addr = ((addr - CIA_IO) << 5) + CIA_IO + 0x18;
428+
return *(vulp)addr;
429+
}
430+
431+
__EXTERN_INLINE void cia_iowrite64(u64 b, void __iomem *xaddr)
432+
{
433+
unsigned long addr = (unsigned long) xaddr;
434+
if (addr < CIA_DENSE_MEM)
435+
addr = ((addr - CIA_IO) << 5) + CIA_IO + 0x18;
436+
*(vulp)addr = b;
437+
}
438+
423439
__EXTERN_INLINE void __iomem *cia_ioportmap(unsigned long addr)
424440
{
425441
return (void __iomem *)(addr + CIA_IO);

arch/alpha/include/asm/core_lca.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ union el_lca {
230230
} while (0)
231231

232232

233-
__EXTERN_INLINE unsigned int lca_ioread8(const void __iomem *xaddr)
233+
__EXTERN_INLINE u8 lca_ioread8(const void __iomem *xaddr)
234234
{
235235
unsigned long addr = (unsigned long) xaddr;
236236
unsigned long result, base_and_type;
@@ -266,7 +266,7 @@ __EXTERN_INLINE void lca_iowrite8(u8 b, void __iomem *xaddr)
266266
*(vuip) ((addr << 5) + base_and_type) = w;
267267
}
268268

269-
__EXTERN_INLINE unsigned int lca_ioread16(const void __iomem *xaddr)
269+
__EXTERN_INLINE u16 lca_ioread16(const void __iomem *xaddr)
270270
{
271271
unsigned long addr = (unsigned long) xaddr;
272272
unsigned long result, base_and_type;
@@ -302,7 +302,7 @@ __EXTERN_INLINE void lca_iowrite16(u16 b, void __iomem *xaddr)
302302
*(vuip) ((addr << 5) + base_and_type) = w;
303303
}
304304

305-
__EXTERN_INLINE unsigned int lca_ioread32(const void __iomem *xaddr)
305+
__EXTERN_INLINE u32 lca_ioread32(const void __iomem *xaddr)
306306
{
307307
unsigned long addr = (unsigned long) xaddr;
308308
if (addr < LCA_DENSE_MEM)
@@ -318,6 +318,22 @@ __EXTERN_INLINE void lca_iowrite32(u32 b, void __iomem *xaddr)
318318
*(vuip)addr = b;
319319
}
320320

321+
__EXTERN_INLINE u64 lca_ioread64(const void __iomem *xaddr)
322+
{
323+
unsigned long addr = (unsigned long) xaddr;
324+
if (addr < LCA_DENSE_MEM)
325+
addr = ((addr - LCA_IO) << 5) + LCA_IO + 0x18;
326+
return *(vulp)addr;
327+
}
328+
329+
__EXTERN_INLINE void lca_iowrite64(u64 b, void __iomem *xaddr)
330+
{
331+
unsigned long addr = (unsigned long) xaddr;
332+
if (addr < LCA_DENSE_MEM)
333+
addr = ((addr - LCA_IO) << 5) + LCA_IO + 0x18;
334+
*(vulp)addr = b;
335+
}
336+
321337
__EXTERN_INLINE void __iomem *lca_ioportmap(unsigned long addr)
322338
{
323339
return (void __iomem *)(addr + LCA_IO);

arch/alpha/include/asm/core_marvel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ struct io7 {
332332
#define vucp volatile unsigned char __force *
333333
#define vusp volatile unsigned short __force *
334334

335-
extern unsigned int marvel_ioread8(const void __iomem *);
335+
extern u8 marvel_ioread8(const void __iomem *);
336336
extern void marvel_iowrite8(u8 b, void __iomem *);
337337

338-
__EXTERN_INLINE unsigned int marvel_ioread16(const void __iomem *addr)
338+
__EXTERN_INLINE u16 marvel_ioread16(const void __iomem *addr)
339339
{
340340
return __kernel_ldwu(*(vusp)addr);
341341
}

arch/alpha/include/asm/core_mcpcia.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ struct el_MCPCIA_uncorrected_frame_mcheck {
248248

249249
#define vip volatile int __force *
250250
#define vuip volatile unsigned int __force *
251+
#define vulp volatile unsigned long __force *
251252

252253
#ifndef MCPCIA_ONE_HAE_WINDOW
253254
#define MCPCIA_FROB_MMIO \
@@ -267,7 +268,7 @@ extern inline int __mcpcia_is_mmio(unsigned long addr)
267268
return (addr & 0x80000000UL) == 0;
268269
}
269270

270-
__EXTERN_INLINE unsigned int mcpcia_ioread8(const void __iomem *xaddr)
271+
__EXTERN_INLINE u8 mcpcia_ioread8(const void __iomem *xaddr)
271272
{
272273
unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
273274
unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
@@ -291,7 +292,7 @@ __EXTERN_INLINE void mcpcia_iowrite8(u8 b, void __iomem *xaddr)
291292
*(vuip) ((addr << 5) + hose + 0x00) = w;
292293
}
293294

294-
__EXTERN_INLINE unsigned int mcpcia_ioread16(const void __iomem *xaddr)
295+
__EXTERN_INLINE u16 mcpcia_ioread16(const void __iomem *xaddr)
295296
{
296297
unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
297298
unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
@@ -315,7 +316,7 @@ __EXTERN_INLINE void mcpcia_iowrite16(u16 b, void __iomem *xaddr)
315316
*(vuip) ((addr << 5) + hose + 0x08) = w;
316317
}
317318

318-
__EXTERN_INLINE unsigned int mcpcia_ioread32(const void __iomem *xaddr)
319+
__EXTERN_INLINE u32 mcpcia_ioread32(const void __iomem *xaddr)
319320
{
320321
unsigned long addr = (unsigned long)xaddr;
321322

@@ -335,6 +336,26 @@ __EXTERN_INLINE void mcpcia_iowrite32(u32 b, void __iomem *xaddr)
335336
*(vuip)addr = b;
336337
}
337338

339+
__EXTERN_INLINE u64 mcpcia_ioread64(const void __iomem *xaddr)
340+
{
341+
unsigned long addr = (unsigned long)xaddr;
342+
343+
if (!__mcpcia_is_mmio(addr))
344+
addr = ((addr & 0xffff) << 5) + (addr & ~0xfffful) + 0x18;
345+
346+
return *(vulp)addr;
347+
}
348+
349+
__EXTERN_INLINE void mcpcia_iowrite64(u64 b, void __iomem *xaddr)
350+
{
351+
unsigned long addr = (unsigned long)xaddr;
352+
353+
if (!__mcpcia_is_mmio(addr))
354+
addr = ((addr & 0xffff) << 5) + (addr & ~0xfffful) + 0x18;
355+
356+
*(vulp)addr = b;
357+
}
358+
338359

339360
__EXTERN_INLINE void __iomem *mcpcia_ioportmap(unsigned long addr)
340361
{
@@ -362,6 +383,7 @@ __EXTERN_INLINE int mcpcia_is_mmio(const volatile void __iomem *xaddr)
362383

363384
#undef vip
364385
#undef vuip
386+
#undef vulp
365387

366388
#undef __IO_PREFIX
367389
#define __IO_PREFIX mcpcia

arch/alpha/include/asm/core_t2.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ struct el_t2_frame_corrected {
360360

361361
#define vip volatile int *
362362
#define vuip volatile unsigned int *
363+
#define vulp volatile unsigned long *
363364

364365
extern inline u8 t2_inb(unsigned long addr)
365366
{
@@ -402,6 +403,17 @@ extern inline void t2_outl(u32 b, unsigned long addr)
402403
mb();
403404
}
404405

406+
extern inline u64 t2_inq(unsigned long addr)
407+
{
408+
return *(vulp) ((addr << 5) + T2_IO + 0x18);
409+
}
410+
411+
extern inline void t2_outq(u64 b, unsigned long addr)
412+
{
413+
*(vulp) ((addr << 5) + T2_IO + 0x18) = b;
414+
mb();
415+
}
416+
405417

406418
/*
407419
* Memory functions.
@@ -572,7 +584,7 @@ __EXTERN_INLINE int t2_is_mmio(const volatile void __iomem *addr)
572584
it doesn't make sense to merge the pio and mmio routines. */
573585

574586
#define IOPORT(OS, NS) \
575-
__EXTERN_INLINE unsigned int t2_ioread##NS(const void __iomem *xaddr) \
587+
__EXTERN_INLINE u##NS t2_ioread##NS(const void __iomem *xaddr) \
576588
{ \
577589
if (t2_is_mmio(xaddr)) \
578590
return t2_read##OS(xaddr); \
@@ -590,11 +602,13 @@ __EXTERN_INLINE void t2_iowrite##NS(u##NS b, void __iomem *xaddr) \
590602
IOPORT(b, 8)
591603
IOPORT(w, 16)
592604
IOPORT(l, 32)
605+
IOPORT(q, 64)
593606

594607
#undef IOPORT
595608

596609
#undef vip
597610
#undef vuip
611+
#undef vulp
598612

599613
#undef __IO_PREFIX
600614
#define __IO_PREFIX t2

arch/alpha/include/asm/io.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ static inline void generic_##NAME(TYPE b, QUAL void __iomem *addr) \
155155
REMAP1(unsigned int, ioread8, const)
156156
REMAP1(unsigned int, ioread16, const)
157157
REMAP1(unsigned int, ioread32, const)
158+
REMAP1(u64, ioread64, const)
158159
REMAP1(u8, readb, const volatile)
159160
REMAP1(u16, readw, const volatile)
160161
REMAP1(u32, readl, const volatile)
@@ -163,6 +164,7 @@ REMAP1(u64, readq, const volatile)
163164
REMAP2(u8, iowrite8, /**/)
164165
REMAP2(u16, iowrite16, /**/)
165166
REMAP2(u32, iowrite32, /**/)
167+
REMAP2(u64, iowrite64, /**/)
166168
REMAP2(u8, writeb, volatile)
167169
REMAP2(u16, writew, volatile)
168170
REMAP2(u32, writel, volatile)
@@ -400,12 +402,27 @@ extern inline unsigned int ioread32(const void __iomem *addr)
400402
return ret;
401403
}
402404

405+
extern inline u64 ioread64(const void __iomem *addr)
406+
{
407+
unsigned int ret;
408+
mb();
409+
ret = IO_CONCAT(__IO_PREFIX,ioread64)(addr);
410+
mb();
411+
return ret;
412+
}
413+
403414
extern inline void iowrite32(u32 b, void __iomem *addr)
404415
{
405416
mb();
406417
IO_CONCAT(__IO_PREFIX, iowrite32)(b, addr);
407418
}
408419

420+
extern inline void iowrite64(u64 b, void __iomem *addr)
421+
{
422+
mb();
423+
IO_CONCAT(__IO_PREFIX, iowrite64)(b, addr);
424+
}
425+
409426
extern inline u32 inl(unsigned long port)
410427
{
411428
return ioread32(ioport_map(port, 4));
@@ -418,7 +435,9 @@ extern inline void outl(u32 b, unsigned long port)
418435
#endif
419436

420437
#define ioread32 ioread32
438+
#define ioread64 ioread64
421439
#define iowrite32 iowrite32
440+
#define iowrite64 iowrite64
422441

423442
#if IO_CONCAT(__IO_PREFIX,trivial_rw_bw) == 1
424443
extern inline u8 __raw_readb(const volatile void __iomem *addr)

arch/alpha/include/asm/io_trivial.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
/* This file may be included multiple times. */
77

88
#if IO_CONCAT(__IO_PREFIX,trivial_io_bw)
9-
__EXTERN_INLINE unsigned int
9+
__EXTERN_INLINE u8
1010
IO_CONCAT(__IO_PREFIX,ioread8)(const void __iomem *a)
1111
{
1212
return __kernel_ldbu(*(const volatile u8 __force *)a);
1313
}
1414

15-
__EXTERN_INLINE unsigned int
15+
__EXTERN_INLINE u16
1616
IO_CONCAT(__IO_PREFIX,ioread16)(const void __iomem *a)
1717
{
1818
return __kernel_ldwu(*(const volatile u16 __force *)a);
@@ -32,7 +32,7 @@ IO_CONCAT(__IO_PREFIX,iowrite16)(u16 b, void __iomem *a)
3232
#endif
3333

3434
#if IO_CONCAT(__IO_PREFIX,trivial_io_lq)
35-
__EXTERN_INLINE unsigned int
35+
__EXTERN_INLINE u32
3636
IO_CONCAT(__IO_PREFIX,ioread32)(const void __iomem *a)
3737
{
3838
return *(const volatile u32 __force *)a;
@@ -43,6 +43,18 @@ IO_CONCAT(__IO_PREFIX,iowrite32)(u32 b, void __iomem *a)
4343
{
4444
*(volatile u32 __force *)a = b;
4545
}
46+
47+
__EXTERN_INLINE u64
48+
IO_CONCAT(__IO_PREFIX,ioread64)(const void __iomem *a)
49+
{
50+
return *(const volatile u64 __force *)a;
51+
}
52+
53+
__EXTERN_INLINE void
54+
IO_CONCAT(__IO_PREFIX,iowrite64)(u64 b, void __iomem *a)
55+
{
56+
*(volatile u64 __force *)a = b;
57+
}
4658
#endif
4759

4860
#if IO_CONCAT(__IO_PREFIX,trivial_rw_bw) == 1

0 commit comments

Comments
 (0)