On Mon, 28 Jul 2025 19:21:59 +0530 "Aneesh Kumar K.V (Arm)" <aneesh.kumar@xxxxxxxxxx> wrote: > Add support for vdev_stop and vdev_destroy. > > Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx> Really trivial comments. > --- > arch/arm64/include/asm/rmi_cmds.h | 21 ++++++++ > arch/arm64/include/asm/rmi_smc.h | 3 +- > drivers/virt/coco/arm-cca-host/arm-cca.c | 10 ++++ > drivers/virt/coco/arm-cca-host/rmm-da.c | 61 +++++++++++++++++++++++- > drivers/virt/coco/arm-cca-host/rmm-da.h | 2 + > 5 files changed, 95 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/rmi_cmds.h b/arch/arm64/include/asm/rmi_cmds.h > index 25197f47a0a9..eb4f67eb6b01 100644 > --- a/arch/arm64/include/asm/rmi_cmds.h > +++ b/arch/arm64/include/asm/rmi_cmds.h > @@ -609,4 +609,25 @@ static inline unsigned long rmi_vdev_get_state(unsigned long vdev_phys, unsigned > return res.a0; > } > > +static inline unsigned long rmi_vdev_stop(unsigned long vdev_phys) > +{ > + struct arm_smccc_res res; > + > + arm_smccc_1_1_invoke(SMC_RMI_VDEV_STOP, vdev_phys, &res); > + > + return res.a0; > +} > + > +static inline unsigned long rmi_vdev_destroy(unsigned long rd, > + unsigned long pdev_phys, > + unsigned long vdev_phys) > +{ > + struct arm_smccc_res res; > + > + arm_smccc_1_1_invoke(SMC_RMI_VDEV_DESTROY, rd, pdev_phys, vdev_phys, &res); > + > + return res.a0; > +} > + One is enough. > + > #endif /* __ASM_RMI_CMDS_H */ > diff --git a/arch/arm64/include/asm/rmi_smc.h b/arch/arm64/include/asm/rmi_smc.h > index 127dd0938604..c6e16ab608e1 100644 > --- a/arch/arm64/include/asm/rmi_smc.h > +++ b/arch/arm64/include/asm/rmi_smc.h > @@ -55,8 +55,9 @@ > #define SMC_RMI_PDEV_STOP SMC_RMI_CALL(0x017c) > #define SMC_RMI_VDEV_COMMUNICATE SMC_RMI_CALL(0x0186) > #define SMC_RMI_VDEV_CREATE SMC_RMI_CALL(0x0187) > +#define SMC_RMI_VDEV_DESTROY SMC_RMI_CALL(0x0188) > #define SMC_RMI_VDEV_GET_STATE SMC_RMI_CALL(0x0189) > - There have been a few of these. Check v2 carefully to make sure no more sneak in. > +#define SMC_RMI_VDEV_STOP SMC_RMI_CALL(0x018A) > > #define RMI_ABI_MAJOR_VERSION 1 > #define RMI_ABI_MINOR_VERSION 0 > static void cca_tsm_remove(void *tsm_core) > diff --git a/drivers/virt/coco/arm-cca-host/rmm-da.c b/drivers/virt/coco/arm-cca-host/rmm-da.c > index 8635f361bbe8..53072610fa67 100644 > --- a/drivers/virt/coco/arm-cca-host/rmm-da.c > +++ b/drivers/virt/coco/arm-cca-host/rmm-da.c > +void rme_unbind_vdev(struct realm *realm, struct pci_dev *pdev, struct pci_dev *pf0_dev) > +{ > + int ret; > + phys_addr_t rmm_pdev_phys; > + phys_addr_t rmm_vdev_phys; > + struct cca_host_dsc_pf0 *dsc_pf0; > + struct cca_host_tdi *host_tdi; > + phys_addr_t rd_phys = virt_to_phys(realm->rd); > + > + host_tdi = container_of(pdev->tsm->tdi, struct cca_host_tdi, tdi); > + rmm_vdev_phys = virt_to_phys(host_tdi->rmm_vdev); > + > + dsc_pf0 = to_cca_dsc_pf0(pf0_dev); > + rmm_pdev_phys = virt_to_phys(dsc_pf0->rmm_pdev); > + /* Request stopping the VDEV */ > + ret = rmi_vdev_stop(rmm_vdev_phys); > + if (ret) { > + pr_err("failed to stop vdev (%d)\n", ret); > + return; > + } > + > + schedule_vdev_unbind(pdev); > + ret = rmi_vdev_destroy(rd_phys, rmm_pdev_phys, rmm_vdev_phys); > + if (ret) { > + pr_err("failed to destroy vdev (%d)\n", ret); > + return; No point in returning here. Maybe fine to keep this if more code is coming after this in future patches. > + } > +}