From patchwork Tue Jan 31 16:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 50949 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2839565wrn; Tue, 31 Jan 2023 08:12:44 -0800 (PST) X-Google-Smtp-Source: AK7set8UQ+1/pVUYunS2WS54x3sKUw3oS3bn1z0OvRoMWZVdGJMvESV2/iBPv8avHrFKKJyj/+mZ X-Received: by 2002:a05:6a20:c188:b0:be:e908:3292 with SMTP id bg8-20020a056a20c18800b000bee9083292mr2757243pzb.15.1675181563922; Tue, 31 Jan 2023 08:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675181563; cv=none; d=google.com; s=arc-20160816; b=FjMWF1R4rNmk3tWZ1RqnuWnhxLKqNMuiDSSEWip+ftK5B4DHwfZZjbD3w5Tu3TAA8f oEu5mrLWxAzllEMRgNt4B92KuvAvFy7ee/xUVYOkPS5UvqVm062x3Hsj0+ClsVkGRmIF D9tmOPQlM5ZO4FzR7lrPGdylQjBG0RE09qf5LeAR5DybzfaYjFsF3OTQwCAndDTcYyVJ KWSVgh9jr/rm3wFFWYyC/168VGcbtxemuHPh5lqqJWC2BfRqH6wAP/V/VwCWNJ33HKZh DivzCDUbs0vN55HcacEIK8hW+N6/iIrYNYi/DhlrBvVjeR8b9irYrDGVTjCZscM31g5F qRKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=VDJhzXE+EpJpWLKyPjwl5rb02w6NGxOvd6kEb5Nte8w=; b=Zw7vVkbcDhVbLahVyU9iCBFevQ4HyeO5hf/WRYg7fsKm1W+U4+koENP34CLmBJ1Xwo exVi7shzWkFZKAVMHSDLk+5PWPN9x3/AAjnCvjzr7y/xQBDZsG/oT3gTbKO1taab65Rr K7CZ26KsUhNzE8SbinfhDsh5dCEAhj4hbk65SskmWf3jXvi9BeiZXkTnPV1S1eB4Bm5k SRviXmz4+UAohI8rQA+IpGalhybzCvoaMuRbjtdCHv61dk+uxfxZwaAxC/5aPTyTd54a oAZQq22V6NxT2+imk+3W8qaFXliK01KLMJaat0YUnH2pwV72cleReZpP9SJ1pHktNvLa k8Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZjWU9vis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020a170902b7c300b00178170100fasi16011216plz.337.2023.01.31.08.12.30; Tue, 31 Jan 2023 08:12:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZjWU9vis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232069AbjAaQIm (ORCPT + 99 others); Tue, 31 Jan 2023 11:08:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbjAaQIj (ORCPT ); Tue, 31 Jan 2023 11:08:39 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 501A74A224; Tue, 31 Jan 2023 08:08:38 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso5978374wms.5; Tue, 31 Jan 2023 08:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VDJhzXE+EpJpWLKyPjwl5rb02w6NGxOvd6kEb5Nte8w=; b=ZjWU9vis4X8/Qrhodr1WlT2K9ZnNsLVgva3UtZhvNvGRHWrQnFGO/2W6fxRA36F7pe dwXAEFEGWN/qpVcv0E9L/2w0WOwrrgD3oEsIYhurtEKkO7Wh5goB22S+QtW0BhGWTkf3 i48IWtlvHzz9XJanlA3i/J9hjKjqcC0RVrF0Y69OAayeOY0X1g93s0JbSFWRbL0I3BJq g5VEMQiFCG10EU2PN79NktWsONIKWcqm28er8CwDU36EbbMlc7PU3zfjhNTd9WXWttVS rsnjAxIbqsCDUjj3hgWRKZsvCNYMEdW65DaVB9BfEaxGOd8ya7KdGA22gRp5UpdOot6F LmJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VDJhzXE+EpJpWLKyPjwl5rb02w6NGxOvd6kEb5Nte8w=; b=kzFFWDY9y3T351maNwtXCUaglT5mVB/YiepLRxiwPJDzkSJbhmR/s3oD7kvUUEAfTm +kh1EW4O0BtOflrQGGdikloCJKFhQIiu/FuF+nJcrZW9WlaCCRSN51PeVPD3CxK8BXAu G3gAKwEjIwOGFNmuIimJMnDeIr2efbA/RAHRZ+2034yr60GYg35UwMwJUSNAiuzboAv0 vgiXPMAjRePnlUaguUs3gW6L8TNKIkAQSX8iGzEyOvf6HSZPgSECjznGyezzM5rOa/qA l5CK/N3nAWUQ/qWXjaNxn85HUr46CjAnsM4aIgOy5hk9G6H5pvmelZD/N0efu4QUUW/4 6TFQ== X-Gm-Message-State: AO0yUKXD9tUMmyWUzeUOfG0EpV7KxrxqrsBuJJ1tuSks04ulhJUhFL6q tt/sj0Jsm/Ugmvw+ihQ4EbbbuoEk2MY= X-Received: by 2002:a7b:c3d3:0:b0:3de:1d31:1042 with SMTP id t19-20020a7bc3d3000000b003de1d311042mr594561wmj.23.1675181316729; Tue, 31 Jan 2023 08:08:36 -0800 (PST) Received: from localhost.localdomain (93-34-88-241.ip49.fastwebnet.it. [93.34.88.241]) by smtp.googlemail.com with ESMTPSA id ip7-20020a05600ca68700b003dc433bb5e1sm12622794wmb.9.2023.01.31.08.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 08:08:36 -0800 (PST) From: Christian Marangi To: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [PATCH v2 1/2] clk: Warn and add workaround on misuse of .parent_data with .name only Date: Tue, 31 Jan 2023 17:08:28 +0100 Message-Id: <20230131160829.23369-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756555183270887765?= X-GMAIL-MSGID: =?utf-8?q?1756555183270887765?= By a simple mistake in a .parent_names to .parent_data conversion it was found that clk core assume fw_name is always provided with a parent_data struct for each parent and never fallback to .name to get parent name even if declared. This is caused by clk_core_get that only checks for parent .fw_name and doesn't handle .name. While it's sane to request the dev to correctly do the conversion and add both .fw_name and .name in a parent_data struct, it's not sane to silently drop parents without a warning. Fix this in 2 ways. Add a kernel warning when a wrong implementation is used and copy .name in .fw_name in parent map populate function to handle clk problems and malfunctions. Signed-off-by: Christian Marangi --- drivers/clk/clk.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 57b83665e5c3..dccd4ea6f692 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -4015,10 +4015,21 @@ static int clk_core_populate_parent_map(struct clk_core *core, ret = clk_cpy_name(&parent->name, parent_names[i], true); } else if (parent_data) { + const char *parent_name; + parent->hw = parent_data[i].hw; parent->index = parent_data[i].index; + parent_name = parent_data[i].fw_name; + + if (!parent_name && parent_data[i].name) { + WARN(1, "Empty .fw_name with .name in %s's .parent_data. Using .name for .fw_name declaration.\n", + core->name); + parent_name = parent_data[i].name; + } + ret = clk_cpy_name(&parent->fw_name, - parent_data[i].fw_name, false); + parent_name, false); + if (!ret) ret = clk_cpy_name(&parent->name, parent_data[i].name,