Skip to content

Commit a1d8a83

Browse files
committed
Merge branch 'irq/platform-msi' into irq/msi
Pull in the platform MSI/GIC changes which are seperate for the PCI endpoint driver updates.
2 parents 9357e32 + f1680d9 commit a1d8a83

File tree

5 files changed

+85
-1
lines changed

5 files changed

+85
-1
lines changed

Documentation/devicetree/bindings/pci/pci-ep.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ properties:
1717
$nodename:
1818
pattern: "^pcie-ep@"
1919

20+
iommu-map:
21+
$ref: /schemas/types.yaml#/definitions/uint32-matrix
22+
items:
23+
items:
24+
- description: Device ID (see msi-map) base
25+
maximum: 0x7ffff
26+
- description: phandle to IOMMU
27+
- description: IOMMU specifier base (currently always 1 cell)
28+
- description: Number of Device IDs
29+
maximum: 0x80000
30+
31+
iommu-map-mask:
32+
description:
33+
A mask to be applied to each Device ID prior to being mapped to an
34+
IOMMU specifier per the iommu-map property.
35+
$ref: /schemas/types.yaml#/definitions/uint32
36+
maximum: 0x7ffff
37+
2038
max-functions:
2139
description: Maximum number of functions that can be configured
2240
$ref: /schemas/types.yaml#/definitions/uint8
@@ -35,6 +53,56 @@ properties:
3553
$ref: /schemas/types.yaml#/definitions/uint32
3654
enum: [ 1, 2, 3, 4 ]
3755

56+
msi-map:
57+
description: |
58+
Maps a Device ID to an MSI and associated MSI specifier data.
59+
60+
A PCI Endpoint (EP) can use MSI as a doorbell function. This is achieved by
61+
mapping the MSI controller's address into PCI BAR<n>. The PCI Root Complex
62+
can write to this BAR<n>, triggering the EP to generate IRQ. This notifies
63+
the EP-side driver of an event, eliminating the need for the driver to
64+
continuously poll for status changes.
65+
66+
However, the EP cannot rely on Requester ID (RID) because the RID is
67+
determined by the PCI topology of the host system. Since the EP may be
68+
connected to different PCI hosts, the RID can vary between systems and is
69+
therefore not a reliable identifier.
70+
71+
Each EP can support up to 8 physical functions and up to 65,536 virtual
72+
functions. To uniquely identify each child device, a device ID is defined
73+
as
74+
- Bits [2:0] for the function number (func)
75+
- Bits [18:3] for the virtual function index (vfunc)
76+
77+
The resulting device ID is computed as:
78+
79+
(func & 0x7) | (vfunc << 3)
80+
81+
The property is an arbitrary number of tuples of
82+
(device-id-base, msi, msi-base,length).
83+
84+
Any Device ID id in the interval [id-base, id-base + length) is
85+
associated with the listed MSI, with the MSI specifier
86+
(id - id-base + msi-base).
87+
$ref: /schemas/types.yaml#/definitions/uint32-matrix
88+
items:
89+
items:
90+
- description: The Device ID base matched by the entry
91+
maximum: 0x7ffff
92+
- description: phandle to msi-controller node
93+
- description: (optional) The msi-specifier produced for the first
94+
Device ID matched by the entry. Currently, msi-specifier is 0 or
95+
1 cells.
96+
- description: The length of consecutive Device IDs following the
97+
Device ID base
98+
maximum: 0x80000
99+
100+
msi-map-mask:
101+
description: A mask to be applied to each Device ID prior to being
102+
mapped to an msi-specifier per the msi-map property.
103+
$ref: /schemas/types.yaml#/definitions/uint32
104+
maximum: 0x7ffff
105+
38106
num-lanes:
39107
description: maximum number of lanes
40108
$ref: /schemas/types.yaml#/definitions/uint32

drivers/base/platform-msi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,6 @@ EXPORT_SYMBOL_GPL(platform_device_msi_init_and_alloc_irqs);
9595
void platform_device_msi_free_irqs_all(struct device *dev)
9696
{
9797
msi_domain_free_irqs_all(dev, MSI_DEFAULT_DOMAIN);
98+
msi_remove_device_irq_domain(dev, MSI_DEFAULT_DOMAIN);
9899
}
99100
EXPORT_SYMBOL_GPL(platform_device_msi_free_irqs_all);

drivers/irqchip/irq-gic-v3-its-msi-parent.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *dev,
118118
index++;
119119
} while (!ret);
120120

121+
if (ret) {
122+
struct device_node *np = NULL;
123+
124+
ret = of_map_id(dev->of_node, dev->id, "msi-map", "msi-map-mask", &np, dev_id);
125+
if (np)
126+
of_node_put(np);
127+
}
128+
121129
return ret;
122130
}
123131

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5140,7 +5140,7 @@ static int its_init_domain(struct its_node *its)
51405140
irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
51415141

51425142
inner_domain->msi_parent_ops = &gic_v3_its_msi_parent_ops;
5143-
inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
5143+
inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT | IRQ_DOMAIN_FLAG_MSI_IMMUTABLE;
51445144

51455145
return 0;
51465146
}

include/linux/irqdomain.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ enum {
231231
/* Irq domain must destroy generic chips when removed */
232232
IRQ_DOMAIN_FLAG_DESTROY_GC = (1 << 10),
233233

234+
/* Address and data pair is mutable when irq_set_affinity() */
235+
IRQ_DOMAIN_FLAG_MSI_IMMUTABLE = (1 << 11),
236+
234237
/*
235238
* Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved
236239
* for implementation specific purposes and ignored by the
@@ -693,6 +696,10 @@ static inline bool irq_domain_is_msi_device(struct irq_domain *domain)
693696
return domain->flags & IRQ_DOMAIN_FLAG_MSI_DEVICE;
694697
}
695698

699+
static inline bool irq_domain_is_msi_immutable(struct irq_domain *domain)
700+
{
701+
return domain->flags & IRQ_DOMAIN_FLAG_MSI_IMMUTABLE;
702+
}
696703
#else /* CONFIG_IRQ_DOMAIN_HIERARCHY */
697704
static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
698705
unsigned int nr_irqs, int node, void *arg)

0 commit comments

Comments
 (0)