From patchwork Thu Jul 10 17:43:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 152 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 3373F283FD2 for ; Thu, 10 Jul 2025 17:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752169402; cv=none; b=WK3f2aZIMFcmT/FVSjR1yMd+H4e/cJIVBtFgJGV5IAnUZdBO3ICgtmWBSsFP1jjIEHiqkHWYKL3T5xhXzkaa1+hijE5IPbgKE0jqyXb7uJmmWc5AWUSSJD8ppMoaChCaZX0x7uGWCuHs54F4vE0/0/HTuy+mtzNMrfC7FWB+FBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752169402; c=relaxed/simple; bh=vneJkQuL/Z9KZYxCdcdDpCorNOqE4VZX51RmlX/8Hik=; h=From:Subject:Date:Message-Id:MIME-Version:To:Cc:Content-Type; b=GIxAyMmBQHfWrTEAET+SQUNbLCa/iSESBiykC10eNyZ9ifKXw7RTTVUmpOE4j7BnzM1su4mJUyvyn7D4nR5dZE9mUjHkzBB7/OBe7Qy4tvpz9zw06dEQzrxvMt9RdBTGSNIU5qVq4iMdKk44/AbXMmnN8Kgwmq7+KkzeU0yWjzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JNgUuJ/p; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JNgUuJ/p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752169400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DyfQeplimHxaigWHPTIL8Brwr48uc1PFyqGCkna6oLc=; b=JNgUuJ/pN1gE8zcHwMvQv34MIGDKxfc8zrUimEzGwlmOgvSWxLR8U4vnUPdJHBgFV5Oe5H Vw0rJ2+mlcVEo2Mu5JADPmh4OV9496ZYYx8GAnGS2OcovA2HjXRFZsSfSv9Rsxx8DrkLbg ANNt8wH3ECjrpQk0T/uwZmCHtf704TM= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-262-cOLsGneePyiNc7mpHRdjSQ-1; Thu, 10 Jul 2025 13:43:19 -0400 X-MC-Unique: cOLsGneePyiNc7mpHRdjSQ-1 X-Mimecast-MFC-AGG-ID: cOLsGneePyiNc7mpHRdjSQ_1752169399 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4a581009dc5so23327281cf.0 for ; Thu, 10 Jul 2025 10:43:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752169398; x=1752774198; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DyfQeplimHxaigWHPTIL8Brwr48uc1PFyqGCkna6oLc=; b=U3PpDszkjzF9kp/1n7epFAtftIsR+8TtsUh/k3+qdLP7Of9O0S2oixAl5Yqr1KQBCN Ev0badcluhIj+FyxA4+6iw1uNiOVjgP5m5uu159PHPULSjYUfW0cClNga8aWkCMvbsIR xo7vdxFm/X6C2JJatnBh+p6/ZpBdW36tJVusH1iHXTVgA4fxc77w1Ym8ffYp6YxbcgzZ D08rh8s1QYGqHog0/erIai9rrQuZaXO1iV79pgIqaJuCEm40Z68hTsM8BvdfPasgZcHQ AP9tZrqxpKUN3nfIIYjVpxPFHDWOGGimt7wfU+vX6vZOXjOvvyTJGRqiuEMkAMFlPvov fxog== X-Forwarded-Encrypted: i=1; AJvYcCXNyqFmzsWbxOw/iT70KdXMVOdhIRBSfti7Gn8WP7Ly1VWsgduueaWnQcMmPbvFBA8+5lKSZxgjLgp26w==@lists.linux.dev X-Gm-Message-State: AOJu0YwY6HeV81lh6FaP0CZfDacxHBzBru3s0hB8GHUKhQndPJDfSPcf V3PaeSOV+bR0eZ2lQtoy30ihUmCL9unqUBmHZRn6vOBoMJLCo2bs0w9WBQ4TUyjW566CWQkrR0c tqTG5t4v1xYjE3WTJQ9lhmtBfcfWq8Wz/fL5HbbCkmsR2mUXyKsBBEBemcoAGsHejtmnUlTzB1z 1XoU3kxIjND6mIOaZW+gNUJFYcNLm1LZbGiBVGC1orfL6WheS79g== X-Gm-Gg: ASbGncv+YIPz4LMlL/3FVDChMsVqm+IYUXItxtHDc4evVimEW1WYe89Hqjcq8ryT3+Y L98qg8ua8AoTfwouobtVWJNiWVS4mJmDqg13jVrOBahH3vPeG35vuroSZVFYtcJilva238ojmqc hd/xJ/i20wrHTLXnjiV2trF6NsXSEdXWUe+7GnmCe0cQtDegR+NOhhDE6+bJ3qJHuBfu6StUP4K WAuefMq+junzuFIbjGeQJQPw8QHRH7EO16aFLi+33FZm2o/4bDYj57ehWRjJQ1mKQUTN3ILlqP4 ILFE5hecZAZvyMH4nwhxHGwLq3wdT6tuXFn4B31tlcn5C+lLm3NhpxAyq7sU X-Received: by 2002:a05:622a:2587:b0:4a7:944:9af6 with SMTP id d75a77b69052e-4a9e9bb2cb6mr64646321cf.3.1752169397810; Thu, 10 Jul 2025 10:43:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzZd5sCbip5ZJYV/QhNlPWrkBJ+B+0jLvPSQhYSok5Gwj5HHCpjaKv310CLkZIEGxcJf2Gkg== X-Received: by 2002:a05:622a:2587:b0:4a7:944:9af6 with SMTP id d75a77b69052e-4a9e9bb2cb6mr64645231cf.3.1752169397063; Thu, 10 Jul 2025 10:43:17 -0700 (PDT) Received: from [192.168.1.3] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70497d71419sm10652876d6.86.2025.07.10.10.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jul 2025 10:43:16 -0700 (PDT) From: Brian Masney Subject: [PATCH 0/9] drm: convert from clk round_rate() to determine_rate() Date: Thu, 10 Jul 2025 13:43:01 -0400 Message-Id: <20250710-drm-clk-round-rate-v1-0-601b9ea384c3@redhat.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAKX7b2gC/x2M0QpAQBAAf0X7bOuQdH5FHs7dYsPRHlKXf3d5n KaZCIGEKUCbRRC6OfDuExR5BnY2fiJklxhKVdaqKRQ62dCuC8p+eYdiTsIhKa2tspVpIIWH0Mj PP+369/0AcAOnAmQAAAA= X-Change-ID: 20250710-drm-clk-round-rate-b25099c0c3a7 To: Philipp Zabel , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Linus Walleij , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , Yannick Fertre , Raphael Gallais-Pou , Philippe Cornu , Maxime Coquelin , Alexandre Torgue , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Stephen Boyd Cc: dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752169393; l=5611; i=bmasney@redhat.com; s=20250528; h=from:subject:message-id; bh=vneJkQuL/Z9KZYxCdcdDpCorNOqE4VZX51RmlX/8Hik=; b=SpSyr0e3I/aRNxEswleY3osHpqJj9B58Sz5Gtf7aIsUZ1Ktyc0g084VrIsjKHpCXHyL9qqOiF ZRnFirWq0YVBiYQPmMMBH7RCwJ87s3PvceRTEkBR4y7+BkHAKJo5Jbj X-Developer-Key: i=bmasney@redhat.com; a=ed25519; pk=x20f2BQYftANnik+wvlm4HqLqAlNs/npfVcbhHPOK2U= X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8Zyk2LccGcgqwy6c7yD_muwSvuYoxuH985ERahf5K9c_1752169399 X-Mimecast-Originator: redhat.com Status: O The round_rate() clk ops is deprecated in the clk framework in favor of the determine_rate() clk ops, so let's go ahead and convert the drivers in the drm subsystem using the Coccinelle semantic patch posted below. I did a few minor cosmetic cleanups of the code in a few cases. Coccinelle semantic patch: virtual patch // Look up the current name of the round_rate function @ has_round_rate @ identifier round_rate_name =~ ".*_round_rate"; identifier hw_param, rate_param, parent_rate_param; @@ long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param, unsigned long *parent_rate_param) { ... } // Rename the route_rate function name to determine_rate() @ script:python generate_name depends on has_round_rate @ round_rate_name << has_round_rate.round_rate_name; new_name; @@ coccinelle.new_name = round_rate_name.replace("_round_rate", "_determine_rate") // Change rate to req->rate; also change occurrences of 'return XXX'. @ chg_rate depends on generate_name @ identifier has_round_rate.round_rate_name; identifier has_round_rate.hw_param; identifier has_round_rate.rate_param; identifier has_round_rate.parent_rate_param; identifier ERR =~ "E.*"; expression E; @@ long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param, unsigned long *parent_rate_param) { <... ( -return -ERR; +return -ERR; | - return rate_param; + return 0; | - return E; + req->rate = E; + + return 0; | - rate_param + req->rate ) ...> } // Coccinelle only transforms the first occurrence of the rate parameter // Run a second time. FIXME: Is there a better way to do this? @ chg_rate2 depends on generate_name @ identifier has_round_rate.round_rate_name; identifier has_round_rate.hw_param; identifier has_round_rate.rate_param; identifier has_round_rate.parent_rate_param; @@ long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param, unsigned long *parent_rate_param) { <... - rate_param + req->rate ...> } // Change parent_rate to req->best_parent_rate @ chg_parent_rate depends on generate_name @ identifier has_round_rate.round_rate_name; identifier has_round_rate.hw_param; identifier has_round_rate.rate_param; identifier has_round_rate.parent_rate_param; @@ long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param, unsigned long *parent_rate_param) { <... ( - *parent_rate_param + req->best_parent_rate | - parent_rate_param + &req->best_parent_rate ) ...> } // Convert the function definition from round_rate() to determine_rate() @ func_definition depends on chg_rate @ identifier has_round_rate.round_rate_name; identifier has_round_rate.hw_param; identifier has_round_rate.rate_param; identifier has_round_rate.parent_rate_param; identifier generate_name.new_name; @@ - long round_rate_name(struct clk_hw *hw_param, unsigned long rate_param, - unsigned long *parent_rate_param) + int new_name(struct clk_hw *hw, struct clk_rate_request *req) { ... } // Update the ops from round_rate() to determine_rate() @ ops depends on func_definition @ identifier has_round_rate.round_rate_name; identifier generate_name.new_name; @@ { ..., - .round_rate = round_rate_name, + .determine_rate = new_name, ..., } Note that I used coccinelle 1.2 instead of 1.3 since the newer version adds unnecessary braces as described in this post. https://lore.kernel.org/cocci/67642477-5f3e-4b2a-914d-579a54f48cbd@intel.com/ Signed-off-by: Brian Masney --- Brian Masney (9): drm/imx/ipuv3/imx-tve: convert from round_rate() to determine_rate() drm/mcde/mcde_clk_div: convert from round_rate() to determine_rate() drm/msm/disp/mdp4/mdp4_lvds_pll: convert from round_rate() to determine_rate() drm/msm/hdmi_pll_8960: convert from round_rate() to determine_rate() drm/pl111: convert from round_rate() to determine_rate() drm/stm/dw_mipi_dsi-stm: convert from round_rate() to determine_rate() drm/stm/lvds: convert from round_rate() to determine_rate() drm/sun4i/sun4i_hdmi_ddc_clk: convert from round_rate() to determine_rate() drm/sun4i/sun4i_tcon_dclk: convert from round_rate() to determine_rate() drivers/gpu/drm/imx/ipuv3/imx-tve.c | 17 ++++++++++------- drivers/gpu/drm/mcde/mcde_clk_div.c | 13 ++++++++----- drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_pll.c | 13 ++++++++----- drivers/gpu/drm/msm/hdmi/hdmi_pll_8960.c | 12 +++++++----- drivers/gpu/drm/pl111/pl111_display.c | 13 ++++++++----- drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 14 ++++++++------ drivers/gpu/drm/stm/lvds.c | 12 +++++++----- drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c | 12 +++++++----- drivers/gpu/drm/sun4i/sun4i_tcon_dclk.c | 18 ++++++++++-------- 9 files changed, 73 insertions(+), 51 deletions(-) --- base-commit: b551c4e2a98a177a06148cf16505643cd2108386 change-id: 20250710-drm-clk-round-rate-b25099c0c3a7 Best regards,