From patchwork Mon Jun 20 00:42:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 12886918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEC94C433EF for ; Mon, 20 Jun 2022 00:43:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4504A6B0073; Sun, 19 Jun 2022 20:43:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 401AB6B0087; Sun, 19 Jun 2022 20:43:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CE376B0088; Sun, 19 Jun 2022 20:43:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E0C1B6B0073 for ; Sun, 19 Jun 2022 20:43:33 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C079133AEE for ; Mon, 20 Jun 2022 00:43:33 +0000 (UTC) X-FDA: 79596765906.08.10C46EF Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf01.hostedemail.com (Postfix) with ESMTP id 6F42640010 for ; Mon, 20 Jun 2022 00:43:33 +0000 (UTC) Received: by mail-qv1-f50.google.com with SMTP id cs6so9536528qvb.6 for ; Sun, 19 Jun 2022 17:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gsfcZAwqlEFdpq95DCanp3EHZzLLogwQwMtGGhdzNxc=; b=IJg+Op9gT+0zu+I1RSZ69r2h/io0Iax9HRwqmS4TNZwJTDJb7fQj026KZbjdqpzkeQ jl63+ujHD9wLMzImVc5A4YY4qI9U2LNA4I8nLz6Ol+iQOJjRrtaICS3bqCJLtm94lkMX HlRwKatR1EWzhIi0kVdHwo7ijnkdt45FIgHRrvgsVL5dZRFPVZofaM8mB83/j4l1Y5JR de2b8vrhPFqHXAhnsiNg9oAo1naki+8XE3L9tyvz45B1eG2U/C1sxsCrFe0K1ge80Tq2 QxqXh5GjwwdfbGbY3qllndBsStR188f/LqZMiittFETjyR0Ev3SqPq0l+ztbB3+OacT6 qoXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gsfcZAwqlEFdpq95DCanp3EHZzLLogwQwMtGGhdzNxc=; b=B80P4s4bzctPWFfYr+oEd5VFRGv+1Vd1gsQF8L7uFxcZpgsudAtgoTk25EievkQ826 nbI4NTTkExA6Fqvwwvvwi7e+gpnelYQDcLyH9x6xb/2PHxv8Fal764JqiFZnx4ka+qHz 77xWhGzipeynrUJJmYvh6KyHpNTxOdqq6TI258QGFoXlsGtycSmSRSkGHYdQZBck4k5I qE0+arvp5dT57UmBYor335LOJ22QWkkz4eUJiH5eIXCoZS+qhn4ueWRYUHIlk1XIwcIg 7QwwiTZ6M+jCwhNieF2TZ8EUFDiLaJvUoB9kYyX3QxulgCFrFI62jRH3KhCLclZyAlnz g+fw== X-Gm-Message-State: AJIora+eGbreHfNBuvRwHjp9nhQNzL2pcrMIPZJHZKZ66JGxpzwmxNyF dEamk01SgBR+7Wo6fJH4yw== X-Google-Smtp-Source: AGRyM1tQ+0xDN5He/7+qn3hDH+zCCBLc6Ym4XEqTwDgs43uHcX8GDVZ/W0pK2YuJv48o6g71jadKkQ== X-Received: by 2002:a05:622a:493:b0:306:7794:a16 with SMTP id p19-20020a05622a049300b0030677940a16mr17925571qtx.605.1655685812910; Sun, 19 Jun 2022 17:43:32 -0700 (PDT) Received: from localhost (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id b7-20020ac86787000000b002f93be3ccfdsm9462183qtp.18.2022.06.19.17.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 17:43:32 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, pmladek@suse.com Cc: Kent Overstreet , rostedt@goodmis.org, enozhatsky@chromium.org, linux@rasmusvillemoes.dk, willy@infradead.org Subject: [PATCH v4 25/34] clk: tegra: bpmp: Convert to printbuf Date: Sun, 19 Jun 2022 20:42:24 -0400 Message-Id: <20220620004233.3805-26-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620004233.3805-1-kent.overstreet@gmail.com> References: <20220620004233.3805-1-kent.overstreet@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655685813; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gsfcZAwqlEFdpq95DCanp3EHZzLLogwQwMtGGhdzNxc=; b=JfxuyZCZ3Uy97GaR/ivGaNb9fWKQ+L+5ANet2At9y9UL+BuRqL5B/4hgRYZ73ir4ZL4IBR 27kPt2S+vVi2nIRAniFr3+M6Pt3HUwJ3BqkB89YzHcq/43yO/vXPHdTXLtT5cxTkDFaT+b OPiSWUt02GEaSSQX1XzbREgarTUtmi0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655685813; a=rsa-sha256; cv=none; b=wb8TAWL66hTozc9SHnRrsFWLmY8eUTns2lNwy3Q3sDR1LDA4n+cLM1v59qVhentS5jXZWS 5PI/wE3SnJk0Ac/Po+EEuwJ5K+v9GO6XY0lShaomp636Kg8OxKUMrnreu8Apgejh/zgbiL v2KZxUKqzXC28tM02sOpEdOotBa9fow= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IJg+Op9g; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 4mozt99g33ret4dxpi8msoaec9e61t59 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IJg+Op9g; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Queue-Id: 6F42640010 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655685813-317824 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This converts from seq_buf to printbuf, which is similar but heap allocates the string buffer. Previously in this code the string buffer was allocated on the stack; this means we've added a new potential memory allocation failure. This is fine though since it's only for a dev_printk() message. Memory allocation context: printbuf doesn't take gfp flags, instead we prefer the new memalloc_no*_(save|restore) interfaces to be used. Here the surrounding code is already allocating with GFP_KERNEL, so everything is fine. Signed-off-by: Kent Overstreet --- drivers/clk/tegra/clk-bpmp.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c index 6ecf18f71c..301551174c 100644 --- a/drivers/clk/tegra/clk-bpmp.c +++ b/drivers/clk/tegra/clk-bpmp.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -360,39 +360,38 @@ static void tegra_bpmp_clk_info_dump(struct tegra_bpmp *bpmp, const struct tegra_bpmp_clk_info *info) { const char *prefix = ""; - struct seq_buf buf; + struct printbuf buf = PRINTBUF; unsigned int i; - char flags[64]; - - seq_buf_init(&buf, flags, sizeof(flags)); if (info->flags) - seq_buf_printf(&buf, "("); + prt_printf(&buf, "("); if (info->flags & TEGRA_BPMP_CLK_HAS_MUX) { - seq_buf_printf(&buf, "%smux", prefix); + prt_printf(&buf, "%smux", prefix); prefix = ", "; } if ((info->flags & TEGRA_BPMP_CLK_HAS_SET_RATE) == 0) { - seq_buf_printf(&buf, "%sfixed", prefix); + prt_printf(&buf, "%sfixed", prefix); prefix = ", "; } if (info->flags & TEGRA_BPMP_CLK_IS_ROOT) { - seq_buf_printf(&buf, "%sroot", prefix); + prt_printf(&buf, "%sroot", prefix); prefix = ", "; } if (info->flags) - seq_buf_printf(&buf, ")"); + prt_printf(&buf, ")"); dev_printk(level, bpmp->dev, "%03u: %s\n", info->id, info->name); - dev_printk(level, bpmp->dev, " flags: %lx %s\n", info->flags, flags); + dev_printk(level, bpmp->dev, " flags: %lx %s\n", info->flags, printbuf_str(&buf)); dev_printk(level, bpmp->dev, " parents: %u\n", info->num_parents); for (i = 0; i < info->num_parents; i++) dev_printk(level, bpmp->dev, " %03u\n", info->parents[i]); + + printbuf_exit(&buf); } static int tegra_bpmp_probe_clocks(struct tegra_bpmp *bpmp,