[PATCH] i3c: dw-i3c-master: Set SIR_REJECT in DAT on device attach and reattach

adrianhoyin.ng@altera.com posted 1 patch 1 month, 2 weeks ago
There is a newer version of this series
drivers/i3c/master/dw-i3c-master.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] i3c: dw-i3c-master: Set SIR_REJECT in DAT on device attach and reattach
Posted by adrianhoyin.ng@altera.com 1 month, 2 weeks ago
From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>

The DesignWare I3C master controller ACKs IBIs as soon as a valid
Device Address Table (DAT) entry is present. This can create a race
between device attachment (after DAA) and the point where the client
driver enables IBIs via i3c_device_enable_ibi().

Set DEV_ADDR_TABLE_SIR_REJECT in the DAT entry during
attach_i3c_dev() and reattach_i3c_dev() so that IBIs are rejected
by default. The bit is cleared in enable_ibi() after ENEC is issued,
and restored in disable_ibi() after DISEC, keeping the controller
state aligned with the device event configuration.

Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
---
 drivers/i3c/master/dw-i3c-master.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 7eb09ad10171..d014f2cd6071 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -1024,7 +1024,7 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev,
 		master->free_pos &= ~BIT(pos);
 	}
 
-	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr),
+	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr) | DEV_ADDR_TABLE_SIR_REJECT,
 	       master->regs +
 	       DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
 
@@ -1053,7 +1053,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev)
 	master->free_pos &= ~BIT(pos);
 	i3c_dev_set_master_data(dev, data);
 
-	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr),
+	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr) | DEV_ADDR_TABLE_SIR_REJECT,
 	       master->regs +
 	       DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
 
-- 
2.49.GIT
Re: [PATCH] i3c: dw-i3c-master: Set SIR_REJECT in DAT on device attach and reattach
Posted by Frank Li 1 month, 2 weeks ago
On Wed, Feb 11, 2026 at 03:49:21PM +0800, adrianhoyin.ng@altera.com wrote:
> From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>
> The DesignWare I3C master controller ACKs IBIs as soon as a valid
> Device Address Table (DAT) entry is present. This can create a race
> between device attachment (after DAA) and the point where the client
> driver enables IBIs via i3c_device_enable_ibi().
>
> Set DEV_ADDR_TABLE_SIR_REJECT in the DAT entry during
> attach_i3c_dev() and reattach_i3c_dev() so that IBIs are rejected
> by default. The bit is cleared in enable_ibi() after ENEC is issued,

In patch, there are not clean this bit code?

> and restored in disable_ibi() after DISEC, keeping the controller
> state aligned with the device event configuration.
>

Fixes tags

Frank
> Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
> ---
>  drivers/i3c/master/dw-i3c-master.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index 7eb09ad10171..d014f2cd6071 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -1024,7 +1024,7 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev,
>  		master->free_pos &= ~BIT(pos);
>  	}
>
> -	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr),
> +	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr) | DEV_ADDR_TABLE_SIR_REJECT,
>  	       master->regs +
>  	       DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
>
> @@ -1053,7 +1053,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev)
>  	master->free_pos &= ~BIT(pos);
>  	i3c_dev_set_master_data(dev, data);
>
> -	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr),
> +	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr) | DEV_ADDR_TABLE_SIR_REJECT,
>  	       master->regs +
>  	       DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
>
> --
> 2.49.GIT
>
Re: [PATCH] i3c: dw-i3c-master: Set SIR_REJECT in DAT on device attach and reattach
Posted by Ng, Adrian Ho Yin 1 month, 2 weeks ago
On 2/11/2026 11:39 PM, Frank Li wrote:
> On Wed, Feb 11, 2026 at 03:49:21PM +0800, adrianhoyin.ng@altera.com wrote:
>> From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>>
>> The DesignWare I3C master controller ACKs IBIs as soon as a valid
>> Device Address Table (DAT) entry is present. This can create a race
>> between device attachment (after DAA) and the point where the client
>> driver enables IBIs via i3c_device_enable_ibi().
>>
>> Set DEV_ADDR_TABLE_SIR_REJECT in the DAT entry during
>> attach_i3c_dev() and reattach_i3c_dev() so that IBIs are rejected
>> by default. The bit is cleared in enable_ibi() after ENEC is issued,
> 
> In patch, there are not clean this bit code?
>
The clear/restore handling is already implemented in
dw_i3c_master_set_sir_enabled(), which is called from
enable_ibi() and disable_ibi().

This patch only ensures SIR_REJECT is set when the DAT entry
is initially programmed during attach/reattach.

I will update the commit message in V2 for better clarity.
>> and restored in disable_ibi() after DISEC, keeping the controller
>> state aligned with the device event configuration.
>>
> 
> Fixes tags
> 
Will add Fixes tag in V2.
> Frank
>> Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>> ---
>>   drivers/i3c/master/dw-i3c-master.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
>> index 7eb09ad10171..d014f2cd6071 100644
>> --- a/drivers/i3c/master/dw-i3c-master.c
>> +++ b/drivers/i3c/master/dw-i3c-master.c
>> @@ -1024,7 +1024,7 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev,
>>   		master->free_pos &= ~BIT(pos);
>>   	}
>>
>> -	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr),
>> +	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr) | DEV_ADDR_TABLE_SIR_REJECT,
>>   	       master->regs +
>>   	       DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
>>
>> @@ -1053,7 +1053,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev)
>>   	master->free_pos &= ~BIT(pos);
>>   	i3c_dev_set_master_data(dev, data);
>>
>> -	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr),
>> +	writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr) | DEV_ADDR_TABLE_SIR_REJECT,
>>   	       master->regs +
>>   	       DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
>>
>> --
>> 2.49.GIT
>>