Re: [PATCH kernel 6/6] crypto/ccp: Implement SEV-TIO PCIe IDE (phase1)
From: Alexey Kardashevskiy
Date: Thu Nov 20 2025 - 20:40:46 EST
On 21/11/25 08:28, dan.j.williams@xxxxxxxxx wrote:
Alexey Kardashevskiy wrote:
[..]
+/*to_pci_tsm_pf0((pdev)->tsm)*/
Left over of something?
Actually not, to_pci_tsm_pf0() is a static helper in drivers/pci/tsm.c
and pdev_to_tsm_pf0() (below) is the same thing defined for
drivers/crypto/ccp/sev-dev-tsm.c and I wonder if to_pci_tsm_pf0() is
better be exported. pdev_to_tsm_pf0() does not need all the checks as
if we are that far past the initial setup, we can skip on some checks
which to_pci_tsm_pf0() performs so I have not exported
to_pci_tsm_pf0() but left the comment. Thanks,
Why does the low-level TSM driver need to_pci_tsm_pf0() when it
allocated the container for @tsm in the first place?
If the question "can I skip pci_tsm_pf0 and cast straight to tsm_dsm_tio" - yes I can and probably will, so so many leftovers are still there :)
If the question why I need pf0 in the TSM driver - for things like tdi_bind/unbind which take VFs pdev and I'll need PF0 for DOE.
Thanks,
For example, samples/devsec/ does this:
static void devsec_link_tsm_pci_remove(struct pci_tsm *tsm)
{
struct pci_dev *pdev = tsm->pdev;
dev_dbg(pci_tsm_host(pdev), "%s\n", pci_name(pdev));
if (is_pci_tsm_pf0(pdev)) {
struct devsec_tsm_pf0 *devsec_tsm = to_devsec_tsm_pf0(tsm);
pci_tsm_pf0_destructor(&devsec_tsm->pci);
kfree(devsec_tsm);
} else {
struct devsec_tsm_fn *devsec_tsm = to_devsec_tsm_fn(tsm);
kfree(devsec_tsm);
}
}
...where that to_devsec_tsm_pf0() is:
static struct devsec_tsm_pf0 *to_devsec_tsm_pf0(struct pci_tsm *tsm)
{
return container_of(tsm, struct devsec_tsm_pf0, pci.base_tsm);
}
--
Alexey