Skip to content

Commit 81deca1

Browse files
sebottMartin Schwidefsky
authored andcommitted
s390/pci: move io address mapping code to pci_insn.c
This is a preparation patch for usage of new pci instructions. No functional change. Signed-off-by: Sebastian Ott <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent fbfe07d commit 81deca1

File tree

5 files changed

+61
-40
lines changed

5 files changed

+61
-40
lines changed

arch/s390/include/asm/pci_insn.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ union zpci_sic_iib {
124124

125125
u8 zpci_mod_fc(u64 req, struct zpci_fib *fib, u8 *status);
126126
int zpci_refresh_trans(u64 fn, u64 addr, u64 range);
127-
int zpci_load(u64 *data, u64 req, u64 offset);
128-
int zpci_store(u64 data, u64 req, u64 offset);
129-
int zpci_store_block(const u64 *data, u64 req, u64 offset);
127+
int __zpci_load(u64 *data, u64 req, u64 offset);
128+
int zpci_load(u64 *data, const volatile void __iomem *addr, unsigned long len);
129+
int __zpci_store(u64 data, u64 req, u64 offset);
130+
int zpci_store(const volatile void __iomem *addr, u64 data, unsigned long len);
131+
int __zpci_store_block(const u64 *data, u64 req, u64 offset);
130132
int __zpci_set_irq_ctrl(u16 ctl, u8 isc, union zpci_sic_iib *iib);
131133

132134
static inline int zpci_set_irq_ctrl(u16 ctl, u8 isc)

arch/s390/include/asm/pci_io.h

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ extern struct zpci_iomap_entry *zpci_iomap_start;
3737
#define zpci_read(LENGTH, RETTYPE) \
3838
static inline RETTYPE zpci_read_##RETTYPE(const volatile void __iomem *addr) \
3939
{ \
40-
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(addr)]; \
41-
u64 req = ZPCI_CREATE_REQ(entry->fh, entry->bar, LENGTH); \
4240
u64 data; \
4341
int rc; \
4442
\
45-
rc = zpci_load(&data, req, ZPCI_OFFSET(addr)); \
43+
rc = zpci_load(&data, addr, LENGTH); \
4644
if (rc) \
4745
data = -1ULL; \
4846
return (RETTYPE) data; \
@@ -52,11 +50,9 @@ static inline RETTYPE zpci_read_##RETTYPE(const volatile void __iomem *addr) \
5250
static inline void zpci_write_##VALTYPE(VALTYPE val, \
5351
const volatile void __iomem *addr) \
5452
{ \
55-
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(addr)]; \
56-
u64 req = ZPCI_CREATE_REQ(entry->fh, entry->bar, LENGTH); \
5753
u64 data = (VALTYPE) val; \
5854
\
59-
zpci_store(data, req, ZPCI_OFFSET(addr)); \
55+
zpci_store(addr, data, LENGTH); \
6056
}
6157

6258
zpci_read(8, u64)
@@ -68,36 +64,38 @@ zpci_write(4, u32)
6864
zpci_write(2, u16)
6965
zpci_write(1, u8)
7066

71-
static inline int zpci_write_single(u64 req, const u64 *data, u64 offset, u8 len)
67+
static inline int zpci_write_single(volatile void __iomem *dst, const void *src,
68+
unsigned long len)
7269
{
7370
u64 val;
7471

7572
switch (len) {
7673
case 1:
77-
val = (u64) *((u8 *) data);
74+
val = (u64) *((u8 *) src);
7875
break;
7976
case 2:
80-
val = (u64) *((u16 *) data);
77+
val = (u64) *((u16 *) src);
8178
break;
8279
case 4:
83-
val = (u64) *((u32 *) data);
80+
val = (u64) *((u32 *) src);
8481
break;
8582
case 8:
86-
val = (u64) *((u64 *) data);
83+
val = (u64) *((u64 *) src);
8784
break;
8885
default:
8986
val = 0; /* let FW report error */
9087
break;
9188
}
92-
return zpci_store(val, req, offset);
89+
return zpci_store(dst, val, len);
9390
}
9491

