linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: <lewis.hanly@microchip.com>
Cc: <linux-gpio@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
	<linus.walleij@linaro.org>, <brgl@bgdev.pl>,
	<linux-kernel@vger.kernel.org>, <palmer@dabbelt.com>,
	<conor.dooley@microchip.com>, <daire.mcnamara@microchip.com>
Subject: Re: [PATCH v3 1/1] gpio: mpfs: add polarfire soc gpio support
Date: Sat, 16 Jul 2022 11:33:08 +0100	[thread overview]
Message-ID: <87r12l4aaj.wl-maz@kernel.org> (raw)
In-Reply-To: <20220716071113.1646887-2-lewis.hanly@microchip.com>

On Sat, 16 Jul 2022 08:11:13 +0100,
<lewis.hanly@microchip.com> wrote:
> 
> From: Lewis Hanly <lewis.hanly@microchip.com>
> 
> Add a driver to support the Polarfire SoC gpio controller.
> 
> Signed-off-by: Lewis Hanly <lewis.hanly@microchip.com>

[...]

> +static int mpfs_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
> +					   unsigned int child,
> +					   unsigned int child_type,
> +					   unsigned int *parent,
> +					   unsigned int *parent_type)
> +{
> +	struct mpfs_gpio_chip *mpfs_gpio = gpiochip_get_data(gc);
> +	struct irq_data *d = irq_get_irq_data(mpfs_gpio->irq_number[child]);

This looks totally wrong. It means that you have already instantiated
part of the hierarchy, and it is likely that you will get multiple
hierarchy sharing some levels, which isn't intended.

> +	*parent_type = IRQ_TYPE_NONE;
> +	*parent = irqd_to_hwirq(d);
> +
> +	return 0;
> +}
> +
> +static int mpfs_gpio_probe(struct platform_device *pdev)
> +{
> +	struct clk *clk;
> +	struct device *dev = &pdev->dev;
> +	struct device_node *node = pdev->dev.of_node;
> +	struct device_node *irq_parent;
> +	struct gpio_irq_chip *girq;
> +	struct irq_domain *parent;
> +	struct mpfs_gpio_chip *mpfs_gpio;
> +	int i, ret, ngpio;
> +
> +	mpfs_gpio = devm_kzalloc(dev, sizeof(*mpfs_gpio), GFP_KERNEL);
> +	if (!mpfs_gpio)
> +		return -ENOMEM;
> +
> +	mpfs_gpio->base = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(mpfs_gpio->base))
> +		return dev_err_probe(dev, PTR_ERR(mpfs_gpio->clk), "input clock not found.\n");
> +
> +	clk = devm_clk_get(dev, NULL);
> +	if (IS_ERR(clk))
> +		return dev_err_probe(dev, PTR_ERR(clk), "devm_clk_get failed\n");
> +
> +	ret = clk_prepare_enable(clk);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to enable clock\n");
> +
> +	mpfs_gpio->clk = clk;
> +
> +	ngpio = of_irq_count(node);
> +	if (ngpio > NUM_GPIO) {
> +		ret = -ENXIO;
> +		goto cleanup_clock;
> +	}
> +
> +	irq_parent = of_irq_find_parent(node);
> +	if (!irq_parent) {
> +		ret = -ENODEV;
> +		goto cleanup_clock;
> +	}
> +	parent = irq_find_host(irq_parent);
> +	if (!parent) {
> +		ret = -ENODEV;
> +		goto cleanup_clock;
> +	}
> +
> +	/* Get the interrupt numbers. */
> +	/* Clear/Disable All interrupts before enabling parent interrupts. */
> +	for (i = 0; i < ngpio; i++) {
> +		mpfs_gpio->irq_number[i] = platform_get_irq(pdev, i);

Bingo. You are allocating the interrupt for the level below. You
really shouldn't do that.

If you need to retrieve the *hwirq* for the level below, you need to
parse the DT without triggering an IRQ allocation (of_irq_parse_one()
and co).

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2022-07-16 10:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-16  7:11 [PATCH v3 0/1] Add Polarfire SoC GPIO support lewis.hanly
2022-07-16  7:11 ` [PATCH v3 1/1] gpio: mpfs: add polarfire soc gpio support lewis.hanly
2022-07-16 10:33   ` Marc Zyngier [this message]
2022-07-16 15:21     ` Lewis.Hanly
2022-07-16 17:52       ` Marc Zyngier
2022-07-16 18:32         ` Conor.Dooley
2022-07-17 15:10           ` Marc Zyngier
2022-07-17 15:46             ` Conor.Dooley
2022-07-31  8:56     ` Lewis.Hanly
2022-07-16 10:44   ` Marc Zyngier
2022-07-16 12:17     ` Lewis.Hanly
2022-07-16 12:20     ` Conor.Dooley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r12l4aaj.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=conor.dooley@microchip.com \
    --cc=daire.mcnamara@microchip.com \
    --cc=lewis.hanly@microchip.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).