Skip to content

hwrng: starfive - fixes and JHB100 support

lianfeng.ouyang linux-crypto linux-devicetree lkml 9 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v11 Latest6 patches 1 replyIn review
  2. v106 patches 1 replySuperseded
  3. v92 patches 2 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v82 patches3 repliesSuperseded
v72 patches2 repliesSuperseded
v62 patches2 repliesSuperseded
v52 patches2 repliesSuperseded
v42 patches1 replySuperseded
v32 patches2 repliesSuperseded

Changes in v11 from the cover letter

- 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.

Patches in v11 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6dt-bindings: rng: starfive,jh7110-trng: add jhb100, drop jh8100Documentation/devicetree/bindings/rng/starfive,jh7110-trng.yaml+4 -60 replies
2/6hwrng: starfive - fix runtime PM and power teardown handlingdrivers/char/hw_random/jh7110-trng.c+103 -470 replies
3/6hwrng: starfive - move the SEU reseed out of the interrupt handlerdrivers/char/hw_random/jh7110-trng.c+270 -910 replies
4/6hwrng: starfive - tidy up includes and drop unused codedrivers/char/hw_random/jh7110-trng.c+39 -420 replies
5/6hwrng: starfive - add JHB100 supportdrivers/char/hw_random/jh7110-trng.c+42 -30 replies
6/6MAINTAINERS: update the StarFive TRNG driver maintainerMAINTAINERS+1 -10 replies

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by.

PatchConor Dooley
1/6A-b
2/6
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v11 thread

Cover letter [PATCH v11 0/6] hwrng: starfive - fixes and JHB100 support

From: Lianfeng Ouyang <[email protected]>

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