mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
Pull request rng-2024-04-rc1
QEMU does not provide information in the device-tree if the ARMv8.5 RNDR or the RISC-V Zkr RNG have been enabled on the command line. In different parts of our code we assume that the first RNG device is the one to be used. Therefore it is preferable to detect the availability of said devices already in the bind method. There has been a related discussion if the U_BOOT_DRVINFO() macro should be used for architectural devices (https://lore.kernel.org/u-boot/20231031125552.26698-1-heinrich.schuchardt@canonical.com/). This aspect is not touched by this series. -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEK7wKXt3/btL6/yA+hO4vgnE3U0sFAmWc8AgACgkQhO4vgnE3 U0u/fxAAqkb7en80XhWHM3iKn6R81JuixxD33FkPPfD7+EDTkkBr/2ylEENNNzSl nSI+LIPQ7/Isew/L/wlylg9+db76nZ1QC49avIIF/Q1Gl4yjOzi88nLT9cn4wZhT HhdbW19XB68APmkJJ5f9jwG+Oli7GZdtZQHtkVKJeBD90pBaH1pOW3sRki4nxmAO 3qWpdwQWAi0S2itPyDXIA/FcxIQqK2ateoBGqNoiwNkTwEyJIh74M7y3nm5UW7xC hmUful9qiiI6Xu/GUZ/RNpMbjevEO0buQNB43RVrR4SpkkU3cwgx5zJBF9Z+/Hiv tHGUlbrPUnMp+I8gDp7VaaKELIY6FVJREzb8GQxb3yj6+wI+b3v/AyOsV4yy86eI 5KX6p1UBJ0RJxB6D9A54F1nVwNXiu8ujRk6zcfBtupKMV8Srxl8tF0OoZSbULb30 CpaoPjWnW2itSvK4+2zFZYsIIWZpkqK3cuHDxmrrQomOynB6VkKDToXmwLkp1uUA kKWh+gqrJkZn3omiDfTNpQwiHRPuOXy0zB2KLPXmGDEDhKSZs9VVvQTzfaXcpKNp YFPGG62Bk/h/cJUF4wOawB4ufEvDoG3qMyJUBY8AJNCH7KeMDV3VeWXx1ABUgruw 2WzfjcM1FgxdUyr5Qrj1cP/bBKuwu0TJpy66pEaoQ4w68csDFtE= =5m7m -----END PGP SIGNATURE----- Merge tag 'rng-2024-04-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request rng-2024-04-rc1 QEMU does not provide information in the device-tree if the ARMv8.5 RNDR or the RISC-V Zkr RNG have been enabled on the command line. In different parts of our code we assume that the first RNG device is the one to be used. Therefore it is preferable to detect the availability of said devices already in the bind method. There has been a related discussion if the U_BOOT_DRVINFO() macro should be used for architectural devices (https://lore.kernel.org/u-boot/20231031125552.26698-1-heinrich.schuchardt@canonical.com/). This aspect is not touched by this series.
This commit is contained in:
commit
c7937a4199
2 changed files with 29 additions and 11 deletions
|
@ -62,10 +62,10 @@ static const struct dm_rng_ops arm_rndr_ops = {
|
|||
.read = arm_rndr_read,
|
||||
};
|
||||
|
||||
static int arm_rndr_probe(struct udevice *dev)
|
||||
static int arm_rndr_bind(struct udevice *dev)
|
||||
{
|
||||
if (!cpu_has_rndr())
|
||||
return -ENODEV;
|
||||
return -ENOENT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ U_BOOT_DRIVER(arm_rndr) = {
|
|||
.name = DRIVER_NAME,
|
||||
.id = UCLASS_RNG,
|
||||
.ops = &arm_rndr_ops,
|
||||
.probe = arm_rndr_probe,
|
||||
.bind = arm_rndr_bind,
|
||||
};
|
||||
|
||||
U_BOOT_DRVINFO(cpu_arm_rndr) = {
|
||||
|
|
|
@ -55,7 +55,7 @@ static int riscv_zkr_read(struct udevice *dev, void *data, size_t len)
|
|||
}
|
||||
break;
|
||||
case DEAD:
|
||||
return -ENODEV;
|
||||
return -ENOENT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,16 +63,16 @@ static int riscv_zkr_read(struct udevice *dev, void *data, size_t len)
|
|||
}
|
||||
|
||||
/**
|
||||
* riscv_zkr_probe() - check if the seed register is available
|
||||
* riscv_zkr_bind() - check if the seed register is available
|
||||
*
|
||||
* If the SBI software has not set mseccfg.sseed=1 or the Zkr
|
||||
* extension is not available this probe function will result
|
||||
* in an exception. Currently we cannot recover from this.
|
||||
* If the SBI software has not set mseccfg.sseed=1 or the Zkr extension is not
|
||||
* available, reading the seed register will result in an exception from which
|
||||
* this function safely resumes.
|
||||
*
|
||||
* @dev: RNG device
|
||||
* Return: 0 if successfully probed
|
||||
*/
|
||||
static int riscv_zkr_probe(struct udevice *dev)
|
||||
static int riscv_zkr_bind(struct udevice *dev)
|
||||
{
|
||||
struct resume_data resume;
|
||||
int ret;
|
||||
|
@ -87,7 +87,24 @@ static int riscv_zkr_probe(struct udevice *dev)
|
|||
val = read_seed();
|
||||
set_resume(NULL);
|
||||
if (ret)
|
||||
return -ENODEV;
|
||||
return -ENOENT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* riscv_zkr_probe() - check if entropy is available
|
||||
*
|
||||
* The bind method already checked that the seed register can be read without
|
||||
* excpetiong. Here we wait for the self test to finish and entropy becoming
|
||||
* available.
|
||||
*
|
||||
* @dev: RNG device
|
||||
* Return: 0 if successfully probed
|
||||
*/
|
||||
static int riscv_zkr_probe(struct udevice *dev)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
do {
|
||||
val = read_seed();
|
||||
|
@ -95,7 +112,7 @@ static int riscv_zkr_probe(struct udevice *dev)
|
|||
} while (val == BIST || val == WAIT);
|
||||
|
||||
if (val == DEAD)
|
||||
return -ENODEV;
|
||||
return -ENOENT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -108,6 +125,7 @@ U_BOOT_DRIVER(riscv_zkr) = {
|
|||
.name = DRIVER_NAME,
|
||||
.id = UCLASS_RNG,
|
||||
.ops = &riscv_zkr_ops,
|
||||
.bind = riscv_zkr_bind,
|
||||
.probe = riscv_zkr_probe,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue