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,
"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 14:37:12 +0200 [thread overview]
Message-ID: <20240606143712.6b834d7c@dellmb> (raw)
In-Reply-To: <ZmGLPW6vUqOFEK4j@smile.fi.intel.com>
On Thu, 6 Jun 2024 13:11:09 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> 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.
Rewriting to gpio_device_get_desc() is simple, since
gpiochip_get_desc(gc, hwnum)
is equivalent to
gpio_device_get_desc(gc->gpiodev, hwnum)
Obviously neither of these take care of reference counting. But what
reference counting are you talking about?
Is it the
try_module_get(desc->gdev->owner)
in gpiod_request()?
Or are we talking only about the FLAG_REQUESTED flag on the descriptor
flags? (This one should not be needed since the GPIO line cannot be
requested, becuase it is not a valid GPIO line.)
Since the line is not a valid GPIO line, I thought that we don't need
to refcount in GPIO code. gpiod_to_irq() will call the gpiochip's
.to_irq() method, which will call gpiochip_to_irq(), which will call
irq_create_mapping()
gpiod_to_irq()
gpiochip_to_irq()
irq_create_mapping()
Then on gpiochip removal, the gpiochip_irqchip_remove() manually
disposes all IRQ mappings with irq_dispose_mapping().
Marek
next prev parent reply other threads:[~2024-06-06 12:37 UTC|newest]
Thread overview: 31+ 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 1/8] dt-bindings: firmware: add cznic,turris-omnia-mcu binding Marek Behún
2024-06-05 16:18 ` [PATCH v11 2/8] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2024-06-05 18:04 ` Andy Shevchenko
2024-06-05 16:18 ` [PATCH v11 3/8] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2024-06-05 18:29 ` Andy Shevchenko
2024-06-05 19:03 ` Andy Shevchenko
2024-06-05 16:18 ` [PATCH v11 4/8] platform: cznic: turris-omnia-mcu: Add support for poweroff and wakeup Marek Behún
2024-06-05 18:41 ` Andy Shevchenko
2024-06-06 8:01 ` Marek Behún
2024-06-05 16:18 ` [PATCH v11 5/8] platform: cznic: turris-omnia-mcu: Add support for MCU watchdog Marek Behún
2024-06-05 18:45 ` Andy Shevchenko
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 [this message]
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 16:18 ` [PATCH v11 7/8] ARM: dts: turris-omnia: Add MCU system-controller node Marek Behún
2024-06-05 16:18 ` [PATCH v11 8/8] ARM: dts: turris-omnia: Add GPIO key node for front button 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=20240606143712.6b834d7c@dellmb \
--to=kabel@kernel.org \
--cc=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=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).