95-
static inline int zpci_read_single(u64 req, u64 *dst, u64 offset, u8 len)
92+
static inline int zpci_read_single(void *dst, const volatile void __iomem *src,
93+
unsigned long len)
9694
{
9795
u64 data;
9896
int cc;
9997

100-
cc = zpci_load(&data, req, offset);
98+
cc = zpci_load(&data, src, len);
10199
if (cc)
102100
goto out;
103101

@@ -119,10 +117,8 @@ static inline int zpci_read_single(u64 req, u64 *dst, u64 offset, u8 len)
119117
return cc;
120118
}
121119

122-
static inline int zpci_write_block(u64 req, const u64 *data, u64 offset)
123-
{
124-
return zpci_store_block(data, req, offset);
125-
}
120+
int zpci_write_block(volatile void __iomem *dst, const void *src,
121+
unsigned long len);
126122

127123
static inline u8 zpci_get_max_write_size(u64 src, u64 dst, int len, int max)
128124
{
@@ -140,18 +136,15 @@ static inline int zpci_memcpy_fromio(void *dst,
140136
const volatile void __iomem *src,
141137
unsigned long n)
142138
{
143-
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(src)];
144-
u64 req, offset = ZPCI_OFFSET(src);
145139
int size, rc = 0;
146140

147141
while (n > 0) {
148142
size = zpci_get_max_write_size((u64 __force) src,
149143
(u64) dst, n, 8);
150-
req = ZPCI_CREATE_REQ(entry->fh, entry->bar, size);
151-
rc = zpci_read_single(req, dst, offset, size);
144+
rc = zpci_read_single(dst, src, size);
152145
if (rc)
153146
break;
154-
offset += size;
147+
src += size;
155148
dst += size;
156149
n -= size;
157150
}
@@ -161,8 +154,6 @@ static inline int zpci_memcpy_fromio(void *dst,
161154
static inline int zpci_memcpy_toio(volatile void __iomem *dst,
162155
const void *src, unsigned long n)
163156
{
164-
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(dst)];
165-
u64 req, offset = ZPCI_OFFSET(dst);
166157
int size, rc = 0;
167158

168159
if (!src)
@@ -171,16 +162,14 @@ static inline int zpci_memcpy_toio(volatile void __iomem *dst,
171162
while (n > 0) {
172163
size = zpci_get_max_write_size((u64 __force) dst,
173164
(u64) src, n, 128);
174-
req = ZPCI_CREATE_REQ(entry->fh, entry->bar, size);
175-
176165
if (size > 8) /* main path */
177-
rc = zpci_write_block(req, src, offset);
166+
rc = zpci_write_block(dst, src, size);
178167
else
179-
rc = zpci_write_single(req, src, offset, size);
168+
rc = zpci_write_single(dst, src, size);
180169
if (rc)
181170
break;
182-
offset += size;
183171
src += size;
172+
dst += size;
184173
n -= size;
185174
}
186175
return rc;

arch/s390/pci/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len)
188188
u64 data;
189189
int rc;
190190

191-
rc = zpci_load(&data, req, offset);
191+
rc = __zpci_load(&data, req, offset);
192192
if (!rc) {
193193
data = le64_to_cpu((__force __le64) data);
194194
data >>= (8 - len) * 8;
@@ -206,7 +206,7 @@ static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len)
206206

207207
data <<= (8 - len) * 8;
208208
data = (__force u64) cpu_to_le64(data);
209-
rc = zpci_store(data, req, offset);
209+
rc = __zpci_store(data, req, offset);
210210
return rc;
211211
}
212212

arch/s390/pci/pci_insn.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <asm/facility.h>
1212
#include <asm/pci_insn.h>
1313
#include <asm/pci_debug.h>
14+
#include <asm/pci_io.h>
1415
#include <asm/processor.h>
1516

1617
#define ZPCI_INSN_BUSY_DELAY 1 /* 1 microsecond */
@@ -142,7 +143,7 @@ static inline int __pcilg(u64 *data, u64 req, u64 offset, u8 *status)
142143
return cc;
143144
}
144145

