i2c-designware: Add support for AMD PSP semaphore
Subsystems (4)
v4 cover i2c-designware: Add support for AMD PSP semaphore
This patchset comprises support for new i2c-designware controller setup on some AMD Cezanne SoCs, where x86 is sharing i2c bus with PSP. PSP uses the same controller and acts as an i2c arbitrator there (x86 is leasing bus from it).
First commit aims to improve generic i2c-designware code by adding extra locking on probe() and disable() paths. I would like to ask someone with access to boards which use Intel BayTrail(CONFIG_I2C_DESIGNWARE_BAYTRAIL) to verify behavior of my changes on such setup.
Second commit adds support for new PSP semaphore arbitration mechanism. Implementation is similar to the one from i2c-designware-baytrail.c however there are two main differences:
1) Add new ACPI ID in order to protect against silent binding of the old driver to the setup with PSP semaphore. Extra flag ARBITRATION_SEMAPHORE added to this new _HID allows to recognize setup with PSP.
2) Beside acquire_lock() and release_lock() methods we are also applying quirks to the lock_bus() and unlock_bus() global adapter methods. With this in place all i2c clients drivers may lock i2c bus for a desired number of i2c transactions (e.g. write-wait-read) without being aware of that such bus is shared with another entity.
This patchset is a follow-up to the RFC sent earlier on LKML [1], with review comments applied.
Looking forward to some feedback.
[1] https://lkml.org/lkml/2021/12/22/219
v3->v4:
* Remove unnecessary alignment of psp_i2c_req
* Add missing bits.h header
* Make use of USEC_PER_MSEC
* Simplify if conditions with unsigned variables
* Add additional comments
v2 -> v3:
* Change X86_64 Kconfig dependency to X86_MSR
* Switch from phys_addr_t to u64 in mailbox struct definition
* Remove redundant guard in semaphores' probes
* Add comments about error propagation
* Move credits for kernel test robot into changelog
v1 -> v2:
* Remove usage of unions
* Get rid of unnecessary __packed attributes
* Switch to use iopoll.h and bitfields.h APIs were applicable
* Follow the convention to check for the error first
* Reorder entries (includes, table entries) alphabetically
* Add necessary includes
* Add Kconfig dependency on X86_64
* Modify probe() to use terminating entry for traversing through table instead of ARRAY_SIZE
* Fix typos in comments
* Rebase patchset
Jan Dabros (2):
i2c: designware: Add missing locks
i2c: designware: Add AMD PSP I2C bus support
MAINTAINERS | 1 + drivers/acpi/acpi_apd.c | 7 +- drivers/i2c/busses/Kconfig | 11 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-amdpsp.c | 394 +++++++++++++++++++ drivers/i2c/busses/i2c-designware-baytrail.c | 12 +- drivers/i2c/busses/i2c-designware-common.c | 12 + drivers/i2c/busses/i2c-designware-core.h | 18 +- drivers/i2c/busses/i2c-designware-master.c | 6 + drivers/i2c/busses/i2c-designware-platdrv.c | 60 +++ 10 files changed, 510 insertions(+), 12 deletions(-) create mode 100644 drivers/i2c/busses/i2c-designware-amdpsp.c
Signature · 1 line
2.35.0.263.gb82422642f-goog
PATCH v4 1/2 i2c: designware: Add missing locks
All accesses to controller's registers should be protected on probe, disable and xfer paths. This is needed for i2c bus controllers that are shared with but not controller by kernel.
--- drivers/i2c/busses/i2c-designware-common.c | 12 ++++++++++++ drivers/i2c/busses/i2c-designware-master.c | 6 ++++++ 2 files changed, 18 insertions(+)
drivers/i2c/busses/i2c-designware-common.c +12 -0
@@ -578,7 +578,12 @@ int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev)* Try to detect the FIFO depth if not set by interface driver, * the depth could be from 2 to 256 from HW spec. */ + ret =i2c_dw_acquire_lock (dev); +if (ret) +return ret; + ret =regmap_read (dev->map,DW_IC_COMP_PARAM_1 , ¶m); +i2c_dw_release_lock (dev);if (ret)return ret;
@@ -607,6 +612,11 @@ u32 i2c_dw_func(struct i2c_adapter *adap)void i2c_dw_disable (struct dw_i2c_dev *dev) {u32 dummy; +int ret; + + ret =i2c_dw_acquire_lock (dev); +if (ret) +return ;/* Disable controller */ __i2c_dw_disable (dev);
@@ -614,6 +624,8 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)/* Disable all interrupts */ regmap_write (dev->map,DW_IC_INTR_MASK ,0 );regmap_read (dev->map,DW_IC_CLR_INTR , &dummy); + +i2c_dw_release_lock (dev); }void i2c_dw_disable_int (struct dw_i2c_dev *dev)
drivers/i2c/busses/i2c-designware-master.c +6 -0
@@ -905,7 +905,13 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev) irq_flags =IRQF_SHARED |IRQF_COND_SUSPEND ; } + ret =i2c_dw_acquire_lock (dev); +if (ret) +return ret; +i2c_dw_disable_int (dev); +i2c_dw_release_lock (dev); + ret =devm_request_irq (dev->dev, dev->irq, i2c_dw_isr, irq_flags,dev_name (dev->dev), dev);if (ret) {
Signature · 1 line
2.35.0.263.gb82422642f-goog
Re: [PATCH v4 1/2] i2c: designware: Add missing locks
Quoted 11 lines · Jan Dabros
All accesses to controller's registers should be protected on probe, disable and xfer paths. This is needed for i2c bus controllers that are shared with but not controller by kernel.
Signed-off-by Jan Dabros <[email protected]>Reviewed-by Hans de Goede <[email protected]>--- drivers/i2c/busses/i2c-designware-common.c | 12 ++++++++++++ drivers/i2c/busses/i2c-designware-master.c | 6 ++++++ 2 files changed, 18 insertions(+)
Shortly tested by rmmod & modprobe loop.
Re: [PATCH v4 1/2] i2c: designware: Add missing locks
In reply to Jan DabrosQuoted 3 lines · Jan Dabros
All accesses to controller's registers should be protected on probe, disable and xfer paths. This is needed for i2c bus controllers that are shared with but not controller by kernel.
Quoted 66 lines
Signed-off-by Jan Dabros <[email protected]>Reviewed-by Hans de Goede <[email protected]>--- drivers/i2c/busses/i2c-designware-common.c | 12 ++++++++++++ drivers/i2c/busses/i2c-designware-master.c | 6 ++++++ 2 files changed, 18 insertions(+)drivers/i2c/busses/i2c-designware-common.c +12
-0@@ -578,7 +578,12 @@ int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev)* Try to detect the FIFO depth if not set by interface driver, * the depth could be from 2 to 256 from HW spec. */ + ret =i2c_dw_acquire_lock (dev); +if (ret) +return ret; + ret =regmap_read (dev->map,DW_IC_COMP_PARAM_1 , ¶m); +i2c_dw_release_lock (dev);if (ret)return ret;@@ -607,6 +612,11 @@ u32 i2c_dw_func(struct i2c_adapter *adap)void i2c_dw_disable (struct dw_i2c_dev *dev) {u32 dummy; +int ret; + + ret =i2c_dw_acquire_lock (dev); +if (ret) +return ;/* Disable controller */ __i2c_dw_disable (dev);@@ -614,6 +624,8 @@ void i2c_dw_disable(struct dw_i2c_dev *dev)/* Disable all interrupts */ regmap_write (dev->map,DW_IC_INTR_MASK ,0 );regmap_read (dev->map,DW_IC_CLR_INTR , &dummy); + +i2c_dw_release_lock (dev); }void i2c_dw_disable_int (struct dw_i2c_dev *dev)drivers/i2c/busses/i2c-designware-master.c +6
-0@@ -905,7 +905,13 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev) irq_flags =IRQF_SHARED |IRQF_COND_SUSPEND ; } + ret =i2c_dw_acquire_lock (dev); +if (ret) +return ret; +i2c_dw_disable_int (dev); +i2c_dw_release_lock (dev); + ret =devm_request_irq (dev->dev, dev->irq, i2c_dw_isr, irq_flags,dev_name (dev->dev), dev);if (ret) {Signature · 1 line
2.35.0.263.gb82422642f-goog
Signature · 2 lines
With Best Regards, Andy Shevchenko
Wolfram Sang
AppliedRe: [PATCH v4 1/2] i2c: designware: Add missing locks
In reply to Jan DabrosQuoted 6 lines · Jan Dabros
All accesses to controller's registers should be protected on probe, disable and xfer paths. This is needed for i2c bus controllers that are shared with but not controller by kernel.
Signed-off-by Jan Dabros <[email protected]>Reviewed-by Hans de Goede <[email protected]>
Applied to for-next, thanks!
Re: [PATCH v4 1/2] i2c: designware: Add missing locks
czw., 10 lut 2022 o 23:08 Wolfram Sang <[email protected]> napisał(a):
Quoted 10 lines · Jan Dabros
Quoted 6 lines
All accesses to controller's registers should be protected on probe, disable and xfer paths. This is needed for i2c bus controllers that are shared with but not controller by kernel.
Signed-off-by Jan Dabros <[email protected]>Reviewed-by Hans de Goede <[email protected]>Applied to for-next, thanks!
Thanks!
Best Regards,
Jan
PATCH v4 2/2 i2c: designware: Add AMD PSP I2C bus support
In reply to Jan DabrosImplement an I2C controller sharing mechanism between the host (kernel) and PSP co-processor on some platforms equipped with AMD Cezanne SoC.
On these platforms we need to implement "software" i2c arbitration. Default arbitration owner is PSP and kernel asks for acquire as well as inform about release of the i2c bus via mailbox mechanism.
+---------+
<- ACQUIRE | |
+---------| CPU |\
| | | \ +----------+ SDA
| +---------+ \ | |-------
MAILBOX +--> | I2C-DW | SCL
| +---------+ | |-------
| | | +----------+
+---------| PSP |
<- ACK | |
+---------+ +---------+
<- RELEASE | |
+---------| CPU |
| | | +----------+ SDA
| +---------+ | |-------
MAILBOX +--> | I2C-DW | SCL
| +---------+ / | |-------
| | | / +----------+
+---------| PSP |/
<- ACK | |
+---------+The solution is similar to i2c-designware-baytrail.c implementation, where we are using a generic i2c-designware-* driver with a small "wrapper".
In contrary to baytrail semaphore implementation, beside internal acquire_lock() and release_lock() methods we are also applying quirks to lock_bus() and unlock_bus() global adapter methods. With this in place all i2c clients drivers may lock i2c bus for a desired number of i2c transactions (e.g. write-wait-read) without being aware of that such bus is shared with another entity.
Modify i2c_dw_probe_lock_support() to select correct semaphore implementation at runtime, since now we have more than one available.
Configure new matching ACPI ID "AMDI0019" and register ARBITRATION_SEMAPHORE flag in order to distinguish setup with PSP arbitration.
Add myself as a reviewer for I2C DesignWare in order to help with reviewing and testing possible changes touching new i2c-designware-amdpsp.c module.
--- MAINTAINERS | 1 + drivers/acpi/acpi_apd.c | 7 +- drivers/i2c/busses/Kconfig | 11 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-amdpsp.c | 394 +++++++++++++++++++ drivers/i2c/busses/i2c-designware-baytrail.c | 12 +- drivers/i2c/busses/i2c-designware-core.h | 18 +- drivers/i2c/busses/i2c-designware-platdrv.c | 60 +++ 8 files changed, 492 insertions(+), 12 deletions(-) create mode 100644 drivers/i2c/busses/i2c-designware-amdpsp.c
MAINTAINERS +1 -0
@@ -18679,6 +18679,7 @@ SYNOPSYS DESIGNWARE I2C DRIVER M: Jarkko Nikula <[email protected]> R: Andy Shevchenko <[email protected]> R: Mika Westerberg <[email protected]> +R: Jan Dabros <[email protected]> L: [email protected] S: Maintained F: drivers/i2c/busses/i2c-designware-*
drivers/acpi/acpi_apd.c +4 -3
@@ -232,12 +232,13 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {/* Generic apd devices */ #ifdef CONFIG_X86_AMD_PLATFORM_DEVICE { "AMD0010", APD_ADDR(cz_i2c_desc) }, - { "AMDI0010", APD_ADDR(wt_i2c_desc) }, { "AMD0020", APD_ADDR(cz_uart_desc) }, - { "AMDI0020", APD_ADDR(cz_uart_desc) }, - { "AMDI0022", APD_ADDR(cz_uart_desc) }, { "AMD0030", }, { "AMD0040", APD_ADDR(fch_misc_desc)}, + { "AMDI0010", APD_ADDR(wt_i2c_desc) }, + { "AMDI0019", APD_ADDR(wt_i2c_desc) }, + { "AMDI0020", APD_ADDR(cz_uart_desc) }, + { "AMDI0022", APD_ADDR(cz_uart_desc) }, { "HYGO0010", APD_ADDR(wt_i2c_desc) }, #endif #ifdef CONFIG_ARM64
drivers/i2c/busses/Kconfig +11 -0
@@ -553,6 +553,17 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +config I2C_DESIGNWARE_AMDPSP + bool "AMD PSP I2C semaphore support" + depends on X86_MSR + depends on ACPI + depends on I2C_DESIGNWARE_PLATFORM + help + This driver enables managed host access to the selected I2C bus shared + between AMD CPU and AMD PSP. + + You should say Y if running on an AMD system equipped with the PSP. + config I2C_DESIGNWARE_BAYTRAIL bool "Intel Baytrail I2C semaphore support" depends on ACPI
drivers/i2c/busses/Makefile +1 -0
@@ -54,6 +54,7 @@ i2c-designware-core-y += i2c-designware-master.o i2c-designware-core-$(CONFIG_I2C_DESIGNWARE_SLAVE) += i2c-designware-slave.o obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o +i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o
drivers/i2c/busses/i2c-designware-amdpsp.c new file +394 -0
394 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-baytrail.c +6 -6
@@ -12,25 +12,25 @@#include "i2c-designware-core.h" -int i2c_dw_probe_lock_support (struct dw_i2c_dev *dev) +int i2c_dw_baytrail_probe_lock_support (struct dw_i2c_dev *dev) {acpi_status status;unsigned long long shared_host =0 ;acpi_handle handle; -if (!dev || !dev->dev) -return 0 ; +if (!dev) +return -ENODEV ; handle =ACPI_HANDLE (dev->dev);if (!handle) -return 0 ; +return -ENODEV ; status =acpi_evaluate_integer (handle,"_SEM" ,NULL , &shared_host);if (ACPI_FAILURE (status)) -return 0 ; +return -ENODEV ;if (!shared_host) -return 0 ; +return -ENODEV ;if (!iosf_mbi_available ())return -EPROBE_DEFER ;
drivers/i2c/busses/i2c-designware-core.h +15 -3
@@ -227,6 +227,8 @@ struct reset_control;* @hs_lcnt: high speed LCNT value * @acquire_lock: function to acquire a hardware lock on the bus * @release_lock: function to release a hardware lock on the bus +* @semaphore_idx: Index of table with semaphore type attached to the bus. It's +* -1 if there is no semaphore. * @shared_with_punit: true if this bus is shared with the SoCs PUNIT * @disable: function to disable the controller * @disable_int: function to disable all interrupts
@@ -285,6 +287,7 @@ struct dw_i2c_dev {u16 hs_lcnt;int (*acquire_lock)(void );void (*release_lock)(void ); +int semaphore_idx;bool shared_with_punit;void (*disable)(struct dw_i2c_dev *dev);void (*disable_int)(struct dw_i2c_dev *dev);
@@ -297,6 +300,7 @@ struct dw_i2c_dev {#define ACCESS_INTR_MASK BIT(0)#define ACCESS_NO_IRQ_SUSPEND BIT(1) +#define ARBITRATION_SEMAPHORE BIT(2)#define MODEL_MSCC_OCELOT BIT(8)#define MODEL_BAIKAL_BT1 BIT(9)
@@ -310,6 +314,11 @@ struct dw_i2c_dev {#define AMD_UCSI_INTR_REG 0x474#define AMD_UCSI_INTR_EN 0xd +struct i2c_dw_semaphore_callbacks { +int (*probe)(struct dw_i2c_dev *dev); +void (*remove)(struct dw_i2c_dev *dev); +}; +int i2c_dw_init_regmap (struct dw_i2c_dev *dev);u32 i2c_dw_scl_hcnt (u32 ic_clk,u32 tSYMBOL,u32 tf,int cond,int offset);u32 i2c_dw_scl_lcnt (u32 ic_clk,u32 tLOW,u32 tf,int offset);
@@ -370,9 +379,12 @@ static inline void i2c_dw_configure(struct dw_i2c_dev *dev) }#if IS_ENABLED (CONFIG_I2C_DESIGNWARE_BAYTRAIL ) -extern int i2c_dw_probe_lock_support (struct dw_i2c_dev *dev); -#else -static inline int i2c_dw_probe_lock_support (struct dw_i2c_dev *dev) {return 0 ; } +int i2c_dw_baytrail_probe_lock_support (struct dw_i2c_dev *dev); +#endif + +#if IS_ENABLED (CONFIG_I2C_DESIGNWARE_AMDPSP ) +int i2c_dw_amdpsp_probe_lock_support (struct dw_i2c_dev *dev); +void i2c_dw_amdpsp_remove_lock_support (struct dw_i2c_dev *dev);#endif int i2c_dw_validate_speed (struct dw_i2c_dev *dev);
drivers/i2c/busses/i2c-designware-platdrv.c +60 -0
78 lines not on this page · raw message
Signature · 1 line
2.35.0.263.gb82422642f-goog
Andy Shevchenko
reviewerRe: [PATCH v4 2/2] i2c: designware: Add AMD PSP I2C bus support
On Tue, Feb 08, 2022 at 03:12:18PM +0100, Jan Dabros wrote:
...
I have noticed code duplication.
Quoted 14 lines
drivers/i2c/busses/i2c-designware-amdpsp.c new file +13
-0+ status =psp_send_i2c_req (PSP_I2C_REQ_ACQUIRE ); +if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to release I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + } +/* Send a release command to PSP */ + status =psp_send_i2c_req (PSP_I2C_REQ_RELEASE );
drivers/i2c/busses/i2c-designware-amdpsp.c line 307
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdpsp.c new file +10
-0+if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to acquire I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + }
If you are going to update the series, consider to introduce a common helper. Otherwise, consider a follow up.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/2] i2c: designware: Add AMD PSP I2C bus support
śr., 9 lut 2022 o 16:28 Andy Shevchenko
<[email protected]> napisał(a):
Quoted 32 lines · Jan Dabros
...
I have noticed code duplication.
Quoted 14 lines
drivers/i2c/busses/i2c-designware-amdpsp.c new file +13
-0+ status =psp_send_i2c_req (PSP_I2C_REQ_ACQUIRE ); +if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to release I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + } +/* Send a release command to PSP */ + status =psp_send_i2c_req (PSP_I2C_REQ_RELEASE );drivers/i2c/busses/i2c-designware-amdpsp.c line 307
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdpsp.c new file +10
-0+if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to acquire I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + }
Quoted 2 lines
If you are going to update the series, consider to introduce a common helper. Otherwise, consider a follow up.
Thanks for your comment. Since Jarkko is running some long-lasting tests with v4 patchset, I would like to keep this as is for now (and make a follow up commit). If there will be some additional comments for v4 from him and will spin v5 - I will introduce a common helper function then.
Best Regards,
Jan
Re: [PATCH v4 2/2] i2c: designware: Add AMD PSP I2C bus support
Quoted 34 lines · Jan Dąbroś
śr., 9 lut 2022 o 16:28 Andy Shevchenko
<[email protected]> napisał(a):Quoted 32 lines · Jan Dabros
...
I have noticed code duplication.
Quoted 24 lines
drivers/i2c/busses/i2c-designware-amdpsp.c new file +23
-0+ status =psp_send_i2c_req (PSP_I2C_REQ_ACQUIRE ); +if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to release I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + } +/* Send a release command to PSP */ + status =psp_send_i2c_req (PSP_I2C_REQ_RELEASE ); +if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to acquire I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + }
Quoted 9 lines
Quoted 2 lines
If you are going to update the series, consider to introduce a common helper. Otherwise, consider a follow up.
Thanks for your comment. Since Jarkko is running some long-lasting tests with v4 patchset, I would like to keep this as is for now (and make a follow up commit). If there will be some additional comments for v4 from him and will spin v5 - I will introduce a common helper function then.
Test run fine overnight, although I wasn't expecting this breaking Baytrail since patch is practically touching only semaphore detection at probe time on Baytrail. I'm up to you would you address Andy's comments as a follow up or as v5.
Re: [PATCH v4 2/2] i2c: designware: Add AMD PSP I2C bus support
Hi,
czw., 10 lut 2022 o 15:43 Jarkko Nikula
<[email protected]> napisał(a):
Quoted 45 lines · Jan Dąbroś
Quoted 34 lines
śr., 9 lut 2022 o 16:28 Andy Shevchenko
<[email protected]> napisał(a):Quoted 32 lines · Jan Dabros
...
I have noticed code duplication.
Quoted 24 lines
drivers/i2c/busses/i2c-designware-amdpsp.c new file +23
-0+ status =psp_send_i2c_req (PSP_I2C_REQ_ACQUIRE ); +if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to release I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + } +/* Send a release command to PSP */ + status =psp_send_i2c_req (PSP_I2C_REQ_RELEASE ); +if (status) { +if (status == -ETIMEDOUT ) +dev_err (psp_i2c_dev,"Timed out waiting for PSP to acquire I2C bus\n" ); +else +dev_err (psp_i2c_dev,"PSP communication error\n" ); + +dev_err (psp_i2c_dev,"Assume i2c bus is for exclusive host usage\n" ); + psp_i2c_mbox_fail = true; + goto cleanup; + }Quoted 9 lines
Quoted 2 lines
If you are going to update the series, consider to introduce a common helper. Otherwise, consider a follow up.
Thanks for your comment. Since Jarkko is running some long-lasting tests with v4 patchset, I would like to keep this as is for now (and make a follow up commit). If there will be some additional comments for v4 from him and will spin v5 - I will introduce a common helper function then.
Quoted 7 lines
Test run fine overnight, although I wasn't expecting this breaking Baytrail since patch is practically touching only semaphore detection at probe time on Baytrail. I'm up to you would you address Andy's comments as a follow up or as v5.
Acked-by Jarkko Nikula <[email protected]>Tested-by Jarkko Nikula <[email protected]>
Thanks!
If you don't mind I'd prefer a merge and a follow-up improvement on top. Current version is tested and in case of breakage it would be easier to track.
Best Regards,
Jan
Wolfram Sang
AppliedRe: [PATCH v4 2/2] i2c: designware: Add AMD PSP I2C bus support
In reply to Jan DabrosQuoted 11 lines · Jan Dabros
Implement an I2C controller sharing mechanism between the host (kernel) and PSP co-processor on some platforms equipped with AMD Cezanne SoC.
On these platforms we need to implement "software" i2c arbitration. Default arbitration owner is PSP and kernel asks for acquire as well as inform about release of the i2c bus via mailbox mechanism.
+---------+ <- ACQUIRE | | +---------| CPU |\ | | | \ +----------+ SDA
Applied to for-next, thanks! I fixed the following checkpatch warnings:
CHECK: Please don't use multiple blank lines #232: FILE: drivers/i2c/busses/i2c-designware-amdpsp.c:92:
+
+
WARNING: braces {} are not necessary for single statement blocks #361: FILE: drivers/i2c/busses/i2c-designware-amdpsp.c:221:
+ if (ret) {
+ goto cleanup;
+ }
Please also use checkpatch next time.
Re: [PATCH v4 2/2] i2c: designware: Add AMD PSP I2C bus support
czw., 10 lut 2022 o 23:09 Wolfram Sang <[email protected]> napisał(a):
Quoted 9 lines · Jan Dabros
Quoted 7 lines
Implement an I2C controller sharing mechanism between the host (kernel) and PSP co-processor on some platforms equipped with AMD Cezanne SoC.
On these platforms we need to implement "software" i2c arbitration. Default arbitration owner is PSP and kernel asks for acquire as well as inform about release of the i2c bus via mailbox mechanism.
Quoted 6 lines
Quoted 4 lines
+---------+ <- ACQUIRE | | +---------| CPU |\ | | | \ +----------+ SDAApplied to for-next, thanks!
Thanks a lot!
Quoted 13 lines
I fixed the following checkpatch warnings:
CHECK: Please don't use multiple blank lines #232: FILE:
drivers/i2c/busses/i2c-designware-amdpsp.c:92:(quoted diff) +2
-0+ +WARNING: braces {} are not necessary for single statement blocks #361: FILE:
drivers/i2c/busses/i2c-designware-amdpsp.c:221:drivers/i2c/busses/i2c-designware-amdpsp.c new file +3
-0+if (ret) { + goto cleanup; + }
Quoted 1 line
Please also use checkpatch next time.
Ooops, sorry for this. Actually I used checkpatch till v3, but forgot to run this on v4 where this change was introduced, my bad. Will improve going forward :)
Best Regards,
Jan
Re: [PATCH v4 2/2] i2c: designware: Add AMD PSP I2C bus support
Quoted 4 lines
Ooops, sorry for this. Actually I used checkpatch till v3, but forgot to run this on v4 where this change was introduced, my bad. Will improve going forward :)
No worries, happened to me as well. Thanks for your contribution!
Quoted 9 lines · Jan Dabros
This patchset comprises support for new i2c-designware controller setup on some AMD Cezanne SoCs, where x86 is sharing i2c bus with PSP. PSP uses the same controller and acts as an i2c arbitrator there (x86 is leasing bus from it).
First commit aims to improve generic i2c-designware code by adding extra locking on
probe()anddisable()paths. I would like to ask someone with access to boards which use IntelBayTrail(CONFIG_I2C_DESIGNWARE_BAYTRAIL)to verify behavior of my changes on such setup.
I'm going to run overnight with both patches a test case that used to cause some activity on a shared I2C bus on Baytrail based MRD 7 tablet. Test below used to trigger system hang after a few hours - days before some PUNIT - graphics related issue was fixed a few years ago:
#!/bin/sh
X &
export DISPLAY=:0
sleep 2
xclock -update 30 -digital -geometry 500x50+1+1027 &
xload -update 60 -bg black -hl red -fg green -geometry 1916x250+1+774 & sleep 1
xsetroot -solid red
xset s noblank s off -dpms
glxgears >/dev/null &
while :; do acpi -b; sleep 1.2; done
śr., 9 lut 2022 o 16:11 Jarkko Nikula <[email protected]> napisał(a):
Quoted 16 lines · Jan Dabros
Quoted 9 lines
This patchset comprises support for new i2c-designware controller setup on some AMD Cezanne SoCs, where x86 is sharing i2c bus with PSP. PSP uses the same controller and acts as an i2c arbitrator there (x86 is leasing bus from it).
First commit aims to improve generic i2c-designware code by adding extra locking on
probe()anddisable()paths. I would like to ask someone with access to boards which use IntelBayTrail(CONFIG_I2C_DESIGNWARE_BAYTRAIL)to verify behavior of my changes on such setup.I'm going to run overnight with both patches a test case that used to cause some activity on a shared I2C bus on Baytrail based MRD 7 tablet. Test below used to trigger system hang after a few hours - days before some PUNIT - graphics related issue was fixed a few years ago:
Quoted 11 lines
#!/bin/sh
X &
export DISPLAY=:0
sleep 2
xclock -update 30 -digital -geometry 500x50+1+1027 &
xload -update 60 -bg black -hl red -fg green -geometry 1916x250+1+774 & sleep 1
xsetroot -solid red
xset s noblank s off -dpms
glxgears >/dev/null &
while :; do acpi -b; sleep 1.2; done
Thanks, looking forward to the results.
Best Regards,
Jan