Re: [PATCH 4/7] coresight: tpiu: Move ACPI support from AMBA driver to platform driver

Sudeep Holla
2023-11-22T11:22:03Z

On Wed, Nov 22, 2023 at 12:32:33PM +0530, Anshuman Khandual wrote:
> On 11/15/23 19:23, James Clark wrote:
> > On 27/10/2023 08:29, Anshuman Khandual wrote:
> >> Add support for the tpiu device in the platform driver, which can then be
> >> used on ACPI based platforms. This change would now allow runtime power
> >> management for ACPI based systems. The driver would try to enable the APB
> >> clock if available.
> >>
> > [...]
> >> +#ifdef CONFIG_ACPI
> >> +static const struct acpi_device_id tpiu_acpi_ids[] = {
> >> + {"ARMHC979", 0}, /* ARM CoreSight TPIU */
> >> + {}
> >> +};
> >> +MODULE_DEVICE_TABLE(acpi, tpiu_acpi_ids);
> >> +#endif
> >> +
> >> +static struct platform_driver tpiu_platform_driver = {
> >> + .probe = tpiu_platform_probe,
> >> + .remove = tpiu_platform_remove,
> >> + .driver = {
> >> + .name = "coresight-tpiu-platform",
> >> + .acpi_match_table = ACPI_PTR(tpiu_acpi_ids),
> >> + .suppress_bind_attrs = true,
> >> + .pm = &tpiu_dev_pm_ops,
> >> + },
> >> +};
> >> +module_platform_driver(tpiu_platform_driver);
> >> +
> >
> > Is there a special build config where this works? I get an error here
>
> I have been testing this with a config known to work on RB5 board.
>
> > because module_platform_driver() redefines things that are in
> > module_amba_driver() which is defined above:
> >
> > module_amba_driver(tpiu_driver);
> >
> > This isn't a W=1 build or anything, just a normal one. And it applies to
> > most of the patches in this set.
>
> You are right, I am able to recreate this problem with defconfig on
> 6.7-rc2 as well. The problem here seems to be caused by having both
> module_amba_driver() and module_platform_driver() in the same file.
>
> #define module_amba_driver(__amba_drv) \
> module_driver(__amba_drv, amba_driver_register, amba_driver_unregister)
>
> #define module_platform_driver(__platform_driver) \
> module_driver(__platform_driver, platform_driver_register, \
> platform_driver_unregister)
>
> Although, AFAICT, have not seen these before - even on the defconfig.
> Just to work around this problem, there can be a common module_init()
> /module_exit() to register/unregister both AMBA and platform drivers,
> similar to etm4x_init()/etm4x_exit() setup in coresight-etm4x-core.c.

Could this be the reason why I am seeing the below error why booting with
ACPI ? I wanted to check the tables before I comment but this discussion
made me think it could be the reason, hence posting this before I got time
to analyse it.

| coresight-tmc-platform ARMHC97C:00: can't request region for resource [mem 0x20010000-0x20010fff]
| coresight-tmc-platform: probe of ARMHC97C:00 failed with error -16
| coresight-tmc-platform ARMHC501:00: can't request region for resource [mem 0x20070000-0x20070fff]
| coresight-tmc-platform: probe of ARMHC501:00 failed with error -16

--
Regards,
Sudeep