From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 89919365A14 for ; Mon, 8 Jun 2026 05:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780897410; cv=none; b=io4GUgcPeEWVt9Rr7BEYUwxsxbrUaHk6tlrFzejYlsi3lsFGauYNT9L8dYpjz92YLQiVCAp86KlQcW/88gsNEltpK1+TjGBebQ6MeGGl6+bkIrfJG81Apk75ydpXvFE6CiZKPufsHmSvvRQwJvNfRI7hck7YYcF+te3OpfOX9rc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780897410; c=relaxed/simple; bh=sHmZ9Hs+c2OgytBjaBgs3aCzSZjdfUAJbkqreEo5ReU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y2jgfgV5l96ybFsLRI+hyZANJxsG9YbARO9/l8Z/Ed5q3X9+4tb3SthImgCt1n244Sr1+TysgfumqwEAKjuGErBJRBN0+QVUchLqozdUBU/Lic0XhmRWm4JvbhXPIOmfEA4h2cmjwkp0DE2QRTTe3KgIjTD+KXkWuhiUQuGh/CA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DfJkjAQP; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DfJkjAQP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780897409; x=1812433409; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sHmZ9Hs+c2OgytBjaBgs3aCzSZjdfUAJbkqreEo5ReU=; b=DfJkjAQP09qZTsm1FrQiVO2lFRLbec8OdqtTmVnbcsxErIdBuQDKbICR /OMLKNV+dyIerVMpT4utNy6NksEB4r93rTq5iGjwrwPxRtvESopVG/S8v SUf0AB9LgLgfCuZWFap+3FfO7rYjq+IWlYreH6OGJbKYoA83pWMhWIjuk X3gq2qEX5O2zxQUxjCVILJ04dVdA0+A6QI8QLPFDberHhz+38RugMNQZy tJWhFiSAWNIlvTbzapbgzwy6HISMvxu8i53Vf0mps/cJ9eF1TqTrmlgOR BUQx4ajlFvlnAcjCZtzjS7wIb9Rt0M3Y2JiXSN71oGy67XOqKwcb1tu56 A==; X-CSE-ConnectionGUID: c5Qm3ezkQyq7ovuUHAnQDg== X-CSE-MsgGUID: 1Zpwbnc5Qny5LriYCRHD4w== X-IronPort-AV: E=McAfee;i="6800,10657,11810"; a="104284027" X-IronPort-AV: E=Sophos;i="6.24,193,1774335600"; d="scan'208";a="104284027" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2026 22:43:28 -0700 X-CSE-ConnectionGUID: iBmnY1m2SrOGfUgdrLgNiw== X-CSE-MsgGUID: WSWw9h4tQZOTP9VJOztWOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,193,1774335600"; d="scan'208";a="245505660" Received: from conormcd-mobl2.ger.corp.intel.com (HELO ahunter6-desk) ([10.245.244.114]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2026 22:43:25 -0700 From: Adrian Hunter To: alexandre.belloni@bootlin.com Cc: Frank.Li@nxp.com, david.nystrom@est.tech, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 2/8] i3c: master: Serialize i3c_set_hotjoin() with the maintenance lock Date: Mon, 8 Jun 2026 08:43:06 +0300 Message-ID: <20260608054312.10604-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260608054312.10604-1-adrian.hunter@intel.com> References: <20260608054312.10604-1-adrian.hunter@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Content-Transfer-Encoding: 8bit i3c_set_hotjoin() dispatches the controller's enable_hotjoin() or disable_hotjoin() op and updates master->hotjoin under i3c_bus_normaluse_lock(). That lock is a read-side acquisition of bus->lock (down_read()), so it does not exclude concurrent callers. The hotjoin sysfs attribute can be opened multiple times, and writes through different opens are not serialized. Two concurrent writers to "hotjoin" can therefore race in i3c_set_hotjoin(), with the controller op and the master->hotjoin store from one call interleaving with the other. The hardware enable/disable state and the value reported by hotjoin_show() can end up out of sync. Take i3c_bus_maintenance_lock() instead. Toggling Hot Join enable changes bus state and is conceptually a maintenance operation, so the write-side acquisition of bus->lock is the appropriate lock and serializes concurrent callers against each other and against other maintenance operations. Fixes: 317bacf960a48 ("i3c: master: add enable(disable) hot join in sys entry") Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V3: Add Frank's Rev'd by Changes in V2: Add Fixes tag drivers/i3c/master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index ab11e2d79aab..38ffc8713167 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -649,7 +649,7 @@ static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable) return ret; } - i3c_bus_normaluse_lock(&master->bus); + i3c_bus_maintenance_lock(&master->bus); if (enable) ret = master->ops->enable_hotjoin(master); @@ -659,7 +659,7 @@ static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable) if (!ret) master->hotjoin = enable; - i3c_bus_normaluse_unlock(&master->bus); + i3c_bus_maintenance_unlock(&master->bus); if ((enable && ret) || (!enable && !ret) || master->rpm_ibi_allowed) i3c_master_rpm_put(master); -- 2.51.0