Skip to content

Commit d236843

Browse files
rosatomjjoergroedel
authored andcommitted
s390/pci: store DMA offset in bus_dma_region
PCI devices on s390 have a DMA offset that is reported via CLP. In preparation for allowing identity domains, setup the bus_dma_region for all PCI devices using the reported CLP value. Signed-off-by: Matthew Rosato <[email protected]> Reviewed-by: Niklas Schnelle <[email protected]> Tested-by: Niklas Schnelle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 6d52cb7 commit d236843

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

arch/s390/pci/pci_bus.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/jump_label.h>
2020
#include <linux/pci.h>
2121
#include <linux/printk.h>
22+
#include <linux/dma-direct.h>
2223

2324
#include <asm/pci_clp.h>
2425
#include <asm/pci_dma.h>
@@ -283,10 +284,34 @@ static struct zpci_bus *zpci_bus_alloc(int topo, bool topo_is_tid)
283284
return zbus;
284285
}
285286

287+
static void pci_dma_range_setup(struct pci_dev *pdev)
288+
{
289+
struct zpci_dev *zdev = to_zpci(pdev);
290+
struct bus_dma_region *map;
291+
u64 aligned_end;
292+
293+
map = kzalloc(sizeof(*map), GFP_KERNEL);
294+
if (!map)
295+
return;
296+
297+
map->cpu_start = 0;
298+
map->dma_start = PAGE_ALIGN(zdev->start_dma);
299+
aligned_end = PAGE_ALIGN_DOWN(zdev->end_dma + 1);
300+
if (aligned_end >= map->dma_start)
301+
map->size = aligned_end - map->dma_start;
302+
else
303+
map->size = 0;
304+
WARN_ON_ONCE(map->size == 0);
305+
306+
pdev->dev.dma_range_map = map;
307+
}
308+
286309
void pcibios_bus_add_device(struct pci_dev *pdev)
287310
{
288311
struct zpci_dev *zdev = to_zpci(pdev);
289312

313+
pci_dma_range_setup(pdev);
314+
290315
/*
291316
* With pdev->no_vf_scan the common PCI probing code does not
292317
* perform PF/VF linking.

0 commit comments

Comments
 (0)