[PATCH v8 0/3] I3C: master: fix the address assign issue if assign-address is exist in dts

Frank Li posted 3 patches 1 month ago
drivers/i3c/master.c       | 82 +++++++++++++++++++++++++++++++++-------------
include/linux/i3c/master.h |  9 +++--
2 files changed, 67 insertions(+), 24 deletions(-)
[PATCH v8 0/3] I3C: master: fix the address assign issue if assign-address is exist in dts
Posted by Frank Li 1 month ago
These patches are split from
https://lore.kernel.org/linux-i3c/ZvrAuOBLgi+HtrPD@lizhi-Precision-Tower-5810/#R

There are discussion on
https://lore.kernel.org/linux-i3c/20240819-i3c_fix-v3-0-7d69f7b0a05e@nxp.com/T/#m16fa9bb875b0ae9d37c5f6e91f90e375551c6366

Basic back ground is
The current framework is
1. get free i3c dynamic address
2. if found dt have assign-address for such device (identify by PID),
change to such address.

There are problem in current implement.
If device A have assign-address 0xa, device B have assign-address 0xB,
which described at dts file.

If device A is not ready during i3c probe, and device B hotjoin happen,
0xA will assign to device B, so if device A hotjoin later, address 0xA
Can't assign to A because B already use it.

Mirquel's opinion is return address B when B hotjoin by scan dts by PID.

The issue is the controller HCI (i3C standard),

I3C HCI Spec 1.2, sec 6.4.1, when do DAA,  "DAA CMD and dynmatic address"
queue to cmd together.  We don't know PID before DAA CMD. So dynamic
address can NOT get based on PID.

When do DAA in HCI, it needs a dynamtic address firstly before get PID
information.

Consider this need more time to discuss, so split from previous big serial
to avoid prevent other fix patches can't be merged into i3c tree.

This patches's overall design:

1. keep current frame's work flow
2. reserver all address, which assigned in dts.
3. the device with assigned address have high priorioty to get such
address.
4. if all address without assigned by dt are used, use offline devices's
assigned address.

To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-i3c@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: arnd@arndb.de
Cc: bbrezillon@kernel.org
Cc: boris.brezillon@collabora.com
Cc: conor.culhane@silvaco.com
Cc: gregkh@linuxfoundation.org
Cc: imx@lists.linux.dev
Cc: linux-i3c@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: miquel.raynal@bootlin.com
Cc: pthombar@cadence.com
Cc: ravindra.yashvant.shinde@nxp.com

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v8:
- see each patch.
- Link to v7: https://lore.kernel.org/r/20241008-i3c_dts_assign-v7-0-96ec93d1f34c@nxp.com

Changes in v7:
- see each patch
- Link to v6: https://lore.kernel.org/r/20241003-i3c_dts_assign-v6-0-eae2569c92ca@nxp.com

Changes in v2:
- see each patch
- Link to v1: https://lore.kernel.org/r/20241001-i3c_dts_assign-v1-0-6ba83dc15eb8@nxp.com

---
Frank Li (3):
      i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS
      i3c: master: Extend address status bit to 4 and add I3C_ADDR_SLOT_EXT_DESIRED
      i3c: master: Fix dynamic address leak when 'assigned-address' is present

 drivers/i3c/master.c       | 82 +++++++++++++++++++++++++++++++++-------------
 include/linux/i3c/master.h |  9 +++--
 2 files changed, 67 insertions(+), 24 deletions(-)
---
base-commit: 77df9e4bb2224d8ffbddec04c333a9d7965dad6c
change-id: 20241001-i3c_dts_assign-d615fc33cc1d

Best regards,
---
Frank Li <Frank.Li@nxp.com>
Re: [PATCH v8 0/3] I3C: master: fix the address assign issue if assign-address is exist in dts
Posted by Alexandre Belloni 3 weeks, 4 days ago
On Mon, 21 Oct 2024 11:45:05 -0400, Frank Li wrote:
> These patches are split from
> https://lore.kernel.org/linux-i3c/ZvrAuOBLgi+HtrPD@lizhi-Precision-Tower-5810/#R
> 
> There are discussion on
> https://lore.kernel.org/linux-i3c/20240819-i3c_fix-v3-0-7d69f7b0a05e@nxp.com/T/#m16fa9bb875b0ae9d37c5f6e91f90e375551c6366
> 
> Basic back ground is
> The current framework is
> 1. get free i3c dynamic address
> 2. if found dt have assign-address for such device (identify by PID),
> change to such address.
> 
> [...]

Applied, thanks!

[1/3] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS
      https://git.kernel.org/abelloni/c/16aed0a6520b
[2/3] i3c: master: Extend address status bit to 4 and add I3C_ADDR_SLOT_EXT_DESIRED
      https://git.kernel.org/abelloni/c/2f552fa28059
[3/3] i3c: master: Fix dynamic address leak when 'assigned-address' is present
      https://git.kernel.org/abelloni/c/851bd21cdb55

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com