* [PATCH] tpm_tis_spi: set default probe function if device id not match @ 2021-05-07 14:52 Liguang Zhang 2021-05-08 2:01 ` Jarkko Sakkinen 0 siblings, 1 reply; 7+ messages in thread From: Liguang Zhang @ 2021-05-07 14:52 UTC (permalink / raw) To: Peter Huewe, Jarkko Sakkinen Cc: Jason Gunthorpe, linux-integrity, linux-kernel, Liguang Zhang In DSDT table, TPM _CID was SMO0768, and no _HID definition. After a kernel upgrade from 4.19 to 5.10, TPM probe function was changed which causes device probe fails. In order to make newer kernel to be compatible with the older acpi definition, it would be best set default probe function. Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> --- drivers/char/tpm/tpm_tis_spi_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c index 3856f6ebcb34..da632a582621 100644 --- a/drivers/char/tpm/tpm_tis_spi_main.c +++ b/drivers/char/tpm/tpm_tis_spi_main.c @@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) tpm_tis_spi_probe_func probe_func; probe_func = of_device_get_match_data(&spi->dev); - if (!probe_func && spi_dev_id) - probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; - if (!probe_func) - return -ENODEV; + if (!probe_func) { + if (spi_dev_id) { + probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; + if (!probe_func) + return -ENODEV; + } else + probe_func = tpm_tis_spi_probe; + } return probe_func(spi); } -- 2.19.1.6.gb485710b ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm_tis_spi: set default probe function if device id not match 2021-05-07 14:52 [PATCH] tpm_tis_spi: set default probe function if device id not match Liguang Zhang @ 2021-05-08 2:01 ` Jarkko Sakkinen 2021-05-08 2:46 ` 乱石 0 siblings, 1 reply; 7+ messages in thread From: Jarkko Sakkinen @ 2021-05-08 2:01 UTC (permalink / raw) To: Liguang Zhang; +Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel On Fri, May 07, 2021 at 10:52:55PM +0800, Liguang Zhang wrote: > In DSDT table, TPM _CID was SMO0768, and no _HID definition. After a > kernel upgrade from 4.19 to 5.10, TPM probe function was changed which > causes device probe fails. In order to make newer kernel to be > compatible with the older acpi definition, it would be best set default > probe function. > > Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> > --- > drivers/char/tpm/tpm_tis_spi_main.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c > index 3856f6ebcb34..da632a582621 100644 > --- a/drivers/char/tpm/tpm_tis_spi_main.c > +++ b/drivers/char/tpm/tpm_tis_spi_main.c > @@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) > tpm_tis_spi_probe_func probe_func; > > probe_func = of_device_get_match_data(&spi->dev); > - if (!probe_func && spi_dev_id) > - probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > - if (!probe_func) > - return -ENODEV; > + if (!probe_func) { > + if (spi_dev_id) { > + probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > + if (!probe_func) > + return -ENODEV; Perhaps also hear fallback to tpm_tis_spi_probe? > + } else > + probe_func = tpm_tis_spi_probe; > + } > > return probe_func(spi); > } > -- > 2.19.1.6.gb485710b > > /Jarkko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm_tis_spi: set default probe function if device id not match 2021-05-08 2:01 ` Jarkko Sakkinen @ 2021-05-08 2:46 ` 乱石 2021-05-09 20:39 ` Jarkko Sakkinen 0 siblings, 1 reply; 7+ messages in thread From: 乱石 @ 2021-05-08 2:46 UTC (permalink / raw) To: Jarkko Sakkinen Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel Hi, 在 2021/5/8 10:01, Jarkko Sakkinen 写道: > On Fri, May 07, 2021 at 10:52:55PM +0800, Liguang Zhang wrote: >> In DSDT table, TPM _CID was SMO0768, and no _HID definition. After a >> kernel upgrade from 4.19 to 5.10, TPM probe function was changed which >> causes device probe fails. In order to make newer kernel to be >> compatible with the older acpi definition, it would be best set default >> probe function. >> >> Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> >> --- >> drivers/char/tpm/tpm_tis_spi_main.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c >> index 3856f6ebcb34..da632a582621 100644 >> --- a/drivers/char/tpm/tpm_tis_spi_main.c >> +++ b/drivers/char/tpm/tpm_tis_spi_main.c >> @@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) >> tpm_tis_spi_probe_func probe_func; >> >> probe_func = of_device_get_match_data(&spi->dev); >> - if (!probe_func && spi_dev_id) >> - probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; >> - if (!probe_func) >> - return -ENODEV; >> + if (!probe_func) { >> + if (spi_dev_id) { >> + probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; >> + if (!probe_func) >> + return -ENODEV; > Perhaps also hear fallback to tpm_tis_spi_probe? Yes, I do not think of a good way. Do you have any suggestions? The arm platform is kunpeng-920, detail dsdt information here: Device (SPI0) { Name (_HID, "HISI0173") // _HID: Hardware ID Name (_ADR, Zero) // _ADR: Address Name (_UID, Zero) // _UID: Unique ID Name (RBUF, ResourceTemplate () { GpioIo (Exclusive, PullUp, 0x0000, 0x0000, IoRestrictionNone, "\\_SB.GPO1", 0x00, ResourceConsumer, , ) { // Pin list 0x0006 } QWordMemory (ResourceConsumer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, 0x0000000000000000, // Granularity 0x00000002011A0000, // Range Minimum 0x00000002011AFFFF, // Range Maximum 0x0000000000000000, // Translation Offset 0x0000000000010000, // Length ,, , AddressRangeMemory, TypeStatic) Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) { 0x000001EB, } }) Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings { Return (RBUF) /* \_SB_.SPI0.RBUF */ } Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x03) { Package (0x02) { "reg-io-width", 0x04 }, Package (0x02) { "num-cs", One }, Package (0x02) { "cs-gpios", Package (0x04) { SPI0, Zero, Zero, Zero } } } }) } Scope (SPI0) { Device (TPM) { Name (_ADR, Zero) // _ADR: Address Name (_CID, Package (0x01) // _CID: Compatible ID { "SMO0768" }) Name (_UID, Zero) // _UID: Unique ID Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x00){} }) Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings { Name (RBUF, ResourceTemplate () { SpiSerialBusV2 (0x0000, PolarityLow, FourWireMode, 0x08, ControllerInitiated, 0x000F4240, ClockPolarityLow, ClockPhaseFirst, "\\_SB.SPI0", 0x00, ResourceConsumer, , Exclusive, ) }) Return (RBUF) /* \_SB_.SPI0.TPM_._CRS.RBUF */ } Method (_STA, 0, NotSerialized) // _STA: Status { If ((TPEN == One)) { Return (0x0F) } Else { Return (Zero) } } } } } Regards Liguang > >> + } else >> + probe_func = tpm_tis_spi_probe; >> + } >> >> return probe_func(spi); >> } >> -- >> 2.19.1.6.gb485710b >> >> > /Jarkko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm_tis_spi: set default probe function if device id not match 2021-05-08 2:46 ` 乱石 @ 2021-05-09 20:39 ` Jarkko Sakkinen 2021-05-10 1:23 ` 乱石 2021-05-12 1:07 ` 乱石 0 siblings, 2 replies; 7+ messages in thread From: Jarkko Sakkinen @ 2021-05-09 20:39 UTC (permalink / raw) To: 乱石 Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel On Sat, May 08, 2021 at 10:46:57AM +0800, 乱石 wrote: > Hi, > > 在 2021/5/8 10:01, Jarkko Sakkinen 写道: > > On Fri, May 07, 2021 at 10:52:55PM +0800, Liguang Zhang wrote: > > > In DSDT table, TPM _CID was SMO0768, and no _HID definition. After a > > > kernel upgrade from 4.19 to 5.10, TPM probe function was changed which > > > causes device probe fails. In order to make newer kernel to be > > > compatible with the older acpi definition, it would be best set default > > > probe function. > > > > > > Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> > > > --- > > > drivers/char/tpm/tpm_tis_spi_main.c | 12 ++++++++---- > > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c > > > index 3856f6ebcb34..da632a582621 100644 > > > --- a/drivers/char/tpm/tpm_tis_spi_main.c > > > +++ b/drivers/char/tpm/tpm_tis_spi_main.c > > > @@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) > > > tpm_tis_spi_probe_func probe_func; > > > probe_func = of_device_get_match_data(&spi->dev); > > > - if (!probe_func && spi_dev_id) > > > - probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > > > - if (!probe_func) > > > - return -ENODEV; > > > + if (!probe_func) { > > > + if (spi_dev_id) { > > > + probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > > > + if (!probe_func) > > > + return -ENODEV; > > Perhaps also hear fallback to tpm_tis_spi_probe? > > > Yes, I do not think of a good way. Do you have any suggestions? So, I just think that when you have this part: if (!probe_func) { if (spi_dev_id) { probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; if (!probe_func) return -ENODEV; Why in here would not you also want to fallback to tpm_tis_spi_probe? /Jarkko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm_tis_spi: set default probe function if device id not match 2021-05-09 20:39 ` Jarkko Sakkinen @ 2021-05-10 1:23 ` 乱石 2021-05-12 1:07 ` 乱石 1 sibling, 0 replies; 7+ messages in thread From: 乱石 @ 2021-05-10 1:23 UTC (permalink / raw) To: Jarkko Sakkinen Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel 在 2021/5/10 4:39, Jarkko Sakkinen 写道: > On Sat, May 08, 2021 at 10:46:57AM +0800, 乱石 wrote: >> Hi, >> >> 在 2021/5/8 10:01, Jarkko Sakkinen 写道: >>> On Fri, May 07, 2021 at 10:52:55PM +0800, Liguang Zhang wrote: >>>> In DSDT table, TPM _CID was SMO0768, and no _HID definition. After a >>>> kernel upgrade from 4.19 to 5.10, TPM probe function was changed which >>>> causes device probe fails. In order to make newer kernel to be >>>> compatible with the older acpi definition, it would be best set default >>>> probe function. >>>> >>>> Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> >>>> --- >>>> drivers/char/tpm/tpm_tis_spi_main.c | 12 ++++++++---- >>>> 1 file changed, 8 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c >>>> index 3856f6ebcb34..da632a582621 100644 >>>> --- a/drivers/char/tpm/tpm_tis_spi_main.c >>>> +++ b/drivers/char/tpm/tpm_tis_spi_main.c >>>> @@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) >>>> tpm_tis_spi_probe_func probe_func; >>>> probe_func = of_device_get_match_data(&spi->dev); >>>> - if (!probe_func && spi_dev_id) >>>> - probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; >>>> - if (!probe_func) >>>> - return -ENODEV; >>>> + if (!probe_func) { >>>> + if (spi_dev_id) { >>>> + probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; >>>> + if (!probe_func) >>>> + return -ENODEV; >>> Perhaps also hear fallback to tpm_tis_spi_probe? >> >> Yes, I do not think of a good way. Do you have any suggestions? > So, I just think that when you have this part: > > > if (!probe_func) { > if (spi_dev_id) { > probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > if (!probe_func) > return -ENODEV; > > Why in here would not you also want to fallback to tpm_tis_spi_probe? Thanks, I got it. If spi_dev_id exists, prob_func is NULL, I think it's not reasonable , but not neccessarily correct. In this scenario, maybe can also fallback to tpm_tis_spi_probe. Liguang > > /Jarkko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm_tis_spi: set default probe function if device id not match 2021-05-09 20:39 ` Jarkko Sakkinen 2021-05-10 1:23 ` 乱石 @ 2021-05-12 1:07 ` 乱石 2021-05-12 1:19 ` Jarkko Sakkinen 1 sibling, 1 reply; 7+ messages in thread From: 乱石 @ 2021-05-12 1:07 UTC (permalink / raw) To: Jarkko Sakkinen Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel 在 2021/5/10 4:39, Jarkko Sakkinen 写道: > On Sat, May 08, 2021 at 10:46:57AM +0800, 乱石 wrote: >> Hi, >> >> 在 2021/5/8 10:01, Jarkko Sakkinen 写道: >>> On Fri, May 07, 2021 at 10:52:55PM +0800, Liguang Zhang wrote: >>>> In DSDT table, TPM _CID was SMO0768, and no _HID definition. After a >>>> kernel upgrade from 4.19 to 5.10, TPM probe function was changed which >>>> causes device probe fails. In order to make newer kernel to be >>>> compatible with the older acpi definition, it would be best set default >>>> probe function. >>>> >>>> Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> >>>> --- >>>> drivers/char/tpm/tpm_tis_spi_main.c | 12 ++++++++---- >>>> 1 file changed, 8 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c >>>> index 3856f6ebcb34..da632a582621 100644 >>>> --- a/drivers/char/tpm/tpm_tis_spi_main.c >>>> +++ b/drivers/char/tpm/tpm_tis_spi_main.c >>>> @@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) >>>> tpm_tis_spi_probe_func probe_func; >>>> probe_func = of_device_get_match_data(&spi->dev); >>>> - if (!probe_func && spi_dev_id) >>>> - probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; >>>> - if (!probe_func) >>>> - return -ENODEV; >>>> + if (!probe_func) { >>>> + if (spi_dev_id) { >>>> + probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; >>>> + if (!probe_func) >>>> + return -ENODEV; >>> Perhaps also hear fallback to tpm_tis_spi_probe? >> >> Yes, I do not think of a good way. Do you have any suggestions? > So, I just think that when you have this part: > > > if (!probe_func) { > if (spi_dev_id) { > probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > if (!probe_func) > return -ENODEV; > > Why in here would not you also want to fallback to tpm_tis_spi_probe? Sorry to trouble you, do you have a good way to resolve the compatible problem caused by kernel update (4.19 -> 5.10) ? Liguang > > /Jarkko ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tpm_tis_spi: set default probe function if device id not match 2021-05-12 1:07 ` 乱石 @ 2021-05-12 1:19 ` Jarkko Sakkinen 0 siblings, 0 replies; 7+ messages in thread From: Jarkko Sakkinen @ 2021-05-12 1:19 UTC (permalink / raw) To: 乱石 Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, linux-kernel On Wed, May 12, 2021 at 09:07:56AM +0800, 乱石 wrote: > 在 2021/5/10 4:39, Jarkko Sakkinen 写道: > > On Sat, May 08, 2021 at 10:46:57AM +0800, 乱石 wrote: > > > Hi, > > > > > > 在 2021/5/8 10:01, Jarkko Sakkinen 写道: > > > > On Fri, May 07, 2021 at 10:52:55PM +0800, Liguang Zhang wrote: > > > > > In DSDT table, TPM _CID was SMO0768, and no _HID definition. After a > > > > > kernel upgrade from 4.19 to 5.10, TPM probe function was changed which > > > > > causes device probe fails. In order to make newer kernel to be > > > > > compatible with the older acpi definition, it would be best set default > > > > > probe function. > > > > > > > > > > Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> > > > > > --- > > > > > drivers/char/tpm/tpm_tis_spi_main.c | 12 ++++++++---- > > > > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > > > > > > > diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c > > > > > index 3856f6ebcb34..da632a582621 100644 > > > > > --- a/drivers/char/tpm/tpm_tis_spi_main.c > > > > > +++ b/drivers/char/tpm/tpm_tis_spi_main.c > > > > > @@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) > > > > > tpm_tis_spi_probe_func probe_func; > > > > > probe_func = of_device_get_match_data(&spi->dev); > > > > > - if (!probe_func && spi_dev_id) > > > > > - probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > > > > > - if (!probe_func) > > > > > - return -ENODEV; > > > > > + if (!probe_func) { > > > > > + if (spi_dev_id) { > > > > > + probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > > > > > + if (!probe_func) > > > > > + return -ENODEV; > > > > Perhaps also hear fallback to tpm_tis_spi_probe? > > > > > > Yes, I do not think of a good way. Do you have any suggestions? > > So, I just think that when you have this part: > > > > > > if (!probe_func) { > > if (spi_dev_id) { > > probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; > > if (!probe_func) > > return -ENODEV; > > > > Why in here would not you also want to fallback to tpm_tis_spi_probe? > > Sorry to trouble you, do you have a good way to resolve the compatible > problem caused by kernel update (4.19 -> 5.10) ? I think I'll take this as it is. I'll apply it to my tree and take it as part of next pr. Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> /Jarkko ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-05-12 1:19 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-05-07 14:52 [PATCH] tpm_tis_spi: set default probe function if device id not match Liguang Zhang 2021-05-08 2:01 ` Jarkko Sakkinen 2021-05-08 2:46 ` 乱石 2021-05-09 20:39 ` Jarkko Sakkinen 2021-05-10 1:23 ` 乱石 2021-05-12 1:07 ` 乱石 2021-05-12 1:19 ` Jarkko Sakkinen
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.