From patchwork Sun Oct 29 12:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13439782 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5074AC4332F for ; Sun, 29 Oct 2023 12:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aHu9bxaECw9ug2UmMAgtEbB5oqLx/J9g+6ovInMY0ts=; b=nNgiwaRDkaDEKB 7rbuyJjWb08hRxXxD2c14qxf5mjWnacKPhVJODahb0Qzdq6pbGEyMP4P1bOWFRYxZcVL/49Tvqq4n WVL5KmB7qz2qHpY9zOVy6p8/R4J4H5zMIoojVAa+d+ecDSzcUL7Jp4btvq6+QFvS4hdPm1cwh9eiI 343E5mn3/wVDskqxe5x668P9soGi2WypXdEmUmZnG6z5+NHBf++02xNTQMX7b9inDRBuYhmPEAh7i BvIWYrnUrcMTKC6j2Mj55rkjvz8+ueB/3gnm3GWJdU1DwOlO0HPiKbEXXyGxHM08acd+e5Euzx6tQ DM+sbJwqOikCMV889Myg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qx5EF-001ki6-0M; Sun, 29 Oct 2023 12:49:19 +0000 Received: from mout.gmx.net ([212.227.17.20]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qx5E3-001kfN-37 for linux-arm-kernel@lists.infradead.org; Sun, 29 Oct 2023 12:49:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1698583737; x=1699188537; i=wahrenst@gmx.net; bh=LLHvVo63AjV5Hqcr1vFlrSG2w/jB0JpbolqJznId/kE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=NeebYyrrvcGl6+DhmjHYxeWsdi+B0X6H6t/6s3LW4ZhzMl54pzbX753IVfFUMKo1 FqXMRjfRJfx6tbHj+r4soKiR+ljk1Zq5btnv2fTXYM47lXYXN7WH7zvpcE+GAR1kK 57QqiFC1vEqC25ZQ79dme4rZDJ5cZNtG1ed2juX9ZvfPLSnZInVgJC2gwAwfffZLk nmHrzgAQyRQQt9a8nC9kIqN8e8DQ3I8cMNt+mtbnxZ/M2W1Q0AH9F0YWxvOc+WHtL yT4qJ4fUfuHkErxd+9+sD4PajHlw3YmPcMYU9DBFIO+y+L3IXHaYbfoN4YQkr1Ig2 XRwXdICQmaSKQfN3cA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MVeMG-1r4kCj1yZ2-00RaJP; Sun, 29 Oct 2023 13:48:57 +0100 From: Stefan Wahren To: Umang Jain , Greg Kroah-Hartman Cc: Florian Fainelli , Dan Carpenter , Phil Elwell , Dave Stevenson , Kieran Bingham , Laurent Pinchart , linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, Stefan Wahren Subject: [PATCH V2 1/3] staging: vchiq_core: Make vchiq_dump_service_state static Date: Sun, 29 Oct 2023 13:48:35 +0100 Message-Id: <20231029124837.119832-2-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231029124837.119832-1-wahrenst@gmx.net> References: <20231029124837.119832-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:fnQaSbRNyE9QMj90gnh3LQXlCZg7uJYe9hHnatjhlHLfMbkPXvG sdKpB0bsJBnJeASH2+F/QqIW/Z4NSpF5h+uFpqWKK+lcOmr74Fn/s945G/uyoR+9Fy++JZ+ 0NiiKwoEjQNGnTitdVBQR1DCpQ4NVzGoAKyhKt+WrztZAyJjgdmIyJ4SasCPukRir3ZyqEF Tag00ON6rzf+AF5/he4Gw== UI-OutboundReport: notjunk:1;M01:P0:2v1R47j4rlg=;k7PpRxaVxhP+ZA8phL3tU1EEqlN qex9xgUePnxL0PuwmVBITeXKqu1VMzPtnUlURFHI8yspwb4Zfo2edCJaM+moxXcRRYcxCwLJX LgSZCCRgnJCxAzl2uYOTaMuXcPj8KpD6dczHL8ldNEre8kZgYcg1QG+WH7bq2BIxqpwj2iPow c0irtk43eswyv9go7RbyKfotpnoasQgX2y2QfCbW4Li3tE58xrT0dpzuhrcHY2vTMpH0SiGdT b08wlJmy0flEix/NEaWy/ga1eV7x/8VOYYXQYL+KiG8HsXT1de3Bx2++eAqWquAloIZfVb5rC LUrSCPmoeyDWu6fsvcfL9qHd1MuLJ0qFh3pzIzQxcFTAtdNj8rX6+B4vOgmzeqlyfJhPtuG6N 19MBcocafrowmuoaeqzP37+uq/Ev5invREh/YEb16PXqxcVTLZq2fkI64CFIVatVKVc1y5mM4 CauygI3idzz3XpboqrDjhtIJ59c24PrYIsQY/NI24QzOEmZ0yQcNcWE1VXh0NcouWOneJXg3U /lH+VKARh2fZbFxsaKG/sdXHOqzqSIn9WqcmJ3/O7DQNVmLc2BegNFDhXgePEn8NxmGG/4pgG XyYKromRl78Nz5QrEbYr7ZxSJYvyXGXApmWpwYldxr7E6da+YOW9wxDVu83HCa81ad1xR9Vb8 Xz6gb2L341Ytd2eIeXGWtzfpmYYaMnvH+m7qniHHvXskQ+V3QvyFokyUpC9AYe6yUoRrJsCMP s1edEuu3DUmJapbEPzUitSIHZU14Fu4zX/jLYwAkge9fpPPdxbu4nRZ9BOtzHeLxHhWSEphdW BomxIsiY7A6TrxLkmtC6nVH7S0F8EVH/hGXCEpw4q7imQE4AfS15gz/iBzyZlyXG7twOb2l0p 1rfDjCMf3YotIOGGnEXdIckjBs+Q3Mm4PRikBbUHa3XgQo/DHu5psk7HvW+IQ9B/Ka1dQtgcU ZOH9pjIelgvNWOqhiQOWchnlFhM= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231029_054908_318210_4911B28B X-CRM114-Status: GOOD ( 12.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The function vchiq_dump_service_state() is only used by vchiq_dump_state() within vchiq_core.c. So move the definition of vchiq_dump_state() below vchiq_dump_service_state() in order to make it static. Suggested-by: Laurent Pinchart Signed-off-by: Stefan Wahren Reviewed-by: Laurent Pinchart --- .../interface/vchiq_arm/vchiq_core.c | 169 +++++++++--------- .../interface/vchiq_arm/vchiq_core.h | 3 - 2 files changed, 85 insertions(+), 87 deletions(-) -- 2.34.1 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 39b857da2d42..94073f92651a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3428,90 +3428,8 @@ vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, return 0; } -int vchiq_dump_state(void *dump_context, struct vchiq_state *state) -{ - char buf[80]; - int len; - int i; - int err; - - len = scnprintf(buf, sizeof(buf), "State %d: %s", state->id, - conn_state_names[state->conn_state]); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - len = scnprintf(buf, sizeof(buf), " tx_pos=%x(@%pK), rx_pos=%x(@%pK)", - state->local->tx_pos, - state->tx_data + (state->local_tx_pos & VCHIQ_SLOT_MASK), - state->rx_pos, - state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - len = scnprintf(buf, sizeof(buf), " Version: %d (min %d)", - VCHIQ_VERSION, VCHIQ_VERSION_MIN); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - if (VCHIQ_ENABLE_STATS) { - len = scnprintf(buf, sizeof(buf), - " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, error_count=%d", - state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, - state->stats.error_count); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - } - - len = scnprintf(buf, sizeof(buf), - " Slots: %d available (%d data), %d recyclable, %d stalls (%d data)", - ((state->slot_queue_available * VCHIQ_SLOT_SIZE) - - state->local_tx_pos) / VCHIQ_SLOT_SIZE, - state->data_quota - state->data_use_count, - state->local->slot_queue_recycle - state->slot_queue_available, - state->stats.slot_stalls, state->stats.data_stalls); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - err = vchiq_dump_platform_state(dump_context); - if (err) - return err; - - err = vchiq_dump_shared_state(dump_context, - state, - state->local, - "Local"); - if (err) - return err; - err = vchiq_dump_shared_state(dump_context, - state, - state->remote, - "Remote"); - if (err) - return err; - - err = vchiq_dump_platform_instances(dump_context); - if (err) - return err; - - for (i = 0; i < state->unused_service; i++) { - struct vchiq_service *service = find_service_by_port(state, i); - - if (service) { - err = vchiq_dump_service_state(dump_context, service); - vchiq_service_put(service); - if (err) - return err; - } - } - return 0; -} - -int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) +static int +vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) { char buf[80]; int len; @@ -3606,6 +3524,89 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) return err; } +int vchiq_dump_state(void *dump_context, struct vchiq_state *state) +{ + char buf[80]; + int len; + int i; + int err; + + len = scnprintf(buf, sizeof(buf), "State %d: %s", state->id, + conn_state_names[state->conn_state]); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + + len = scnprintf(buf, sizeof(buf), " tx_pos=%x(@%pK), rx_pos=%x(@%pK)", + state->local->tx_pos, + state->tx_data + (state->local_tx_pos & VCHIQ_SLOT_MASK), + state->rx_pos, + state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + + len = scnprintf(buf, sizeof(buf), " Version: %d (min %d)", + VCHIQ_VERSION, VCHIQ_VERSION_MIN); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + + if (VCHIQ_ENABLE_STATS) { + len = scnprintf(buf, sizeof(buf), + " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, error_count=%d", + state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, + state->stats.error_count); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + } + + len = scnprintf(buf, sizeof(buf), + " Slots: %d available (%d data), %d recyclable, %d stalls (%d data)", + ((state->slot_queue_available * VCHIQ_SLOT_SIZE) - + state->local_tx_pos) / VCHIQ_SLOT_SIZE, + state->data_quota - state->data_use_count, + state->local->slot_queue_recycle - state->slot_queue_available, + state->stats.slot_stalls, state->stats.data_stalls); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + + err = vchiq_dump_platform_state(dump_context); + if (err) + return err; + + err = vchiq_dump_shared_state(dump_context, + state, + state->local, + "Local"); + if (err) + return err; + err = vchiq_dump_shared_state(dump_context, + state, + state->remote, + "Remote"); + if (err) + return err; + + err = vchiq_dump_platform_instances(dump_context); + if (err) + return err; + + for (i = 0; i < state->unused_service; i++) { + struct vchiq_service *service = find_service_by_port(state, i); + + if (service) { + err = vchiq_dump_service_state(dump_context, service); + vchiq_service_put(service); + if (err) + return err; + } + } + return 0; +} + int vchiq_send_remote_use(struct vchiq_state *state) { if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 161358db457c..ea8d58844775 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -507,9 +507,6 @@ vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void * extern int vchiq_dump_state(void *dump_context, struct vchiq_state *state); -extern int -vchiq_dump_service_state(void *dump_context, struct vchiq_service *service); - extern void vchiq_loud_error_header(void); From patchwork Sun Oct 29 12:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13439779 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6A04C4332F for ; Sun, 29 Oct 2023 12:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rIkjq3gYbHBJYygogVMM4UTg5U04d3MMY3G3qcV1XI4=; b=VwMVwWf+AlTCI8 RhjXO4NQ/PrK+5fVMN7+40AXlRj0UiAGIl7+wEWheTAbLj4f80T/aAR/mXa5p7uxw7qRFlN72fZXn HRVw7KCamv7/RI7B2IcKi7EWdxno+w7DtwHhm5VsRzAWdp12VmR6SrGelUziLV8Wcdb+SnGyYvkYg ww5hApnct+pZ3t/lUNpYkjuKSrRZtBasUQy7g1Yl0uzKbERXnTadoIw2ZH+AT9r4mgVuKlk9vGmyp wDk5v3tgtuHF7niv65qbTWuIcEtwISUHHkKBuYSyrYu0KyI0bBPNGeBkSeyZ8Cq8sipoatXFbAFpP ZzvRDemeO6nXg3pHZsLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qx5E6-001kh1-2n; Sun, 29 Oct 2023 12:49:10 +0000 Received: from mout.gmx.net ([212.227.17.22]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qx5E3-001kfH-2N for linux-arm-kernel@lists.infradead.org; Sun, 29 Oct 2023 12:49:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1698583738; x=1699188538; i=wahrenst@gmx.net; bh=lb1OtERw+AGwlwx7wh86H5dO1K1o6Yr1Q3BtzK1SjYA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=quRCaAux/teG2h9PIkiC6DlvwNUhmHQGuFG/EY4hEkVmESzL1HZwyI5ABEunIGhG yyQ5Emk1TryAwNCbak0nJVHOVo20H3TlXVBa52qy/mvzy6TCH5hgJsVmecKFBrDvG ucDhCszVIZ+nwxS/LaBLzXEvp0tdS+rwaJDP1lHLDoNLYK3oDIcfx1/wW/8xXgz21 QD2eIa6zN9f8W4VmTYloJyY8fIFsURQWYK3fE2jM58PR6h9Ggli3cSpqdG390nYPC lywBjzoh28GK9g8ZsZMim2Lhekeix0iW0t7bREq/omrFTHa83keo2kLwTd3fohrjF 9nt4R79tZn2g+gYg+A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MzQkK-1rjX0T3w8G-00vRTr; Sun, 29 Oct 2023 13:48:58 +0100 From: Stefan Wahren To: Umang Jain , Greg Kroah-Hartman Cc: Florian Fainelli , Dan Carpenter , Phil Elwell , Dave Stevenson , Kieran Bingham , Laurent Pinchart , linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, Stefan Wahren Subject: [PATCH V2 2/3] staging: vchiq_core: Shorten bulk TX/RX pending dump Date: Sun, 29 Oct 2023 13:48:36 +0100 Message-Id: <20231029124837.119832-3-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231029124837.119832-1-wahrenst@gmx.net> References: <20231029124837.119832-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:sfOpDu0Vm9zeCyrISDNRl3qwamKKktE9YklDU+o8o0uWp7XJUtN 9cBHveRTGEbrmjXluEtc0YdA+IZ4GXwurQyMCSCo9NeXETMqdMB4qc1eNX7SWaGz0usN2TB X1xVfS/Zz61A00hVsvY121Mbs68ezwSaAjuIfMASj2zqAEwFkYjtCH6Pm0/W5Ny/wDN/IsA HVsIdSi5QPM13P3upXaOQ== UI-OutboundReport: notjunk:1;M01:P0:ukpQllaRuds=;YCk7Z0kGW8eP24jKoxzAzkeSMdu srQ7Cl4zB90xC21kUr1hsMT7bZRT9RMEHDXUvXWFzEtwTqQVJYah6KuOpmj3uLhqPcP6fBKyw 4EVDFwg6XbWfWBTZ14jtptsam/aETVAVcVZAcia6cpTUfsc2kPkLGbfcEUWdfpnJcGCpbcbn0 or75iMo/Jn2NWDRXVJ6nPxyewoW+WeALugZdCuK9eQSwuJSx/TlOTVvrsrnNhLlrnsi5424z5 I+/91NpEJA5reEAw7XlcLoYRQ/6b5mHN8g5ZcXPUNcNNEw49CPzKVXqS80Rm4POWyr2ELqI5D DDirZZdKn8/hokpBjRoYcYt6G4VPHmiDp/t94P4nc3hJOETyXnB2v1Uy3Zrso9FQWnXkdtXLA M/C1o66QX/AMqdHPGoEf27DcbdvRoPrmbekyPWoZwffVhKZTEgnXS6lhlmj5/pli5GaVvsDXJ I1a3X+n7s9hC+2PVE0RB3uqclPmRXalO/EWHCSEHzWym6ejqGzwnO00I76fSejYJOw9ISN8Sa /QLjg0HwOE5FDIAp7BuIMdtzOxt0khlMbs1I4OCHxav+bSpyiPqBTtpv503k32PcCDJZsXsyR DCSqoOVDVL31EAyeh9U+W2Z+VCCptfAYf8Hyda/dlrvERHLDaQdZBH+Ob8ZdcZKd2O9LYK1Fu eY/zn463UXpHAg8kJEvXLVEFIBaXldWLpBXKzQIgwXcI9FH1+oR+QFO3POZpqHnhCd/nhwRBm u8fgbIXa6/g7xyZN2yTN9fmEdfGbH1LncGAyNeDG9Lfz3sHLMG13Cz4YWOu+OB7J/gcitDtJ7 GB7xScB/fHTW/M7HVOZnOCHKlG+VUcgDSCQegoU3O9ZbvX9kqoGEHM0nOkj3TX2TwXz4/z5Wn iEuxk4brKjetSnvqS2TiHH2WqMfBeb3dYx6BXajsPqCbYHbwfjWmI+mcQ99BZpS6SCPuLP2UH K3l8Gfj6XxgmYtsWb9aNVMwgRxg= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231029_054908_081922_46FECDC7 X-CRM114-Status: UNSURE ( 9.55 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The calculation for the bulk TX/RX pending is complex and reaches 99 chars per line. So move the size determination below the pending calculation and get the rid of the ternary operator. Signed-off-by: Stefan Wahren Reviewed-by: Laurent Pinchart --- .../interface/vchiq_arm/vchiq_core.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.34.1 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 94073f92651a..36c742a2f3b2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3447,7 +3447,7 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) struct vchiq_service_quota *quota = &service->state->service_quotas[service->localport]; int fourcc = service->base.fourcc; - int tx_pending, rx_pending; + int tx_pending, rx_pending, tx_size = 0, rx_size = 0; if (service->remoteport != VCHIQ_PORT_FREE) { int len2 = scnprintf(remoteport, sizeof(remoteport), @@ -3472,18 +3472,23 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) tx_pending = service->bulk_tx.local_insert - service->bulk_tx.remote_insert; + if (tx_pending) { + unsigned int i = BULK_INDEX(service->bulk_tx.remove); + + tx_size = service->bulk_tx.bulks[i].size; + } rx_pending = service->bulk_rx.local_insert - service->bulk_rx.remote_insert; + if (rx_pending) { + unsigned int i = BULK_INDEX(service->bulk_rx.remove); + + rx_size = service->bulk_rx.bulks[i].size; + } len = scnprintf(buf, sizeof(buf), " Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)", - tx_pending, - tx_pending ? - service->bulk_tx.bulks[BULK_INDEX(service->bulk_tx.remove)].size : - 0, rx_pending, rx_pending ? - service->bulk_rx.bulks[BULK_INDEX(service->bulk_rx.remove)].size : - 0); + tx_pending, tx_size, rx_pending, rx_size); if (VCHIQ_ENABLE_STATS) { err = vchiq_dump(dump_context, buf, len + 1); From patchwork Sun Oct 29 12:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13439781 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9BA8C41535 for ; Sun, 29 Oct 2023 12:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FriCOfUL0QoMdXOxaNIlYaRnQSIlFr9iSzU6fUbGGLM=; b=vEnog8x5T2vbhn 373xxEYRVSVfBIJPBUdywjoEXeRg3uO3HODPWCsvWkaFPq/skqgf+u8H2fHLFz52QIBkPYa5BIMxT WWvsWj2NzBjoGY7By+t8HDWq9xxsIJlTRkGtsuagQZJqxqFenneQgTYdZLLQbAa6hnQVy/z9jOHbU Au+VjADFiSA2CsHsQDzRyHWFgwNh60T+Ra3V9XNNtM1ezMk3D7Q7ZWQriQ8+wxn+WC+i6vp91H3oX 8zUtxvKgTysbxmeGouG5JBOErc2UwfHH9lYXbiSH8eYEtxecWYYs8OSBWT3xg8uZSR+0ZwkibNmzQ snQHApPIe6vUIQUTRa5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qx5EF-001kid-2P; Sun, 29 Oct 2023 12:49:19 +0000 Received: from mout.gmx.net ([212.227.17.22]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qx5E3-001kfI-2V for linux-arm-kernel@lists.infradead.org; Sun, 29 Oct 2023 12:49:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1698583738; x=1699188538; i=wahrenst@gmx.net; bh=38s87pSM+eHjO1XG/joTmQMxhQwediVownhNpeypMb8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=djH+8b3xRKYQVX1rt+7bIJW00kKrGiXoEztzutoGr/QylNhsJ5AsLLKFiQ1oM+nT N8GeD5toxehyreSM05kn3fd2f03o7A5InBAj3nsqdvKuUBA08D7lWXnTMEPYbZPqE tSr96wtcZqxM4OiY1xj3F/bgORMyozf+ujCKawhnAbUnVQSBDxsyvH/yK2JgYtKDG nI7oF25gU7RbiZc2mfhJ2um2qICA0lMhPdVAAM8IJ6g+sukroeIroko8/strkgrGn Fb4zebdRKzevOhpJ6tX/DIlWkDHlG/Qf683cvyNFBZBqgqauuwrX7mblumHWSaSdz 5IikgRAVSHcCVrow0Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MeCpb-1rV2fF1aX1-00bJUW; Sun, 29 Oct 2023 13:48:58 +0100 From: Stefan Wahren To: Umang Jain , Greg Kroah-Hartman Cc: Florian Fainelli , Dan Carpenter , Phil Elwell , Dave Stevenson , Kieran Bingham , Laurent Pinchart , linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, Stefan Wahren Subject: [PATCH V2 3/3] staging: vchiq_arm: move state dump to debugfs Date: Sun, 29 Oct 2023 13:48:37 +0100 Message-Id: <20231029124837.119832-4-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231029124837.119832-1-wahrenst@gmx.net> References: <20231029124837.119832-1-wahrenst@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:6OduE9fvYZNLspe1CIjqeOWFX5MaEQD3ac+q0K27ItBOsWTZw2a rUwJSalOfWFT3nINyyDMS4Tq0EDdOp5aQyTMwMpnbizQKNfXrqB/KITyWw1vCZAdFKHCL5+ 03+2rofznoMyeZrBDZOb/bDvlpz108A7W84kLHNTv6tOwRNXgTn3Qs5oofMydACBQ8SlBij CG3Zk3Ox6+H2mjDPUr1Eg== UI-OutboundReport: notjunk:1;M01:P0:mnLuPj/vmYU=;N6Xx3H3JKpepoAnbcFJDYb9pi5V 7w4HKXP9WDg9QYkqvxYeXGAIy+Wg2Q2XxCRIx1e43kQZh7uAmsLOPBTANRHS1ZGbv71Blpweh jE6dDKRL9XnMhb9UjrgNPlQgVMIvRK6LbubT3SJP3hiu/LEGAz5Hln6Jw9yYvUwMIlBDyOTts lKbZSUdxJDiv3prFfDK2JFmyfcaco+Urilr8JEFe5tLS3IGT4t1baC80cxhXQLfQhcFW5eQNq yvPx5ptkRrS2+OSxy86u6B6sYK5ene8APzOBoRD1cfSUZ3l9CTUDotjE4TK89YIKLw426zLec KKpYpjRxNnC50VADAdQc/OxE9N8XLeseQZDmWDFU/EPX9DLKm+Lfq81/f+CMXVhfSnFUcpyRV A6j6MEoF0GoCE5Q8r15QtxhgtpGoHTpGza00Ud4Jf/rSaLJB1BoLvpvevJwytFU4Sm1NupE69 cNmiaj+HVSUiB6nG9ruKBx8K0xMBB6vwSwquGOtKz5H4MXcumTnOpQwIKdHkm6jqaxhVI+M3v hNnsS6yrmGdZzJk+fqMUnAXa5FrsBqpoidVKPHigYm65kTEPiD2lIyh8xyiIT4vO+ppmJXL5g frZxHCmo/Vl4R/hFwdJ09DawAObkjSPe5Ck9n0R6uw2jiECFE1bIDyiRwHxEOFnbjm2DbQxB9 vAfarBW7auFvUdsNHwpdVGU3i+76WhcEHDDHQAmfFHwRQ4MaCtxpFFPEr4bqu7H4fyA4Fc/fR n3GVSaQGTdQil4arIBtgZhJddCq5J5dw1ChMO80oGpKscOSA0cpndXu7WqlYKnMUkOzWPUrUX f859JsfyT6+B8pcrivkozAGU17epD4Dzw0J9ddBj0/obG4DzGI4S05lswvVerIiBeY+KPz9+W VR/pVKIeOJWNFFQ/9/4k8QL8CZbpQf3NfMhLCLt1PUKKI8M4VNEYFMluNH5d3vM45vggdVDh/ JLQ4d8U+sHRTnCIXiKtZXorvcn4= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231029_054908_109379_9AE1A1BE X-CRM114-Status: GOOD ( 21.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Besides the IOCTL interface the VCHIQ character device also provides a state dump of the whole VCHIQ driver via read. Moving the state dump function to debugfs has a lot advantages: - following changes on state dump doesn't break userspace ABI - debug doesn't depend on VCHIQ_CDEV - dump code simplifies a lot and reduce the chance of buffer overflows Signed-off-by: Stefan Wahren Tested-by: Ricardo B. Marliere --- .../interface/vchiq_arm/vchiq_arm.c | 94 ++------ .../interface/vchiq_arm/vchiq_arm.h | 7 - .../interface/vchiq_arm/vchiq_core.c | 220 ++++++------------ .../interface/vchiq_arm/vchiq_core.h | 13 +- .../interface/vchiq_arm/vchiq_debugfs.c | 10 + .../interface/vchiq_arm/vchiq_dev.c | 21 -- 6 files changed, 107 insertions(+), 258 deletions(-) -- 2.34.1 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 9fb8f657cc78..7978fb6dc4fb 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -659,13 +659,9 @@ vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bulk *bulk) bulk->actual); } -int vchiq_dump_platform_state(void *dump_context) +void vchiq_dump_platform_state(struct seq_file *f) { - char buf[80]; - int len; - - len = snprintf(buf, sizeof(buf), " Platform: 2835 (VC master)"); - return vchiq_dump(dump_context, buf, len + 1); + seq_puts(f, " Platform: 2835 (VC master)\n"); } #define VCHIQ_INIT_RETRIES 10 @@ -1190,56 +1186,13 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, bulk_userdata); } -int vchiq_dump(void *dump_context, const char *str, int len) -{ - struct dump_context *context = (struct dump_context *)dump_context; - int copy_bytes; - - if (context->actual >= context->space) - return 0; - - if (context->offset > 0) { - int skip_bytes = min_t(int, len, context->offset); - - str += skip_bytes; - len -= skip_bytes; - context->offset -= skip_bytes; - if (context->offset > 0) - return 0; - } - copy_bytes = min_t(int, len, context->space - context->actual); - if (copy_bytes == 0) - return 0; - if (copy_to_user(context->buf + context->actual, str, - copy_bytes)) - return -EFAULT; - context->actual += copy_bytes; - len -= copy_bytes; - - /* - * If the terminating NUL is included in the length, then it - * marks the end of a line and should be replaced with a - * carriage return. - */ - if ((len == 0) && (str[copy_bytes - 1] == '\0')) { - char cr = '\n'; - - if (copy_to_user(context->buf + context->actual - 1, - &cr, 1)) - return -EFAULT; - } - return 0; -} - -int vchiq_dump_platform_instances(void *dump_context) +void vchiq_dump_platform_instances(struct seq_file *f) { struct vchiq_state *state = vchiq_get_state(); - char buf[80]; - int len; int i; if (!state) - return -ENOTCONN; + return; /* * There is no list of instances, so instead scan all services, @@ -1264,7 +1217,6 @@ int vchiq_dump_platform_instances(void *dump_context) for (i = 0; i < state->unused_service; i++) { struct vchiq_service *service; struct vchiq_instance *instance; - int err; rcu_read_lock(); service = rcu_dereference(state->services[i]); @@ -1280,43 +1232,35 @@ int vchiq_dump_platform_instances(void *dump_context) } rcu_read_unlock(); - len = snprintf(buf, sizeof(buf), - "Instance %pK: pid %d,%s completions %d/%d", - instance, instance->pid, - instance->connected ? " connected, " : - "", - instance->completion_insert - - instance->completion_remove, - MAX_COMPLETIONS); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + seq_printf(f, "Instance %pK: pid %d,%s completions %d/%d\n", + instance, instance->pid, + instance->connected ? " connected, " : + "", + instance->completion_insert - + instance->completion_remove, + MAX_COMPLETIONS); instance->mark = 1; } - return 0; } -int vchiq_dump_platform_service_state(void *dump_context, - struct vchiq_service *service) +void vchiq_dump_platform_service_state(struct seq_file *f, + struct vchiq_service *service) { struct user_service *user_service = (struct user_service *)service->base.userdata; - char buf[80]; - int len; - len = scnprintf(buf, sizeof(buf), " instance %pK", service->instance); + seq_printf(f, " instance %pK", service->instance); if ((service->base.callback == service_callback) && user_service->is_vchi) { - len += scnprintf(buf + len, sizeof(buf) - len, ", %d/%d messages", - user_service->msg_insert - user_service->msg_remove, - MSG_QUEUE_SIZE); + seq_printf(f, ", %d/%d messages", + user_service->msg_insert - user_service->msg_remove, + MSG_QUEUE_SIZE); if (user_service->dequeue_pending) - len += scnprintf(buf + len, sizeof(buf) - len, - " (dequeue pending)"); + seq_puts(f, " (dequeue pending)"); } - return vchiq_dump(dump_context, buf, len + 1); + seq_puts(f, "\n"); } struct vchiq_state * diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index 7cdc3d70bd2c..7844ef765a00 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -69,13 +69,6 @@ struct vchiq_instance { struct vchiq_debugfs_node debugfs_node; }; -struct dump_context { - char __user *buf; - size_t actual; - size_t space; - loff_t offset; -}; - extern spinlock_t msg_queue_spinlock; extern struct vchiq_state g_state; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 36c742a2f3b2..6ca83f79622e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3372,8 +3372,8 @@ vchiq_set_service_option(struct vchiq_instance *instance, unsigned int handle, return ret; } -static int -vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, +static void +vchiq_dump_shared_state(struct seq_file *f, struct vchiq_state *state, struct vchiq_shared_state *shared, const char *label) { static const char *const debug_names[] = { @@ -3390,57 +3390,37 @@ vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, "COMPLETION_QUEUE_FULL_COUNT" }; int i; - char buf[80]; - int len; - int err; - - len = scnprintf(buf, sizeof(buf), " %s: slots %d-%d tx_pos=%x recycle=%x", - label, shared->slot_first, shared->slot_last, - shared->tx_pos, shared->slot_queue_recycle); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - len = scnprintf(buf, sizeof(buf), " Slots claimed:"); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + + seq_printf(f, " %s: slots %d-%d tx_pos=%x recycle=%x\n", + label, shared->slot_first, shared->slot_last, + shared->tx_pos, shared->slot_queue_recycle); + + seq_puts(f, " Slots claimed:\n"); for (i = shared->slot_first; i <= shared->slot_last; i++) { struct vchiq_slot_info slot_info = *SLOT_INFO_FROM_INDEX(state, i); if (slot_info.use_count != slot_info.release_count) { - len = scnprintf(buf, sizeof(buf), " %d: %d/%d", i, slot_info.use_count, - slot_info.release_count); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + seq_printf(f, " %d: %d/%d\n", i, slot_info.use_count, + slot_info.release_count); } } for (i = 1; i < shared->debug[DEBUG_ENTRIES]; i++) { - len = scnprintf(buf, sizeof(buf), " DEBUG: %s = %d(%x)", - debug_names[i], shared->debug[i], shared->debug[i]); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + seq_printf(f, " DEBUG: %s = %d(%x)\n", + debug_names[i], shared->debug[i], shared->debug[i]); } - return 0; } -static int -vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) +static void +vchiq_dump_service_state(struct seq_file *f, struct vchiq_service *service) { - char buf[80]; - int len; - int err; unsigned int ref_count; /*Don't include the lock just taken*/ ref_count = kref_read(&service->ref_count) - 1; - len = scnprintf(buf, sizeof(buf), "Service %u: %s (ref %u)", - service->localport, srvstate_names[service->srvstate], - ref_count); + seq_printf(f, "Service %u: %s (ref %u)", service->localport, + srvstate_names[service->srvstate], ref_count); if (service->srvstate != VCHIQ_SRVSTATE_FREE) { char remoteport[30]; @@ -3460,15 +3440,10 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) strscpy(remoteport, "n/a", sizeof(remoteport)); } - len += scnprintf(buf + len, sizeof(buf) - len, - " '%p4cc' remote %s (msg use %d/%d, slot use %d/%d)", - &fourcc, remoteport, - quota->message_use_count, quota->message_quota, - quota->slot_use_count, quota->slot_quota); - - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + seq_printf(f, " '%p4cc' remote %s (msg use %d/%d, slot use %d/%d)\n", + &fourcc, remoteport, + quota->message_use_count, quota->message_quota, + quota->slot_use_count, quota->slot_quota); tx_pending = service->bulk_tx.local_insert - service->bulk_tx.remote_insert; @@ -3486,130 +3461,79 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) rx_size = service->bulk_rx.bulks[i].size; } - len = scnprintf(buf, sizeof(buf), - " Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)", - tx_pending, tx_size, rx_pending, rx_size); + seq_printf(f, " Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)\n", + tx_pending, tx_size, rx_pending, rx_size); if (VCHIQ_ENABLE_STATS) { - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + seq_printf(f, " Ctrl: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu\n", + service->stats.ctrl_tx_count, + service->stats.ctrl_tx_bytes, + service->stats.ctrl_rx_count, + service->stats.ctrl_rx_bytes); - len = scnprintf(buf, sizeof(buf), - " Ctrl: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", - service->stats.ctrl_tx_count, service->stats.ctrl_tx_bytes, - service->stats.ctrl_rx_count, service->stats.ctrl_rx_bytes); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + seq_printf(f, " Bulk: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu\n", + service->stats.bulk_tx_count, + service->stats.bulk_tx_bytes, + service->stats.bulk_rx_count, + service->stats.bulk_rx_bytes); - len = scnprintf(buf, sizeof(buf), - " Bulk: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", - service->stats.bulk_tx_count, service->stats.bulk_tx_bytes, - service->stats.bulk_rx_count, service->stats.bulk_rx_bytes); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - len = scnprintf(buf, sizeof(buf), - " %d quota stalls, %d slot stalls, %d bulk stalls, %d aborted, %d errors", - service->stats.quota_stalls, service->stats.slot_stalls, - service->stats.bulk_stalls, - service->stats.bulk_aborted_count, - service->stats.error_count); + seq_printf(f, " %d quota stalls, %d slot stalls, %d bulk stalls, %d aborted, %d errors\n", + service->stats.quota_stalls, + service->stats.slot_stalls, + service->stats.bulk_stalls, + service->stats.bulk_aborted_count, + service->stats.error_count); } } - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - if (service->srvstate != VCHIQ_SRVSTATE_FREE) - err = vchiq_dump_platform_service_state(dump_context, service); - return err; + vchiq_dump_platform_service_state(f, service); } -int vchiq_dump_state(void *dump_context, struct vchiq_state *state) +void vchiq_dump_state(struct seq_file *f, struct vchiq_state *state) { - char buf[80]; - int len; int i; - int err; - - len = scnprintf(buf, sizeof(buf), "State %d: %s", state->id, - conn_state_names[state->conn_state]); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - len = scnprintf(buf, sizeof(buf), " tx_pos=%x(@%pK), rx_pos=%x(@%pK)", - state->local->tx_pos, - state->tx_data + (state->local_tx_pos & VCHIQ_SLOT_MASK), - state->rx_pos, - state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - len = scnprintf(buf, sizeof(buf), " Version: %d (min %d)", - VCHIQ_VERSION, VCHIQ_VERSION_MIN); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; + + seq_printf(f, "State %d: %s\n", state->id, + conn_state_names[state->conn_state]); + + seq_printf(f, " tx_pos=%x(@%pK), rx_pos=%x(@%pK)\n", + state->local->tx_pos, + state->tx_data + (state->local_tx_pos & VCHIQ_SLOT_MASK), + state->rx_pos, + state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); + + seq_printf(f, " Version: %d (min %d)\n", VCHIQ_VERSION, + VCHIQ_VERSION_MIN); if (VCHIQ_ENABLE_STATS) { - len = scnprintf(buf, sizeof(buf), - " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, error_count=%d", - state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, - state->stats.error_count); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - } - - len = scnprintf(buf, sizeof(buf), - " Slots: %d available (%d data), %d recyclable, %d stalls (%d data)", - ((state->slot_queue_available * VCHIQ_SLOT_SIZE) - - state->local_tx_pos) / VCHIQ_SLOT_SIZE, - state->data_quota - state->data_use_count, - state->local->slot_queue_recycle - state->slot_queue_available, - state->stats.slot_stalls, state->stats.data_stalls); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - - err = vchiq_dump_platform_state(dump_context); - if (err) - return err; - - err = vchiq_dump_shared_state(dump_context, - state, - state->local, - "Local"); - if (err) - return err; - err = vchiq_dump_shared_state(dump_context, - state, - state->remote, - "Remote"); - if (err) - return err; - - err = vchiq_dump_platform_instances(dump_context); - if (err) - return err; + seq_printf(f, " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, error_count=%d\n", + state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, + state->stats.error_count); + } + + seq_printf(f, " Slots: %d available (%d data), %d recyclable, %d stalls (%d data)\n", + ((state->slot_queue_available * VCHIQ_SLOT_SIZE) - + state->local_tx_pos) / VCHIQ_SLOT_SIZE, + state->data_quota - state->data_use_count, + state->local->slot_queue_recycle - state->slot_queue_available, + state->stats.slot_stalls, state->stats.data_stalls); + + vchiq_dump_platform_state(f); + + vchiq_dump_shared_state(f, state, state->local, "Local"); + + vchiq_dump_shared_state(f, state, state->remote, "Remote"); + + vchiq_dump_platform_instances(f); for (i = 0; i < state->unused_service; i++) { struct vchiq_service *service = find_service_by_port(state, i); if (service) { - err = vchiq_dump_service_state(dump_context, service); + vchiq_dump_service_state(f, service); vchiq_service_put(service); - if (err) - return err; } } - return 0; } int vchiq_send_remote_use(struct vchiq_state *state) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index ea8d58844775..564b5c707267 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -504,8 +505,8 @@ vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void * void __user *uoffset, int size, void *userdata, enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir); -extern int -vchiq_dump_state(void *dump_context, struct vchiq_state *state); +extern void +vchiq_dump_state(struct seq_file *f, struct vchiq_state *state); extern void vchiq_loud_error_header(void); @@ -561,13 +562,11 @@ void vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bulk *bul void remote_event_signal(struct remote_event *event); -int vchiq_dump(void *dump_context, const char *str, int len); - -int vchiq_dump_platform_state(void *dump_context); +void vchiq_dump_platform_state(struct seq_file *f); -int vchiq_dump_platform_instances(void *dump_context); +void vchiq_dump_platform_instances(struct seq_file *f); -int vchiq_dump_platform_service_state(void *dump_context, struct vchiq_service *service); +void vchiq_dump_platform_service_state(struct seq_file *f, struct vchiq_service *service); int vchiq_use_service_internal(struct vchiq_service *service); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c index 58db78a9c8d4..d833e4e2973a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -40,6 +40,13 @@ static int debugfs_trace_show(struct seq_file *f, void *offset) return 0; } +static int vchiq_dump_show(struct seq_file *f, void *offset) +{ + vchiq_dump_state(f, &g_state); + return 0; +} +DEFINE_SHOW_ATTRIBUTE(vchiq_dump); + static int debugfs_trace_open(struct inode *inode, struct file *file) { return single_open(file, debugfs_trace_show, inode->i_private); @@ -115,6 +122,9 @@ void vchiq_debugfs_init(void) { vchiq_dbg_dir = debugfs_create_dir("vchiq", NULL); vchiq_dbg_clients = debugfs_create_dir("clients", vchiq_dbg_dir); + + debugfs_create_file("state", S_IFREG | 0444, vchiq_dbg_dir, NULL, + &vchiq_dump_fops); } /* remove all the debugfs entries */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index 0bc93f48c14c..307a2d76cbb7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -1306,26 +1306,6 @@ static int vchiq_release(struct inode *inode, struct file *file) return ret; } -static ssize_t -vchiq_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) -{ - struct dump_context context; - int err; - - context.buf = buf; - context.actual = 0; - context.space = count; - context.offset = *ppos; - - err = vchiq_dump_state(&context, &g_state); - if (err) - return err; - - *ppos += context.actual; - - return context.actual; -} - static const struct file_operations vchiq_fops = { .owner = THIS_MODULE, @@ -1335,7 +1315,6 @@ vchiq_fops = { #endif .open = vchiq_open, .release = vchiq_release, - .read = vchiq_read }; static struct miscdevice vchiq_miscdev = {