Skip to content

Commit ce44d1f

Browse files
committed
irqchip/irq-mvebu-icu: Remove platform MSI leftovers
All related domains provide MSI parent functionality, so the fallback code to the original platform MSI implementation is not longer required. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Anna-Maria Behnsen <[email protected]> Signed-off-by: Shivamurthy Shastri <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fbdf14e commit ce44d1f

File tree

1 file changed

+6
-206
lines changed

1 file changed

+6
-206
lines changed

drivers/irqchip/irq-mvebu-icu.c

Lines changed: 6 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -129,196 +129,6 @@ static void mvebu_icu_init(struct mvebu_icu *icu,
129129
writel_relaxed(msg[1].address_lo, icu->base + subset->offset_clr_al);
130130
}
131131

132-
/* Start of area to be removed once all parent chips provide MSI parent */
133-
134-
struct mvebu_icu_irq_data {
135-
struct mvebu_icu *icu;
136-
unsigned int icu_group;
137-
unsigned int type;
138-
};
139-
140-
static void mvebu_icu_write_msg(struct msi_desc *desc, struct msi_msg *msg)
141-
{
142-
struct irq_data *d = irq_get_irq_data(desc->irq);
143-
struct mvebu_icu_msi_data *msi_data = platform_msi_get_host_data(d->domain);
144-
struct mvebu_icu_irq_data *icu_irqd = d->chip_data;
145-
struct mvebu_icu *icu = icu_irqd->icu;
146-
unsigned int icu_int;
147-
148-
if (msg->address_lo || msg->address_hi) {
149-
/* One off initialization per domain */
150-
mvebu_icu_init(icu, msi_data, msg);
151-
/* Configure the ICU with irq number & type */
152-
icu_int = msg->data | ICU_INT_ENABLE;
153-
if (icu_irqd->type & IRQ_TYPE_EDGE_RISING)
154-
icu_int |= ICU_IS_EDGE;
155-
icu_int |= icu_irqd->icu_group << ICU_GROUP_SHIFT;
156-
} else {
157-
/* De-configure the ICU */
158-
icu_int = 0;
159-
}
160-
161-
writel_relaxed(icu_int, icu->base + ICU_INT_CFG(d->hwirq));
162-
163-
/*
164-
* The SATA unit has 2 ports, and a dedicated ICU entry per
165-
* port. The ahci sata driver supports only one irq interrupt
166-
* per SATA unit. To solve this conflict, we configure the 2
167-
* SATA wired interrupts in the south bridge into 1 GIC
168-
* interrupt in the north bridge. Even if only a single port
169-
* is enabled, if sata node is enabled, both interrupts are
170-
* configured (regardless of which port is actually in use).
171-
*/
172-
if (d->hwirq == ICU_SATA0_ICU_ID || d->hwirq == ICU_SATA1_ICU_ID) {
173-
writel_relaxed(icu_int,
174-
icu->base + ICU_INT_CFG(ICU_SATA0_ICU_ID));
175-
writel_relaxed(icu_int,
176-
icu->base + ICU_INT_CFG(ICU_SATA1_ICU_ID));
177-
}
178-
}
179-
180-
static struct irq_chip mvebu_icu_nsr_chip = {
181-
.name = "ICU-NSR",
182-
.irq_mask = irq_chip_mask_parent,
183-
.irq_unmask = irq_chip_unmask_parent,
184-
.irq_eoi = irq_chip_eoi_parent,
185-
.irq_set_type = irq_chip_set_type_parent,
186-
.irq_set_affinity = irq_chip_set_affinity_parent,
187-
};
188-
189-
static struct irq_chip mvebu_icu_sei_chip = {
190-
.name = "ICU-SEI",
191-
.irq_ack = irq_chip_ack_parent,
192-
.irq_mask = irq_chip_mask_parent,
193-
.irq_unmask = irq_chip_unmask_parent,
194-
.irq_set_type = irq_chip_set_type_parent,
195-
.irq_set_affinity = irq_chip_set_affinity_parent,
196-
};
197-
198-
static int
199-
mvebu_icu_irq_domain_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
200-
unsigned long *hwirq, unsigned int *type)
201-
{
202-
unsigned int param_count = static_branch_unlikely(&legacy_bindings) ? 3 : 2;
203-
struct mvebu_icu_msi_data *msi_data = platform_msi_get_host_data(d);
204-
struct mvebu_icu *icu = msi_data->icu;
205-
206-
/* Check the count of the parameters in dt */
207-
if (WARN_ON(fwspec->param_count != param_count)) {
208-
dev_err(icu->dev, "wrong ICU parameter count %d\n",
209-
fwspec->param_count);
210-
return -EINVAL;
211-
}
212-
213-
if (static_branch_unlikely(&legacy_bindings)) {
214-
*hwirq = fwspec->param[1];
215-
*type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK;
216-
if (fwspec->param[0] != ICU_GRP_NSR) {
217-
dev_err(icu->dev, "wrong ICU group type %x\n",
218-
fwspec->param[0]);
219-
return -EINVAL;
220-
}
221-
} else {
222-
*hwirq = fwspec->param[0];
223-
*type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK;
224-
225-
/*
226-
* The ICU receives level interrupts. While the NSR are also
227-
* level interrupts, SEI are edge interrupts. Force the type
228-
* here in this case. Please note that this makes the interrupt
229-
* handling unreliable.
230-
*/
231-
if (msi_data->subset_data->icu_group == ICU_GRP_SEI)
232-
*type = IRQ_TYPE_EDGE_RISING;
233-
}
234-
235-
if (*hwirq >= ICU_MAX_IRQS) {
236-
dev_err(icu->dev, "invalid interrupt number %ld\n", *hwirq);
237-
return -EINVAL;
238-
}
239-
240-
return 0;
241-
}
242-
243-
static int
244-
mvebu_icu_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
245-
unsigned int nr_irqs, void *args)
246-
{
247-
int err;
248-
unsigned long hwirq;
249-
struct irq_fwspec *fwspec = args;
250-
struct mvebu_icu_msi_data *msi_data = platform_msi_get_host_data(domain);
251-
struct mvebu_icu *icu = msi_data->icu;
252-
struct mvebu_icu_irq_data *icu_irqd;
253-
struct irq_chip *chip = &mvebu_icu_nsr_chip;
254-
255-
icu_irqd = kmalloc(sizeof(*icu_irqd), GFP_KERNEL);
256-
if (!icu_irqd)
257-
return -ENOMEM;
258-
259-
err = mvebu_icu_irq_domain_translate(domain, fwspec, &hwirq,
260-
&icu_irqd->type);
261-
if (err) {
262-
dev_err(icu->dev, "failed to translate ICU parameters\n");
263-
goto free_irqd;
264-
}
265-
266-
if (static_branch_unlikely(&legacy_bindings))
267-
icu_irqd->icu_group = fwspec->param[0];
268-
else
269-
icu_irqd->icu_group = msi_data->subset_data->icu_group;
270-
icu_irqd->icu = icu;
271-
272-
err = platform_msi_device_domain_alloc(domain, virq, nr_irqs);
273-
if (err) {
274-
dev_err(icu->dev, "failed to allocate ICU interrupt in parent domain\n");
275-
goto free_irqd;
276-
}
277-
278-
/* Make sure there is no interrupt left pending by the firmware */
279-
err = irq_set_irqchip_state(virq, IRQCHIP_STATE_PENDING, false);
280-
if (err)
281-
goto free_msi;
282-
283-
if (icu_irqd->icu_group == ICU_GRP_SEI)
284-
chip = &mvebu_icu_sei_chip;
285-
286-
err = irq_domain_set_hwirq_and_chip(domain, virq, hwirq,
287-
chip, icu_irqd);
288-
if (err) {
289-
dev_err(icu->dev, "failed to set the data to IRQ domain\n");
290-
goto free_msi;
291-
}
292-
293-
return 0;
294-
295-
free_msi:
296-
platform_msi_device_domain_free(domain, virq, nr_irqs);
297-
free_irqd:
298-
kfree(icu_irqd);
299-
return err;
300-
}
301-
302-
static void
303-
mvebu_icu_irq_domain_free(struct irq_domain *domain, unsigned int virq,
304-
unsigned int nr_irqs)
305-
{
306-
struct irq_data *d = irq_get_irq_data(virq);
307-
struct mvebu_icu_irq_data *icu_irqd = d->chip_data;
308-
309-
kfree(icu_irqd);
310-
311-
platform_msi_device_domain_free(domain, virq, nr_irqs);
312-
}
313-
314-
static const struct irq_domain_ops mvebu_icu_domain_ops = {
315-
.translate = mvebu_icu_irq_domain_translate,
316-
.alloc = mvebu_icu_irq_domain_alloc,
317-
.free = mvebu_icu_irq_domain_free,
318-
};
319-
320-
/* End of removal area */
321-
322132
static int mvebu_icu_msi_init(struct irq_domain *domain, struct msi_domain_info *info,
323133
unsigned int virq, irq_hw_number_t hwirq, msi_alloc_info_t *arg)
324134
{
@@ -448,9 +258,10 @@ static const struct of_device_id mvebu_icu_subset_of_match[] = {
448258

449259
static int mvebu_icu_subset_probe(struct platform_device *pdev)
450260
{
261+
const struct msi_domain_template *tmpl;
451262
struct mvebu_icu_msi_data *msi_data;
452263
struct device *dev = &pdev->dev;
453-
struct irq_domain *irq_domain;
264+
bool sei;
454265

455266
msi_data = devm_kzalloc(dev, sizeof(*msi_data), GFP_KERNEL);
456267
if (!msi_data)
@@ -471,22 +282,11 @@ static int mvebu_icu_subset_probe(struct platform_device *pdev)
471282
if (!irq_domain_get_of_node(dev->msi.domain))
472283
return -ENODEV;
473284

474-
if (irq_domain_is_msi_parent(dev->msi.domain)) {
475-
bool sei = msi_data->subset_data->icu_group == ICU_GRP_SEI;
476-
const struct msi_domain_template *tmpl;
477-
478-
tmpl = sei ? &mvebu_icu_sei_msi_template : &mvebu_icu_nsr_msi_template;
479-
480-
if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, tmpl,
481-
ICU_MAX_IRQS, NULL, msi_data))
482-
return -ENOMEM;
483-
}
285+
sei = msi_data->subset_data->icu_group == ICU_GRP_SEI;
286+
tmpl = sei ? &mvebu_icu_sei_msi_template : &mvebu_icu_nsr_msi_template;
484287

485-
irq_domain = platform_msi_create_device_tree_domain(dev, ICU_MAX_IRQS,
486-
mvebu_icu_write_msg,
487-
&mvebu_icu_domain_ops,
488-
msi_data);
489-
if (!irq_domain) {
288+
if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, tmpl,
289+
ICU_MAX_IRQS, NULL, msi_data)) {
490290
dev_err(dev, "Failed to create ICU MSI domain\n");
491291
return -ENOMEM;
492292
}

0 commit comments

Comments
 (0)