145-
int zpci_load(u64 *data, u64 req, u64 offset)
146+
int __zpci_load(u64 *data, u64 req, u64 offset)
146147
{
147148
u8 status;
148149
int cc;
@@ -158,6 +159,15 @@ int zpci_load(u64 *data, u64 req, u64 offset)
158159

159160
return (cc > 0) ? -EIO : cc;
160161
}
162+
EXPORT_SYMBOL_GPL(__zpci_load);
163+
164+
int zpci_load(u64 *data, const volatile void __iomem *addr, unsigned long len)
165+
{
166+
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(addr)];
167+
u64 req = ZPCI_CREATE_REQ(entry->fh, entry->bar, len);
168+
169+
return __zpci_load(data, req, ZPCI_OFFSET(addr));
170+
}
161171
EXPORT_SYMBOL_GPL(zpci_load);
162172

163173
/* PCI Store */
@@ -180,7 +190,7 @@ static inline int __pcistg(u64 data, u64 req, u64 offset, u8 *status)
180190
return cc;
181191
}
182192

183-
int zpci_store(u64 data, u64 req, u64 offset)
193+
int __zpci_store(u64 data, u64 req, u64 offset)
184194
{
185195
u8 status;
186196
int cc;
@@ -196,6 +206,15 @@ int zpci_store(u64 data, u64 req, u64 offset)
196206

197207
return (cc > 0) ? -EIO : cc;
198208
}
209+
EXPORT_SYMBOL_GPL(__zpci_store);
210+
211+
int zpci_store(const volatile void __iomem *addr, u64 data, unsigned long len)
212+
{
213+
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(addr)];
214+
u64 req = ZPCI_CREATE_REQ(entry->fh, entry->bar, len);
215+
216+
return __zpci_store(data, req, ZPCI_OFFSET(addr));
217+
}
199218
EXPORT_SYMBOL_GPL(zpci_store);
200219

201220
/* PCI Store Block */
@@ -216,7 +235,7 @@ static inline int __pcistb(const u64 *data, u64 req, u64 offset, u8 *status)
216235
return cc;
217236
}
218237

219-
int zpci_store_block(const u64 *data, u64 req, u64 offset)
238+
int __zpci_store_block(const u64 *data, u64 req, u64 offset)
220239
{
221240
u8 status;
222241
int cc;
@@ -232,4 +251,15 @@ int zpci_store_block(const u64 *data, u64 req, u64 offset)
232251

233252
return (cc > 0) ? -EIO : cc;
234253
}
235-
EXPORT_SYMBOL_GPL(zpci_store_block);
254+
EXPORT_SYMBOL_GPL(__zpci_store_block);
255+
256+
int zpci_write_block(volatile void __iomem *dst,
257+
const void *src, unsigned long len)
258+
{
259+
struct zpci_iomap_entry *entry = &zpci_iomap_start[ZPCI_IDX(dst)];
260+
u64 req = ZPCI_CREATE_REQ(entry->fh, entry->bar, len);
261+
u64 offset = ZPCI_OFFSET(dst);
262+
263+
return __zpci_store_block(src, req, offset);
264+
}
265+
EXPORT_SYMBOL_GPL(zpci_write_block);

drivers/s390/net/ism.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static inline int __ism_move(struct ism_dev *ism, u64 dmb_req, void *data,
215215
struct zpci_dev *zdev = to_zpci(ism->pdev);
216216
u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, size);
217217

218-
return zpci_write_block(req, data, dmb_req);
218+
return __zpci_store_block(data, req, dmb_req);
219219
}
220220

221221
#endif /* S390_ISM_H */

0 commit comments

Comments
 (0)