From patchwork Tue Oct 24 11:44:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434281 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38215C07545 for ; Tue, 24 Oct 2023 11:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbjJXLon (ORCPT ); Tue, 24 Oct 2023 07:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232461AbjJXLol (ORCPT ); Tue, 24 Oct 2023 07:44:41 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2615128 for ; Tue, 24 Oct 2023 04:44:39 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 076EFB53; Tue, 24 Oct 2023 13:44:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147867; bh=EEmI146MNO9Guz2M5JYX2IrVkVYp8pkDrymbdqfznxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZZVw/CPurN+QgdNImXsn7WDSe9/xfY/xaLd/FUm7MUJzQ8b3nocKztKWeNcBW/fe wGSHngqwFz9zhSsoSi1Mg07UC4E8zZf2gGoI0b/Cmyo+kEJMNtoDBtZDkACbo8Qg70 FQnSpyBrelpNhdcylOFKaUlB9CvY8DbxBDkOooOc= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 1/8] staging: vc04_services: Pass struct device to vchiq_log_dump_mem() Date: Tue, 24 Oct 2023 07:44:21 -0400 Message-ID: <20231024114428.443528-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Pass struct device pointer to vchiq_log_dump_mem(). In subsequent commits, vchiq_log_* macros will be ported to use dynamic debug (dev_dbg()), hence they need access to a struct device pointer. No functional changes intended in this commit. Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 11 ++++++----- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) 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 596894338cb4..a12afac95dcd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1052,7 +1052,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, if (SRVTRACE_ENABLED(service, VCHIQ_LOG_INFO)) - vchiq_log_dump_mem("Sent", 0, + vchiq_log_dump_mem(state->dev, "Sent", 0, header->data, min_t(size_t, 16, callback_result)); @@ -1201,7 +1201,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, if (service) { if (SRVTRACE_ENABLED(service, VCHIQ_LOG_INFO)) - vchiq_log_dump_mem("Sent", 0, + vchiq_log_dump_mem(state->dev, "Sent", 0, header->data, min_t(size_t, 16, callback_result)); @@ -1653,7 +1653,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) msg_type_str(type), type, VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), remoteport, localport, size); if (size > 0) - vchiq_log_dump_mem("Rcvd", 0, header->data, min(16, size)); + vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); } if (((unsigned long)header & VCHIQ_SLOT_MASK) + @@ -2065,7 +2065,7 @@ sync_func(void *v) msg_type_str(type), VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), remoteport, localport, size); if (size > 0) - vchiq_log_dump_mem("Rcvd", 0, header->data, min(16, size)); + vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); } switch (type) { @@ -3665,7 +3665,8 @@ int vchiq_send_remote_use_active(struct vchiq_state *state) NULL, NULL, 0, 0); } -void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, size_t num_bytes) +void vchiq_log_dump_mem(struct device *dev, const char *label, u32 addr, + const void *void_mem, size_t num_bytes) { const u8 *mem = void_mem; size_t offset; 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 ec1a3caefaea..8b234cad24ea 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -600,7 +600,8 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state, void vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate); -void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, size_t num_bytes); +void vchiq_log_dump_mem(struct device *dev, const char *label, u32 addr, + const void *void_mem, size_t num_bytes); int vchiq_remove_service(struct vchiq_instance *instance, unsigned int service); From patchwork Tue Oct 24 11:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434282 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2DEFC07545 for ; Tue, 24 Oct 2023 11:44:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232461AbjJXLot (ORCPT ); Tue, 24 Oct 2023 07:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbjJXLor (ORCPT ); Tue, 24 Oct 2023 07:44:47 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB73C128 for ; Tue, 24 Oct 2023 04:44:41 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6FC45C67; Tue, 24 Oct 2023 13:44:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147869; bh=UDw7HdIOhh9PBndXp+jZ/iO/eXfz1vImrJOM86kYLko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QxQwlaYk+Z/Nj+yRKihIf3non9OJw6BwE1Ys6Xi7+MST5c28myaRInetjZjntOp5f dTZF5PZkrQzTVlZN/9ido9hQkv8b3/h50ZiIPeDT7XHwcgjal88HX8i9/xYBHeRzPU n66kgLDUfMm3MRYKZh7p+ww3NTVVjnF18MTRjFCs= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 2/8] staging: vc04_services: Pass struct device to vchiq_init_slots() Date: Tue, 24 Oct 2023 07:44:22 -0400 Message-ID: <20231024114428.443528-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Pass struct device pointer to vchiq_init_slots(). In subsequent commits, vchiq_log_* macros will be ported to use dynamic debug (dev_dbg()), hence they need access to a struct device pointer. No functional changes intended in this commit. Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 eef9c8c06e66..8d15ac4e1700 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -506,7 +506,7 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state WARN_ON(((unsigned long)slot_mem & (PAGE_SIZE - 1)) != 0); - vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size); + vchiq_slot_zero = vchiq_init_slots(dev, slot_mem, slot_mem_size); if (!vchiq_slot_zero) return -ENOMEM; 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 a12afac95dcd..fb9af0127c49 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2122,7 +2122,7 @@ get_conn_state_name(enum vchiq_connstate conn_state) } struct vchiq_slot_zero * -vchiq_init_slots(void *mem_base, int mem_size) +vchiq_init_slots(struct device *dev, void *mem_base, int mem_size) { int mem_align = (int)((VCHIQ_SLOT_SIZE - (long)mem_base) & VCHIQ_SLOT_MASK); 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 8b234cad24ea..ddab99017395 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -471,7 +471,7 @@ extern const char * get_conn_state_name(enum vchiq_connstate conn_state); extern struct vchiq_slot_zero * -vchiq_init_slots(void *mem_base, int mem_size); +vchiq_init_slots(struct device *dev, void *mem_base, int mem_size); extern int vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero, struct device *dev); From patchwork Tue Oct 24 11:44:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434283 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CD40C00A8F for ; Tue, 24 Oct 2023 11:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232397AbjJXLow (ORCPT ); Tue, 24 Oct 2023 07:44:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbjJXLov (ORCPT ); Tue, 24 Oct 2023 07:44:51 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E3410CB for ; Tue, 24 Oct 2023 04:44:44 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D7784EBA; Tue, 24 Oct 2023 13:44:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147871; bh=Df6IBotlVqmdTxx9QXw9qUyP2aXsLov2y/kePB4wkoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBok+AXhpGA3QHmiiw/9/MyFVEgFy+9lMuVZJ62jz4UVrWEk6cFa2cfkGnL26aDom 9FOR4enSOA4dtTXGBNhVfHE129XabLCrITIoHsfXQNvxuiTsI4d6LbBHwP4GKOD/qK uAD3HqKH/iIBz8F7G+r1T4lkhseSPYhjc+HCTonM= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 3/8] staging: vc04: Convert vchiq_log_error() to use dynamic debug Date: Tue, 24 Oct 2023 07:44:23 -0400 Message-ID: <20231024114428.443528-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Move vchiq_log_error() custom logging wrapper based on printk, to use dynamic debug. To categorise, enum vchiq_log_category has been introduced, which will become the part of the error string format that will be logged to dynamic debug (for grep). All the vchiq_log_error() calls are adjusted to use the dynamic debug wrapper. vchiq_loud_error_*() has been removed as a part of this patch and replaced with dev_err (so that they directly end up in kernel log, even if dynamic debug isn't enabled), which serves the purpose. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 36 ++++--- .../interface/vchiq_arm/vchiq_connected.c | 2 +- .../interface/vchiq_arm/vchiq_core.c | 100 +++++++----------- .../interface/vchiq_arm/vchiq_core.h | 30 ++++-- .../interface/vchiq_arm/vchiq_dev.c | 14 +-- 5 files changed, 88 insertions(+), 94 deletions(-) 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 8d15ac4e1700..2c760cf734f1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -690,7 +690,8 @@ int vchiq_initialise(struct vchiq_instance **instance_out) usleep_range(500, 600); } if (i == VCHIQ_INIT_RETRIES) { - vchiq_log_error(vchiq_core_log_level, "%s: videocore not initialized\n", __func__); + vchiq_log_error(state->dev, VCHIQ_CORE, "%s: videocore not initialized\n", + __func__); ret = -ENOTCONN; goto failed; } else if (i > 0) { @@ -700,7 +701,7 @@ int vchiq_initialise(struct vchiq_instance **instance_out) instance = kzalloc(sizeof(*instance), GFP_KERNEL); if (!instance) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "%s: error allocating vchiq instance\n", __func__); ret = -ENOMEM; goto failed; @@ -966,7 +967,8 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl } else { waiter = kzalloc(sizeof(*waiter), GFP_KERNEL); if (!waiter) { - vchiq_log_error(vchiq_core_log_level, "%s - out of memory", __func__); + vchiq_log_error(service->state->dev, VCHIQ_CORE, + "%s - out of memory", __func__); return -ENOMEM; } } @@ -1333,7 +1335,8 @@ vchiq_keepalive_vchiq_callback(struct vchiq_instance *instance, struct vchiq_header *header, unsigned int service_user, void *bulk_user) { - vchiq_log_error(vchiq_susp_log_level, "%s callback reason %d", __func__, reason); + vchiq_log_error(instance->state->dev, VCHIQ_SUSPEND, + "%s callback reason %d", __func__, reason); return 0; } @@ -1357,22 +1360,22 @@ vchiq_keepalive_thread_func(void *v) ret = vchiq_initialise(&instance); if (ret) { - vchiq_log_error(vchiq_susp_log_level, "%s vchiq_initialise failed %d", __func__, - ret); + vchiq_log_error(state->dev, VCHIQ_SUSPEND, + "%s vchiq_initialise failed %d", __func__, ret); goto exit; } status = vchiq_connect(instance); if (status) { - vchiq_log_error(vchiq_susp_log_level, "%s vchiq_connect failed %d", __func__, - status); + vchiq_log_error(state->dev, VCHIQ_SUSPEND, + "%s vchiq_connect failed %d", __func__, status); goto shutdown; } status = vchiq_add_service(instance, ¶ms, &ka_handle); if (status) { - vchiq_log_error(vchiq_susp_log_level, "%s vchiq_open_service failed %d", __func__, - status); + vchiq_log_error(state->dev, VCHIQ_SUSPEND, + "%s vchiq_open_service failed %d", __func__, status); goto shutdown; } @@ -1380,7 +1383,8 @@ vchiq_keepalive_thread_func(void *v) long rc = 0, uc = 0; if (wait_for_completion_interruptible(&arm_state->ka_evt)) { - vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); + vchiq_log_error(state->dev, VCHIQ_SUSPEND, + "%s interrupted", __func__); flush_signals(current); continue; } @@ -1400,14 +1404,14 @@ vchiq_keepalive_thread_func(void *v) atomic_inc(&arm_state->ka_use_ack_count); status = vchiq_use_service(instance, ka_handle); if (status) { - vchiq_log_error(vchiq_susp_log_level, + vchiq_log_error(state->dev, VCHIQ_SUSPEND, "%s vchiq_use_service error %d", __func__, status); } } while (rc--) { status = vchiq_release_service(instance, ka_handle); if (status) { - vchiq_log_error(vchiq_susp_log_level, + vchiq_log_error(state->dev, VCHIQ_SUSPEND, "%s vchiq_release_service error %d", __func__, status); } @@ -1444,7 +1448,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, service->client_id); entity_uc = &service->service_use_count; } else { - vchiq_log_error(vchiq_susp_log_level, "%s null service ptr", __func__); + vchiq_log_error(state->dev, VCHIQ_SUSPEND, "%s null service ptr", __func__); ret = -EINVAL; goto out; } @@ -1725,7 +1729,7 @@ vchiq_check_service(struct vchiq_service *service) read_unlock_bh(&arm_state->susp_res_lock); if (ret) { - vchiq_log_error(vchiq_susp_log_level, + vchiq_log_error(service->state->dev, VCHIQ_SUSPEND, "%s ERROR - %c%c%c%c:%d service count %d, state count %d", __func__, VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), service->client_id, service->service_use_count, arm_state->videocore_use_count); @@ -1761,7 +1765,7 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state, (void *)state, threadname); if (IS_ERR(arm_state->ka_thread)) { - vchiq_log_error(vchiq_susp_log_level, + vchiq_log_error(state->dev, VCHIQ_SUSPEND, "vchiq: FATAL: couldn't create thread %s", threadname); } else { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c index bdb0ab617d8b..b3928bd8c9c6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c @@ -39,7 +39,7 @@ void vchiq_add_connected_callback(void (*callback)(void)) callback(); } else { if (g_num_deferred_callbacks >= MAX_CALLBACKS) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(NULL, VCHIQ_CORE, "There already %d callback registered - please increase MAX_CALLBACKS", g_num_deferred_callbacks); } else { 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 fb9af0127c49..12fcb229124c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -751,7 +751,7 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found, */ complete("a->quota_event); } else if (count == 0) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)", port, quota->message_use_count, header, msgid, header->msgid, header->size); @@ -776,7 +776,7 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found, vchiq_log_trace(vchiq_core_log_level, "%d: pfq:%d %x@%pK - slot_use->%d", state->id, port, header->size, header, count - 1); } else { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "service %d slot_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)", port, count, header, msgid, header->msgid, header->size); WARN(1, "bad slot use count\n"); @@ -841,7 +841,7 @@ process_free_queue(struct vchiq_state *state, u32 *service_found, pos += calc_stride(header->size); if (pos > VCHIQ_SLOT_SIZE) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "pfq - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x", pos, header, msgid, header->msgid, header->size); WARN(1, "invalid slot position\n"); @@ -1178,7 +1178,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, int oldmsgid = header->msgid; if (oldmsgid != VCHIQ_MSGID_PADDING) - vchiq_log_error(vchiq_core_log_level, "%d: qms - msgid %x, not PADDING", + vchiq_log_error(state->dev, VCHIQ_CORE, "%d: qms - msgid %x, not PADDING", state->id, oldmsgid); } @@ -1512,11 +1512,9 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) if ((service->version < version_min) || (version < service->version_min)) { /* Version mismatch */ - vchiq_loud_error_header(); - vchiq_loud_error("%d: service %d (%c%c%c%c) version mismatch - local (%d, min %d) vs. remote (%d, min %d)", - state->id, service->localport, VCHIQ_FOURCC_AS_4CHARS(fourcc), - service->version, service->version_min, version, version_min); - vchiq_loud_error_footer(); + dev_err(state->dev, "%d: service %d (%c%c%c%c) version mismatch - local (%d, min %d) vs. remote (%d, min %d)", + state->id, service->localport, VCHIQ_FOURCC_AS_4CHARS(fourcc), + service->version, service->version_min, version, version_min); vchiq_service_put(service); service = NULL; goto fail_open; @@ -1631,7 +1629,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } if (!service) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "%d: prs %s@%pK (%d->%d) - invalid/closed service %d", state->id, msg_type_str(type), header, remoteport, localport, localport); @@ -1658,7 +1656,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) if (((unsigned long)header & VCHIQ_SLOT_MASK) + calc_stride(size) > VCHIQ_SLOT_SIZE) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "header %pK (msgid %x) - size %x too big for slot", header, (unsigned int)msgid, (unsigned int)size); WARN(1, "oversized for slot\n"); @@ -1685,7 +1683,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) set_service_state(service, VCHIQ_SRVSTATE_OPEN); complete(&service->remove_event); } else { - vchiq_log_error(vchiq_core_log_level, "OPENACK received in state %s", + vchiq_log_error(state->dev, VCHIQ_CORE, "OPENACK received in state %s", srvstate_names[service->srvstate]); } break; @@ -1756,7 +1754,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } if ((int)(queue->remote_insert - queue->local_insert) >= 0) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "%d: prs %s@%pK (%d->%d) unexpected (ri=%d,li=%d)", state->id, msg_type_str(type), header, remoteport, localport, queue->remote_insert, @@ -1805,8 +1803,8 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) vchiq_log_trace(vchiq_core_log_level, "%d: prs PAUSE@%pK,%x", state->id, header, size); if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { - vchiq_log_error(vchiq_core_log_level, "%d: PAUSE received in state PAUSED", - state->id); + vchiq_log_error(state->dev, VCHIQ_CORE, + "%d: PAUSE received in state PAUSED", state->id); break; } if (state->conn_state != VCHIQ_CONNSTATE_PAUSE_SENT) { @@ -1836,7 +1834,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) break; default: - vchiq_log_error(vchiq_core_log_level, "%d: prs invalid msgid %x@%pK,%x", + vchiq_log_error(state->dev, VCHIQ_CORE, "%d: prs invalid msgid %x@%pK,%x", state->id, msgid, header, size); WARN(1, "invalid message\n"); break; @@ -1947,7 +1945,7 @@ handle_poll(struct vchiq_state *state) * since the PAUSE should have flushed * through outstanding messages. */ - vchiq_log_error(vchiq_core_log_level, "Failed to send RESUME message"); + vchiq_log_error(state->dev, VCHIQ_CORE, "Failed to send RESUME message"); } break; default: @@ -2046,7 +2044,7 @@ sync_func(void *v) service = find_service_by_port(state, localport); if (!service) { - vchiq_log_error(vchiq_sync_log_level, + vchiq_log_error(state->dev, VCHIQ_SYNC, "%d: sf %s@%pK (%d->%d) - invalid/closed service %d", state->id, msg_type_str(type), header, remoteport, localport, localport); @@ -2096,14 +2094,14 @@ sync_func(void *v) (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC)) { if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, NULL) == -EAGAIN) - vchiq_log_error(vchiq_sync_log_level, + vchiq_log_error(state->dev, VCHIQ_SYNC, "synchronous callback to service %d returns -EAGAIN", localport); } break; default: - vchiq_log_error(vchiq_sync_log_level, "%d: sf unexpected msgid %x@%pK,%x", + vchiq_log_error(state->dev, VCHIQ_SYNC, "%d: sf unexpected msgid %x@%pK,%x", state->id, msgid, header, size); release_message_sync(state, header); break; @@ -2137,7 +2135,7 @@ vchiq_init_slots(struct device *dev, void *mem_base, int mem_size) num_slots -= first_data_slot; if (num_slots < 4) { - vchiq_log_error(vchiq_core_log_level, "%s - insufficient memory %x bytes", + vchiq_log_error(dev, VCHIQ_CORE, "%s - insufficient memory %x bytes", __func__, mem_size); return NULL; } @@ -2174,12 +2172,11 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero, s remote = &slot_zero->master; if (local->initialised) { - vchiq_loud_error_header(); if (remote->initialised) - vchiq_loud_error("local state has already been initialised"); + dev_err(dev, "local state has already been initialised\n"); else - vchiq_loud_error("master/slave mismatch two slaves"); - vchiq_loud_error_footer(); + dev_err(dev, "master/slave mismatch two slaves\n"); + return -EINVAL; } @@ -2257,9 +2254,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero, s state->slot_handler_thread = kthread_create(&slot_handler_func, (void *)state, threadname); if (IS_ERR(state->slot_handler_thread)) { - vchiq_loud_error_header(); - vchiq_loud_error("couldn't create thread %s", threadname); - vchiq_loud_error_footer(); + dev_err(state->dev, "couldn't create thread %s\n", threadname); return PTR_ERR(state->slot_handler_thread); } set_user_nice(state->slot_handler_thread, -19); @@ -2267,9 +2262,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero, s snprintf(threadname, sizeof(threadname), "vchiq-recy/%d", state->id); state->recycle_thread = kthread_create(&recycle_func, (void *)state, threadname); if (IS_ERR(state->recycle_thread)) { - vchiq_loud_error_header(); - vchiq_loud_error("couldn't create thread %s", threadname); - vchiq_loud_error_footer(); + dev_err(state->dev, "couldn't create thread %s\n", threadname); ret = PTR_ERR(state->recycle_thread); goto fail_free_handler_thread; } @@ -2278,9 +2271,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero, s snprintf(threadname, sizeof(threadname), "vchiq-sync/%d", state->id); state->sync_thread = kthread_create(&sync_func, (void *)state, threadname); if (IS_ERR(state->sync_thread)) { - vchiq_loud_error_header(); - vchiq_loud_error("couldn't create thread %s", threadname); - vchiq_loud_error_footer(); + dev_err(state->dev, "couldn't create thread %s\n", threadname); ret = PTR_ERR(state->sync_thread); goto fail_free_recycle_thread; } @@ -2353,10 +2344,11 @@ struct vchiq_header *vchiq_msg_hold(struct vchiq_instance *instance, unsigned in } EXPORT_SYMBOL(vchiq_msg_hold); -static int vchiq_validate_params(const struct vchiq_service_params_kernel *params) +static int vchiq_validate_params(struct vchiq_state *state, + const struct vchiq_service_params_kernel *params) { if (!params->callback || !params->fourcc) { - vchiq_loud_error("Can't add service, invalid params\n"); + dev_err(state->dev, "Can't add service, invalid params\n"); return -EINVAL; } @@ -2376,7 +2368,7 @@ vchiq_add_service_internal(struct vchiq_state *state, int ret; int i; - ret = vchiq_validate_params(params); + ret = vchiq_validate_params(state, params); if (ret) return NULL; @@ -2525,7 +2517,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) && (service->srvstate != VCHIQ_SRVSTATE_OPENSYNC)) { if (service->srvstate != VCHIQ_SRVSTATE_CLOSEWAIT) - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(service->state->dev, VCHIQ_CORE, "%d: osi - srvstate = %s (ref %u)", service->state->id, srvstate_names[service->srvstate], @@ -2589,7 +2581,7 @@ release_service_messages(struct vchiq_service *service) } pos += calc_stride(header->size); if (pos > VCHIQ_SLOT_SIZE) { - vchiq_log_error(vchiq_core_log_level, + vchiq_log_error(state->dev, VCHIQ_CORE, "fsi - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x", pos, header, msgid, header->msgid, header->size); WARN(1, "invalid slot position\n"); @@ -2645,8 +2637,8 @@ close_service_complete(struct vchiq_service *service, int failstate) case VCHIQ_SRVSTATE_LISTENING: break; default: - vchiq_log_error(vchiq_core_log_level, "%s(%x) called in state %s", __func__, - service->handle, srvstate_names[service->srvstate]); + vchiq_log_error(service->state->dev, VCHIQ_CORE, "%s(%x) called in state %s", + __func__, service->handle, srvstate_names[service->srvstate]); WARN(1, "%s in unexpected state\n", __func__); return -EINVAL; } @@ -2701,7 +2693,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) case VCHIQ_SRVSTATE_LISTENING: case VCHIQ_SRVSTATE_CLOSEWAIT: if (close_recvd) { - vchiq_log_error(vchiq_core_log_level, "%s(1) called in state %s", + vchiq_log_error(state->dev, VCHIQ_CORE, "%s(1) called in state %s", __func__, srvstate_names[service->srvstate]); } else if (is_server) { if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) { @@ -2789,7 +2781,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) break; default: - vchiq_log_error(vchiq_core_log_level, "%s(%d) called in state %s", __func__, + vchiq_log_error(state->dev, VCHIQ_CORE, "%s(%d) called in state %s", __func__, close_recvd, srvstate_names[service->srvstate]); break; } @@ -2828,7 +2820,7 @@ vchiq_free_service_internal(struct vchiq_service *service) case VCHIQ_SRVSTATE_CLOSEWAIT: break; default: - vchiq_log_error(vchiq_core_log_level, "%d: fsi - (%d) in state %s", state->id, + vchiq_log_error(state->dev, VCHIQ_CORE, "%d: fsi - (%d) in state %s", state->id, service->localport, srvstate_names[service->srvstate]); return; } @@ -3628,26 +3620,6 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) return err; } -void -vchiq_loud_error_header(void) -{ - vchiq_log_error(vchiq_core_log_level, - "============================================================================"); - vchiq_log_error(vchiq_core_log_level, - "============================================================================"); - vchiq_log_error(vchiq_core_log_level, "====="); -} - -void -vchiq_loud_error_footer(void) -{ - vchiq_log_error(vchiq_core_log_level, "====="); - vchiq_log_error(vchiq_core_log_level, - "============================================================================"); - vchiq_log_error(vchiq_core_log_level, - "============================================================================"); -} - 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 ddab99017395..219d5db9df0e 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 @@ -39,10 +40,30 @@ #define VCHIQ_LOG_PREFIX KERN_INFO "vchiq: " +enum vchiq_log_category { + VCHIQ_ARM, + VCHIQ_CORE, + VCHIQ_CORE_MSG, + VCHIQ_SYNC, + VCHIQ_SUSPEND, +}; + +static inline const char *log_category_str(enum vchiq_log_category c) +{ + static const char * const strings[] = { + "vchiq_arm", + "vchiq_core", + "vchiq_core_msg", + "vchiq_sync", + "vchiq_suspend", + }; + + return strings[c]; +}; + #ifndef vchiq_log_error -#define vchiq_log_error(cat, fmt, ...) \ - do { if (cat >= VCHIQ_LOG_ERROR) \ - printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) +#define vchiq_log_error(dev, cat, fmt, ...) \ + do { dev_dbg(dev, "%s error: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) #endif #ifndef vchiq_log_warning #define vchiq_log_warning(cat, fmt, ...) \ @@ -60,9 +81,6 @@ printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) #endif -#define vchiq_loud_error(...) \ - vchiq_log_error(vchiq_core_log_level, "===== " __VA_ARGS__) - #define VCHIQ_SLOT_MASK (VCHIQ_SLOT_SIZE - 1) #define VCHIQ_SLOT_QUEUE_MASK (VCHIQ_MAX_SLOTS_PER_SIDE - 1) #define VCHIQ_SLOT_ZERO_SLOTS DIV_ROUND_UP(sizeof(struct vchiq_slot_zero), \ 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 841e1a535642..2622a4477a67 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -271,7 +271,7 @@ static int vchiq_ioc_dequeue_message(struct vchiq_instance *instance, ret = -EFAULT; } } else { - vchiq_log_error(vchiq_arm_log_level, + vchiq_log_error(service->state->dev, VCHIQ_ARM, "header %pK: bufsize %x < size %x", header, args->bufsize, header->size); WARN(1, "invalid size\n"); @@ -318,7 +318,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, } mutex_unlock(&instance->bulk_waiter_list_mutex); if (!waiter) { - vchiq_log_error(vchiq_arm_log_level, + vchiq_log_error(service->state->dev, VCHIQ_ARM, "no bulk_waiter found for pid %d", current->pid); ret = -ESRCH; goto out; @@ -501,7 +501,7 @@ static int vchiq_ioc_await_completion(struct vchiq_instance *instance, msglen = header->size + sizeof(struct vchiq_header); /* This must be a VCHIQ-style service */ if (args->msgbufsize < msglen) { - vchiq_log_error(vchiq_arm_log_level, + vchiq_log_error(service->state->dev, VCHIQ_ARM, "header %pK: msgbufsize %x < msglen %x", header, args->msgbufsize, msglen); WARN(1, "invalid message size\n"); @@ -618,7 +618,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } rc = mutex_lock_killable(&instance->state->mutex); if (rc) { - vchiq_log_error(vchiq_arm_log_level, + vchiq_log_error(instance->state->dev, VCHIQ_ARM, "vchiq: connect: could not lock mutex for state %d: %d", instance->state->id, rc); ret = -EINTR; @@ -630,7 +630,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (!status) instance->connected = 1; else - vchiq_log_error(vchiq_arm_log_level, + vchiq_log_error(instance->state->dev, VCHIQ_ARM, "vchiq: could not connect: %d", status); break; @@ -700,7 +700,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) vchiq_use_service_internal(service) : vchiq_release_service_internal(service); if (ret) { - vchiq_log_error(vchiq_susp_log_level, + vchiq_log_error(instance->state->dev, VCHIQ_SUSPEND, "%s: cmd %s returned error %ld for service %c%c%c%c:%03d", __func__, (cmd == VCHIQ_IOC_USE_SERVICE) ? "VCHIQ_IOC_USE_SERVICE" : @@ -1173,7 +1173,7 @@ static int vchiq_open(struct inode *inode, struct file *file) vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); if (!state) { - vchiq_log_error(vchiq_arm_log_level, + vchiq_log_error(state->dev, VCHIQ_ARM, "vchiq has no connection to VideoCore"); return -ENOTCONN; } From patchwork Tue Oct 24 11:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434284 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A87E1C25B48 for ; Tue, 24 Oct 2023 11:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232469AbjJXLoy (ORCPT ); Tue, 24 Oct 2023 07:44:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232463AbjJXLox (ORCPT ); Tue, 24 Oct 2023 07:44:53 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5482610C0 for ; Tue, 24 Oct 2023 04:44:48 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 60D1C128D; Tue, 24 Oct 2023 13:44:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147874; bh=jSv8c12sL4oMPyAZcET1tDHpval4s9kiQ9zFZpRPihc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P/NRRwqgtAfElWoi0HI9dCDw4kLi4saLHw1RNxo4klLhN8N3EgwfS+vcCj5Nmji+C 5qt4ZzNFrwLdA1PXE9YKs4spoXjhoGEU6JgkFyCGFJrwMQm6ClpCgtokPRdBcmq1zu pyxZLXaZFrl0Oi8CnU6dwPl/U5xytOOfWs+kwPvk= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 4/8] staging: vc04: Convert vchiq_log_warning() to use dynamic debug Date: Tue, 24 Oct 2023 07:44:24 -0400 Message-ID: <20231024114428.443528-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Move vchiq_log_warning() custom logging wrapper based on printk to use dynamic debug. The log category is dictated by vchiq_log_category which will become the part of the warning string format that will be logged to dynamic debug (for grep). All the vchiq_log_warning() calls are adjusted to use the modified wrapper. While at that, remove the extraneous "----" from few of the warning string text. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- .../interface/vchiq_arm/vchiq_arm.c | 16 +++++++++------- .../interface/vchiq_arm/vchiq_core.c | 8 ++++---- .../interface/vchiq_arm/vchiq_core.h | 5 ++--- 3 files changed, 15 insertions(+), 14 deletions(-) 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 2c760cf734f1..8e8c6ebfa0c8 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -695,7 +695,7 @@ int vchiq_initialise(struct vchiq_instance **instance_out) ret = -ENOTCONN; goto failed; } else if (i > 0) { - vchiq_log_warning(vchiq_core_log_level, + vchiq_log_warning(state->dev, VCHIQ_CORE, "%s: videocore initialized after %d retries\n", __func__, i); } @@ -1696,17 +1696,19 @@ vchiq_dump_service_use_state(struct vchiq_state *state) read_unlock_bh(&arm_state->susp_res_lock); if (only_nonzero) - vchiq_log_warning(vchiq_susp_log_level, "Too many active services (%d). Only dumping up to first %d services with non-zero use-count", + vchiq_log_warning(state->dev, VCHIQ_SUSPEND, + "Too many active services (%d). Only dumping up to first %d services with non-zero use-count", active_services, found); for (i = 0; i < found; i++) { - vchiq_log_warning(vchiq_susp_log_level, "----- %c%c%c%c:%d service count %d %s", + vchiq_log_warning(state->dev, VCHIQ_SUSPEND, + "%c%c%c%c:%d service count %d %s", VCHIQ_FOURCC_AS_4CHARS(service_data[i].fourcc), service_data[i].clientid, service_data[i].use_count, service_data[i].use_count ? nz : ""); } - vchiq_log_warning(vchiq_susp_log_level, "----- VCHIQ use count %d", peer_count); - vchiq_log_warning(vchiq_susp_log_level, "--- Overall vchiq instance use count %d", + vchiq_log_warning(state->dev, VCHIQ_SUSPEND, "VCHIQ use count %d", peer_count); + vchiq_log_warning(state->dev, VCHIQ_SUSPEND, "Overall vchiq instance use count %d", vc_use_count); kfree(service_data); @@ -1822,7 +1824,7 @@ static int vchiq_probe(struct platform_device *pdev) */ err = vchiq_register_chrdev(&pdev->dev); if (err) { - vchiq_log_warning(vchiq_arm_log_level, + vchiq_log_warning(&pdev->dev, VCHIQ_ARM, "Failed to initialize vchiq cdev"); goto error_exit; } @@ -1833,7 +1835,7 @@ static int vchiq_probe(struct platform_device *pdev) return 0; failed_platform_init: - vchiq_log_warning(vchiq_arm_log_level, "could not initialize vchiq platform"); + vchiq_log_warning(&pdev->dev, VCHIQ_ARM, "could not initialize vchiq platform"); error_exit: return err; } 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 12fcb229124c..5f535003f25f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -475,7 +475,7 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, status = service->base.callback(service->instance, reason, header, service->handle, bulk_userdata); if (status && (status != -EAGAIN)) { - vchiq_log_warning(vchiq_core_log_level, + vchiq_log_warning(service->state->dev, VCHIQ_CORE, "%d: ignoring ERROR from callback to service %x", service->state->id, service->handle); status = 0; @@ -1622,7 +1622,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) vchiq_service_put(service); service = get_connected_service(state, remoteport); if (service) - vchiq_log_warning(vchiq_core_log_level, + vchiq_log_warning(state->dev, VCHIQ_CORE, "%d: prs %s@%pK (%d->%d) - found connected service %d", state->id, msg_type_str(type), header, remoteport, localport, service->localport); @@ -2921,7 +2921,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) (service->srvstate == VCHIQ_SRVSTATE_OPEN)) break; - vchiq_log_warning(vchiq_core_log_level, + vchiq_log_warning(service->state->dev, VCHIQ_CORE, "%d: close_service:%d - waiting in state %s", service->state->id, service->localport, srvstate_names[service->srvstate]); @@ -2982,7 +2982,7 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) (service->srvstate == VCHIQ_SRVSTATE_OPEN)) break; - vchiq_log_warning(vchiq_core_log_level, + vchiq_log_warning(service->state->dev, VCHIQ_CORE, "%d: remove_service:%d - waiting in state %s", service->state->id, service->localport, srvstate_names[service->srvstate]); 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 219d5db9df0e..d1e5c50170da 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -66,9 +66,8 @@ static inline const char *log_category_str(enum vchiq_log_category c) do { dev_dbg(dev, "%s error: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) #endif #ifndef vchiq_log_warning -#define vchiq_log_warning(cat, fmt, ...) \ - do { if (cat >= VCHIQ_LOG_WARNING) \ - printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) +#define vchiq_log_warning(dev, cat, fmt, ...) \ + do { dev_dbg(dev, "%s warning: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) #endif #ifndef vchiq_log_info #define vchiq_log_info(cat, fmt, ...) \ From patchwork Tue Oct 24 11:44:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434286 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 316CDC07545 for ; Tue, 24 Oct 2023 11:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232580AbjJXLpD (ORCPT ); Tue, 24 Oct 2023 07:45:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbjJXLpC (ORCPT ); Tue, 24 Oct 2023 07:45:02 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E048510D7 for ; Tue, 24 Oct 2023 04:44:51 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C95629CC; Tue, 24 Oct 2023 13:44:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147877; bh=tvUXA04xvgT7ndwueIIDqe4UMeJC9w4Z20EIRakfPX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVqT4IYEupeSX4T7btcwKA0Z57IjsL0zxcXzjoDg9jDV0XPReJ7W0gPxKIplBJDqi aO9naiDdt4HxBiFFNpZTbgeZimh8ttuisVaIxEPQvurwu1a6r3wnS3WI2QDAucGw+1 CzHvzQj6KtFoW3p78ynlU0XqQjbgUs7JGf6VfMqc= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 5/8] staging: vc04: Convert(and rename) vchiq_log_info() to use dynamic debug Date: Tue, 24 Oct 2023 07:44:25 -0400 Message-ID: <20231024114428.443528-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Convert(and rename) vchiq_log_info() custom logging wrapping based on printk to use dynamic debug. The wrapper is now renamed to vchiq_log_debug() since most of the usage is around printing debug information. The log category is dictated by enum vchiq_log_category which will become the part of the debug string format that will be logged to dynamic debug (for grep). All the vchiq_log_info() calls are adjusted to use the modified wrapper vchiq_log_debug(). The existing custom logging for vchiq_log_info() also tries to log trace messages using SRVTRACE_LEVEL. This is simply moved to use the vchiq_log_debug() directly. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 46 +++-- .../interface/vchiq_arm/vchiq_core.c | 171 +++++++++--------- .../interface/vchiq_arm/vchiq_core.h | 7 +- .../interface/vchiq_arm/vchiq_dev.c | 41 +++-- 4 files changed, 137 insertions(+), 128 deletions(-) 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 8e8c6ebfa0c8..7a51c2f62586 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -314,9 +314,9 @@ create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf, type == PAGELIST_READ, pages); if (actual_pages != num_pages) { - vchiq_log_info(vchiq_arm_log_level, - "%s - only %d/%d pages locked", - __func__, actual_pages, num_pages); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "%s - only %d/%d pages locked", + __func__, actual_pages, num_pages); /* This is probably due to the process being killed */ if (actual_pages > 0) @@ -559,8 +559,8 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state return -ENXIO; } - vchiq_log_info(vchiq_arm_log_level, "vchiq_init - done (slots %pK, phys %pad)", - vchiq_slot_zero, &slot_phys); + vchiq_log_debug(&pdev->dev, VCHIQ_ARM, "vchiq_init - done (slots %pK, phys %pad)", + vchiq_slot_zero, &slot_phys); vchiq_call_connected_callbacks(); @@ -730,8 +730,9 @@ void free_bulk_waiter(struct vchiq_instance *instance) list_for_each_entry_safe(waiter, next, &instance->bulk_waiter_list, list) { list_del(&waiter->list); - vchiq_log_info(vchiq_arm_log_level, "bulk_waiter - cleaned up %pK for pid %d", - waiter, waiter->pid); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "bulk_waiter - cleaned up %pK for pid %d", + waiter, waiter->pid); kfree(waiter); } } @@ -991,8 +992,9 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl mutex_lock(&instance->bulk_waiter_list_mutex); list_add(&waiter->list, &instance->bulk_waiter_list); mutex_unlock(&instance->bulk_waiter_list_mutex); - vchiq_log_info(vchiq_arm_log_level, "saved bulk_waiter %pK for pid %d", waiter, - current->pid); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "saved bulk_waiter %pK for pid %d", waiter, + current->pid); } return status; @@ -1015,10 +1017,12 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, vchiq_log_trace(vchiq_arm_log_level, "%s - completion queue full", __func__); DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); if (wait_for_completion_interruptible(&instance->remove_event)) { - vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted"); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "service_callback interrupted"); return -EAGAIN; } else if (instance->closing) { - vchiq_log_info(vchiq_arm_log_level, "service_callback closing"); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "service_callback closing"); return 0; } DEBUG_TRACE(SERVICE_CALLBACK_LINE); @@ -1120,8 +1124,8 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, instance->completion_remove) < 0) { int status; - vchiq_log_info(vchiq_arm_log_level, - "Inserting extra MESSAGE_AVAILABLE"); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "Inserting extra MESSAGE_AVAILABLE"); DEBUG_TRACE(SERVICE_CALLBACK_LINE); status = add_completion(instance, reason, NULL, user_service, bulk_userdata); @@ -1134,12 +1138,14 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, DEBUG_TRACE(SERVICE_CALLBACK_LINE); if (wait_for_completion_interruptible(&user_service->remove_event)) { - vchiq_log_info(vchiq_arm_log_level, "%s interrupted", __func__); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "%s interrupted", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); return -EAGAIN; } else if (instance->closing) { - vchiq_log_info(vchiq_arm_log_level, "%s closing", __func__); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "%s closing", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); return -EINVAL; @@ -1748,8 +1754,8 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state, struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); char threadname[16]; - vchiq_log_info(vchiq_susp_log_level, "%d: %s->%s", state->id, - get_conn_state_name(oldstate), get_conn_state_name(newstate)); + vchiq_log_debug(state->dev, VCHIQ_SUSPEND, "%d: %s->%s", state->id, + get_conn_state_name(oldstate), get_conn_state_name(newstate)); if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED) return; @@ -1814,9 +1820,9 @@ static int vchiq_probe(struct platform_device *pdev) vchiq_debugfs_init(); - vchiq_log_info(vchiq_arm_log_level, - "vchiq: platform initialised - version %d (min %d)", - VCHIQ_VERSION, VCHIQ_VERSION_MIN); + vchiq_log_debug(&pdev->dev, VCHIQ_ARM, + "vchiq: platform initialised - version %d (min %d)", + VCHIQ_VERSION, VCHIQ_VERSION_MIN); /* * Simply exit on error since the function handles cleanup in 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 5f535003f25f..926b0f6ea82a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -103,8 +103,6 @@ static_assert((unsigned int)VCHIQ_PORT_MAX < #define BULK_INDEX(x) ((x) & (VCHIQ_NUM_SERVICE_BULKS - 1)) -#define SRVTRACE_LEVEL(srv) \ - (((srv) && (srv)->trace) ? VCHIQ_LOG_TRACE : vchiq_core_msg_log_level) #define SRVTRACE_ENABLED(srv, lev) \ (((srv) && (srv)->trace) || (vchiq_core_msg_log_level >= (lev))) @@ -227,10 +225,10 @@ static const char *msg_type_str(unsigned int msg_type) static inline void set_service_state(struct vchiq_service *service, int newstate) { - vchiq_log_info(vchiq_core_log_level, "%d: srv:%d %s->%s", - service->state->id, service->localport, - srvstate_names[service->srvstate], - srvstate_names[newstate]); + vchiq_log_debug(service->state->dev, VCHIQ_CORE, "%d: srv:%d %s->%s", + service->state->id, service->localport, + srvstate_names[service->srvstate], + srvstate_names[newstate]); service->srvstate = newstate; } @@ -255,8 +253,8 @@ find_service_by_handle(struct vchiq_instance *instance, unsigned int handle) return service; } rcu_read_unlock(); - vchiq_log_info(vchiq_core_log_level, - "Invalid service handle 0x%x", handle); + vchiq_log_debug(service->state->dev, VCHIQ_CORE, + "Invalid service handle 0x%x", handle); return NULL; } @@ -276,8 +274,8 @@ find_service_by_port(struct vchiq_state *state, unsigned int localport) } rcu_read_unlock(); } - vchiq_log_info(vchiq_core_log_level, - "Invalid port %u", localport); + vchiq_log_debug(state->dev, VCHIQ_CORE, + "Invalid port %u", localport); return NULL; } @@ -297,8 +295,8 @@ find_service_for_instance(struct vchiq_instance *instance, unsigned int handle) return service; } rcu_read_unlock(); - vchiq_log_info(vchiq_core_log_level, - "Invalid service handle 0x%x", handle); + vchiq_log_debug(service->state->dev, VCHIQ_CORE, + "Invalid service handle 0x%x", handle); return NULL; } @@ -320,8 +318,8 @@ find_closed_service_for_instance(struct vchiq_instance *instance, unsigned int h return service; } rcu_read_unlock(); - vchiq_log_info(vchiq_core_log_level, - "Invalid service handle 0x%x", handle); + vchiq_log_debug(service->state->dev, VCHIQ_CORE, + "Invalid service handle 0x%x", handle); return service; } @@ -492,8 +490,8 @@ vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate) { enum vchiq_connstate oldstate = state->conn_state; - vchiq_log_info(vchiq_core_log_level, "%d: %s->%s", state->id, conn_state_names[oldstate], - conn_state_names[newstate]); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: %s->%s", state->id, conn_state_names[oldstate], + conn_state_names[newstate]); state->conn_state = newstate; vchiq_platform_conn_state_changed(state, oldstate, newstate); } @@ -1033,9 +1031,9 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, int tx_end_index; int slot_use_count; - vchiq_log_info(vchiq_core_log_level, "%d: qm %s@%pK,%zx (%d->%d)", state->id, - msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, - VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: qm %s@%pK,%zx (%d->%d)", state->id, + msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, + VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | QMFLAGS_NO_MUTEX_UNLOCK)); @@ -1093,9 +1091,9 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count); VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size); } else { - vchiq_log_info(vchiq_core_log_level, "%d: qm %s@%pK,%zx (%d->%d)", state->id, - msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, - VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: qm %s@%pK,%zx (%d->%d)", state->id, + msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, + VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); if (size != 0) { /* * It is assumed for now that this code path @@ -1123,11 +1121,11 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_info(SRVTRACE_LEVEL(service), - "Sent Msg %s(%u) to %c%c%c%c s:%u d:%d len:%zu", - msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), - VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid), size); + vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, + "Sent Msg %s(%u) to %c%c%c%c s:%u d:%d len:%zu", + msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), + VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), VCHIQ_MSG_SRCPORT(msgid), + VCHIQ_MSG_DSTPORT(msgid), size); } /* Make sure the new header is visible to the peer. */ @@ -1182,11 +1180,11 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, state->id, oldmsgid); } - vchiq_log_info(vchiq_sync_log_level, - "%d: qms %s@%pK,%x (%d->%d)", state->id, - msg_type_str(VCHIQ_MSG_TYPE(msgid)), - header, size, VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid)); + vchiq_log_debug(state->dev, VCHIQ_SYNC, + "%d: qms %s@%pK,%x (%d->%d)", state->id, + msg_type_str(VCHIQ_MSG_TYPE(msgid)), + header, size, VCHIQ_MSG_SRCPORT(msgid), + VCHIQ_MSG_DSTPORT(msgid)); callback_result = copy_message_data(copy_callback, context, @@ -1278,9 +1276,9 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, VCHIQ_SLOT_QUEUE_MASK] = SLOT_INDEX_FROM_INFO(state, slot_info); state->remote->slot_queue_recycle = slot_queue_recycle + 1; - vchiq_log_info(vchiq_core_log_level, "%d: %s %d - recycle->%x", state->id, __func__, - SLOT_INDEX_FROM_INFO(state, slot_info), - state->remote->slot_queue_recycle); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: %s %d - recycle->%x", + state->id, __func__, SLOT_INDEX_FROM_INFO(state, slot_info), + state->remote->slot_queue_recycle); /* * A write barrier is necessary, but remote_event_signal @@ -1397,9 +1395,8 @@ poll_services_of_group(struct vchiq_state *state, int group) service_flags = atomic_xchg(&service->poll_flags, 0); if (service_flags & BIT(VCHIQ_POLL_REMOVE)) { - vchiq_log_info(vchiq_core_log_level, "%d: ps - remove %d<->%d", - state->id, service->localport, - service->remoteport); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: ps - remove %d<->%d", + state->id, service->localport, service->remoteport); /* * Make it look like a client, because @@ -1411,8 +1408,8 @@ poll_services_of_group(struct vchiq_state *state, int group) if (vchiq_close_service_internal(service, NO_CLOSE_RECVD)) request_poll(state, service, VCHIQ_POLL_REMOVE); } else if (service_flags & BIT(VCHIQ_POLL_TERMINATE)) { - vchiq_log_info(vchiq_core_log_level, "%d: ps - terminate %d<->%d", - state->id, service->localport, service->remoteport); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: ps - terminate %d<->%d", + state->id, service->localport, service->remoteport); if (vchiq_close_service_internal(service, NO_CLOSE_RECVD)) request_poll(state, service, VCHIQ_POLL_TERMINATE); } @@ -1462,11 +1459,11 @@ abort_outstanding_bulks(struct vchiq_service *service, if (queue->process != queue->local_insert) { vchiq_complete_bulk(service->instance, bulk); - vchiq_log_info(SRVTRACE_LEVEL(service), - "%s %c%c%c%c d:%d ABORTED - tx len:%d, rx len:%d", - is_tx ? "Send Bulk to" : "Recv Bulk from", - VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), - service->remoteport, bulk->size, bulk->remote_size); + vchiq_log_debug(service->state->dev, VCHIQ_CORE_MSG, + "%s %c%c%c%c d:%d ABORTED - tx len:%d, rx len:%d", + is_tx ? "Send Bulk to" : "Recv Bulk from", + VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), + service->remoteport, bulk->size, bulk->remote_size); } else { /* fabricate a matching dummy bulk */ bulk->data = 0; @@ -1499,8 +1496,8 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) payload = (struct vchiq_open_payload *)header->data; fourcc = payload->fourcc; - vchiq_log_info(vchiq_core_log_level, "%d: prs OPEN@%pK (%d->'%c%c%c%c')", - state->id, header, localport, VCHIQ_FOURCC_AS_4CHARS(fourcc)); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs OPEN@%pK (%d->'%c%c%c%c')", + state->id, header, localport, VCHIQ_FOURCC_AS_4CHARS(fourcc)); service = get_listening_service(state, fourcc); if (!service) @@ -1646,10 +1643,11 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) svc_fourcc = service ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_info(SRVTRACE_LEVEL(service), - "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d len:%d", - msg_type_str(type), type, VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), - remoteport, localport, size); + + vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, + "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d len:%d", + msg_type_str(type), type, VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), + remoteport, localport, size); if (size > 0) vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); } @@ -1675,9 +1673,10 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) header->data; service->peer_version = payload->version; } - vchiq_log_info(vchiq_core_log_level, "%d: prs OPENACK@%pK,%x (%d->%d) v:%d", - state->id, header, size, remoteport, localport, - service->peer_version); + vchiq_log_debug(state->dev, VCHIQ_CORE, + "%d: prs OPENACK@%pK,%x (%d->%d) v:%d", + state->id, header, size, remoteport, localport, + service->peer_version); if (service->srvstate == VCHIQ_SRVSTATE_OPENING) { service->remoteport = remoteport; set_service_state(service, VCHIQ_SRVSTATE_OPEN); @@ -1690,21 +1689,21 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) case VCHIQ_MSG_CLOSE: WARN_ON(size); /* There should be no data */ - vchiq_log_info(vchiq_core_log_level, "%d: prs CLOSE@%pK (%d->%d)", - state->id, header, remoteport, localport); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs CLOSE@%pK (%d->%d)", + state->id, header, remoteport, localport); mark_service_closing_internal(service, 1); if (vchiq_close_service_internal(service, CLOSE_RECVD) == -EAGAIN) goto bail_not_ready; - vchiq_log_info(vchiq_core_log_level, "Close Service %c%c%c%c s:%u d:%d", - VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), - service->localport, service->remoteport); + vchiq_log_debug(state->dev, VCHIQ_CORE, "Close Service %c%c%c%c s:%u d:%d", + VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), + service->localport, service->remoteport); break; case VCHIQ_MSG_DATA: - vchiq_log_info(vchiq_core_log_level, "%d: prs DATA@%pK,%x (%d->%d)", - state->id, header, size, remoteport, localport); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs DATA@%pK,%x (%d->%d)", + state->id, header, size, remoteport, localport); if ((service->remoteport == remoteport) && (service->srvstate == VCHIQ_SRVSTATE_OPEN)) { @@ -1723,7 +1722,8 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } break; case VCHIQ_MSG_CONNECT: - vchiq_log_info(vchiq_core_log_level, "%d: prs CONNECT@%pK", state->id, header); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs CONNECT@%pK", + state->id, header); state->version_common = ((struct vchiq_slot_zero *) state->slot_data)->version; complete(&state->connect); @@ -1775,9 +1775,10 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) bulk->actual = *(int *)header->data; queue->remote_insert++; - vchiq_log_info(vchiq_core_log_level, "%d: prs %s@%pK (%d->%d) %x@%pad", - state->id, msg_type_str(type), header, remoteport, localport, - bulk->actual, &bulk->data); + vchiq_log_debug(state->dev, VCHIQ_CORE, + "%d: prs %s@%pK (%d->%d) %x@%pad", + state->id, msg_type_str(type), header, remoteport, + localport, bulk->actual, &bulk->data); vchiq_log_trace(vchiq_core_log_level, "%d: prs:%d %cx li=%x ri=%x p=%x", state->id, localport, @@ -2074,9 +2075,9 @@ sync_func(void *v) header->data; service->peer_version = payload->version; } - vchiq_log_info(vchiq_sync_log_level, "%d: sf OPENACK@%pK,%x (%d->%d) v:%d", - state->id, header, size, remoteport, localport, - service->peer_version); + vchiq_log_debug(state->dev, VCHIQ_SYNC, "%d: sf OPENACK@%pK,%x (%d->%d) v:%d", + state->id, header, size, remoteport, localport, + service->peer_version); if (service->srvstate == VCHIQ_SRVSTATE_OPENING) { service->remoteport = remoteport; set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); @@ -2478,9 +2479,9 @@ vchiq_add_service_internal(struct vchiq_state *state, /* Bring this service online */ set_service_state(service, srvstate); - vchiq_log_info(vchiq_core_msg_log_level, "%s Service %c%c%c%c SrcPort:%d", - (srvstate == VCHIQ_SRVSTATE_OPENING) ? "Open" : "Add", - VCHIQ_FOURCC_AS_4CHARS(params->fourcc), service->localport); + vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, "%s Service %c%c%c%c SrcPort:%d", + (srvstate == VCHIQ_SRVSTATE_OPENING) ? "Open" : "Add", + VCHIQ_FOURCC_AS_4CHARS(params->fourcc), service->localport); /* Don't unlock the service - leave it with a ref_count of 1. */ @@ -2576,7 +2577,8 @@ release_service_messages(struct vchiq_service *service) int port = VCHIQ_MSG_DSTPORT(msgid); if ((port == service->localport) && (msgid & VCHIQ_MSGID_CLAIMED)) { - vchiq_log_info(vchiq_core_log_level, " fsi - hdr %pK", header); + vchiq_log_debug(state->dev, VCHIQ_CORE, + " fsi - hdr %pK", header); release_slot(state, slot_info, header, NULL); } pos += calc_stride(header->size); @@ -2684,8 +2686,8 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) int close_id = MAKE_CLOSE(service->localport, VCHIQ_MSG_DSTPORT(service->remoteport)); - vchiq_log_info(vchiq_core_log_level, "%d: csi:%d,%d (%s)", service->state->id, - service->localport, close_recvd, srvstate_names[service->srvstate]); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: csi:%d,%d (%s)", service->state->id, + service->localport, close_recvd, srvstate_names[service->srvstate]); switch (service->srvstate) { case VCHIQ_SRVSTATE_CLOSED: @@ -2795,8 +2797,8 @@ vchiq_terminate_service_internal(struct vchiq_service *service) { struct vchiq_state *state = service->state; - vchiq_log_info(vchiq_core_log_level, "%d: tsi - (%d<->%d)", state->id, - service->localport, service->remoteport); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: tsi - (%d<->%d)", state->id, + service->localport, service->remoteport); mark_service_closing(service); @@ -2810,7 +2812,8 @@ vchiq_free_service_internal(struct vchiq_service *service) { struct vchiq_state *state = service->state; - vchiq_log_info(vchiq_core_log_level, "%d: fsi - (%d)", state->id, service->localport); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: fsi - (%d)", + state->id, service->localport); switch (service->srvstate) { case VCHIQ_SRVSTATE_OPENING: @@ -2890,8 +2893,8 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) if (!service) return -EINVAL; - vchiq_log_info(vchiq_core_log_level, "%d: close_service:%d", - service->state->id, service->localport); + vchiq_log_debug(service->state->dev, VCHIQ_CORE, "%d: close_service:%d", + service->state->id, service->localport); if ((service->srvstate == VCHIQ_SRVSTATE_FREE) || (service->srvstate == VCHIQ_SRVSTATE_LISTENING) || @@ -2948,8 +2951,8 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) if (!service) return -EINVAL; - vchiq_log_info(vchiq_core_log_level, "%d: remove_service:%d", - service->state->id, service->localport); + vchiq_log_debug(service->state->dev, VCHIQ_CORE, "%d: remove_service:%d", + service->state->id, service->localport); if (service->srvstate == VCHIQ_SRVSTATE_FREE) { vchiq_service_put(service); @@ -3092,9 +3095,9 @@ int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, */ wmb(); - vchiq_log_info(vchiq_core_log_level, "%d: bt (%d->%d) %cx %x@%pad %pK", - state->id, service->localport, service->remoteport, - dir_char, size, &bulk->data, userdata); + vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: bt (%d->%d) %cx %x@%pad %pK", + state->id, service->localport, service->remoteport, + dir_char, size, &bulk->data, userdata); /* * The slot mutex must be held when the service is being closed, so 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 d1e5c50170da..e2d59dea653d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -69,10 +69,9 @@ static inline const char *log_category_str(enum vchiq_log_category c) #define vchiq_log_warning(dev, cat, fmt, ...) \ do { dev_dbg(dev, "%s warning: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) #endif -#ifndef vchiq_log_info -#define vchiq_log_info(cat, fmt, ...) \ - do { if (cat >= VCHIQ_LOG_INFO) \ - printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) +#ifndef vchiq_log_debug +#define vchiq_log_debug(dev, cat, fmt, ...) \ + do { dev_dbg(dev, "%s debug: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) #endif #ifndef vchiq_log_trace #define vchiq_log_trace(cat, fmt, ...) \ 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 2622a4477a67..403e96610460 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -47,9 +47,9 @@ user_service_free(void *userdata) static void close_delivered(struct user_service *user_service) { - vchiq_log_info(vchiq_arm_log_level, - "%s(handle=%x)", - __func__, user_service->service->handle); + vchiq_log_debug(user_service->service->state->dev, VCHIQ_ARM, + "%s(handle=%x)", + __func__, user_service->service->handle); if (user_service->close_pending) { /* Allow the underlying service to be culled */ @@ -235,8 +235,8 @@ static int vchiq_ioc_dequeue_message(struct vchiq_instance *instance, spin_unlock(&msg_queue_spinlock); DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); if (wait_for_completion_interruptible(&user_service->insert_event)) { - vchiq_log_info(vchiq_arm_log_level, - "DEQUEUE_MESSAGE interrupted"); + vchiq_log_debug(service->state->dev, VCHIQ_ARM, + "DEQUEUE_MESSAGE interrupted"); ret = -EINTR; break; } @@ -323,8 +323,8 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, ret = -ESRCH; goto out; } - vchiq_log_info(vchiq_arm_log_level, - "found bulk_waiter %pK for pid %d", waiter, current->pid); + vchiq_log_debug(service->state->dev, VCHIQ_ARM, + "found bulk_waiter %pK for pid %d", waiter, current->pid); userdata = &waiter->bulk_waiter; } else { userdata = args->userdata; @@ -355,8 +355,8 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, mutex_lock(&instance->bulk_waiter_list_mutex); list_add(&waiter->list, &instance->bulk_waiter_list); mutex_unlock(&instance->bulk_waiter_list_mutex); - vchiq_log_info(vchiq_arm_log_level, - "saved bulk_waiter %pK for pid %d", waiter, current->pid); + vchiq_log_debug(service->state->dev, VCHIQ_ARM, + "saved bulk_waiter %pK for pid %d", waiter, current->pid); ret = put_user(mode_waiting, mode); } @@ -455,8 +455,8 @@ static int vchiq_ioc_await_completion(struct vchiq_instance *instance, mutex_lock(&instance->completion_mutex); if (rc) { DEBUG_TRACE(AWAIT_COMPLETION_LINE); - vchiq_log_info(vchiq_arm_log_level, - "AWAIT_COMPLETION interrupted"); + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + "AWAIT_COMPLETION interrupted"); ret = -EINTR; goto out; } @@ -868,16 +868,17 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = -EINTR; } - if (!status && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK)) - vchiq_log_info(vchiq_arm_log_level, - " ioctl instance %pK, cmd %s -> status %d, %ld", - instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? - ioctl_names[_IOC_NR(cmd)] : "", status, ret); - else + if (!status && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK)) { + vchiq_log_debug(instance->state->dev, VCHIQ_ARM, + " ioctl instance %pK, cmd %s -> status %d, %ld", + instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? + ioctl_names[_IOC_NR(cmd)] : "", status, ret); + } else { vchiq_log_trace(vchiq_arm_log_level, " ioctl instance %pK, cmd %s -> status %d, %ld", instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? ioctl_names[_IOC_NR(cmd)] : "", status, ret); + } return ret; } @@ -1170,7 +1171,7 @@ static int vchiq_open(struct inode *inode, struct file *file) struct vchiq_state *state = vchiq_get_state(); struct vchiq_instance *instance; - vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); + vchiq_log_debug(state->dev, VCHIQ_ARM, "vchiq_open"); if (!state) { vchiq_log_error(state->dev, VCHIQ_ARM, @@ -1206,8 +1207,8 @@ static int vchiq_release(struct inode *inode, struct file *file) int ret = 0; int i; - vchiq_log_info(vchiq_arm_log_level, "%s: instance=%lx", __func__, - (unsigned long)instance); + vchiq_log_debug(state->dev, VCHIQ_ARM, "%s: instance=%lx", __func__, + (unsigned long)instance); if (!state) { ret = -EPERM; From patchwork Tue Oct 24 11:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434285 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FB43C00A8F for ; Tue, 24 Oct 2023 11:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbjJXLpC (ORCPT ); Tue, 24 Oct 2023 07:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232463AbjJXLpA (ORCPT ); Tue, 24 Oct 2023 07:45:00 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68EEFF9 for ; Tue, 24 Oct 2023 04:44:53 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 648EDB53; Tue, 24 Oct 2023 13:44:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147879; bh=PFhp7JJtC1BzJHPmgadMtyDOLv32xf4N2UXk+oREQ4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rRrrHKanNwwGu+U4NnRr6tj2b4Xj6xKeJalAI2nQSAW6uMQUeC+dr0qcDDWznH6aV F8evYmv3VVotnc+whOGNdNCotKGwgxlLu/amHpo0O33Lb81alU452IjSIvKKEGutDt YKEb5mSS5zP7xv782KB8/2ex8zF2n8f4yz4ZlKhE= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 6/8] staging: vc04: Convert vchiq_log_trace() to use dynamic debug Date: Tue, 24 Oct 2023 07:44:26 -0400 Message-ID: <20231024114428.443528-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Move vchiq_log_trace() custom logging wrapper based on printk to use dynamic debug. The log category is dictated by enum vchiq_log_category which will become the part of the trace string format that will be logged to dynamic debug (for grep). All the vchiq_log_trace() calls are adjusted to use the modified wrapper. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 45 +++++++++++-------- .../interface/vchiq_arm/vchiq_core.c | 44 +++++++++--------- .../interface/vchiq_arm/vchiq_core.h | 5 +-- .../interface/vchiq_arm/vchiq_dev.c | 4 +- 4 files changed, 55 insertions(+), 43 deletions(-) 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 7a51c2f62586..a28b89908c92 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -259,7 +259,8 @@ create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf, pagelist = dma_alloc_coherent(instance->state->dev, pagelist_size, &dma_addr, GFP_KERNEL); - vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, pagelist); + vchiq_log_trace(instance->state->dev, VCHIQ_ARM, + "%s - %pK", __func__, pagelist); if (!pagelist) return NULL; @@ -410,8 +411,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel struct page **pages = pagelistinfo->pages; unsigned int num_pages = pagelistinfo->num_pages; - vchiq_log_trace(vchiq_arm_log_level, "%s - %pK, %d", - __func__, pagelistinfo->pagelist, actual); + vchiq_log_trace(instance->state->dev, VCHIQ_ARM, + "%s - %pK, %d", __func__, pagelistinfo->pagelist, actual); /* * NOTE: dma_unmap_sg must be called before the @@ -717,7 +718,8 @@ int vchiq_initialise(struct vchiq_instance **instance_out) ret = 0; failed: - vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, instance, ret); + vchiq_log_trace(state->dev, VCHIQ_CORE, + "%s(%p): returning %d", __func__, instance, ret); return ret; } @@ -750,7 +752,8 @@ int vchiq_shutdown(struct vchiq_instance *instance) mutex_unlock(&state->mutex); - vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, instance, status); + vchiq_log_trace(state->dev, VCHIQ_CORE, + "%s(%p): returning %d", __func__, instance, status); free_bulk_waiter(instance); kfree(instance); @@ -770,7 +773,8 @@ int vchiq_connect(struct vchiq_instance *instance) struct vchiq_state *state = instance->state; if (mutex_lock_killable(&state->mutex)) { - vchiq_log_trace(vchiq_core_log_level, "%s: call to mutex_lock failed", __func__); + vchiq_log_trace(state->dev, VCHIQ_CORE, + "%s: call to mutex_lock failed", __func__); status = -EAGAIN; goto failed; } @@ -782,7 +786,8 @@ int vchiq_connect(struct vchiq_instance *instance) mutex_unlock(&state->mutex); failed: - vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, instance, status); + vchiq_log_trace(state->dev, VCHIQ_CORE, + "%s(%p): returning %d", __func__, instance, status); return status; } @@ -813,7 +818,8 @@ vchiq_add_service(struct vchiq_instance *instance, status = -EINVAL; } - vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, instance, status); + vchiq_log_trace(state->dev, VCHIQ_CORE, + "%s(%p): returning %d", __func__, instance, status); return status; } @@ -844,7 +850,8 @@ vchiq_open_service(struct vchiq_instance *instance, } failed: - vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, instance, status); + vchiq_log_trace(state->dev, VCHIQ_CORE, + "%s(%p): returning %d", __func__, instance, status); return status; } @@ -1014,7 +1021,8 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, while ((insert - instance->completion_remove) >= MAX_COMPLETIONS) { /* Out of space - wait for the client */ DEBUG_TRACE(SERVICE_CALLBACK_LINE); - vchiq_log_trace(vchiq_arm_log_level, "%s - completion queue full", __func__); + vchiq_log_trace(instance->state->dev, VCHIQ_CORE, + "%s - completion queue full", __func__); DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); if (wait_for_completion_interruptible(&instance->remove_event)) { vchiq_log_debug(instance->state->dev, VCHIQ_ARM, @@ -1102,7 +1110,7 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, vchiq_service_get(service); rcu_read_unlock(); - vchiq_log_trace(vchiq_arm_log_level, + vchiq_log_trace(service->state->dev, VCHIQ_ARM, "%s - service %lx(%d,%p), reason %d, header %lx, instance %lx, bulk_userdata %lx", __func__, (unsigned long)user_service, service->localport, user_service->userdata, reason, (unsigned long)header, @@ -1115,7 +1123,8 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, spin_unlock(&msg_queue_spinlock); DEBUG_TRACE(SERVICE_CALLBACK_LINE); DEBUG_COUNT(MSG_QUEUE_FULL_COUNT); - vchiq_log_trace(vchiq_arm_log_level, "%s - msg queue full", __func__); + vchiq_log_trace(service->state->dev, VCHIQ_ARM, + "%s - msg queue full", __func__); /* * If there is no MESSAGE_AVAILABLE in the completion * queue, add one @@ -1463,8 +1472,8 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, local_uc = ++arm_state->videocore_use_count; ++(*entity_uc); - vchiq_log_trace(vchiq_susp_log_level, "%s %s count %d, state count %d", __func__, entity, - *entity_uc, local_uc); + vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s %s count %d, state count %d", + __func__, entity, *entity_uc, local_uc); write_unlock_bh(&arm_state->susp_res_lock); @@ -1483,7 +1492,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, } out: - vchiq_log_trace(vchiq_susp_log_level, "%s exit %d", __func__, ret); + vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s exit %d", __func__, ret); return ret; } @@ -1521,14 +1530,14 @@ vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service) --arm_state->videocore_use_count; --(*entity_uc); - vchiq_log_trace(vchiq_susp_log_level, "%s %s count %d, state count %d", __func__, entity, - *entity_uc, arm_state->videocore_use_count); + vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s %s count %d, state count %d", + __func__, entity, *entity_uc, arm_state->videocore_use_count); unlock: write_unlock_bh(&arm_state->susp_res_lock); out: - vchiq_log_trace(vchiq_susp_log_level, "%s exit %d", __func__, ret); + vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s exit %d", __func__, ret); return ret; } 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 926b0f6ea82a..a1f2e14c64fa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -467,7 +467,7 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, { int status; - vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)", + vchiq_log_trace(service->state->dev, VCHIQ_CORE, "%d: callback:%d (%s, %pK, %pK)", service->state->id, service->localport, reason_names[reason], header, bulk_userdata); status = service->base.callback(service->instance, reason, header, service->handle, @@ -771,7 +771,7 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found, * it has dropped below its quota */ complete("a->quota_event); - vchiq_log_trace(vchiq_core_log_level, "%d: pfq:%d %x@%pK - slot_use->%d", + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: pfq:%d %x@%pK - slot_use->%d", state->id, port, header->size, header, count - 1); } else { vchiq_log_error(state->dev, VCHIQ_CORE, @@ -817,7 +817,7 @@ process_free_queue(struct vchiq_state *state, u32 *service_found, */ rmb(); - vchiq_log_trace(vchiq_core_log_level, "%d: pfq %d=%pK %x %x", + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: pfq %d=%pK %x %x", state->id, slot_index, data, local->slot_queue_recycle, slot_queue_available); @@ -988,7 +988,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, ((tx_end_index != quota->previous_tx_index) && (quota->slot_use_count == quota->slot_quota))) { spin_unlock("a_spinlock); - vchiq_log_trace(vchiq_core_log_level, + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: qm:%d %s,%zx - quota stall (msg %d, slot %d)", state->id, service->localport, msg_type_str(type), size, quota->message_use_count, quota->slot_use_count); @@ -1083,7 +1083,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, spin_unlock("a_spinlock); if (slot_use_count) - vchiq_log_trace(vchiq_core_log_level, + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: qm:%d %s,%zx - slot_use->%d (hdr %p)", state->id, service->localport, msg_type_str(VCHIQ_MSG_TYPE(msgid)), size, slot_use_count, header); @@ -1219,7 +1219,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_trace(vchiq_sync_log_level, + vchiq_log_trace(state->dev, VCHIQ_SYNC, "Sent Sync Msg %s(%u) to %c%c%c%c s:%u d:%d len:%d", msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), VCHIQ_MSG_SRCPORT(msgid), @@ -1313,8 +1313,10 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, { int status = 0; - vchiq_log_trace(vchiq_core_log_level, "%d: nb:%d %cx - p=%x rn=%x r=%x", service->state->id, - service->localport, (queue == &service->bulk_tx) ? 't' : 'r', + vchiq_log_trace(service->state->dev, VCHIQ_CORE, + "%d: nb:%d %cx - p=%x rn=%x r=%x", + service->state->id, service->localport, + (queue == &service->bulk_tx) ? 't' : 'r', queue->process, queue->remote_notify, queue->remove); queue->remote_notify = queue->process; @@ -1438,9 +1440,11 @@ abort_outstanding_bulks(struct vchiq_service *service, { int is_tx = (queue == &service->bulk_tx); - vchiq_log_trace(vchiq_core_log_level, "%d: aob:%d %cx - li=%x ri=%x p=%x", - service->state->id, service->localport, is_tx ? 't' : 'r', - queue->local_insert, queue->remote_insert, queue->process); + vchiq_log_trace(service->state->dev, VCHIQ_CORE, + "%d: aob:%d %cx - li=%x ri=%x p=%x", + service->state->id, service->localport, + is_tx ? 't' : 'r', queue->local_insert, + queue->remote_insert, queue->process); WARN_ON((int)(queue->local_insert - queue->process) < 0); WARN_ON((int)(queue->remote_insert - queue->process) < 0); @@ -1780,7 +1784,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) state->id, msg_type_str(type), header, remoteport, localport, bulk->actual, &bulk->data); - vchiq_log_trace(vchiq_core_log_level, "%d: prs:%d %cx li=%x ri=%x p=%x", + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: prs:%d %cx li=%x ri=%x p=%x", state->id, localport, (type == VCHIQ_MSG_BULK_RX_DONE) ? 'r' : 't', queue->local_insert, queue->remote_insert, queue->process); @@ -1796,12 +1800,12 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } break; case VCHIQ_MSG_PADDING: - vchiq_log_trace(vchiq_core_log_level, "%d: prs PADDING@%pK,%x", + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: prs PADDING@%pK,%x", state->id, header, size); break; case VCHIQ_MSG_PAUSE: /* If initiated, signal the application thread */ - vchiq_log_trace(vchiq_core_log_level, "%d: prs PAUSE@%pK,%x", + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: prs PAUSE@%pK,%x", state->id, header, size); if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { vchiq_log_error(state->dev, VCHIQ_CORE, @@ -1818,7 +1822,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSED); break; case VCHIQ_MSG_RESUME: - vchiq_log_trace(vchiq_core_log_level, "%d: prs RESUME@%pK,%x", + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: prs RESUME@%pK,%x", state->id, header, size); /* Release the slot mutex */ mutex_unlock(&state->slot_mutex); @@ -2059,7 +2063,7 @@ sync_func(void *v) svc_fourcc = service ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_trace(vchiq_sync_log_level, + vchiq_log_trace(state->dev, VCHIQ_SYNC, "Rcvd Msg %s from %c%c%c%c s:%d d:%d len:%d", msg_type_str(type), VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), remoteport, localport, size); @@ -2088,7 +2092,7 @@ sync_func(void *v) break; case VCHIQ_MSG_DATA: - vchiq_log_trace(vchiq_sync_log_level, "%d: sf DATA@%pK,%x (%d->%d)", + vchiq_log_trace(state->dev, VCHIQ_SYNC, "%d: sf DATA@%pK,%x (%d->%d)", state->id, header, size, remoteport, localport); if ((service->remoteport == remoteport) && @@ -3132,7 +3136,7 @@ int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, mutex_unlock(&state->slot_mutex); mutex_unlock(&service->bulk_mutex); - vchiq_log_trace(vchiq_core_log_level, "%d: bt:%d %cx li=%x ri=%x p=%x", + vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: bt:%d %cx li=%x ri=%x p=%x", state->id, service->localport, dir_char, queue->local_insert, queue->remote_insert, queue->process); @@ -3670,9 +3674,9 @@ void vchiq_log_dump_mem(struct device *dev, const char *label, u32 addr, *s++ = '\0'; if (label && (*label != '\0')) - vchiq_log_trace(VCHIQ_LOG_TRACE, "%s: %08x: %s", label, addr, line_buf); + vchiq_log_trace(dev, VCHIQ_CORE, "%s: %08x: %s", label, addr, line_buf); else - vchiq_log_trace(VCHIQ_LOG_TRACE, "%08x: %s", addr, line_buf); + vchiq_log_trace(dev, VCHIQ_CORE, "%s: %08x: %s", label, addr, line_buf); addr += 16; mem += 16; 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 e2d59dea653d..7a36648d6dad 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -74,9 +74,8 @@ static inline const char *log_category_str(enum vchiq_log_category c) do { dev_dbg(dev, "%s debug: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) #endif #ifndef vchiq_log_trace -#define vchiq_log_trace(cat, fmt, ...) \ - do { if (cat >= VCHIQ_LOG_TRACE) \ - printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0) +#define vchiq_log_trace(dev, cat, fmt, ...) \ + do { dev_dbg(dev, "%s trace: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) #endif #define VCHIQ_SLOT_MASK (VCHIQ_SLOT_SIZE - 1) 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 403e96610460..b6b5804689fa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -582,7 +582,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) long ret = 0; int i, rc; - vchiq_log_trace(vchiq_arm_log_level, + vchiq_log_trace(instance->state->dev, VCHIQ_ARM, "%s - instance %pK, cmd %s, arg %lx", __func__, instance, ((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) && (_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ? ioctl_names[_IOC_NR(cmd)] : "", arg); @@ -874,7 +874,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? ioctl_names[_IOC_NR(cmd)] : "", status, ret); } else { - vchiq_log_trace(vchiq_arm_log_level, + vchiq_log_trace(instance->state->dev, VCHIQ_ARM, " ioctl instance %pK, cmd %s -> status %d, %ld", instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? ioctl_names[_IOC_NR(cmd)] : "", status, ret); From patchwork Tue Oct 24 11:44:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434287 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56478C25B6C for ; Tue, 24 Oct 2023 11:45:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232474AbjJXLpF (ORCPT ); Tue, 24 Oct 2023 07:45:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbjJXLpD (ORCPT ); Tue, 24 Oct 2023 07:45:03 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4379DD7B for ; Tue, 24 Oct 2023 04:45:01 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CEAD4EBA; Tue, 24 Oct 2023 13:44:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147881; bh=H/nz2gkbrMm7IT7ydeLh0hLjQygmW288aTznsob3DGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KLYnWVLOh+BLtw9NZbdro+YtM0sEEkM0vGXLEnZt8Spiyk+o2COQ/RbXeeishohIi X7AUBrXEYW7nxBSa9T8Bs7WGwGmI8yySR3uniGe+OZwbY7Ni6tnob7payB9bT83dJ4 a79A86yFWuFo+EWydrZKZn+BoKnHcr/PiqyfDwgU= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 7/8] staging: vc04_services: Drop VCHIQ_LOG_PREFIX macro Date: Tue, 24 Oct 2023 07:44:27 -0400 Message-ID: <20231024114428.443528-8-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The macro is not used anymore, so drop it. Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 2 -- 1 file changed, 2 deletions(-) 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 7a36648d6dad..076c6d9ad56a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -38,8 +38,6 @@ #define VCHIQ_LOG_INFO 6 #define VCHIQ_LOG_TRACE 7 -#define VCHIQ_LOG_PREFIX KERN_INFO "vchiq: " - enum vchiq_log_category { VCHIQ_ARM, VCHIQ_CORE, From patchwork Tue Oct 24 11:44:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13434288 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 468AEC07545 for ; Tue, 24 Oct 2023 11:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232676AbjJXLpG (ORCPT ); Tue, 24 Oct 2023 07:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232664AbjJXLpG (ORCPT ); Tue, 24 Oct 2023 07:45:06 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78AC710C2 for ; Tue, 24 Oct 2023 04:45:02 -0700 (PDT) Received: from umang.jain (unknown [103.86.18.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4BA15F8B; Tue, 24 Oct 2023 13:44:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698147884; bh=D1qcM51vLafqRLznqGBe13o7XUfizzMgj8+FqIIiapA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ugIdTXKCWEOebSuNNwpohckc1Y1AD+Rp86nwGP5SZnJFoWLMyiF8Y9Vie9KzoTror lLpsz7WUKA9t7k/TFdf2UGKa35WtDC6ze95ZAKGw9fo0bhAM0vwqBSNa9b0BX8cMhz xel9CI2/dDAB7EqmrEy90vHKCZ4Z34AgfrIqkeIo= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Umang Jain Subject: [PATCH v2 8/8] staging: vc04_services: Drop log level mechanisms Date: Tue, 24 Oct 2023 07:44:28 -0400 Message-ID: <20231024114428.443528-9-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024114428.443528-1-umang.jain@ideasonboard.com> References: <20231024114428.443528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Drop the log level remnants since the logs are now ported to use dynamic logging. Drop macros, externs and global variables which were used in the log level mechanisms along with debugfs log entries. Update the drivers/staging/vc04_services/interface/TODO list as well. Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/TODO | 5 - .../interface/vchiq_arm/vchiq_arm.c | 4 - .../interface/vchiq_arm/vchiq_arm.h | 3 - .../interface/vchiq_arm/vchiq_core.c | 87 ++++++--------- .../interface/vchiq_arm/vchiq_core.h | 11 -- .../interface/vchiq_arm/vchiq_debugfs.c | 103 ------------------ 6 files changed, 33 insertions(+), 180 deletions(-) diff --git a/drivers/staging/vc04_services/interface/TODO b/drivers/staging/vc04_services/interface/TODO index 6d9d4a800aa7..05eb5140d096 100644 --- a/drivers/staging/vc04_services/interface/TODO +++ b/drivers/staging/vc04_services/interface/TODO @@ -23,11 +23,6 @@ should properly handle a module unload. This also includes that all resources must be freed (kthreads, debugfs entries, ...) and global variables avoided. -* Cleanup logging mechanism - -The driver should probably be using the standard kernel logging mechanisms -such as dev_info, dev_dbg, and friends. - * Documentation A short top-down description of this driver's architecture (function of 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 a28b89908c92..fc6d33ec5e95 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -60,10 +60,6 @@ #define KEEPALIVE_VER 1 #define KEEPALIVE_VER_MIN KEEPALIVE_VER -/* Run time control of log level, based on KERN_XXX level. */ -int vchiq_arm_log_level = VCHIQ_LOG_DEFAULT; -int vchiq_susp_log_level = VCHIQ_LOG_ERROR; - DEFINE_SPINLOCK(msg_queue_spinlock); struct vchiq_state g_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 2fb31f9b527f..7cdc3d70bd2c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -76,9 +76,6 @@ struct dump_context { loff_t offset; }; -extern int vchiq_arm_log_level; -extern int vchiq_susp_log_level; - 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 a1f2e14c64fa..45ba8f509a84 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -103,9 +103,6 @@ static_assert((unsigned int)VCHIQ_PORT_MAX < #define BULK_INDEX(x) ((x) & (VCHIQ_NUM_SERVICE_BULKS - 1)) -#define SRVTRACE_ENABLED(srv, lev) \ - (((srv) && (srv)->trace) || (vchiq_core_msg_log_level >= (lev))) - #define NO_CLOSE_RECVD 0 #define CLOSE_RECVD 1 @@ -152,11 +149,6 @@ static inline void check_sizes(void) BUILD_BUG_ON_NOT_POWER_OF_2(VCHIQ_MAX_SERVICES); } -/* Run time control of log level, based on KERN_XXX level. */ -int vchiq_core_log_level = VCHIQ_LOG_DEFAULT; -int vchiq_core_msg_log_level = VCHIQ_LOG_DEFAULT; -int vchiq_sync_log_level = VCHIQ_LOG_DEFAULT; - DEFINE_SPINLOCK(bulk_waiter_spinlock); static DEFINE_SPINLOCK(quota_spinlock); @@ -1048,11 +1040,9 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, return -EINVAL; } - if (SRVTRACE_ENABLED(service, - VCHIQ_LOG_INFO)) - vchiq_log_dump_mem(state->dev, "Sent", 0, - header->data, - min_t(size_t, 16, callback_result)); + vchiq_log_dump_mem(state->dev, "Sent", 0, + header->data, + min_t(size_t, 16, callback_result)); spin_lock("a_spinlock); quota->message_use_count++; @@ -1157,6 +1147,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, struct vchiq_shared_state *local; struct vchiq_header *header; ssize_t callback_result; + int svc_fourcc; local = state->local; @@ -1197,11 +1188,9 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, } if (service) { - if (SRVTRACE_ENABLED(service, - VCHIQ_LOG_INFO)) - vchiq_log_dump_mem(state->dev, "Sent", 0, - header->data, - min_t(size_t, 16, callback_result)); + vchiq_log_dump_mem(state->dev, "Sent", 0, + header->data, + min_t(size_t, 16, callback_result)); VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count); VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size); @@ -1212,19 +1201,15 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, header->size = size; header->msgid = msgid; - if (vchiq_sync_log_level >= VCHIQ_LOG_TRACE) { - int svc_fourcc; - svc_fourcc = service - ? service->base.fourcc - : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); + svc_fourcc = service ? service->base.fourcc + : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_trace(state->dev, VCHIQ_SYNC, - "Sent Sync Msg %s(%u) to %c%c%c%c s:%u d:%d len:%d", - msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), - VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid), size); - } + vchiq_log_trace(state->dev, VCHIQ_SYNC, + "Sent Sync Msg %s(%u) to %c%c%c%c s:%u d:%d len:%d", + msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), + VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), VCHIQ_MSG_SRCPORT(msgid), + VCHIQ_MSG_DSTPORT(msgid), size); remote_event_signal(&state->remote->sync_trigger); @@ -1586,6 +1571,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) struct vchiq_service *service = NULL; unsigned int localport, remoteport; int msgid, size, type, ret = -EINVAL; + int svc_fourcc; DEBUG_INITIALISE(state->local); @@ -1641,20 +1627,16 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) break; } - if (SRVTRACE_ENABLED(service, VCHIQ_LOG_INFO)) { - int svc_fourcc; - svc_fourcc = service - ? service->base.fourcc - : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); + svc_fourcc = service ? service->base.fourcc + : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, - "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d len:%d", - msg_type_str(type), type, VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), - remoteport, localport, size); - if (size > 0) - vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); - } + vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, + "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d len:%d", + msg_type_str(type), type, VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), + remoteport, localport, size); + if (size > 0) + vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); if (((unsigned long)header & VCHIQ_SLOT_MASK) + calc_stride(size) > VCHIQ_SLOT_SIZE) { @@ -2028,6 +2010,7 @@ sync_func(void *v) struct vchiq_header *header = (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state, state->remote->slot_sync); + int svc_fourcc; while (1) { struct vchiq_service *service; @@ -2057,19 +2040,15 @@ sync_func(void *v) continue; } - if (vchiq_sync_log_level >= VCHIQ_LOG_TRACE) { - int svc_fourcc; - - svc_fourcc = service - ? service->base.fourcc - : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_trace(state->dev, VCHIQ_SYNC, - "Rcvd Msg %s from %c%c%c%c s:%d d:%d len:%d", - msg_type_str(type), VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), - remoteport, localport, size); - if (size > 0) - vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); - } + svc_fourcc = service ? service->base.fourcc + : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); + + vchiq_log_trace(state->dev, VCHIQ_SYNC, + "Rcvd Msg %s from %c%c%c%c s:%d d:%d len:%d", + msg_type_str(type), VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), + remoteport, localport, size); + if (size > 0) + vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); switch (type) { case VCHIQ_MSG_OPENACK: 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 076c6d9ad56a..10451d6765bd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -31,13 +31,6 @@ #define VCHIQ_SLOT_SIZE 4096 #define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) -/* Run time control of log level, based on KERN_XXX level. */ -#define VCHIQ_LOG_DEFAULT 4 -#define VCHIQ_LOG_ERROR 3 -#define VCHIQ_LOG_WARNING 4 -#define VCHIQ_LOG_INFO 6 -#define VCHIQ_LOG_TRACE 7 - enum vchiq_log_category { VCHIQ_ARM, VCHIQ_CORE, @@ -476,10 +469,6 @@ struct vchiq_config { extern spinlock_t bulk_waiter_spinlock; -extern int vchiq_core_log_level; -extern int vchiq_core_msg_log_level; -extern int vchiq_sync_log_level; - extern const char * get_conn_state_name(enum vchiq_connstate conn_state); 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 dc667afd1f8c..58db78a9c8d4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -13,102 +13,10 @@ #define DEBUGFS_WRITE_BUF_SIZE 256 -#define VCHIQ_LOG_ERROR_STR "error" -#define VCHIQ_LOG_WARNING_STR "warning" -#define VCHIQ_LOG_INFO_STR "info" -#define VCHIQ_LOG_TRACE_STR "trace" - /* Global 'vchiq' debugfs and clients entry used by all instances */ static struct dentry *vchiq_dbg_dir; static struct dentry *vchiq_dbg_clients; -/* Log category debugfs entries */ -struct vchiq_debugfs_log_entry { - const char *name; - void *plevel; -}; - -static struct vchiq_debugfs_log_entry vchiq_debugfs_log_entries[] = { - { "core", &vchiq_core_log_level }, - { "msg", &vchiq_core_msg_log_level }, - { "sync", &vchiq_sync_log_level }, - { "susp", &vchiq_susp_log_level }, - { "arm", &vchiq_arm_log_level }, -}; - -static int debugfs_log_show(struct seq_file *f, void *offset) -{ - int *levp = f->private; - char *log_value = NULL; - - switch (*levp) { - case VCHIQ_LOG_ERROR: - log_value = VCHIQ_LOG_ERROR_STR; - break; - case VCHIQ_LOG_WARNING: - log_value = VCHIQ_LOG_WARNING_STR; - break; - case VCHIQ_LOG_INFO: - log_value = VCHIQ_LOG_INFO_STR; - break; - case VCHIQ_LOG_TRACE: - log_value = VCHIQ_LOG_TRACE_STR; - break; - default: - break; - } - - seq_printf(f, "%s\n", log_value ? log_value : "(null)"); - - return 0; -} - -static int debugfs_log_open(struct inode *inode, struct file *file) -{ - return single_open(file, debugfs_log_show, inode->i_private); -} - -static ssize_t debugfs_log_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos) -{ - struct seq_file *f = (struct seq_file *)file->private_data; - int *levp = f->private; - char kbuf[DEBUGFS_WRITE_BUF_SIZE + 1]; - - memset(kbuf, 0, DEBUGFS_WRITE_BUF_SIZE + 1); - if (count >= DEBUGFS_WRITE_BUF_SIZE) - count = DEBUGFS_WRITE_BUF_SIZE; - - if (copy_from_user(kbuf, buffer, count)) - return -EFAULT; - kbuf[count - 1] = 0; - - if (strncmp("error", kbuf, strlen("error")) == 0) - *levp = VCHIQ_LOG_ERROR; - else if (strncmp("warning", kbuf, strlen("warning")) == 0) - *levp = VCHIQ_LOG_WARNING; - else if (strncmp("info", kbuf, strlen("info")) == 0) - *levp = VCHIQ_LOG_INFO; - else if (strncmp("trace", kbuf, strlen("trace")) == 0) - *levp = VCHIQ_LOG_TRACE; - else - *levp = VCHIQ_LOG_DEFAULT; - - *ppos += count; - - return count; -} - -static const struct file_operations debugfs_log_fops = { - .owner = THIS_MODULE, - .open = debugfs_log_open, - .write = debugfs_log_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - static int debugfs_usecount_show(struct seq_file *f, void *offset) { struct vchiq_instance *instance = f->private; @@ -205,19 +113,8 @@ void vchiq_debugfs_remove_instance(struct vchiq_instance *instance) void vchiq_debugfs_init(void) { - struct dentry *dir; - int i; - vchiq_dbg_dir = debugfs_create_dir("vchiq", NULL); vchiq_dbg_clients = debugfs_create_dir("clients", vchiq_dbg_dir); - - /* create an entry under /vchiq/log for each log category */ - dir = debugfs_create_dir("log", vchiq_dbg_dir); - - for (i = 0; i < ARRAY_SIZE(vchiq_debugfs_log_entries); i++) - debugfs_create_file(vchiq_debugfs_log_entries[i].name, 0644, - dir, vchiq_debugfs_log_entries[i].plevel, - &debugfs_log_fops); } /* remove all the debugfs entries */