From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: "Marek Behún" <kabel@kernel.org>
Cc: "Bartosz Golaszewski" <brgl@bgdev.pl>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Arnd Bergmann" <arnd@arndb.de>,
soc@kernel.org, arm@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: Thu, 6 Jun 2024 13:11:09 +0300 [thread overview]
Message-ID: <ZmGLPW6vUqOFEK4j@smile.fi.intel.com> (raw)
In-Reply-To: <20240606105308.3e02cf1e@dellmb>
On Thu, Jun 06, 2024 at 10:53:08AM +0200, Marek Behún wrote:
> On Wed, 5 Jun 2024 22:00:20 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
> > > + 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.
>
> Note that I can't use gpiochip_request_own_desc(), nor any other
> function that calls gpio_request_commit() (like gpiod_get()), because
> that checks for gpiochip_line_is_valid(), and this returns false for
> the TRNG line, cause that line is not a GPIO line, but interrupt only
> line.
>
> That is why I used
> irq = irq_create_mapping(dev, mcu->gc.irq.domain, irq_idx);
> until v7, with no reference to gpio descriptors, since this line is not
> a GPIO line.
>
> We have discussed this back in April, in the thread
> https://lore.kernel.org/soc/20240418121116.22184-8-kabel@kernel.org/
> where we concluded that
> irq = gpiod_to_irq(gpiochip_get_desc(gc, irq_idx));
> is better...
That's fine to not use other APIs, the problem here is with reference counting
on the GPIO device. The API you could use is gpio_device_get_desc(). But you
need to have a GPIO device pointer somewhere in your driver being available.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-06-06 10:11 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 [this message]
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
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=ZmGLPW6vUqOFEK4j@smile.fi.intel.com \
--to=andy.shevchenko@gmail.com \
--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=kabel@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).