Skip to content

Commit c475f17

Browse files
sebottMartin Schwidefsky
authored andcommitted
s390/ism: move oddities of device IO to wrapper function
ISM devices are special in how they access PCI memory space. Provide wrappers for handling commands to the device. No functional change. Signed-off-by: Sebastian Ott <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 81deca1 commit c475f17

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

drivers/s390/net/ism.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/types.h>
77
#include <linux/pci.h>
88
#include <net/smc.h>
9+
#include <asm/pci_insn.h>
910

1011
#define UTIL_STR_LEN 16
1112

@@ -194,8 +195,6 @@ struct ism_dev {
194195
struct pci_dev *pdev;
195196
struct smcd_dev *smcd;
196197

197-
void __iomem *ctl;
198-
199198
struct ism_sba *sba;
200199
dma_addr_t sba_dma_addr;
201200
DECLARE_BITMAP(sba_bitmap, ISM_NR_DMBS);
@@ -209,6 +208,30 @@ struct ism_dev {
209208
#define ISM_CREATE_REQ(dmb, idx, sf, offset) \
210209
((dmb) | (idx) << 24 | (sf) << 23 | (offset))
211210

211+
static inline void __ism_read_cmd(struct ism_dev *ism, void *data,
212+
unsigned long offset, unsigned long len)
213+
{
214+
struct zpci_dev *zdev = to_zpci(ism->pdev);
215+
u64 req = ZPCI_CREATE_REQ(zdev->fh, 2, 8);
216+
217+
while (len > 0) {
218+
__zpci_load(data, req, offset);
219+
offset += 8;
220+
data += 8;
221+
len -= 8;
222+
}
223+
}
224+
225+
static inline void __ism_write_cmd(struct ism_dev *ism, void *data,
226+
unsigned long offset, unsigned long len)
227+
{
228+
struct zpci_dev *zdev = to_zpci(ism->pdev);
229+
u64 req = ZPCI_CREATE_REQ(zdev->fh, 2, len);
230+
231+
if (len)
232+
__zpci_store_block(data, req, offset);
233+
}
234+
212235
static inline int __ism_move(struct ism_dev *ism, u64 dmb_req, void *data,
213236
unsigned int size)
214237
{

drivers/s390/net/ism_drv.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ static int ism_cmd(struct ism_dev *ism, void *cmd)
3838
struct ism_req_hdr *req = cmd;
3939
struct ism_resp_hdr *resp = cmd;
4040

41-
memcpy_toio(ism->ctl + sizeof(*req), req + 1, req->len - sizeof(*req));
42-
memcpy_toio(ism->ctl, req, sizeof(*req));
41+
__ism_write_cmd(ism, req + 1, sizeof(*req), req->len - sizeof(*req));
42+
__ism_write_cmd(ism, req, 0, sizeof(*req));
4343

4444
WRITE_ONCE(resp->ret, ISM_ERROR);
4545

46-
memcpy_fromio(resp, ism->ctl, sizeof(*resp));
46+
__ism_read_cmd(ism, resp, 0, sizeof(*resp));
4747
if (resp->ret) {
4848
debug_text_event(ism_debug_info, 0, "cmd failure");
4949
debug_event(ism_debug_info, 0, resp, sizeof(*resp));
5050
goto out;
5151
}
52-
memcpy_fromio(resp + 1, ism->ctl + sizeof(*resp),
53-
resp->len - sizeof(*resp));
52+
__ism_read_cmd(ism, resp + 1, sizeof(*resp), resp->len - sizeof(*resp));
5453
out:
5554
return resp->ret;
5655
}
@@ -512,13 +511,9 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)
512511
if (ret)
513512
goto err_disable;
514513

515-
ism->ctl = pci_iomap(pdev, 2, 0);
516-
if (!ism->ctl)
517-
goto err_resource;
518-
519514
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
520515
if (ret)
521-
goto err_unmap;
516+
goto err_resource;
522517

523518
dma_set_seg_boundary(&pdev->dev, SZ_1M - 1);
524519
dma_set_max_seg_size(&pdev->dev, SZ_1M);
@@ -527,7 +522,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)
527522
ism->smcd = smcd_alloc_dev(&pdev->dev, dev_name(&pdev->dev), &ism_ops,
528523
ISM_NR_DMBS);
529524
if (!ism->smcd)
530-
goto err_unmap;
525+
goto err_resource;
531526

532527
ism->smcd->priv = ism;
533528
ret = ism_dev_init(ism);
@@ -538,8 +533,6 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)
538533

539534
err_free:
540535
smcd_free_dev(ism->smcd);
541-
err_unmap:
542-
pci_iounmap(pdev, ism->ctl);
543536
err_resource:
544537
pci_release_mem_regions(pdev);
545538
err_disable:
@@ -568,7 +561,6 @@ static void ism_remove(struct pci_dev *pdev)
568561
ism_dev_exit(ism);
569562

570563
smcd_free_dev(ism->smcd);
571-
pci_iounmap(pdev, ism->ctl);
572564
pci_release_mem_regions(pdev);
573565
pci_disable_device(pdev);
574566
dev_set_drvdata(&pdev->dev, NULL);

0 commit comments

Comments
 (0)