@samitouri / QOSamiQemu / commits / 0a4682368b

hw/tpm: Propagate @ppi_enabled to tpm_tis_reset() and remove in TPMState

Of the TPM devices using FIFO mode, only the ISA variant has PPI, and calls tpm_ppi_init() to initialize the PPI state. Propagate @ppi_enabled to tpm_tis_reset() so it only resets the PPI part when requested (ISA case) otherwise the PPI is in uninitialized state. Remove the now unused TPMState::ppi_enabled field. Set the generic TPMIfClass::ppi_enabled so ACPI subsystem can keep checking its availability. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Message-Id: <20260317120241.16320-5-philmd@linaro.org>

Philippe Mathieu-Daudé committed Mar 17, 2026 at 12:41 UTC 0a4682368b75bdc584bc3aae99c1fd3f6d735546
5 files changed +9 -12
hw/tpm/tpm_tis.h
+1 -2
@@ -75,7 +75,6 @@ typedef struct TPMState {
75
76 size_t be_buffer_size;
77
78 - bool ppi_enabled;
78 TPMPPI ppi;
79 } TPMState;
80
@@ -83,7 +82,7 @@ extern const VMStateDescription vmstate_locty;
82 extern const MemoryRegionOps tpm_tis_memory_ops;
83
84 int tpm_tis_pre_save(TPMState *s);
86 -void tpm_tis_reset(TPMState *s);
85 +void tpm_tis_reset(TPMState *s, bool ppi_enabled);
86 enum TPMVersion tpm_tis_get_tpm_version(TPMState *s);
87 void tpm_tis_request_completed(TPMState *s, int ret);
88 uint32_t tpm_tis_read_data(TPMState *s, hwaddr addr, unsigned size);
hw/tpm/tpm_tis_common.c
+2 -2
@@ -813,7 +813,7 @@ enum TPMVersion tpm_tis_get_tpm_version(TPMState *s)
813 * This function is called when the machine starts, resets or due to
814 * S3 resume.
815 */
816 -void tpm_tis_reset(TPMState *s)
816 +void tpm_tis_reset(TPMState *s, bool ppi_enabled)
817 {
818 int c;
819
@@ -821,7 +821,7 @@ void tpm_tis_reset(TPMState *s)
821 s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->be_driver),
822 TPM_TIS_BUFFER_MAX);
823
824 - if (s->ppi_enabled) {
824 + if (ppi_enabled) {
825 tpm_ppi_reset(&s->ppi);
826 }
827 tpm_backend_reset(s->be_driver);
hw/tpm/tpm_tis_i2c.c
+1 -1
@@ -523,7 +523,7 @@ static void tpm_tis_i2c_reset(DeviceState *dev)
523 i2cst->csum_enable = 0;
524 i2cst->loc_sel = 0x00;
525
526 - return tpm_tis_reset(s);
526 + return tpm_tis_reset(s, false);
527 }
528
529 static void tpm_tis_i2c_class_init(ObjectClass *klass, const void *data)
hw/tpm/tpm_tis_isa.c
+4 -6
@@ -88,13 +88,12 @@ static void tpm_tis_isa_reset(DeviceState *dev)
88 TPMStateISA *isadev = TPM_TIS_ISA(dev);
89 TPMState *s = &isadev->state;
90
91 - return tpm_tis_reset(s);
91 + return tpm_tis_reset(s, true);
92 }
93
94 static const Property tpm_tis_isa_properties[] = {
95 DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, TPM_TIS_IRQ),
96 DEFINE_PROP_TPMBE("tpmdev", TPMStateISA, state.be_driver),
97 - DEFINE_PROP_BOOL("ppi", TPMStateISA, state.ppi_enabled, true),
97 };
98
99 static void tpm_tis_isa_initfn(Object *obj)
@@ -132,10 +131,8 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)
131 memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
132 TPM_TIS_ADDR_BASE, &s->mmio);
133
135 - if (s->ppi_enabled) {
136 - tpm_ppi_init(&s->ppi, isa_address_space(ISA_DEVICE(dev)),
137 - TPM_PPI_ADDR_BASE, OBJECT(dev));
138 - }
134 + tpm_ppi_init(&s->ppi, isa_address_space(ISA_DEVICE(dev)),
135 + TPM_PPI_ADDR_BASE, OBJECT(dev));
136 }
137
138 static void build_tpm_tis_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
@@ -175,6 +172,7 @@ static void tpm_tis_isa_class_init(ObjectClass *klass, const void *data)
172 device_class_set_props(dc, tpm_tis_isa_properties);
173 dc->vmsd = &vmstate_tpm_tis_isa;
174 tc->model = TPM_MODEL_TPM_TIS;
175 + tc->ppi_enabled = true;
176 dc->realize = tpm_tis_isa_realizefn;
177 device_class_set_legacy_reset(dc, tpm_tis_isa_reset);
178 tc->request_completed = tpm_tis_isa_request_completed;
hw/tpm/tpm_tis_sysbus.c
+1 -1
@@ -87,7 +87,7 @@ static void tpm_tis_sysbus_reset(DeviceState *dev)
87 TPMStateSysBus *sbdev = TPM_TIS_SYSBUS(dev);
88 TPMState *s = &sbdev->state;
89
90 - return tpm_tis_reset(s);
90 + return tpm_tis_reset(s, false);
91 }
92
93 static const Property tpm_tis_sysbus_properties[] = {