From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 CDB2136A34A for ; Tue, 12 May 2026 12:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778588271; cv=none; b=IedIroDq1yXL6wS1YLVVqim8etnZ4jjPLObia/Z7fmgzRPCFBHCt7ClJXUi8eMwe52+4LFzykQJ54Yu+SkVnGcR4yXFAhV+anYfEHtIPXBo4t6mGRZFmUfTbv5cNs4jV/RwG2tIRzL9d6anUC74tNn+/Rjrc6zyk80+63wOrPBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778588271; c=relaxed/simple; bh=j1amexI1xVWiYSdm203maTEISYpN+zkYKyM2TcKbHFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IPfqZsRWRmYe2bxNC6AefY6NoitHoZGgCo7ugP4fNlhoEQ1yl2T05wf8OT/2vEBqK0nAck8df0Gg3+pQNo5vngSX+4k3ifzF0ustRzEQL8XExR5COOyx5EE8/vOWw7LVxmbenGH5+4xxBqCgk3aY80WkuTXVelIKBAV6S6OhiSk= 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=asu005hO; arc=none smtp.client-ip=198.175.65.21 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="asu005hO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778588270; x=1810124270; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j1amexI1xVWiYSdm203maTEISYpN+zkYKyM2TcKbHFs=; b=asu005hOfFzqlf8/gG4GLK+km4JxGTSDT52L0PVr+yEAeLcvlzkw0Gyy KzXfkjCJ4344lnheqn8Mii/0xcUzLJxRIa3NDu2SJRQKqZBtD/ZsdXMSZ llNZ45CmMoS5PVoJo0bNQs4GOBkHC3kyanAwFTyo2nSETN7ZKjVkUhgMK HTVdNGk93VioetPt/c6vjleuwsAzcLGWCvWvzfTHG7borvU77sd9nsoTO t/aOT2IhGWO8UD86jsPkJ0aiL8iYC8qnoLKPz7ebxO7j9J6fIsz6OO30R WQEvtsPG9B7XD3ynTYvbOMl6hAPjm7bgFGEyLIQhghLP78OLFuIMrLrU/ g==; X-CSE-ConnectionGUID: lcbWhinlQn+iJ1I0IsLnsQ== X-CSE-MsgGUID: LT7lUOe4S1uQfotWwWdvgQ== X-IronPort-AV: E=McAfee;i="6800,10657,11783"; a="79389487" X-IronPort-AV: E=Sophos;i="6.23,230,1770624000"; d="scan'208";a="79389487" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2026 05:17:50 -0700 X-CSE-ConnectionGUID: vvHoXNu4RHSPZ+ahY/LvEw== X-CSE-MsgGUID: mtV5ZTfPTEmKvSgus8eUdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,230,1770624000"; d="scan'208";a="241756129" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.121]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2026 05:17:48 -0700 From: Adrian Hunter To: alexandre.belloni@bootlin.com Cc: Frank.Li@nxp.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] i3c: master: Serialize i3c_set_hotjoin() with the maintenance lock Date: Tue, 12 May 2026 15:17:26 +0300 Message-ID: <20260512121732.406009-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260512121732.406009-1-adrian.hunter@intel.com> References: <20260512121732.406009-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. Signed-off-by: Adrian Hunter --- 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