Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2445262iog; Sun, 19 Jun 2022 18:16:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vO+r7+ErZVX1eVKcINdV19Wg+Wj5yRbep2KTxQMMAPjdZNCcpx6NunOimTWCU/4A2SZvLP X-Received: by 2002:a65:6e96:0:b0:3fd:c8b7:5fa6 with SMTP id bm22-20020a656e96000000b003fdc8b75fa6mr19201725pgb.569.1655687818016; Sun, 19 Jun 2022 18:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655687818; cv=none; d=google.com; s=arc-20160816; b=WVaNFUFjZT1BxKSKd8aiYOSryfILE0A+v8DVbg9QowxZzL+7W/VcaXX+GVF3jSCXxh 2oQ0ncoCuptRmCdYzwwI/oFaR20ueGNM12Iu47KpsDtOzIO3CXmoeA+yA3ByTjQHZ4Z1 WkBnqRKUF599MYhzdTjd4LoxQe8gmumgvMUp1txtbwaURBdloslbRhtnzsPF6JRNwBdd m6+IntV3lFOnp7nC96TokqTO+jtIFBqQR3brDJ98xNi8yZKDiL/gxTAsRMFZp5UO7z/h 1o+YqQQx95ly1MKtXdN4QCrBfdieb5nKO3Emw2EdypR4wyeV9jlSCcUasO/6Z0jZON/f iPIQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gsfcZAwqlEFdpq95DCanp3EHZzLLogwQwMtGGhdzNxc=; b=VifhiRBKfgpYssuBV5AjozIa8ozwkOEBuJfkFvLo+YHLfQTK/FHjEEu9L8kenhQl+I Mur2t0XZGj571zT9Z58detz3s1+45C4L8xq6EIzqm04yiIHxTRiy9/n9dQN66grJ7Kyc NyTx1NPBmob5E8RPqSt1YSKxA0ZmaT4Y5tW+dv58LPg0WjF317p4pFxv3dKMS1BpL0me UFcVNinh6cbEuZQFgEGAGOa2I62Jd/b950huv9fR5d5C0ULt7oYlUfOjbibT5JJ9IYqc WDRQZr4P8yjnfWA9vw14DN9iDdZI2gLS7cvUIcmZUFiH4u1V0Ev/XfeMMt5AAgGzwkuJ BG+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IJg+Op9g; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y139-20020a626491000000b0051ba908574fsi13905139pfb.231.2022.06.19.18.16.46; Sun, 19 Jun 2022 18:16:58 -0700 (PDT) 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=IJg+Op9g; 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 S238471AbiFTAow (ORCPT + 99 others); Sun, 19 Jun 2022 20:44:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238382AbiFTAnt (ORCPT ); Sun, 19 Jun 2022 20:43:49 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42F226582 for ; Sun, 19 Jun 2022 17:43:34 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id i17so7358941qvo.13 for ; Sun, 19 Jun 2022 17:43:34 -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=IqE3lEmqV2Ico727s9PVPjaUlb+vIlLINsABxqv4XCl9O39ybnOardIyKtE6EgBN+4 ljFC4383jm2S6BcnpfI1kxxqBMuROVI6gD/hnXlUk6JMrVcPf2UPOM62XOvumTAXMUUb t4Bh2RZTz4KU1EmGvQCKq/lN8RtiLUXqvtkE3kfyQnp2vMwkQ662M9BQ1NF6VKy33Vlh Br7ODgD+I0ErSyZcPTAWfvCVEjYWPBpa3gMd6EjgGTRs88YrhV2sgosTxOhC8MdVbYbB rK3QprrY66CqNB+aB2xnnsHaMQQjSO0GWyfvw+QsJpWqoUSD7+wf5zYPIEk6IPMLl5lA Q4og== X-Gm-Message-State: AJIora/Kj9SvXcciyGVs2ZZote98APs1NNoVOzAagUPmDl2+XvIz/iEn rV1goKjf14qcJgKOkrgwHRN/E9TP/wqYMEc= 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 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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 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, -- 2.36.1