From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (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 9C14D170A15 for ; Wed, 22 Jan 2025 09:44:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737539066; cv=none; b=kp6iVTHHZb0XkwQqOyAtDML1Q3RAoqKUdEGgkzza7fReaEzgMwoArAFoe0kl7OJDcH8X7mGrwjT9eXMN7PyOAj27tBciWo7nRfIjZe66s6/i7vAI8RCl4YNH5BEWWJT1Hgsa6pB2XtvEdegkH3RZKkNbJs96MRCTq5lM/cHMaJE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737539066; c=relaxed/simple; bh=yyxOIBo8e4N20eSkHTT5XolYVBk2yPUK9ZgaPtnkCRE=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=i8KrO25tTdvgh3gf34h1BMjIe6VbZfu6APL54SGet2XRyulc/RCSQfTvAkqeMFetst/B+mZaYUdPt6w2pWUlafnYGTMj2LNWt8gNOqH8IjxQvAraHdqUWqJRYOVlXVcWQKOvecw+oTyNIYLjtBfgCBHGJezm5I21vCU8rFCp4rI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Mzs2Y4Xh; arc=none smtp.client-ip=198.47.23.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Mzs2Y4Xh" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 50M9htoK172235 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Jan 2025 03:43:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1737539035; bh=/CXvm0asyjuCXRychYSJFJO4VoOdyWy5Yi9fJ25FM5I=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=Mzs2Y4XhKusIzEiAqCPAnXddqVzi5DzB7CnvubIxuB+s4XRfToNZQNhlWwulDiHe/ 3tu8br2IB4TNVHjK/D/LlaI+Ykjk0emzsv9qgJA2bLy2SUxZP6p8PKXAFdS+81CJzl FUtK9BmxgaQbwiRFAkuBxQv39GuBPda/AKBvaipY= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 50M9ht97022072 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 22 Jan 2025 03:43:55 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 22 Jan 2025 03:43:54 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 22 Jan 2025 03:43:54 -0600 Received: from [10.24.69.142] ([10.24.69.142]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 50M9hmO2086940; Wed, 22 Jan 2025 03:43:49 -0600 Message-ID: Date: Wed, 22 Jan 2025 15:13:48 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/3] mfd: syscon: Allow syscon nodes without a "syscon" compatible To: "Rob Herring (Arm)" , Lee Jones , Arnd Bergmann , Pankaj Dubey , Heiko Stuebner , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi CC: Peter Griffin , Will McVicker , John Madieu , Krzysztof Kozlowski , , , Andrew Davis , Nishanth Menon , Vignesh Raghavendra , "Kumar, Udit" References: <20241217-syscon-fixes-v2-0-4f56d750541d@kernel.org> <20241217-syscon-fixes-v2-3-4f56d750541d@kernel.org> Content-Language: en-US From: Vaishnav Achath In-Reply-To: <20241217-syscon-fixes-v2-3-4f56d750541d@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Hi Rob, On 17/12/24 23:41, Rob Herring (Arm) wrote: > of_syscon_register_regmap() was added for nodes which need a custom > regmap setup. It's not really correct for those nodes to claim they are > compatible with "syscon" as the default handling likely doesn't work in > those cases. If device_node_get_regmap() happens to be called first, > then of_syscon_register() will be called and an incorrect regmap will be > created (barring some other error). That may lead to unknown results in > the worst case. In the best case, of_syscon_register_regmap() will fail > with -EEXIST. This problem remains unless these cases drop "syscon" (an > ABI issue) or we exclude them using their specific compatible. ATM, > there is only one user: "google,gs101-pmu" > > There are also cases of adding "syscon" compatible to existing nodes > after the fact in order to register the syscon. That presents a > potential DT ABI problem. Instead, if there's a kernel change needing a > syscon for a node, then it should be possible to allow the kernel to > register a syscon without a DT change. That's only possible by using > of_syscon_register_regmap() currently, but in the future we may want to > support a match list for cases which don't need a custom regmap. > > With this change, the lookup functions will succeed for any node > registered by of_syscon_register_regmap() regardless of whether the node > compatible contains "syscon". > > Signed-off-by: Rob Herring (Arm) > --- > v2: > - Fix logic when a syscon is found in list to not return an error > --- > drivers/mfd/syscon.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c > index bfb1f69fcff1d3cd35cf04ccd4c449e7d0395c79..226915ca3c93dcaf47bdd46b58e00e10e155f952 100644 > --- a/drivers/mfd/syscon.c > +++ b/drivers/mfd/syscon.c > @@ -171,9 +171,12 @@ static struct regmap *device_node_get_regmap(struct device_node *np, > break; > } > > - if (!syscon) > - syscon = of_syscon_register(np, check_res); > - > + if (!syscon) { > + if (of_device_is_compatible(np, "syscon")) > + syscon = of_syscon_register(np, check_res); > + else > + syscon = ERR_PTR(-EINVAL); > + } Earlier the above check was only in syscon_node_to_regmap() , but now the users of device_node_to_regmap() also undergoes this check and there are few drivers in tree which uses device_node_to_regmap() without having "syscon" in compatible, likely those drivers need to be fixed, but this patch breaks all those drivers now, atleast the below drivers are affected and all TI platforms fail to boot due to this: drivers/soc/ti/k3-socinfo.c drivers/mux/mmio.c ("reg-mux" users) drivers/clk/keystone/syscon-clk.c All the above drivers fail due to the above check for syscon compatible. What is the recommended solution to fix this? Thanks and Regards, Vaishnav > mutex_unlock(&syscon_list_lock); > > if (IS_ERR(syscon)) > @@ -238,9 +241,6 @@ EXPORT_SYMBOL_GPL(device_node_to_regmap); > > struct regmap *syscon_node_to_regmap(struct device_node *np) > { > - if (!of_device_is_compatible(np, "syscon")) > - return ERR_PTR(-EINVAL); > - > return device_node_get_regmap(np, true); > } > EXPORT_SYMBOL_GPL(syscon_node_to_regmap); >