History

device: Move MSI related data into a struct

The only unconditional part of MSI data in struct device is the irqdomain pointer. Everything else can be allocated on demand. Create a data structure and move the irqdomain pointer into it. The other MSI specific parts are going to be removed from struct device in later steps.

Thomas Gleixner committed 4 years ago

Commit 34fff621 parent ed1533b7 files · +29 −21Browse files

Unified · Split

7 files
  1. drivers/base/platform-msi.c +6 −6
  2. drivers/dma/ti/k3-udma.c +2 −2
  3. drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +1 −1
  4. drivers/irqchip/irq-mvebu-icu.c +3 −3
  5. drivers/soc/ti/k3-ringacc.c +2 −2
  6. drivers/soc/ti/ti_sci_inta_msi.c +1 −1
  7. include/linux/device.h +14 −6
drivers/base/platform-msi.c+6−6
@@ -210,10 +210,10 @@ platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec, · 209 unmodified lines
210210 * accordingly (which would impact the max number of MSI
211211 * capable devices).
212212 */
213− if (!dev->msi_domain || !write_msi_msg || !nvec || nvec > MAX_DEV_MSIS)
213+ if (!dev->msi.domain || !write_msi_msg || !nvec || nvec > MAX_DEV_MSIS)
214214 return ERR_PTR(-EINVAL);
215215
216− if (dev->msi_domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) {
216+ if (dev->msi.domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) {
217217 dev_err(dev, "Incompatible msi_domain, giving up\n");
218218 return ERR_PTR(-EINVAL);
219219 }
@@ -269,7 +269,7 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, · 49 unmodified lines
269269 if (err)
270270 goto out_free_priv_data;
271271
272− err = msi_domain_alloc_irqs(dev->msi_domain, dev, nvec);
272+ err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec);
273273 if (err)
274274 goto out_free_desc;
275275
@@ -282,7 +282,7 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, · 6 unmodified lines
282282 return 0;
283283
284284 out_free_irqs:
285− msi_domain_free_irqs(dev->msi_domain, dev);
285+ msi_domain_free_irqs(dev->msi.domain, dev);
286286 out_free_desc:
287287 platform_msi_free_descs(dev, 0, nvec);
288288 out_free_priv_data:
@@ -306,7 +306,7 @@ void platform_msi_domain_free_irqs(struct device *dev) · 17 unmodified lines
306306 platform_msi_free_priv_data(desc->platform.msi_priv_data);
307307 }
308308
309− msi_domain_free_irqs(dev->msi_domain, dev);
309+ msi_domain_free_irqs(dev->msi.domain, dev);
310310 platform_msi_free_descs(dev, 0, MAX_DEV_MSIS);
311311 }
312312 EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs);
@@ -354,7 +354,7 @@ __platform_msi_create_device_domain(struct device *dev, · 41 unmodified lines
354354 return NULL;
355355
356356 data->host_data = host_data;
357− domain = irq_domain_create_hierarchy(dev->msi_domain, 0,
357+ domain = irq_domain_create_hierarchy(dev->msi.domain, 0,
358358 is_tree ? 0 : nvec,
359359 dev->fwnode, ops, data);
360360 if (!domain)
drivers/dma/ti/k3-udma.c+2−2
@@ -5279,9 +5279,9 @@ static int udma_probe(struct platform_device *pdev) · 5278 unmodified lines
52795279 if (IS_ERR(ud->ringacc))
52805280 return PTR_ERR(ud->ringacc);
52815281
5282− dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
5282+ dev->msi.domain = of_msi_get_domain(dev, dev->of_node,
52835283 DOMAIN_BUS_TI_SCI_INTA_MSI);
5284− if (!dev->msi_domain) {
5284+ if (!dev->msi.domain) {
52855285 dev_err(dev, "Failed to get MSI domain\n");
52865286 return -EPROBE_DEFER;
52875287 }
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c+1−1
@@ -3170,7 +3170,7 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu) · 3169 unmodified lines
31703170 if (!(smmu->features & ARM_SMMU_FEAT_MSI))
31713171 return;
31723172
3173− if (!dev->msi_domain) {
3173+ if (!dev->msi.domain) {
31743174 dev_info(smmu->dev, "msi_domain absent - falling back to wired irqs\n");
31753175 return;
31763176 }
drivers/irqchip/irq-mvebu-icu.c+3−3
@@ -314,12 +314,12 @@ static int mvebu_icu_subset_probe(struct platform_device *pdev) · 313 unmodified lines
314314 msi_data->subset_data = of_device_get_match_data(dev);
315315 }
316316
317− dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
317+ dev->msi.domain = of_msi_get_domain(dev, dev->of_node,
318318 DOMAIN_BUS_PLATFORM_MSI);
319− if (!dev->msi_domain)
319+ if (!dev->msi.domain)
320320 return -EPROBE_DEFER;
321321
322− msi_parent_dn = irq_domain_get_of_node(dev->msi_domain);
322+ msi_parent_dn = irq_domain_get_of_node(dev->msi.domain);
323323 if (!msi_parent_dn)
324324 return -ENODEV;
325325
drivers/soc/ti/k3-ringacc.c+2−2
@@ -1356,9 +1356,9 @@ static int k3_ringacc_init(struct platform_device *pdev, · 1355 unmodified lines
13561356 struct resource *res;
13571357 int ret, i;
13581358
1359− dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
1359+ dev->msi.domain = of_msi_get_domain(dev, dev->of_node,
13601360 DOMAIN_BUS_TI_SCI_INTA_MSI);
1361− if (!dev->msi_domain) {
1361+ if (!dev->msi.domain) {
13621362 dev_err(dev, "Failed to get MSI domain\n");
13631363 return -EPROBE_DEFER;
13641364 }
drivers/soc/ti/ti_sci_inta_msi.c+1−1
@@ -140,7 +140,7 @@ EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain_alloc_irqs); · 139 unmodified lines
140140
141141 void ti_sci_inta_msi_domain_free_irqs(struct device *dev)
142142 {
143− msi_domain_free_irqs(dev->msi_domain, dev);
143+ msi_domain_free_irqs(dev->msi.domain, dev);
144144 ti_sci_inta_msi_free_descs(dev);
145145 }
146146 EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain_free_irqs);
include/linux/device.h+14−6
@@ -371,6 +371,16 @@ struct dev_links_info { · 370 unmodified lines
371371 enum dl_dev_state status;
372372 };
373373
374+/**
375+ * struct dev_msi_info - Device data related to MSI
376+ * @domain: The MSI interrupt domain associated to the device
377+ */
378+struct dev_msi_info {
379+#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
380+ struct irq_domain *domain;
381+#endif
382+};
383+
374384 /**
375385 * struct device - The basic device structure
376386 * @parent: The device's "parent" device, the device to which it is attached.
@@ -407,8 +417,8 @@ struct dev_links_info { · 30 unmodified lines
407417 * @em_pd: device's energy model performance domain
408418 * @pins: For device pin management.
409419 * See Documentation/driver-api/pin-control.rst for details.
420+ * @msi: MSI related data
410421 * @msi_list: Hosts MSI descriptors
411− * @msi_domain: The generic MSI domain this device is using.
412422 * @numa_node: NUMA node this device is close to.
413423 * @dma_ops: DMA mapping operations for this device.
414424 * @dma_mask: Dma mask (if dma'ble device).
@@ -500,12 +510,10 @@ struct device { · 85 unmodified lines
500510 struct em_perf_domain *em_pd;
501511 #endif
502512
503−#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
504− struct irq_domain *msi_domain;
505−#endif
506513 #ifdef CONFIG_PINCTRL
507514 struct dev_pin_info *pins;
508515 #endif
516+ struct dev_msi_info msi;
509517 #ifdef CONFIG_GENERIC_MSI_IRQ
510518 struct list_head msi_list;
511519 #endif
@@ -666,7 +674,7 @@ static inline void set_dev_node(struct device *dev, int node) · 154 unmodified lines
666674 static inline struct irq_domain *dev_get_msi_domain(const struct device *dev)
667675 {
668676 #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
669− return dev->msi_domain;
677+ return dev->msi.domain;
670678 #else
671679 return NULL;
672680 #endif
@@ -675,7 +683,7 @@ static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) · 2 unmodified lines
675683 static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d)
676684 {
677685 #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
678− dev->msi_domain = d;
686+ dev->msi.domain = d;
679687 #endif
680688 }
681689