mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v11 0/6] hwrng: starfive - fixes and JHB100 support
@ 2026-11-03  7:32 lianfeng.ouyang
  2026-11-03  7:32 ` [PATCH v11 1/6] dt-bindings: rng: starfive,jh7110-trng: add jhb100, drop jh8100 lianfeng.ouyang
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: lianfeng.ouyang @ 2026-11-03  7:32 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Philipp Zabel
  Cc: linux-crypto, devicetree, linux-kernel, Lianfeng Ouyang

From: Lianfeng Ouyang <lianfeng.ouyang@starfivetech.com>

This series adds support for the TRNG on the StarFive JHB100 SoC. The
JHB100 needs the clocks gated before the reset is asserted, so the
driver grows per-compatible match data describing the power-down
ordering.

Earlier versions of this series carried all of that in the JHB100
patch, which made it hard to review. Since v10 it is split up:

  1: dt-bindings for the new compatible (unchanged)
  2: runtime PM / power teardown fix
  3: SEU reseed moved out of the interrupt handler, command
     serialisation, IRQ lifecycle
  4: include and cleanup tidy-up, no functional change
  5: match data and the JHB100 compatible
  6: MAINTAINERS

Changes in v1:
 - Remove jh8100-trng and Fix the compatible description in .yaml
 - add JHB100 and fix clk/reset teardown logic code

Changes in v2:
 - Balance the PM via pm_runtime_set_active() in ->probe
 - Add devm_add_action_or_reset() to register a resource rollback function

Changes in v3:
 - Supplement .yaml commit message
 - Add pm_runtime_get_if_active() to check PM in irq
 - Balances pm_runtime_get/put calls in init, read, and cleanup paths
 - Add per-compatible match data for the teardown order

Changes in v4:
 - Modify .yaml commit information to non point description
 - serialise the command sequences with a mutex.

Changes in v5:
 - Run the reseed from a workqueue instead of hard IRQ context.
 - Balance the probe reset_control_deassert() via a ->cleanup flag in the
   PM suspend/resume callbacks (was skipped when already suspended).
 - Use devm_pm_runtime_set_active_enabled() instead of manual PM enable.
 - Register the IRQ after clk/reset/PM setup; reuse
    starfive_trng_release() on request_irq() failure.
 - Check reset_control_deassert();
 - drop of_match_ptr() from the match table.

Changes in v6:
 - check lock in starfive_trng_read() using mutex_trylock when wait is 0

Changes in v7:
 - using mutex_trylock when wait is 0, otherwise use mutex_lock()

Changes in v8:
 - rebase patches against the latest tree

Changes in v9:
 - Fixed the PM runtime reference leak in starfive_trng_read()
 - Drop redundant pm_runtime_get/put calls from the interrupt
     handler (starfive_trng_irq).
 - Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() for power
     management operations.
 - Split clock/reset control into starfive_trng_power_on/off()
 - Track power state with clk_on/rst_deassert/initialized/need_reseed
      instead of open-coded clk control.
 - IRQ now requested with IRQF_NO_AUTOEN and enabled only after init
      succeeds.
 - LFSR_LOCKUP no longer schedules work from hard IRQ: set need_reseed
      flag and let starfive_trng_reseed_work() handle reseed on a
      freezable workqueue.
 - starfive_trng_cmd() takes timeout + wait args; read path checks idle,
      reseeds on need_reseed, retries once on lockup, returns 0 for
      non-blocking.
 - Protect ctrl-cmd sequences with mutex + lockdep_assert_held.
 - Cleanup/suspend disables IE, clears ISTAT, synchronize_irq() before
      gating clocks/reset.

Changes in v10:
 - Split the driver change into fixes, cleanup and the JHB100 addition.
 - starfive_trng_init() only enables the interrupt line once and clears
   trng->initialized on failure; starfive_trng_cleanup() only disables
   the line if init left it enabled. Fixes the unbalanced enable_irq()
   when the device is deselected and quickly reselected, and the double
   disable_irq() after a failed init.
 - Non-blocking reads re-queue the reseed work instead of assuming it
   is pending, and starfive_trng_irq_clear() queues it when it clears a
   lockup. Fixes the stall of non-blocking reads after a lockup seen
   outside the interrupt handler or a failed reseed.
 - Do not include <linux/mod_devicetable.h>, <linux/platform_device.h>
   already provides struct of_device_id.
 - Describe the header rearrangement in the commit log.
 - Rebased on top of ace145efdd80.

Changes in v11:
 - starfive_trng_cmd() acks RAND_RDY/SEED_DONE in ISTAT and calls
   synchronize_irq() before re-arming its completion, so that the late
   completion interrupt of a command that timed out cannot complete
   the next command. The v10 commit log claimed this case was already
   covered; it was not.
 - starfive_trng_irq_clear() only queues the reseed work while the
   device is initialised, so the suspend run from ->cleanup() and from
   the runtime PM teardown on unbind can no longer queue the work after
   it has been cancelled.

Lianfeng Ouyang (6):
  dt-bindings: rng: starfive,jh7110-trng: add jhb100, drop jh8100
  hwrng: starfive - fix runtime PM and power teardown handling
  hwrng: starfive - move the SEU reseed out of the interrupt handler
  hwrng: starfive - tidy up includes and drop unused code
  hwrng: starfive - add JHB100 support
  MAINTAINERS: update the StarFive TRNG driver maintainer

 .../bindings/rng/starfive,jh7110-trng.yaml    |  10 +-
 MAINTAINERS                                   |   2 +-
 drivers/char/hw_random/jh7110-trng.c          | 587 +++++++++++++-----
 3 files changed, 434 insertions(+), 165 deletions(-)

--
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-03  7:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03  7:32 [PATCH v11 0/6] hwrng: starfive - fixes and JHB100 support lianfeng.ouyang
2026-11-03  7:32 ` [PATCH v11 1/6] dt-bindings: rng: starfive,jh7110-trng: add jhb100, drop jh8100 lianfeng.ouyang
2026-11-03  7:32 ` [PATCH v11 2/6] hwrng: starfive - fix runtime PM and power teardown handling lianfeng.ouyang
2026-11-03  7:32 ` [PATCH v11 3/6] hwrng: starfive - move the SEU reseed out of the interrupt handler lianfeng.ouyang
2026-11-03  7:32 ` [PATCH v11 4/6] hwrng: starfive - tidy up includes and drop unused code lianfeng.ouyang
2026-11-03  7:32 ` [PATCH v11 5/6] hwrng: starfive - add JHB100 support lianfeng.ouyang
2026-11-03  7:32 ` [PATCH v11 6/6] MAINTAINERS: update the StarFive TRNG driver maintainer lianfeng.ouyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®