Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1377056lqo; Sat, 18 May 2024 00:02:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXHicMkc793BX+vmTHjZ9gzDL8P+KaX1Vrb9ARXI1DcmZ7iPKoVSeoC5veFAAgyYVNebRa8Mi+rbQRXYfzG0bGwmvn/m12Pkc8c2H37Q== X-Google-Smtp-Source: AGHT+IESD31QCAQdxwzNUyAKwFPXeNYBRrR9PsOgNp81r3mjyC+VnSY99obV9Io4MSxmewH560hP X-Received: by 2002:a05:6358:6214:b0:194:801b:150b with SMTP id e5c5f4694b2df-194801b1901mr1404936355d.16.1716015769480; Sat, 18 May 2024 00:02:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716015769; cv=pass; d=google.com; s=arc-20160816; b=h/JkNo4JnmvkrMZ0pAeuvz07vm2JMRax4/vhBTAu5F9ZYkzfuKSM1kdJwWs0QLVwgm RhCJWae+h1FNCl0VuoNDHfzIF0wW8DWlWr71YEaRg4ZscFP7yAWVyIwHC1hQsrWXbkhW pC7ESPZ6jJsW5XR8TN/l32tpH3z8eZ7hyW/YSWNS4fgCTch/NkZY3orrtzKq/g+coG6T geU61298mAb4DJ2sC+nI5Tc48Ffn89NfpynwVxP88RKyEa1u3sXuw7Zp73VA6ooTllSU mJfErIM79iU9mSTF0vb1RyLP2Fg8Mb9K7giFZgsIkRPx1/5UZaRvSKudYB67lDBzVyp7 Mdag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=r277yi+Nyo+3nifP8z4BGCRO8hmMLsoW+s546ZKtUG0=; fh=oscnr9v2rxGptbaSUMr+Dau10xxcdYDmU/BTCEj2hpE=; b=VCCSCcLWYMEIVrLeIvhKD79mPAGGbQT7X78mQxLxYHxQ3Dgj87inupVu/D+4qHRPYI nJGtljR7jK213Sy13G8funXYPoND85tspHL8w/oZpkX9RGqKzcz9SRZ0WpwYeOhnWLVz FbHBS2nzBTCvr+oz7S1MZ13iyca9EQ5rPY/Ta4cWD9TX9TAr8GkA+Tr8r1NX6tWWmW1b 3Kd+IpM45e26eX+qvpRHabS1p8FsSwR14ZlYl6rfrtTKvkctQ0WHRuY4cC9lSBBRfl1q 5mb2ghSgFobHS/huie2zHGjza0hHZOMvqTxTE4QqJf7j1Ad7VyaF36sBTyjiJ39+e3xx 6OJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="GvwBS/lG"; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-182787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-65017f097basi8046512a12.776.2024.05.18.00.02.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 00:02:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="GvwBS/lG"; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-182787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 221DFB20FA9 for ; Sat, 18 May 2024 07:01:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CEC3C8FF; Sat, 18 May 2024 07:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="GvwBS/lG" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 91A452F4A; Sat, 18 May 2024 07:01:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716015703; cv=none; b=QKNdrd9yytREM7TELGBF9MGC6QSMQDnuKZv/7jnJY53/yNRUsCUsaqYWiWw9TnbqIfn4pxd7AvmGLjiE2LBxZXes5fWVer1GhWvI4lFcbsuVjM5L7Yq7HLvXRXDOa3mAKVfvFXyvGY4ZGyU0/5iG2W2e3EKNdScfogR5sKdQ1Nc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716015703; c=relaxed/simple; bh=7gJcAObcPbQw9XW+LduiP1Y3FVVW2Ym0ZJq4JI+/q94=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bmdkMdeFRdldLAQlEzT1MRjcQhQzw3O5o2jCqxSPzICC+Y9W1JFpJqp+t7vZ9WMM9iU4koWks40DVnm0KrgivTJN3Ur33edBJcNcSz/n3Nle4lg+6MunQkAEaTm3H9W7MZhnk/r+G9sbC7SVaM4BnFpmm/eWhQ1xGPoU9PA/2UI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=GvwBS/lG; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=r277yi+Nyo+3nifP8z4BGCRO8hmMLsoW+s546ZKtUG0=; b=GvwBS/lGRWXZq4bL7YXwfpOBIR E0RJEWCEOPhfghLmzPhcIItXA8XtN9/0t1NpfWOKBKqp6j/9fgFMlAr0F7yIquJ2pLQhAEAVjIug5 wtGsQtV5w6GCrv7tSRha7MnNRFCDXxN+Q2coKSOIrVLEfeU17RPmTiXxOpfqerDdBBtENgw1hCrIi BLwQawXSug27i/O+UwvZ7r82hzcNR8aj1pq91FiYflk2BQxXCVdC5qGOI477KbSmgZYLbSkvAAgLG TZVoEDe4VkaTUwFB/L09s/Mm1LNHMLEHJsoJvtn7/h7Fd0kyh3D7VMJMPIxWRBAomEzoshnDGNDpe zy96AYqw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:57026) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1s8E4F-0008BX-2v; Sat, 18 May 2024 08:01:21 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1s8E4B-0002JK-0a; Sat, 18 May 2024 08:01:15 +0100 Date: Sat, 18 May 2024 08:01:14 +0100 From: "Russell King (Oracle)" To: Guenter Roeck Cc: linux-arm-kernel@lists.infradead.org, Duanqiang Wen , mturquette@baylibre.com, sboyd@kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] clkdev: report over-sized strings when creating clkdev entries Message-ID: References: <7eda7621-0dde-4153-89e4-172e4c095d01@roeck-us.net> <4ea9cc83-c7ca-47b8-8d43-dab16193108f@roeck-us.net> <646bd149-f29a-4c91-ab00-4f6d2fce23fd@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <646bd149-f29a-4c91-ab00-4f6d2fce23fd@roeck-us.net> Sender: Russell King (Oracle) On Fri, May 17, 2024 at 08:24:19PM -0700, Guenter Roeck wrote: > On 5/17/24 16:37, Russell King (Oracle) wrote: > > On Fri, May 17, 2024 at 04:34:06PM -0700, Guenter Roeck wrote: > > > On 5/17/24 15:22, Russell King (Oracle) wrote: > > > > On Fri, May 17, 2024 at 03:09:12PM -0700, Guenter Roeck wrote: > > > > > Hi, > > > > > > > > > > On Fri, Mar 15, 2024 at 11:47:55AM +0000, Russell King (Oracle) wrote: > > > > > > Report an error when an attempt to register a clkdev entry results in a > > > > > > truncated string so the problem can be easily spotted. > > > > > > > > > > > > Reported by: Duanqiang Wen > > > > > > Signed-off-by: Russell King (Oracle) > > > > > > Reviewed-by: Stephen Boyd > > > > > > > > > > With this patch in the mainline kernel, I get > > > > > > > > > > 10000000.clock-controller:corepll: device ID is greater than 24 > > > > > sifive-clk-prci 10000000.clock-controller: Failed to register clkdev for corepll: -12 > > > > > sifive-clk-prci 10000000.clock-controller: could not register clocks: -12 > > > > > sifive-clk-prci 10000000.clock-controller: probe with driver sifive-clk-prci failed with error -12 > > > > > ... > > > > > platform 10060000.gpio: deferred probe pending: platform: supplier 10000000.clock-controller not ready > > > > > platform 10010000.serial: deferred probe pending: platform: supplier 10000000.clock-controller not ready > > > > > platform 10011000.serial: deferred probe pending: platform: supplier 10000000.clock-controller not ready > > > > > platform 10040000.spi: deferred probe pending: platform: supplier 10000000.clock-controller not ready > > > > > platform 10050000.spi: deferred probe pending: platform: supplier 10000000.clock-controller not ready > > > > > platform 10090000.ethernet: deferred probe pending: platform: supplier 10000000.clock-controller not ready > > > > > > > > > > when trying to boot sifive_u in qemu. > > > > > > > > > > Apparently, "10000000.clock-controller" is too long. Any suggestion on > > > > > how to solve the problem ? I guess using dev_name(dev) as dev_id parameter > > > > > for clk_hw_register_clkdev() is not or no longer a good idea. > > > > > What else should be used instead ? > > > > > > > > It was *never* a good idea. clkdev uses a fixed buffer size of 20 > > > > characters including the NUL character, and "10000000.clock-controller" > > > > would have been silently truncated to "10000000.clock-cont", and thus > > > > > > > > if (!dev_id || strcmp(p->dev_id, dev_id)) > > > > > > > > would never have matched. > > > > > > > > We need to think about (a) whether your use of clk_hw_register_clkdev() > > > > is still appropriate, and (b) whether we need to increase the size of > > > > the strings. > > > > > > > > > > It isn't _my_ use, really. I only run a variety of boot tests with qemu. > > > I expect we'll see reports from others trying to boot the mainline kernel > > > on real sifive_u hardware or other hardware using the same driver or other > > > drivers using dev_name() as dev_id parameter. Coccinelle finds the > > > following callers: > > > > Using dev_name() is not an issue. It's when dev_name() exceeds 19 > > characters that it becomes an issue (and always has been an issue > > due to the truncation.) clk_get(dev, ...) uses dev_name(dev) to match > > against its entry in the table. > > > > As I say, dev_name() itself is not an issue. The length used for the > > name is. > > > > Maybe, but the existence of best_dev_name() suggests that this has been seen > before and that, as you mentioned, it is not a good idea. Anyway, the patch > below fixes the problem for me. I don't know if it is acceptable / correct, > so it might serve as guidance for others when fixing the problem for real. I get the impression that there's a communication problem here, so I'm not going to continue replying. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!