From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EEB63D47DE; Fri, 22 May 2026 10:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445119; cv=none; b=VLHdzk3pmfTkvlQ3t8qMlGTw9fsHUUFfgU4ovWouogbQEuyhwTgR0CRaYAh7CwIoQ1ay1Swir5EO1A9BYTwjCU5v0lEl2+OslL6itw3093cyUr0OclR1BzsQGxpIzsmFLt25FEYh1z/9sTB9p7IyS+p9bY44qSIFC4af9hhnrNQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779445119; c=relaxed/simple; bh=+R74E5YvNsL5Wej67ou6dUHWim3RWgIorQJ/LkW5EZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=StZGYVSIRdW8CBVAP2CGDFz77h0/fFaq4y2rRl7o9ISfqCiiORUtyMOkGf9sK4NtStZ6fdrdcn45zmhn6YIZNuLkeXZu1kOW4GoA0pJU0ftExZitRNtNAAl16Ke7OeWcdZReenKLZhIgomSx5XMj3o5IACshMZoGbWa24MgkZI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hyGcNSVR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hyGcNSVR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 836F31F00A3D; Fri, 22 May 2026 10:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779445118; bh=ZdZdbTP0Zl4cO/TOEBD6ohZd0OjzNrlsg3iBs2gbCH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hyGcNSVR+OF9Z/oWgWO8av6LPOV4KJacF4eUTOfcvcdAVVvdTUG8N3IU2MWEuZSko dEAlbdLPP29iykxP8aNw4Y5KYDv2uSi9K4r4xuL25db0bMbAbYA5Qi/yUHSIhXOWa+ FuvZsmLYpaJwPRpB/8+NCtOsZG5CDdMkFdcQGt8rc40WZ+jSuqrg+pT93+L34SLwG9 xQDOtl5DTQpg4wjtA17puEdf06Uh8mujOgzXHMM6iQQ9KD6fM8+Rhx3OQjHZFy0CvN xYnsdggAWQg7eMiVNVqIPp11XUqFVS/5P1N1IT8Rnqq/L2Vf/GLCrkc3tDYt4clZou teFto687IxxLw== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH 05/17] i3c: renesas: Fix re-attach Date: Fri, 22 May 2026 13:18:03 +0300 Message-ID: <20260522101815.1722909-6-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260522101815.1722909-1-claudiu.beznea@kernel.org> References: <20260522101815.1722909-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Claudiu Beznea During re-attach, the device may change its position in the i3c->addrs[] array. As a result, it may use a different Device Address Table Basic Register (DATBAS), which needs to be reconfigured. Reconfigure the DATBAS register on re-attach. Along with it update software caches. Fixes: d028219a9f14 ("i3c: master: Add basic driver for the Renesas I3C controller") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea --- drivers/i3c/master/renesas-i3c.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-i3c.c index d2f29ed0b6ed..5174a390d668 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -892,10 +892,28 @@ static int renesas_i3c_reattach_i3c_dev(struct i3c_dev_desc *dev, struct i3c_master_controller *m = i3c_dev_get_master(dev); struct renesas_i3c *i3c = to_renesas_i3c(m); struct renesas_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev); + int pos; + + pos = renesas_i3c_get_free_pos(i3c); + if (pos < 0) + return pos; + + if (data->index != pos) { + renesas_writel(i3c->regs, DATBAS(data->index), 0); + i3c->addrs[data->index] = 0; + i3c->free_pos |= BIT(data->index); + + data->index = pos; + i3c->free_pos &= ~BIT(data->index); + } i3c->addrs[data->index] = dev->info.dyn_addr ? dev->info.dyn_addr : dev->info.static_addr; + renesas_writel(i3c->regs, DATBAS(data->index), + DATBAS_DVSTAD(dev->info.static_addr) | + datbas_dvdyad_with_parity(i3c->addrs[data->index])); + return 0; } -- 2.43.0