From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Bartosz Golaszewski" <brgl@bgdev.pl>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Arnd Bergmann" <arnd@arndb.de>,
soc@kernel.org, arm@kernel.org,
"Andy Shevchenko" <andy@kernel.org>,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Olivia Mackall" <olivia@selenic.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-crypto@vger.kernel.org
Subject: Re: [PATCH v11 6/8] platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG
Date: Mon, 17 Jun 2024 13:34:00 +0200 [thread overview]
Message-ID: <20240617133400.3e4d2910@dellmb> (raw)
In-Reply-To: <CAHp75VcMzZnKi6WUoiSgky5fsvt77FuPr6XZ+X=AD+i_2JzP3Q@mail.gmail.com>
On Mon, 17 Jun 2024 12:42:41 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Mon, Jun 17, 2024 at 11:07 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > On Mon, Jun 17, 2024 at 10:56 AM Marek Behún <kabel@kernel.org> wrote:
> > > On Mon, 17 Jun 2024 10:38:31 +0200
> > > Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > > > On Wed, Jun 5, 2024 at 9:00 PM Andy Shevchenko
> > > > <andy.shevchenko@gmail.com> wrote:
> > > > > On Wed, Jun 5, 2024 at 7:19 PM Marek Behún <kabel@kernel.org> wrote:
> > > > > >
> > > > > > Add support for true random number generator provided by the MCU.
> > > > > > New Omnia boards come without the Atmel SHA204-A chip. Instead the
> > > > > > crypto functionality is provided by new microcontroller, which has
> > > > > > a TRNG peripheral.
> > > > >
> > > > > +Cc: Bart for gpiochip_get_desc() usage.
>
> ...
>
> > > > > > + irq_idx = omnia_int_to_gpio_idx[__bf_shf(OMNIA_INT_TRNG)];
> > > > > > + irq = gpiod_to_irq(gpiochip_get_desc(&mcu->gc, irq_idx));
> > > > > > + if (irq < 0)
> > > > > > + return dev_err_probe(dev, irq, "Cannot get TRNG IRQ\n");
> > > > >
> > > > > Okay, it's a bit more complicated than that. The gpiochip_get_desc()
> > > > > shouldn't be used. Bart, what can you suggest to do here? Opencoding
> > > > > it doesn't sound to me a (fully) correct approach in a long term.
> > > >
> > > > Andy's worried about reference counting of the GPIO device. Maybe you
> > > > should just ref the GPIO device in irq_request_resources() and unref
> > > > it in irq_release_resources()? Then you could use gpiochip_get_desc()
> > > > just fine.
> > >
> > > But this is already being done.
> > >
> > > The irqchip uses GPIOCHIP_IRQ_RESOURCE_HELPERS macro in its definition:
> > >
> > > static const struct irq_chip omnia_mcu_irq_chip = {
> > > ...
> > > GPIOCHIP_IRQ_RESOURCE_HELPERS,
> > > };
> > >
> > > This means that gpiochip_irq_reqres() and gpiochip_irq_relres() are
> > > used as irq_request_resources() and irq_release_resources().
> > >
> > > The gpiochip_reqres_irq() code increases the module refcount and even
> > > locks the line as IRQ:
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpio/gpiolib.c?h=v6.10-rc4#n3732
> >
> > Andy: what is the issue here then exactly?
>
> The function in use is marked as DEPRECATED. If you are fine with its
> usage in this case, I have no issues with it.
> If you want it to be replaced with the respective
> gpio_device_get_desc(), it's fine, but then the question is how
> properly get a pointer to GPIO device object.
>
Aha, I did not notice that the function is deprecated.
What about
irq = gpiod_to_irq(gpio_device_get_desc(mcu->gc.gpiodev, irq_idx));
?
Note: I would prefer
irq_create_mapping(mcu->gc.irq.domain, irq_idx)
since the irq_idx line is not a valid GPIO line and at this part of
the driver the fact that the IRQs are provided through a gpiochip are
semantically irrelevant (we are interested in "an IRQ", not "an IRQ from
a GPIO").
Marek
next prev parent reply other threads:[~2024-06-17 11:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 16:18 [PATCH v11 0/8] Turris Omnia MCU driver Marek Behún
2024-06-05 16:18 ` [PATCH v11 6/8] platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG Marek Behún
2024-06-05 19:00 ` Andy Shevchenko
2024-06-06 8:53 ` Marek Behún
2024-06-06 10:11 ` Andy Shevchenko
2024-06-06 12:37 ` Marek Behún
2024-06-06 9:11 ` Marek Behún
2024-06-06 9:35 ` Andy Shevchenko
2024-06-17 8:38 ` Bartosz Golaszewski
2024-06-17 8:56 ` Marek Behún
2024-06-17 9:07 ` Bartosz Golaszewski
2024-06-17 10:42 ` Andy Shevchenko
2024-06-17 11:34 ` Marek Behún [this message]
2024-06-17 13:35 ` Bartosz Golaszewski
2024-06-07 10:30 ` Herbert Xu
2024-06-07 16:15 ` Marek Behún
2024-06-05 19:05 ` [PATCH v11 0/8] Turris Omnia MCU driver Andy Shevchenko
2024-06-06 7:25 ` Marek Behún
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=20240617133400.3e4d2910@dellmb \
--to=kabel@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=arm@kernel.org \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=hdegoede@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-crypto@vger.kernel.org \
--cc=olivia@selenic.com \
--cc=soc@kernel.org \
/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