From patchwork Mon Jun 20 00:42:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 12886922 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 F2BF9C433EF for ; Mon, 20 Jun 2022 00:43:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E37F8D0003; Sun, 19 Jun 2022 20:43:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86DF88D0001; Sun, 19 Jun 2022 20:43:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E8708D0003; Sun, 19 Jun 2022 20:43:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 565C48D0001 for ; Sun, 19 Jun 2022 20:43:42 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 3025D601C1 for ; Mon, 20 Jun 2022 00:43:42 +0000 (UTC) X-FDA: 79596766284.04.5BD1B88 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by imf01.hostedemail.com (Postfix) with ESMTP id D867640010 for ; Mon, 20 Jun 2022 00:43:41 +0000 (UTC) Received: by mail-qk1-f175.google.com with SMTP id n197so6891510qke.1 for ; Sun, 19 Jun 2022 17:43:41 -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=+Xg1dB8Y2o2fTfyU6/JMm3V6r0Q6Byu7YKRWwJ+H+P4=; b=YMEMmazsTJymTBZg5B+MMIRicoAxtJ7ZVBPY72BhCaDEL02Th5qRPhx4J9aamZdt2R AX6lCzjBTjorsmk12pbSZSnV0blpooWefBhQa6O2wBOTFFgCptAUNs6vG+zx+1sNT2Mw LsDQZlzhxIvqKfjVGHbfpXG9X53Bhl1mbztGVaEhDrq+vD3TvA+a3nopvnrSOryggHkf UClv9V+ds1nzIuGbf+Yfl6o/j7LxV6WRfVzHcH3rr6l+9uBQi3CPFh2zdLvJhef/dXM3 4QAWd9MFzvQ0BmraqaKTlWNuOtkOTVXJWKV3g7AsUDD1EU1RBhJcxlTykX8tjZ3KXK0p br0A== 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=+Xg1dB8Y2o2fTfyU6/JMm3V6r0Q6Byu7YKRWwJ+H+P4=; b=qFuXrDVMmCLTJIXFbgLddrJ5kNd8SQJJQhOEczenaIQzzCVFOICJJUy3GRiVnCnX9H 0BxXgRK3t4I7qu0ucmJfS4jOvOX2I7txzB+/7dkMFvZTeiwBElWsKhSnhaO71QERF9eH BmcaWnY+QwiTu92R1zSU8olfxWnI/IdNxr6TYEfS/3fzKflHOJnktsSDQjmg9zHjn5m3 Wgp95WKCk1iHX4pQhtIZCNQbd6MQ0GIyb9/dW9BeslUO8bvHRSKQqWFXc5DZi5nf4PB0 y/JW1aV63jrzAtQSKVLNGVAbxm/QBYF6gxbQbHWEwsC+Y3H6hiUZb8OsiJ1LEG553F0P JFtw== X-Gm-Message-State: AJIora+Th1UkAL6Zo45PeQ5Q7ovN3wYsLIDONeXPbvjxhOsAzOCr2NZ9 3l13sdMmdQZqOGOZnuiEtA== X-Google-Smtp-Source: AGRyM1uCfrheAlhgCp9i1EFrQVHXoukF22l+FI6Up40z4nZppqvuTPxoWyFhEbHIP29gGwI1wSisVA== X-Received: by 2002:a37:5e46:0:b0:6ab:90dc:d9d6 with SMTP id s67-20020a375e46000000b006ab90dcd9d6mr9561307qkb.131.1655685821224; Sun, 19 Jun 2022 17:43:41 -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 ci6-20020a05622a260600b003051ce7812asm9739089qtb.5.2022.06.19.17.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 17:43:40 -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, linux-pci@vger.kernel.org Subject: [PATCH v4 29/34] PCI/P2PDMA: Convert to printbuf Date: Sun, 19 Jun 2022 20:42:28 -0400 Message-Id: <20220620004233.3805-30-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655685821; a=rsa-sha256; cv=none; b=XuO6lhwMYOadXFF2mG6P9xdxLw+Ox//sGr5f27iKIY79jUK9xYWzlsItPn5T5QtFtFzPQ7 KuU5GDrqtj78IwtV8yoMRckchBbR9MZjtoF9tdURnOI6O7Z+lrwpgw4LHBlrAXeYLOlMy7 b8azleVtoK6p8HPsB+JjdHn3bNUwCY4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=YMEMmazs; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.222.175 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655685821; 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=+Xg1dB8Y2o2fTfyU6/JMm3V6r0Q6Byu7YKRWwJ+H+P4=; b=M1RH3COLI/0URgoyQImTPDbZfGU2NGcfD9YLG40Pf0FoGAwygeAgrN0ERE3L+U04+TAgqy rZSCihhnfzS3kmz56woK8pfO821ZcxMhqJaBxylTRywizrWHFiv5vnTVbzlrGTejl1XEqp Rclp5ceQfitpzSQSNA3mWULm7+TCs4Y= X-Rspamd-Server: rspam01 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=YMEMmazs; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.222.175 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com X-Stat-Signature: gcjp3tdd3fprp7e4wtq5578ypfai5hwh X-Rspamd-Queue-Id: D867640010 X-HE-Tag: 1655685821-193227 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. We're using printbuf in external buffer mode, so it's a direct conversion, aside from some trivial refactoring in cpu_show_meltdown() to make the code more consistent. Signed-off-by: Kent Overstreet Cc: linux-pci@vger.kernel.org --- drivers/pci/p2pdma.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 30b1df3c9d..3b7a6ca446 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include enum pci_p2pdma_map_type { @@ -281,12 +281,9 @@ static int pci_bridge_has_acs_redir(struct pci_dev *pdev) return 0; } -static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev) +static void prt_bus_devfn(struct printbuf *buf, struct pci_dev *pdev) { - if (!buf) - return; - - seq_buf_printf(buf, "%s;", pci_name(pdev)); + prt_printf(buf, "%s;", pci_name(pdev)); } static bool cpu_supports_p2pdma(void) @@ -455,13 +452,11 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, struct pci_dev *a = provider, *b = client, *bb; bool acs_redirects = false; struct pci_p2pdma *p2pdma; - struct seq_buf acs_list; int acs_cnt = 0; int dist_a = 0; int dist_b = 0; char buf[128]; - - seq_buf_init(&acs_list, buf, sizeof(buf)); + struct printbuf acs_list = PRINTBUF_EXTERN(buf, sizeof(buf)); /* * Note, we don't need to take references to devices returned by @@ -472,7 +467,7 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, dist_b = 0; if (pci_bridge_has_acs_redir(a)) { - seq_buf_print_bus_devfn(&acs_list, a); + prt_bus_devfn(&acs_list, a); acs_cnt++; } @@ -501,7 +496,7 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, break; if (pci_bridge_has_acs_redir(bb)) { - seq_buf_print_bus_devfn(&acs_list, bb); + prt_bus_devfn(&acs_list, bb); acs_cnt++; } @@ -516,11 +511,11 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, } if (verbose) { - acs_list.buffer[acs_list.len-1] = 0; /* drop final semicolon */ + acs_list.buf[acs_list.pos-1] = 0; /* drop final semicolon */ pci_warn(client, "ACS redirect is set between the client and provider (%s)\n", pci_name(provider)); pci_warn(client, "to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n", - acs_list.buffer); + acs_list.buf); } acs_redirects = true;