1 From 756f2f1f90524c2620ed7951e436d13bdb929a6b Mon Sep 17 00:00:00 2001
2 From: Andrey Shvetsov <andrey.shvetsov@k2l.de>
3 Date: Mon, 12 Feb 2018 12:25:37 +0100
4 Subject: [PATCH] staging: most: dim2: use device for coherent memory allocation
6 On several modern architectures the allocation of coherent memory needs
7 a device that has the dma_ops properly set. This patch enables use of
8 the DIM2 platform device for the allocation process.
10 Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
12 hdm-dim2/dim2_hdm.c | 9 +++++++--
13 1 file changed, 7 insertions(+), 2 deletions(-)
15 diff --git a/hdm-dim2/dim2_hdm.c b/hdm-dim2/dim2_hdm.c
16 index 05e1896..1847091 100644
17 --- a/hdm-dim2/dim2_hdm.c
18 +++ b/hdm-dim2/dim2_hdm.c
19 @@ -688,12 +688,16 @@ static int poison_channel(struct most_interface *most_iface, int ch_idx)
21 static void *dma_alloc(struct mbo *mbo, u32 size)
23 - return dma_alloc_coherent(NULL, size, &mbo->bus_address, GFP_KERNEL);
24 + struct device *dev = mbo->ifp->dev;
26 + return dma_alloc_coherent(dev, size, &mbo->bus_address, GFP_KERNEL);
29 static void dma_free(struct mbo *mbo, u32 size)
31 - dma_free_coherent(NULL, size, mbo->virt_address, mbo->bus_address);
32 + struct device *dev = mbo->ifp->dev;
34 + dma_free_coherent(dev, size, mbo->virt_address, mbo->bus_address);
37 static const struct of_device_id dim2_of_match[];
38 @@ -875,6 +879,7 @@ static int dim2_probe(struct platform_device *pdev)
39 dev->most_iface.poison_channel = poison_channel;
40 dev->most_iface.request_netinfo = request_netinfo;
41 dev->most_iface.extra_attrs = DBR_ATTRS;
42 + dev->most_iface.dev = &pdev->dev;
44 kobj = most_register_interface(&dev->most_iface);