[PATCH v2 09/11] coco: guest: arm64: Wire Realm TDISP RUN/STOP transitions into guest driver

Aneesh Kumar K.V (Arm) posted 11 patches 2 weeks ago
[PATCH v2 09/11] coco: guest: arm64: Wire Realm TDISP RUN/STOP transitions into guest driver
Posted by Aneesh Kumar K.V (Arm) 2 weeks ago
Teach the Arm CCA guest driver how to transition a Realm device between
RUN and STOP states. The new helpers issue the RSI START/STOP calls,
poll with CONTINUE until completion, and surface errors back to the TSM.
The PCI TSM accept/unlock paths now invoke these helpers so writing `1`
to `tsm/accept` correctly kicks off the TDISP RUN sequence and unlock
tears it back down.

Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
---
 drivers/virt/coco/arm-cca-guest/arm-cca.c | 13 +++++++++++++
 drivers/virt/coco/arm-cca-guest/rsi-da.c  |  5 +++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/virt/coco/arm-cca-guest/arm-cca.c b/drivers/virt/coco/arm-cca-guest/arm-cca.c
index e86c3ad355f8..46cc0fdefe34 100644
--- a/drivers/virt/coco/arm-cca-guest/arm-cca.c
+++ b/drivers/virt/coco/arm-cca-guest/arm-cca.c
@@ -239,9 +239,22 @@ static void cca_tsm_unlock(struct pci_tsm *tsm)
 	kfree(cca_dsc);
 }
 
+static int cca_tsm_accept(struct pci_dev *pdev)
+{
+	int ret;
+
+	ret = cca_device_verify_and_accept(pdev);
+	if (ret) {
+		pci_err(pdev, "failed to transition the device to run state (%d)\n", ret);
+		return -EIO;
+	}
+	return 0;
+}
+
 static struct pci_tsm_ops cca_devsec_pci_ops = {
 	.lock = cca_tsm_lock,
 	.unlock = cca_tsm_unlock,
+	.accept	 = cca_tsm_accept,
 };
 
 static void cca_devsec_tsm_remove(void *tsm_dev)
diff --git a/drivers/virt/coco/arm-cca-guest/rsi-da.c b/drivers/virt/coco/arm-cca-guest/rsi-da.c
index c6b92f4ae9c5..4852a03dd17d 100644
--- a/drivers/virt/coco/arm-cca-guest/rsi-da.c
+++ b/drivers/virt/coco/arm-cca-guest/rsi-da.c
@@ -331,5 +331,10 @@ int cca_device_verify_and_accept(struct pci_dev *pdev)
 		return -EIO;
 	}
 
+	ret = rhi_vdev_set_tdi_state(pdev, RHI_DA_TDI_CONFIG_RUN);
+	if (ret) {
+		pci_err(pdev, "failed to switch the device (%u) to RUN state\n", ret);
+		return -EIO;
+	}
 	return 0;
 }
-- 
2.43.0
Re: [PATCH v2 09/11] coco: guest: arm64: Wire Realm TDISP RUN/STOP transitions into guest driver
Posted by Jonathan Cameron 1 week, 4 days ago
On Mon, 17 Nov 2025 19:30:05 +0530
"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org> wrote:

> Teach the Arm CCA guest driver how to transition a Realm device between
> RUN and STOP states. The new helpers issue the RSI START/STOP calls,
> poll with CONTINUE until completion, and surface errors back to the TSM.
> The PCI TSM accept/unlock paths now invoke these helpers so writing `1`
> to `tsm/accept` correctly kicks off the TDISP RUN sequence and unlock
> tears it back down.
> 
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>