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.
Unified · Split
| @@ -210,10 +210,10 @@ platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec, · 209 unmodified lines | ||
| 210 | 210 | * accordingly (which would impact the max number of MSI |
| 211 | 211 | * capable devices). |
| 212 | 212 | */ |
| 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) | |
| 214 | 214 | return ERR_PTR(-EINVAL); |
| 215 | 215 | |
| 216 | − if (dev->msi_domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) { | |
| 216 | + if (dev->msi.domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) { | |
| 217 | 217 | dev_err(dev, "Incompatible msi_domain, giving up\n"); |
| 218 | 218 | return ERR_PTR(-EINVAL); |
| 219 | 219 | } |
| @@ -269,7 +269,7 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, · 49 unmodified lines | ||
| 269 | 269 | if (err) |
| 270 | 270 | goto out_free_priv_data; |
| 271 | 271 | |
| 272 | − err = msi_domain_alloc_irqs(dev->msi_domain, dev, nvec); | |
| 272 | + err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec); | |
| 273 | 273 | if (err) |
| 274 | 274 | goto out_free_desc; |
| 275 | 275 | |
| @@ -282,7 +282,7 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, · 6 unmodified lines | ||
| 282 | 282 | return 0; |
| 283 | 283 | |
| 284 | 284 | out_free_irqs: |
| 285 | − msi_domain_free_irqs(dev->msi_domain, dev); | |
| 285 | + msi_domain_free_irqs(dev->msi.domain, dev); | |
| 286 | 286 | out_free_desc: |
| 287 | 287 | platform_msi_free_descs(dev, 0, nvec); |
| 288 | 288 | out_free_priv_data: |
| @@ -306,7 +306,7 @@ void platform_msi_domain_free_irqs(struct device *dev) · 17 unmodified lines | ||
| 306 | 306 | platform_msi_free_priv_data(desc->platform.msi_priv_data); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | − msi_domain_free_irqs(dev->msi_domain, dev); | |
| 309 | + msi_domain_free_irqs(dev->msi.domain, dev); | |
| 310 | 310 | platform_msi_free_descs(dev, 0, MAX_DEV_MSIS); |
| 311 | 311 | } |
| 312 | 312 | EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs); |
| @@ -354,7 +354,7 @@ __platform_msi_create_device_domain(struct device *dev, · 41 unmodified lines | ||
| 354 | 354 | return NULL; |
| 355 | 355 | |
| 356 | 356 | 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, | |
| 358 | 358 | is_tree ? 0 : nvec, |
| 359 | 359 | dev->fwnode, ops, data); |
| 360 | 360 | if (!domain) |
| @@ -5279,9 +5279,9 @@ static int udma_probe(struct platform_device *pdev) · 5278 unmodified lines | ||
| 5279 | 5279 | if (IS_ERR(ud->ringacc)) |
| 5280 | 5280 | return PTR_ERR(ud->ringacc); |
| 5281 | 5281 | |
| 5282 | − dev->msi_domain = of_msi_get_domain(dev, dev->of_node, | |
| 5282 | + dev->msi.domain = of_msi_get_domain(dev, dev->of_node, | |
| 5283 | 5283 | DOMAIN_BUS_TI_SCI_INTA_MSI); |
| 5284 | − if (!dev->msi_domain) { | |
| 5284 | + if (!dev->msi.domain) { | |
| 5285 | 5285 | dev_err(dev, "Failed to get MSI domain\n"); |
| 5286 | 5286 | return -EPROBE_DEFER; |
| 5287 | 5287 | } |
| @@ -3170,7 +3170,7 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu) · 3169 unmodified lines | ||
| 3170 | 3170 | if (!(smmu->features & ARM_SMMU_FEAT_MSI)) |
| 3171 | 3171 | return; |
| 3172 | 3172 | |
| 3173 | − if (!dev->msi_domain) { | |
| 3173 | + if (!dev->msi.domain) { | |
| 3174 | 3174 | dev_info(smmu->dev, "msi_domain absent - falling back to wired irqs\n"); |
| 3175 | 3175 | return; |
| 3176 | 3176 | } |
| @@ -314,12 +314,12 @@ static int mvebu_icu_subset_probe(struct platform_device *pdev) · 313 unmodified lines | ||
| 314 | 314 | msi_data->subset_data = of_device_get_match_data(dev); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | − dev->msi_domain = of_msi_get_domain(dev, dev->of_node, | |
| 317 | + dev->msi.domain = of_msi_get_domain(dev, dev->of_node, | |
| 318 | 318 | DOMAIN_BUS_PLATFORM_MSI); |
| 319 | − if (!dev->msi_domain) | |
| 319 | + if (!dev->msi.domain) | |
| 320 | 320 | return -EPROBE_DEFER; |
| 321 | 321 | |
| 322 | − msi_parent_dn = irq_domain_get_of_node(dev->msi_domain); | |
| 322 | + msi_parent_dn = irq_domain_get_of_node(dev->msi.domain); | |
| 323 | 323 | if (!msi_parent_dn) |
| 324 | 324 | return -ENODEV; |
| 325 | 325 | |
| @@ -1356,9 +1356,9 @@ static int k3_ringacc_init(struct platform_device *pdev, · 1355 unmodified lines | ||
| 1356 | 1356 | struct resource *res; |
| 1357 | 1357 | int ret, i; |
| 1358 | 1358 | |
| 1359 | − dev->msi_domain = of_msi_get_domain(dev, dev->of_node, | |
| 1359 | + dev->msi.domain = of_msi_get_domain(dev, dev->of_node, | |
| 1360 | 1360 | DOMAIN_BUS_TI_SCI_INTA_MSI); |
| 1361 | − if (!dev->msi_domain) { | |
| 1361 | + if (!dev->msi.domain) { | |
| 1362 | 1362 | dev_err(dev, "Failed to get MSI domain\n"); |
| 1363 | 1363 | return -EPROBE_DEFER; |
| 1364 | 1364 | } |
| @@ -140,7 +140,7 @@ EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain_alloc_irqs); · 139 unmodified lines | ||
| 140 | 140 | |
| 141 | 141 | void ti_sci_inta_msi_domain_free_irqs(struct device *dev) |
| 142 | 142 | { |
| 143 | − msi_domain_free_irqs(dev->msi_domain, dev); | |
| 143 | + msi_domain_free_irqs(dev->msi.domain, dev); | |
| 144 | 144 | ti_sci_inta_msi_free_descs(dev); |
| 145 | 145 | } |
| 146 | 146 | EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain_free_irqs); |
| @@ -371,6 +371,16 @@ struct dev_links_info { · 370 unmodified lines | ||
| 371 | 371 | enum dl_dev_state status; |
| 372 | 372 | }; |
| 373 | 373 | |
| 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 | + | |
| 374 | 384 | /** |
| 375 | 385 | * struct device - The basic device structure |
| 376 | 386 | * @parent: The device's "parent" device, the device to which it is attached. |
| @@ -407,8 +417,8 @@ struct dev_links_info { · 30 unmodified lines | ||
| 407 | 417 | * @em_pd: device's energy model performance domain |
| 408 | 418 | * @pins: For device pin management. |
| 409 | 419 | * See Documentation/driver-api/pin-control.rst for details. |
| 420 | + * @msi: MSI related data | |
| 410 | 421 | * @msi_list: Hosts MSI descriptors |
| 411 | − * @msi_domain: The generic MSI domain this device is using. | |
| 412 | 422 | * @numa_node: NUMA node this device is close to. |
| 413 | 423 | * @dma_ops: DMA mapping operations for this device. |
| 414 | 424 | * @dma_mask: Dma mask (if dma'ble device). |
| @@ -500,12 +510,10 @@ struct device { · 85 unmodified lines | ||
| 500 | 510 | struct em_perf_domain *em_pd; |
| 501 | 511 | #endif |
| 502 | 512 | |
| 503 | −#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN | |
| 504 | − struct irq_domain *msi_domain; | |
| 505 | −#endif | |
| 506 | 513 | #ifdef CONFIG_PINCTRL |
| 507 | 514 | struct dev_pin_info *pins; |
| 508 | 515 | #endif |
| 516 | + struct dev_msi_info msi; | |
| 509 | 517 | #ifdef CONFIG_GENERIC_MSI_IRQ |
| 510 | 518 | struct list_head msi_list; |
| 511 | 519 | #endif |
| @@ -666,7 +674,7 @@ static inline void set_dev_node(struct device *dev, int node) · 154 unmodified lines | ||
| 666 | 674 | static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) |
| 667 | 675 | { |
| 668 | 676 | #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN |
| 669 | − return dev->msi_domain; | |
| 677 | + return dev->msi.domain; | |
| 670 | 678 | #else |
| 671 | 679 | return NULL; |
| 672 | 680 | #endif |
| @@ -675,7 +683,7 @@ static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) · 2 unmodified lines | ||
| 675 | 683 | static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) |
| 676 | 684 | { |
| 677 | 685 | #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN |
| 678 | − dev->msi_domain = d; | |
| 686 | + dev->msi.domain = d; | |
| 679 | 687 | #endif |
| 680 | 688 | } |
| 681 | 689 | |