Skip to content

Commit e82becf

Browse files
borntraegermstsirkin
authored andcommitted
s390/dma: Allow per device dma ops
As virtio-ccw will have dma ops, we can no longer default to the zPCI ones. Make use of dev_archdata to keep the dma_ops per device. The pci devices now use that to override the default, and the default is changed to use the noop ops for everything that does not specify a device specific one. To compile without PCI support we will enable HAS_DMA all the time, via the default config in lib/Kconfig. Signed-off-by: Christian Borntraeger <[email protected]> Reviewed-by: Joerg Roedel <[email protected]> Acked-by: Cornelia Huck <[email protected]> Acked-by: Sebastian Ott <[email protected]> Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 6aca050 commit e82becf

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ config S390
124124
select HAVE_CMPXCHG_DOUBLE
125125
select HAVE_CMPXCHG_LOCAL
126126
select HAVE_DEBUG_KMEMLEAK
127+
select HAVE_DMA_API_DEBUG
127128
select HAVE_DYNAMIC_FTRACE
128129
select HAVE_DYNAMIC_FTRACE_WITH_REGS
129130
select HAVE_FTRACE_MCOUNT_RECORD
@@ -619,10 +620,6 @@ config HAS_IOMEM
619620
config IOMMU_HELPER
620621
def_bool PCI
621622

622-
config HAS_DMA
623-
def_bool PCI
624-
select HAVE_DMA_API_DEBUG
625-
626623
config NEED_SG_DMA_LENGTH
627624
def_bool PCI
628625

arch/s390/include/asm/device.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
*
44
* This file is released under the GPLv2
55
*/
6-
#include <asm-generic/device.h>
6+
struct dev_archdata {
7+
struct dma_map_ops *dma_ops;
8+
};
79

10+
struct pdev_archdata {
11+
};

arch/s390/include/asm/dma-mapping.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
#define DMA_ERROR_CODE (~(dma_addr_t) 0x0)
1313

14-
extern struct dma_map_ops s390_dma_ops;
14+
extern struct dma_map_ops s390_pci_dma_ops;
1515

1616
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
1717
{
18-
return &s390_dma_ops;
18+
if (dev && dev->archdata.dma_ops)
19+
return dev->archdata.dma_ops;
20+
return &dma_noop_ops;
1921
}
2022

2123
static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,

arch/s390/pci/pci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ int pcibios_add_device(struct pci_dev *pdev)
643643

644644
zdev->pdev = pdev;
645645
pdev->dev.groups = zpci_attr_groups;
646+
pdev->dev.archdata.dma_ops = &s390_pci_dma_ops;
646647
zpci_map_resources(pdev);
647648

648649
for (i = 0; i < PCI_BAR_COUNT; i++) {

arch/s390/pci/pci_dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static int __init dma_debug_do_init(void)
544544
}
545545
fs_initcall(dma_debug_do_init);
546546

547-
struct dma_map_ops s390_dma_ops = {
547+
struct dma_map_ops s390_pci_dma_ops = {
548548
.alloc = s390_dma_alloc,
549549
.free = s390_dma_free,
550550
.map_sg = s390_dma_map_sg,
@@ -555,7 +555,7 @@ struct dma_map_ops s390_dma_ops = {
555555
.is_phys = 0,
556556
/* dma_supported is unconditionally true without a callback */
557557
};
558-
EXPORT_SYMBOL_GPL(s390_dma_ops);
558+
EXPORT_SYMBOL_GPL(s390_pci_dma_ops);
559559

560560
static int __init s390_iommu_setup(char *str)
561561
{

0 commit comments

Comments
 (0)