From patchwork Tue Nov 7 09:51:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96770 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0Ikr-001iue-7v; Tue, 07 Nov 2023 09:52:17 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233864AbjKGJwQ (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbjKGJwO (ORCPT ); Tue, 7 Nov 2023 04:52:14 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 648D610A for ; Tue, 7 Nov 2023 01:52:12 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6CD559CC; Tue, 7 Nov 2023 10:51:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350709; bh=XcQcBwrrItguHb39ejr0MBXHrExUnC6HOo/l8SOH7Lo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hEbFaEIha4d3W0T1gYuX+yETR3FW0eTsMe98KolaO8pHDCmAoSkljtw9uvLW3XWR1 Me5AyVgYOBqnM2I/Ej70mMLsDzCGoj+9PDG+Dq5WE7niD3eaewn03hnQzM0nkw+ruK vZSJcSc31fXlevATWXCFTfyU8G3hnyCgOFfqhUf4= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain , "Ricardo B . Marliere" Subject: [PATCH 1/9] staging: vc04_services: vchiq_core: Log through struct vchiq_instance Date: Tue, 7 Nov 2023 04:51:48 -0500 Message-ID: <20231107095156.365492-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no The handle_to_service() helper can return NULL, so `service` pointer can indeed be set to NULL. So, do not log through service pointer (which will cause NULL-deference), instead, use the vchiq_instance function argument to get access to the struct device. Fixes: f67af5940d6d("staging: vc04: Convert(and rename) vchiq_log_info() to use dynamic debug") Signed-off-by: Umang Jain Reviewed-by: Ricardo B. Marliere --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 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 39b857da2d42..8a9eb0101c2e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -245,7 +245,7 @@ find_service_by_handle(struct vchiq_instance *instance, unsigned int handle) return service; } rcu_read_unlock(); - vchiq_log_debug(service->state->dev, VCHIQ_CORE, + vchiq_log_debug(instance->state->dev, VCHIQ_CORE, "Invalid service handle 0x%x", handle); return NULL; } @@ -287,7 +287,7 @@ find_service_for_instance(struct vchiq_instance *instance, unsigned int handle) return service; } rcu_read_unlock(); - vchiq_log_debug(service->state->dev, VCHIQ_CORE, + vchiq_log_debug(instance->state->dev, VCHIQ_CORE, "Invalid service handle 0x%x", handle); return NULL; } @@ -310,7 +310,7 @@ find_closed_service_for_instance(struct vchiq_instance *instance, unsigned int h return service; } rcu_read_unlock(); - vchiq_log_debug(service->state->dev, VCHIQ_CORE, + vchiq_log_debug(instance->state->dev, VCHIQ_CORE, "Invalid service handle 0x%x", handle); return service; } From patchwork Tue Nov 7 09:51:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96771 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0Ikt-001iue-SL; Tue, 07 Nov 2023 09:52:20 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233866AbjKGJwU (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233867AbjKGJwS (ORCPT ); Tue, 7 Nov 2023 04:52:18 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13E5C11A for ; Tue, 7 Nov 2023 01:52:16 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57302D8B; Tue, 7 Nov 2023 10:51:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350713; bh=OSaU2JfcRpqaoQ4rtzBWYlTRgjft76ZQtKn1Q/INCPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NlmWAtbNmBLdIaH/LGalMA5siqISenWvl3SJ79wlWPstu27dRxQg2KIiuYxScM7DQ z6KbXIViNZ6sTTJExMe91MyCUBeFddOBkHVF0opTtR1mXzTOeuQWGd4duDhBdhtSUX ibD1nnxqWsh7tZlfDgzOX856y63X2A0eeKNN5wus= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain , "Ricardo B . Marliere" Subject: [PATCH 2/9] staging: vc04_services: Log using pr_err() when vchiq_state is unset Date: Tue, 7 Nov 2023 04:51:49 -0500 Message-ID: <20231107095156.365492-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no In cases, where the global vchiq state is still unset, we cannot log to dynamic debug (access to struct device is needed, hence potential NULL de-reference). Log using pr_err() instead. In vchiq_initialise(), remove the 'goto' because it is just again trying to log to dynamic debug. Simply return with -ENNOTCONN after logging to pr_err(). In vchiq_open(), move the vchiq_log_debug() after the state pointer null check. Signed-off-by: Umang Jain Reviewed-by: Ricardo B. Marliere --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 ++---- .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c | 7 +++---- 2 files changed, 5 insertions(+), 8 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 9fb8f657cc78..9fb3e240d9de 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -687,10 +687,8 @@ int vchiq_initialise(struct vchiq_instance **instance_out) usleep_range(500, 600); } if (i == VCHIQ_INIT_RETRIES) { - vchiq_log_error(state->dev, VCHIQ_CORE, "%s: videocore not initialized\n", - __func__); - ret = -ENOTCONN; - goto failed; + pr_err("%s: videocore not initialized\n", __func__); + return -ENOTCONN; } else if (i > 0) { vchiq_log_warning(state->dev, VCHIQ_CORE, "%s: videocore initialized after %d retries\n", __func__, i); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index 0bc93f48c14c..3425d2b199c2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -1170,14 +1170,13 @@ static int vchiq_open(struct inode *inode, struct file *file) struct vchiq_state *state = vchiq_get_state(); struct vchiq_instance *instance; - vchiq_log_debug(state->dev, VCHIQ_ARM, "vchiq_open"); - if (!state) { - vchiq_log_error(state->dev, VCHIQ_ARM, - "vchiq has no connection to VideoCore"); + pr_err("%s: vchiq has no connection to VideoCore\n", __func__); return -ENOTCONN; } + vchiq_log_debug(state->dev, VCHIQ_ARM, "vchiq_open"); + instance = kzalloc(sizeof(*instance), GFP_KERNEL); if (!instance) return -ENOMEM; From patchwork Tue Nov 7 09:51:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96772 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0Iky-001iue-GE; Tue, 07 Nov 2023 09:52:24 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233867AbjKGJwY (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233883AbjKGJwX (ORCPT ); Tue, 7 Nov 2023 04:52:23 -0500 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 2A3A9127 for ; Tue, 7 Nov 2023 01:52:20 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A2B35E62; Tue, 7 Nov 2023 10:51:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350718; bh=4nV8MroyvaUEvxXBtXmcKoHJdIgd3BGt1fRK0ZyPbq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ron37tNl8KNXrLr6k5ec+MfqlI8NWOm3zlqR5Wu0tplOLFY+AWTtWIXUeAg8AbzHr IR6mKJhhHJgrgRoqYO2tEa8NEqk6vOH5Qp9DUoodYhNLOdYI2y9gBT6hqXNrjHVh07 qv0bhiytCjBb62MTnJQs0o4zR9oSvmVTE+kYg0LE= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain , "Ricardo B . Marliere" Subject: [PATCH 3/9] staging: vc04_services: bcm2835-camera: Remove redundant null check Date: Tue, 7 Nov 2023 04:51:50 -0500 Message-ID: <20231107095156.365492-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Remove the buf pointer null check in buffer_cb() as it can never be NULL. buffer_cb() is always called with a valid mmal_buf pointer (which is NULL checked) from which, struct vb2_mmal_buf buf pointer is derived, using container_of macro. Signed-off-by: Umang Jain Reviewed-by: Ricardo B. Marliere --- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index e6e89784d84b..4b2b8f3bf903 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -333,11 +333,8 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, mmal_buf->pts); if (status) { - /* error in transfer */ - if (buf) { - /* there was a buffer with the error so return it */ - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - } + /* There was a buffer with the error so return it. */ + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); return; } From patchwork Tue Nov 7 09:51:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96773 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0Il2-001iue-0d; Tue, 07 Nov 2023 09:52:28 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233875AbjKGJw1 (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbjKGJw0 (ORCPT ); Tue, 7 Nov 2023 04:52:26 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEEDB122 for ; Tue, 7 Nov 2023 01:52:23 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DFE94468; Tue, 7 Nov 2023 10:51:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350722; bh=jj3pdwPVWpDpIbcBPuLxHIbwqXzw11/JBoR+RfsosXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FN2eLvQdYmE+YgNWQ5wKhGV3l6VOwJGVIyHLAOY4nCBqWoUaTh7Qg6jiRyPYG1hSm lDJg53zjKMsCo8LFctFlhaXgYVNplxg0/KiUCuSVZBlftNoiFBrPJvePxhD6YeflXI 4Nt+tRz+kckfmTy9XoyaIVu0EsuXmxowjgPeaWOg= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain Subject: [PATCH 4/9] staging: vc04_services: Shorten helper function name Date: Tue, 7 Nov 2023 04:51:51 -0500 Message-ID: <20231107095156.365492-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Shorten the helper log_category_str() to log_cat(). Going forwards, this will be used at multiple places with dev_dbg(). No functiional changes intended in this patch. Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 161358db457c..cc7bb6ca832a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -39,7 +39,7 @@ enum vchiq_log_category { VCHIQ_SUSPEND, }; -static inline const char *log_category_str(enum vchiq_log_category c) +static inline const char *log_cat(enum vchiq_log_category c) { static const char * const strings[] = { "vchiq_arm", @@ -54,19 +54,19 @@ static inline const char *log_category_str(enum vchiq_log_category c) #ifndef vchiq_log_error #define vchiq_log_error(dev, cat, fmt, ...) \ - do { dev_dbg(dev, "%s error: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) + do { dev_dbg(dev, "%s error: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) #endif #ifndef vchiq_log_warning #define vchiq_log_warning(dev, cat, fmt, ...) \ - do { dev_dbg(dev, "%s warning: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) + do { dev_dbg(dev, "%s warning: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) #endif #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) + do { dev_dbg(dev, "%s debug: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) #endif #ifndef vchiq_log_trace #define vchiq_log_trace(dev, cat, fmt, ...) \ - do { dev_dbg(dev, "%s trace: " fmt, log_category_str(cat), ##__VA_ARGS__); } while (0) + do { dev_dbg(dev, "%s trace: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) #endif #define VCHIQ_SLOT_MASK (VCHIQ_SLOT_SIZE - 1) From patchwork Tue Nov 7 09:51:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96774 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0Il4-001iue-Kb; Tue, 07 Nov 2023 09:52:31 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233892AbjKGJwb (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233883AbjKGJwa (ORCPT ); Tue, 7 Nov 2023 04:52:30 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E844511A for ; Tue, 7 Nov 2023 01:52:27 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 983B39CC; Tue, 7 Nov 2023 10:52:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350726; bh=5pll2VerSf91Fns9zcYO9btUaPO0qhwODTjYgteRDQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFBvTjAOE9WY0IuCtxBuJCOpEM+APDA8VIpT4AQKCw9VZCL1TZzghmqEUc4/X8fFw qC4PmvRdUTVavLOcFlVZAdC52FXeN4uY+wZNh2x5f419v0ilYI74OBQ09hWVJuV8a0 IUQBqoDpABRopNe/1lpCU2CarKbNox9nUou68Wqw= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain Subject: [PATCH 5/9] staging: vc04_services: Do not pass NULL to vchiq_log_error() Date: Tue, 7 Nov 2023 04:51:52 -0500 Message-ID: <20231107095156.365492-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no vchiq_add_connected_callback() logs using vchiq_log_error() macro, but passes NULL instead of a struct device pointer. Fix it. vchiq_add_connected_callback() is not used anywhere in the vc04_services as of now. It will be used when we add new drivers(VC shared memory and bcm2835-isp), hence it kept as it is for now. Fixes: 1d8915cf8899 ("staging: vc04: Convert vchiq_log_error() to use dynamic debug") Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_connected.c | 4 ++-- .../vc04_services/interface/vchiq_arm/vchiq_connected.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) 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 b3928bd8c9c6..21f9fa1a1713 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c @@ -27,7 +27,7 @@ static void connected_init(void) * be made immediately, otherwise it will be deferred until * vchiq_call_connected_callbacks is called. */ -void vchiq_add_connected_callback(void (*callback)(void)) +void vchiq_add_connected_callback(struct vchiq_device *device, void (*callback)(void)) { connected_init(); @@ -39,7 +39,7 @@ void vchiq_add_connected_callback(void (*callback)(void)) callback(); } else { if (g_num_deferred_callbacks >= MAX_CALLBACKS) { - vchiq_log_error(NULL, VCHIQ_CORE, + vchiq_log_error(&device->dev, 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_connected.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.h index 4caf5e30099d..e4ed56446f8a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.h @@ -1,10 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ +#include "vchiq_bus.h" + #ifndef VCHIQ_CONNECTED_H #define VCHIQ_CONNECTED_H -void vchiq_add_connected_callback(void (*callback)(void)); +void vchiq_add_connected_callback(struct vchiq_device *device, void (*callback)(void)); void vchiq_call_connected_callbacks(void); #endif /* VCHIQ_CONNECTED_H */ From patchwork Tue Nov 7 09:51:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96775 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0IlB-001iue-Tv; Tue, 07 Nov 2023 09:52:39 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233897AbjKGJwh (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbjKGJwg (ORCPT ); Tue, 7 Nov 2023 04:52:36 -0500 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 DD91C120 for ; Tue, 7 Nov 2023 01:52:31 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BC094D8B; Tue, 7 Nov 2023 10:52:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350730; bh=mVZw58PmnS5quV9zKtKHRwX2pxDr03xVM5+OTkd3h3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vzKqlz5wWaAz04tfbF6gvRRuWqLMZzwPCAlC6EKxnps/0KHVeTZaYTo/rNheit4E+ NsptlMYhJDUuaAAz8U4uZmhEqaiH0Is7j/yrBoeNzI6aBY5xWEIN5pzIoDAEBoJ472 Mk2RlhYXni+3QtvUR2YRV0uObVFVo4gat9dzN3fY= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain Subject: [PATCH 6/9] staging: vc04_services: Drop vchiq_log_error() in favour of dev_dbg Date: Tue, 7 Nov 2023 04:51:53 -0500 Message-ID: <20231107095156.365492-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Drop vchiq_log_error() macro which wraps dev_dbg(). Introduce the usage of dev_dbg() directly. Add a new enum vchiq_log_type and log_type() helper to faciliate the type of logging in dev_dbg(). This will help to determine the type of logging("error", "warning", "debug", "trace") to dynamic debug. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 54 ++++---- .../interface/vchiq_arm/vchiq_connected.c | 6 +- .../interface/vchiq_arm/vchiq_core.c | 126 ++++++++++-------- .../interface/vchiq_arm/vchiq_core.h | 23 +++- .../interface/vchiq_arm/vchiq_dev.c | 47 ++++--- 5 files changed, 143 insertions(+), 113 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 9fb3e240d9de..2cb2a6503058 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -696,8 +696,8 @@ int vchiq_initialise(struct vchiq_instance **instance_out) instance = kzalloc(sizeof(*instance), GFP_KERNEL); if (!instance) { - vchiq_log_error(state->dev, VCHIQ_CORE, - "%s: error allocating vchiq instance\n", __func__); + dev_dbg(state->dev, "%s: %s: %s: error allocating vchiq instance\n", + log_cat(VCHIQ_CORE), log_type(ERROR), __func__); ret = -ENOMEM; goto failed; } @@ -969,8 +969,8 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl } else { waiter = kzalloc(sizeof(*waiter), GFP_KERNEL); if (!waiter) { - vchiq_log_error(service->state->dev, VCHIQ_CORE, - "%s - out of memory", __func__); + dev_dbg(service->state->dev, "%s: %s: %s - out of memory\n", + log_cat(VCHIQ_CORE), log_type(ERROR), __func__); return -ENOMEM; } } @@ -1344,8 +1344,8 @@ vchiq_keepalive_vchiq_callback(struct vchiq_instance *instance, struct vchiq_header *header, unsigned int service_user, void *bulk_user) { - vchiq_log_error(instance->state->dev, VCHIQ_SUSPEND, - "%s callback reason %d", __func__, reason); + dev_dbg(instance->state->dev, "%s: %s: %s callback reason %d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__, reason); return 0; } @@ -1369,22 +1369,22 @@ vchiq_keepalive_thread_func(void *v) ret = vchiq_initialise(&instance); if (ret) { - vchiq_log_error(state->dev, VCHIQ_SUSPEND, - "%s vchiq_initialise failed %d", __func__, ret); + dev_dbg(state->dev, "%s: %s: %s vchiq_initialise failed %d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__, ret); goto exit; } status = vchiq_connect(instance); if (status) { - vchiq_log_error(state->dev, VCHIQ_SUSPEND, - "%s vchiq_connect failed %d", __func__, status); + dev_dbg(state->dev, "%s: %s: %s vchiq_connect failed %d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__, status); goto shutdown; } status = vchiq_add_service(instance, ¶ms, &ka_handle); if (status) { - vchiq_log_error(state->dev, VCHIQ_SUSPEND, - "%s vchiq_open_service failed %d", __func__, status); + dev_dbg(state->dev, "%s: %s: %s vchiq_open_service failed %d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__, status); goto shutdown; } @@ -1392,8 +1392,8 @@ vchiq_keepalive_thread_func(void *v) long rc = 0, uc = 0; if (wait_for_completion_interruptible(&arm_state->ka_evt)) { - vchiq_log_error(state->dev, VCHIQ_SUSPEND, - "%s interrupted", __func__); + dev_dbg(state->dev, "%s: %s: %s interrupted\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__); flush_signals(current); continue; } @@ -1413,16 +1413,15 @@ 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(state->dev, VCHIQ_SUSPEND, - "%s vchiq_use_service error %d", __func__, status); + dev_dbg(state->dev, "%s: %s: %s vchiq_use_service error %d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__, status); } } while (rc--) { status = vchiq_release_service(instance, ka_handle); if (status) { - vchiq_log_error(state->dev, VCHIQ_SUSPEND, - "%s vchiq_release_service error %d", __func__, - status); + dev_dbg(state->dev, "%s: %s: %s vchiq_release_service error %d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__, status); } } } @@ -1457,7 +1456,8 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, service->client_id); entity_uc = &service->service_use_count; } else { - vchiq_log_error(state->dev, VCHIQ_SUSPEND, "%s null service ptr", __func__); + dev_dbg(state->dev, "%s: %s: %s null service ptr\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__); ret = -EINVAL; goto out; } @@ -1740,10 +1740,11 @@ vchiq_check_service(struct vchiq_service *service) read_unlock_bh(&arm_state->susp_res_lock); if (ret) { - vchiq_log_error(service->state->dev, VCHIQ_SUSPEND, - "%s ERROR - %p4cc:%d service count %d, state count %d", __func__, - &service->base.fourcc, service->client_id, - service->service_use_count, arm_state->videocore_use_count); + dev_dbg(service->state->dev, + "%s: %s: %s ERROR - %p4cc:%d service count %d, state count %d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), __func__, + &service->base.fourcc, service->client_id, service->service_use_count, + arm_state->videocore_use_count); vchiq_dump_service_use_state(service->state); } out: @@ -1776,9 +1777,8 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state, (void *)state, threadname); if (IS_ERR(arm_state->ka_thread)) { - vchiq_log_error(state->dev, VCHIQ_SUSPEND, - "vchiq: FATAL: couldn't create thread %s", - threadname); + dev_dbg(state->dev, "%s: %s: vchiq: FATAL: couldn't create thread %s\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), threadname); } else { wake_up_process(arm_state->ka_thread); } 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 21f9fa1a1713..2b4cbea5f259 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c @@ -39,9 +39,9 @@ void vchiq_add_connected_callback(struct vchiq_device *device, void (*callback)( callback(); } else { if (g_num_deferred_callbacks >= MAX_CALLBACKS) { - vchiq_log_error(&device->dev, VCHIQ_CORE, - "There already %d callback registered - please increase MAX_CALLBACKS", - g_num_deferred_callbacks); + dev_dbg(&device->dev, + "%s: %s: There already %d callback registered - please increase MAX_CALLBACKS\n", + log_cat(VCHIQ_CORE), log_type(ERROR), g_num_deferred_callbacks); } else { g_deferred_callback[g_num_deferred_callbacks] = callback; 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 8a9eb0101c2e..5bc7c66e71e1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -741,10 +741,10 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found, */ complete("a->quota_event); } else if (count == 0) { - 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); + dev_dbg(state->dev, + "%s: %s: service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)\n", + log_cat(VCHIQ_CORE), log_type(ERROR), port, quota->message_use_count, + header, msgid, header->msgid, header->size); WARN(1, "invalid message use count\n"); } if (!BITSET_IS_SET(service_found, port)) { @@ -766,9 +766,10 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found, 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, - "service %d slot_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)", - port, count, header, msgid, header->msgid, header->size); + dev_dbg(state->dev, + "%s: %s: service %d slot_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)\n", + log_cat(VCHIQ_CORE), log_type(ERROR), + port, count, header, msgid, header->msgid, header->size); WARN(1, "bad slot use count\n"); } } @@ -831,9 +832,10 @@ process_free_queue(struct vchiq_state *state, u32 *service_found, pos += calc_stride(header->size); if (pos > VCHIQ_SLOT_SIZE) { - 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); + dev_dbg(state->dev, + "%s: %s: pfq - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x\n", + log_cat(VCHIQ_CORE), log_type(ERROR), pos, header, msgid, + header->msgid, header->size); WARN(1, "invalid slot position\n"); } } @@ -1167,8 +1169,8 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, int oldmsgid = header->msgid; if (oldmsgid != VCHIQ_MSGID_PADDING) - vchiq_log_error(state->dev, VCHIQ_CORE, "%d: qms - msgid %x, not PADDING", - state->id, oldmsgid); + dev_dbg(state->dev, "%s: %s: %d: qms - msgid %x, not PADDING\n", + log_cat(VCHIQ_CORE), log_type(ERROR), state->id, oldmsgid); } vchiq_log_debug(state->dev, VCHIQ_SYNC, @@ -1616,10 +1618,10 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } if (!service) { - 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); + dev_dbg(state->dev, + "%s: %s: %d: prs %s@%pK (%d->%d) - invalid/closed service %d\n", + log_cat(VCHIQ_CORE), log_type(ERROR), state->id, msg_type_str(type), + header, remoteport, localport, localport); goto skip_message; } break; @@ -1640,9 +1642,9 @@ 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(state->dev, VCHIQ_CORE, - "header %pK (msgid %x) - size %x too big for slot", - header, (unsigned int)msgid, (unsigned int)size); + dev_dbg(state->dev, "%s: %s: header %pK (msgid %x) - size %x too big for slot\n", + log_cat(VCHIQ_CORE), log_type(ERROR), + header, (unsigned int)msgid, (unsigned int)size); WARN(1, "oversized for slot\n"); } @@ -1668,8 +1670,9 @@ 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(state->dev, VCHIQ_CORE, "OPENACK received in state %s", - srvstate_names[service->srvstate]); + dev_dbg(state->dev, "%s: %s: OPENACK received in state %s\n", + log_cat(VCHIQ_CORE), log_type(ERROR), + srvstate_names[service->srvstate]); } break; case VCHIQ_MSG_CLOSE: @@ -1740,11 +1743,11 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } if ((int)(queue->remote_insert - queue->local_insert) >= 0) { - 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, - queue->local_insert); + dev_dbg(state->dev, + "%s: %s: %d: prs %s@%pK (%d->%d) unexpected (ri=%d,li=%d)\n", + log_cat(VCHIQ_CORE), log_type(ERROR), + state->id, msg_type_str(type), header, remoteport, + localport, queue->remote_insert, queue->local_insert); mutex_unlock(&service->bulk_mutex); break; } @@ -1790,8 +1793,8 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) 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, - "%d: PAUSE received in state PAUSED", state->id); + dev_dbg(state->dev, "%s: %s: %d: PAUSE received in state PAUSED\n", + log_cat(VCHIQ_CORE), log_type(ERROR), state->id); break; } if (state->conn_state != VCHIQ_CONNSTATE_PAUSE_SENT) { @@ -1821,8 +1824,8 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) break; default: - vchiq_log_error(state->dev, VCHIQ_CORE, "%d: prs invalid msgid %x@%pK,%x", - state->id, msgid, header, size); + dev_dbg(state->dev, "%s: %s: %d: prs invalid msgid %x@%pK,%x\n", + log_cat(VCHIQ_CORE), log_type(ERROR), state->id, msgid, header, size); WARN(1, "invalid message\n"); break; } @@ -1932,7 +1935,8 @@ handle_poll(struct vchiq_state *state) * since the PAUSE should have flushed * through outstanding messages. */ - vchiq_log_error(state->dev, VCHIQ_CORE, "Failed to send RESUME message"); + dev_dbg(state->dev, "%s: %s: Failed to send RESUME message\n", + log_cat(VCHIQ_CORE), log_type(ERROR)); } break; default: @@ -2032,10 +2036,10 @@ sync_func(void *v) service = find_service_by_port(state, localport); if (!service) { - 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); + dev_dbg(state->dev, + "%s: %s: %d: sf %s@%pK (%d->%d) - invalid/closed service %d\n", + log_cat(VCHIQ_SYNC), log_type(ERROR), state->id, msg_type_str(type), + header, remoteport, localport, localport); release_message_sync(state, header); continue; } @@ -2078,15 +2082,16 @@ sync_func(void *v) (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC)) { if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, NULL) == -EAGAIN) - vchiq_log_error(state->dev, VCHIQ_SYNC, - "synchronous callback to service %d returns -EAGAIN", - localport); + dev_dbg(state->dev, + "%s: %s: synchronous callback to service %d returns -EAGAIN\n", + log_cat(VCHIQ_SYNC), log_type(ERROR), localport); } break; default: - vchiq_log_error(state->dev, VCHIQ_SYNC, "%d: sf unexpected msgid %x@%pK,%x", - state->id, msgid, header, size); + dev_dbg(state->dev, "%s: %s: %d: sf unexpected msgid %x@%pK,%x\n", + log_cat(VCHIQ_SYNC), log_type(ERROR), + state->id, msgid, header, size); release_message_sync(state, header); break; } @@ -2119,8 +2124,8 @@ vchiq_init_slots(struct device *dev, void *mem_base, int mem_size) num_slots -= first_data_slot; if (num_slots < 4) { - vchiq_log_error(dev, VCHIQ_CORE, "%s - insufficient memory %x bytes", - __func__, mem_size); + dev_dbg(dev, "%s: %s: %s - insufficient memory %x bytes\n", + log_cat(VCHIQ_CORE), log_type(ERROR), __func__, mem_size); return NULL; } @@ -2501,11 +2506,11 @@ 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(service->state->dev, VCHIQ_CORE, - "%d: osi - srvstate = %s (ref %u)", - service->state->id, - srvstate_names[service->srvstate], - kref_read(&service->ref_count)); + dev_dbg(service->state->dev, + "%s: %s: %d: osi - srvstate = %s (ref %u)\n", + log_cat(VCHIQ_CORE), log_type(ERROR), + service->state->id, srvstate_names[service->srvstate], + kref_read(&service->ref_count)); status = -EINVAL; VCHIQ_SERVICE_STATS_INC(service, error_count); vchiq_release_service_internal(service); @@ -2566,9 +2571,10 @@ release_service_messages(struct vchiq_service *service) } pos += calc_stride(header->size); if (pos > VCHIQ_SLOT_SIZE) { - 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); + dev_dbg(state->dev, + "%s: %s: fsi - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x\n", + log_cat(VCHIQ_CORE), log_type(ERROR), pos, header, msgid, + header->msgid, header->size); WARN(1, "invalid slot position\n"); } } @@ -2622,8 +2628,9 @@ close_service_complete(struct vchiq_service *service, int failstate) case VCHIQ_SRVSTATE_LISTENING: break; default: - vchiq_log_error(service->state->dev, VCHIQ_CORE, "%s(%x) called in state %s", - __func__, service->handle, srvstate_names[service->srvstate]); + dev_dbg(service->state->dev, "%s: %s: %s(%x) called in state %s\n", + log_cat(VCHIQ_CORE), log_type(ERROR), __func__, service->handle, + srvstate_names[service->srvstate]); WARN(1, "%s in unexpected state\n", __func__); return -EINVAL; } @@ -2678,8 +2685,9 @@ 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(state->dev, VCHIQ_CORE, "%s(1) called in state %s", - __func__, srvstate_names[service->srvstate]); + dev_dbg(state->dev, "%s: %s: %s(1) called in state %s\n", + log_cat(VCHIQ_CORE), log_type(ERROR), __func__, + srvstate_names[service->srvstate]); } else if (is_server) { if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) { status = -EINVAL; @@ -2766,8 +2774,9 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) break; default: - vchiq_log_error(state->dev, VCHIQ_CORE, "%s(%d) called in state %s", __func__, - close_recvd, srvstate_names[service->srvstate]); + dev_dbg(state->dev, "%s: %s: %s(%d) called in state %s\n", + log_cat(VCHIQ_CORE), log_type(ERROR), __func__, + close_recvd, srvstate_names[service->srvstate]); break; } @@ -2806,8 +2815,9 @@ vchiq_free_service_internal(struct vchiq_service *service) case VCHIQ_SRVSTATE_CLOSEWAIT: break; default: - vchiq_log_error(state->dev, VCHIQ_CORE, "%d: fsi - (%d) in state %s", state->id, - service->localport, srvstate_names[service->srvstate]); + dev_dbg(state->dev, "%s: %s: %d: fsi - (%d) in state %s\n", + log_cat(VCHIQ_CORE), log_type(ERROR), state->id, + service->localport, srvstate_names[service->srvstate]); return; } 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 cc7bb6ca832a..3583604430b3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -39,6 +39,13 @@ enum vchiq_log_category { VCHIQ_SUSPEND, }; +enum vchiq_log_type { + ERROR, + WARN, + DEBUG, + TRACE, +}; + static inline const char *log_cat(enum vchiq_log_category c) { static const char * const strings[] = { @@ -52,10 +59,18 @@ static inline const char *log_cat(enum vchiq_log_category c) return strings[c]; }; -#ifndef vchiq_log_error -#define vchiq_log_error(dev, cat, fmt, ...) \ - do { dev_dbg(dev, "%s error: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) -#endif +static inline const char *log_type(enum vchiq_log_type t) +{ + static const char * const types_str[] = { + "error", + "warning", + "debug", + "trace", + }; + + return types_str[t]; +}; + #ifndef vchiq_log_warning #define vchiq_log_warning(dev, cat, fmt, ...) \ do { dev_dbg(dev, "%s warning: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) 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 3425d2b199c2..76e16128d4b1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -271,9 +271,10 @@ static int vchiq_ioc_dequeue_message(struct vchiq_instance *instance, ret = -EFAULT; } } else { - vchiq_log_error(service->state->dev, VCHIQ_ARM, - "header %pK: bufsize %x < size %x", - header, args->bufsize, header->size); + dev_dbg(service->state->dev, + "%s: %s: header %pK: bufsize %x < size %x\n", + log_cat(VCHIQ_ARM), log_type(ERROR), header, + args->bufsize, header->size); WARN(1, "invalid size\n"); ret = -EMSGSIZE; } @@ -318,8 +319,9 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, } mutex_unlock(&instance->bulk_waiter_list_mutex); if (!waiter) { - vchiq_log_error(service->state->dev, VCHIQ_ARM, - "no bulk_waiter found for pid %d", current->pid); + dev_dbg(service->state->dev, + "%s: %s: no bulk_waiter found for pid %d\n", + log_cat(VCHIQ_ARM), log_type(ERROR), current->pid); ret = -ESRCH; goto out; } @@ -501,10 +503,11 @@ 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(service->state->dev, VCHIQ_ARM, - "header %pK: msgbufsize %x < msglen %x", - header, args->msgbufsize, msglen); - WARN(1, "invalid message size\n"); + dev_dbg(service->state->dev, + "%s: %s: header %pK: msgbufsize %x < msglen %x\n", + log_cat(VCHIQ_ARM), log_type(ERROR), header, + args->msgbufsize, msglen); + WARN(1, "invalid message size\n"); if (ret == 0) ret = -EMSGSIZE; break; @@ -618,9 +621,9 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } rc = mutex_lock_killable(&instance->state->mutex); if (rc) { - vchiq_log_error(instance->state->dev, VCHIQ_ARM, - "vchiq: connect: could not lock mutex for state %d: %d", - instance->state->id, rc); + dev_dbg(instance->state->dev, + "%s: %s: vchiq: connect: could not lock mutex for state %d: %d\n", + log_cat(VCHIQ_ARM), log_type(ERROR), instance->state->id, rc); ret = -EINTR; break; } @@ -630,8 +633,9 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (!status) instance->connected = 1; else - vchiq_log_error(instance->state->dev, VCHIQ_ARM, - "vchiq: could not connect: %d", status); + dev_dbg(instance->state->dev, + "%s: %s: vchiq: could not connect: %d\n", + log_cat(VCHIQ_ARM), log_type(ERROR), status); break; case VCHIQ_IOC_CREATE_SERVICE: { @@ -700,13 +704,14 @@ 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(instance->state->dev, VCHIQ_SUSPEND, - "%s: cmd %s returned error %ld for service %p4cc:%03d", - __func__, (cmd == VCHIQ_IOC_USE_SERVICE) ? - "VCHIQ_IOC_USE_SERVICE" : - "VCHIQ_IOC_RELEASE_SERVICE", - ret, &service->base.fourcc, - service->client_id); + dev_dbg(instance->state->dev, + "%s: %s: %s: cmd %s returned error %ld for service %p4cc:%03d\n", + log_cat(VCHIQ_SUSPEND), log_type(ERROR), + __func__, (cmd == VCHIQ_IOC_USE_SERVICE) ? + "VCHIQ_IOC_USE_SERVICE" : + "VCHIQ_IOC_RELEASE_SERVICE", + ret, &service->base.fourcc, + service->client_id); } } else { ret = -EINVAL; From patchwork Tue Nov 7 09:51:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96776 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0IlF-001iue-3i; Tue, 07 Nov 2023 09:52:41 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233898AbjKGJwk (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233910AbjKGJwi (ORCPT ); Tue, 7 Nov 2023 04:52:38 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8081C124 for ; Tue, 7 Nov 2023 01:52:35 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A89099CC; Tue, 7 Nov 2023 10:52:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350733; bh=GemfAk188bNFxIbnJFAl/gIGobTxdHdNVJ+YSaVm23Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NzdPLcuXphcXu5vbTkK7Jc8ZohQtYTkHVFmZ4kNbeJyRHepD+hhh2WAH97CMxVl6N 2LfZoyRFYy607o4369WP0jBtyM8qDHE5TJqlCjNuTMZ44s82T/e/MmyNtR0EqgELtL y+LuH9kLyvDX8a7YqrlZtBjnqa+pXg17gm6MBRHg= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain Subject: [PATCH 7/9] staging: vc04_services: Drop vchiq_log_warning() in favour of dev_dbg Date: Tue, 7 Nov 2023 04:51:54 -0500 Message-ID: <20231107095156.365492-8-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Drop vchiq_log_warning() macro which wraps dev_dbg(). Introduce the usage of dev_dbg() directly. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 35 ++++++++++--------- .../interface/vchiq_arm/vchiq_core.c | 33 +++++++++-------- .../interface/vchiq_arm/vchiq_core.h | 4 --- 3 files changed, 37 insertions(+), 35 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 2cb2a6503058..bc0ee8b9d1c3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -690,8 +690,8 @@ int vchiq_initialise(struct vchiq_instance **instance_out) pr_err("%s: videocore not initialized\n", __func__); return -ENOTCONN; } else if (i > 0) { - vchiq_log_warning(state->dev, VCHIQ_CORE, - "%s: videocore initialized after %d retries\n", __func__, i); + dev_dbg(state->dev, "%s: %s: %s: videocore initialized after %d retries\n", + log_cat(VCHIQ_CORE), log_type(WARN), __func__, i); } instance = kzalloc(sizeof(*instance), GFP_KERNEL); @@ -1705,20 +1705,22 @@ vchiq_dump_service_use_state(struct vchiq_state *state) read_unlock_bh(&arm_state->susp_res_lock); if (only_nonzero) - 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); + dev_dbg(state->dev, + "%s: %s: Too many active services (%d). Only dumping up to first %d services with non-zero use-count\n", + log_cat(VCHIQ_SUSPEND), log_type(WARN), active_services, found); for (i = 0; i < found; i++) { - vchiq_log_warning(state->dev, VCHIQ_SUSPEND, - "%p4cc:%d service count %d %s", - &service_data[i].fourcc, - service_data[i].clientid, service_data[i].use_count, - service_data[i].use_count ? nz : ""); + dev_dbg(state->dev, + "%s: %s: %p4cc:%d service count %d %s\n", + log_cat(VCHIQ_SUSPEND), log_type(WARN), + &service_data[i].fourcc, + service_data[i].clientid, service_data[i].use_count, + service_data[i].use_count ? nz : ""); } - 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); + dev_dbg(state->dev, "%s: %s: VCHIQ use count %d\n", + log_cat(VCHIQ_SUSPEND), log_type(WARN), peer_count); + dev_dbg(state->dev, "%s: %s: Overall vchiq instance use count %d\n", + log_cat(VCHIQ_SUSPEND), log_type(WARN), vc_use_count); kfree(service_data); } @@ -1833,8 +1835,8 @@ static int vchiq_probe(struct platform_device *pdev) */ err = vchiq_register_chrdev(&pdev->dev); if (err) { - vchiq_log_warning(&pdev->dev, VCHIQ_ARM, - "Failed to initialize vchiq cdev"); + dev_dbg(&pdev->dev, "%s: %s: Failed to initialize vchiq cdev\n", + log_cat(VCHIQ_ARM), log_type(WARN)); goto error_exit; } @@ -1844,7 +1846,8 @@ static int vchiq_probe(struct platform_device *pdev) return 0; failed_platform_init: - vchiq_log_warning(&pdev->dev, VCHIQ_ARM, "could not initialize vchiq platform"); + dev_dbg(&pdev->dev, "%s: %s: Could not initialize vchiq platform\n", + log_cat(VCHIQ_ARM), log_type(WARN)); 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 5bc7c66e71e1..20055aea29f5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -465,9 +465,9 @@ 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(service->state->dev, VCHIQ_CORE, - "%d: ignoring ERROR from callback to service %x", - service->state->id, service->handle); + dev_dbg(service->state->dev, + "%s: %s: %d: ignoring ERROR from callback to service %x\n", + log_cat(VCHIQ_CORE), log_type(WARN), service->state->id, service->handle); status = 0; } @@ -1611,10 +1611,11 @@ 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(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); + dev_dbg(state->dev, + "%s: %s: %d: prs %s@%pK (%d->%d) - found connected service %d\n", + log_cat(VCHIQ_CORE), log_type(WARN), + state->id, msg_type_str(type), header, + remoteport, localport, service->localport); } if (!service) { @@ -2917,10 +2918,11 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) (service->srvstate == VCHIQ_SRVSTATE_OPEN)) break; - 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]); + dev_dbg(service->state->dev, + "%s: %s: %d: close_service:%d - waiting in state %s\n", + log_cat(VCHIQ_CORE), log_type(WARN), + service->state->id, service->localport, + srvstate_names[service->srvstate]); } if (!status && @@ -2978,10 +2980,11 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) (service->srvstate == VCHIQ_SRVSTATE_OPEN)) break; - 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]); + dev_dbg(service->state->dev, + "%s: %s: %d: remove_service:%d - waiting in state %s\n", + log_cat(VCHIQ_CORE), log_type(WARN), + service->state->id, service->localport, + srvstate_names[service->srvstate]); } if (!status && (service->srvstate != VCHIQ_SRVSTATE_FREE)) 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 3583604430b3..80d0100094e6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -71,10 +71,6 @@ static inline const char *log_type(enum vchiq_log_type t) return types_str[t]; }; -#ifndef vchiq_log_warning -#define vchiq_log_warning(dev, cat, fmt, ...) \ - do { dev_dbg(dev, "%s warning: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) -#endif #ifndef vchiq_log_debug #define vchiq_log_debug(dev, cat, fmt, ...) \ do { dev_dbg(dev, "%s debug: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) From patchwork Tue Nov 7 09:51:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96777 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0IlJ-001iue-3a; Tue, 07 Nov 2023 09:52:46 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233883AbjKGJwp (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233914AbjKGJwn (ORCPT ); Tue, 7 Nov 2023 04:52:43 -0500 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 43CB011A for ; Tue, 7 Nov 2023 01:52:39 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 58E67468; Tue, 7 Nov 2023 10:52:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350737; bh=wRBknlToqM44Q7j3BP0Y2c750SE0b7/gU4HhkeW2Qxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bzo6hVzaM3DeMyQ1iwSm8qLgiqweFGOlQiLb1R6B9CBCwmxjHmRpoSb6SUtCIHdWo 1gpIJ9xQDwhd5tLRpaIrL8CQcq9vESEP3O4pMsLkE9agJD/21bwJKp14arzF956+Wx aM5B3Jtyhtrh49b/gWv/Ov50+1WR76Gpx5I7ArsU= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain Subject: [PATCH 8/9] staging: vc04_services: Drop vchiq_log_trace() in favour of dev_dbg Date: Tue, 7 Nov 2023 04:51:55 -0500 Message-ID: <20231107095156.365492-9-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Drop vchiq_log_trace() macro which wraps dev_dbg(). Introduce the usage of dev_dbg() directly. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 75 +++++++----- .../interface/vchiq_arm/vchiq_core.c | 115 ++++++++++-------- .../interface/vchiq_arm/vchiq_core.h | 4 - .../interface/vchiq_arm/vchiq_dev.c | 17 +-- 4 files changed, 116 insertions(+), 95 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 bc0ee8b9d1c3..5bf22ff8ba83 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -255,8 +255,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(instance->state->dev, VCHIQ_ARM, - "%s - %pK", __func__, pagelist); + dev_dbg(instance->state->dev, + "%s: %s: %s - %pK\n", log_cat(VCHIQ_ARM), log_type(TRACE), __func__, pagelist); if (!pagelist) return NULL; @@ -407,8 +407,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(instance->state->dev, VCHIQ_ARM, - "%s - %pK, %d", __func__, pagelistinfo->pagelist, actual); + dev_dbg(instance->state->dev, "%s: %s: %s - %pK, %d\n", + log_cat(VCHIQ_ARM), log_type(TRACE), __func__, pagelistinfo->pagelist, actual); /* * NOTE: dma_unmap_sg must be called before the @@ -712,8 +712,9 @@ int vchiq_initialise(struct vchiq_instance **instance_out) ret = 0; failed: - vchiq_log_trace(state->dev, VCHIQ_CORE, - "%s(%p): returning %d", __func__, instance, ret); + dev_dbg(state->dev, + "%s: %s: %s(%p): returning %d\n", __func__, + log_cat(VCHIQ_CORE), log_type(TRACE), instance, ret); return ret; } @@ -746,8 +747,9 @@ int vchiq_shutdown(struct vchiq_instance *instance) mutex_unlock(&state->mutex); - vchiq_log_trace(state->dev, VCHIQ_CORE, - "%s(%p): returning %d", __func__, instance, status); + dev_dbg(state->dev, + "%s: %s: %s(%p): returning %d\n", __func__, + log_cat(VCHIQ_CORE), log_type(TRACE), instance, status); free_bulk_waiter(instance); kfree(instance); @@ -767,8 +769,9 @@ int vchiq_connect(struct vchiq_instance *instance) struct vchiq_state *state = instance->state; if (mutex_lock_killable(&state->mutex)) { - vchiq_log_trace(state->dev, VCHIQ_CORE, - "%s: call to mutex_lock failed", __func__); + dev_dbg(state->dev, + "%s: %s: %s: call to mutex_lock failed\n", + log_cat(VCHIQ_CORE), log_type(TRACE), __func__); status = -EAGAIN; goto failed; } @@ -780,8 +783,9 @@ int vchiq_connect(struct vchiq_instance *instance) mutex_unlock(&state->mutex); failed: - vchiq_log_trace(state->dev, VCHIQ_CORE, - "%s(%p): returning %d", __func__, instance, status); + dev_dbg(state->dev, + "%s: %s: %s(%p): returning %d\n", + log_cat(VCHIQ_CORE), log_type(TRACE), __func__, instance, status); return status; } @@ -812,8 +816,9 @@ vchiq_add_service(struct vchiq_instance *instance, status = -EINVAL; } - vchiq_log_trace(state->dev, VCHIQ_CORE, - "%s(%p): returning %d", __func__, instance, status); + dev_dbg(state->dev, + "%s: %s: %s(%p): returning %d\n", + log_cat(VCHIQ_CORE), log_type(TRACE), __func__, instance, status); return status; } @@ -844,8 +849,9 @@ vchiq_open_service(struct vchiq_instance *instance, } failed: - vchiq_log_trace(state->dev, VCHIQ_CORE, - "%s(%p): returning %d", __func__, instance, status); + dev_dbg(state->dev, + "%s: %s: %s(%p): returning %d\n", + log_cat(VCHIQ_CORE), log_type(TRACE), __func__, instance, status); return status; } @@ -1015,8 +1021,9 @@ 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(instance->state->dev, VCHIQ_CORE, - "%s - completion queue full", __func__); + dev_dbg(instance->state->dev, + "%s: %s: %s - completion queue full\n", + log_cat(VCHIQ_CORE), log_type(TRACE), __func__); DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); if (wait_for_completion_interruptible(&instance->remove_event)) { vchiq_log_debug(instance->state->dev, VCHIQ_ARM, @@ -1104,11 +1111,12 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, vchiq_service_get(service); rcu_read_unlock(); - 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, - (unsigned long)instance, (unsigned long)bulk_userdata); + dev_dbg(service->state->dev, + "%s: %s: %s - service %lx(%d,%p), reason %d, header %lx, instance %lx, bulk_userdata %lx\n", + log_cat(VCHIQ_ARM), log_type(TRACE), + __func__, (unsigned long)user_service, service->localport, + user_service->userdata, reason, (unsigned long)header, + (unsigned long)instance, (unsigned long)bulk_userdata); if (header && user_service->is_vchi) { spin_lock(&msg_queue_spinlock); @@ -1117,8 +1125,9 @@ 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(service->state->dev, VCHIQ_ARM, - "%s - msg queue full", __func__); + dev_dbg(service->state->dev, + "%s: %s: %s - msg queue full\n", + log_cat(VCHIQ_ARM), log_type(TRACE), __func__); /* * If there is no MESSAGE_AVAILABLE in the completion * queue, add one @@ -1466,8 +1475,9 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, local_uc = ++arm_state->videocore_use_count; ++(*entity_uc); - vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s %s count %d, state count %d", - __func__, entity, *entity_uc, local_uc); + dev_dbg(state->dev, "%s: %s: %s %s count %d, state count %d\n", + log_cat(VCHIQ_SUSPEND), log_type(TRACE), __func__, + entity, *entity_uc, local_uc); write_unlock_bh(&arm_state->susp_res_lock); @@ -1486,7 +1496,8 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, } out: - vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s exit %d", __func__, ret); + dev_dbg(state->dev, "%s: %s: %s exit %d\n", + log_cat(VCHIQ_SUSPEND), log_type(TRACE), __func__, ret); return ret; } @@ -1524,14 +1535,16 @@ vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service) --arm_state->videocore_use_count; --(*entity_uc); - vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s %s count %d, state count %d", - __func__, entity, *entity_uc, arm_state->videocore_use_count); + dev_dbg(state->dev, "%s: %s: %s %s count %d, state count %d\n", + log_cat(VCHIQ_SUSPEND), log_type(TRACE), __func__, + entity, *entity_uc, arm_state->videocore_use_count); unlock: write_unlock_bh(&arm_state->susp_res_lock); out: - vchiq_log_trace(state->dev, VCHIQ_SUSPEND, "%s exit %d", __func__, ret); + dev_dbg(state->dev, "%s: %s: %s exit %d\n", + log_cat(VCHIQ_SUSPEND), log_type(TRACE), __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 20055aea29f5..f8578d4c81bc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -459,9 +459,10 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, { int status; - 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); + dev_dbg(service->state->dev, "%s: %s: %d: callback:%d (%s, %pK, %pK)\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + service->state->id, service->localport, reason_names[reason], + header, bulk_userdata); status = service->base.callback(service->instance, reason, header, service->handle, bulk_userdata); if (status && (status != -EAGAIN)) { @@ -763,8 +764,9 @@ process_free_data_message(struct vchiq_state *state, u32 *service_found, * it has dropped below its quota */ complete("a->quota_event); - vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: pfq:%d %x@%pK - slot_use->%d", - state->id, port, header->size, header, count - 1); + dev_dbg(state->dev, "%s: %s: %d: pfq:%d %x@%pK - slot_use->%d\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + state->id, port, header->size, header, count - 1); } else { dev_dbg(state->dev, "%s: %s: service %d slot_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)\n", @@ -810,9 +812,10 @@ process_free_queue(struct vchiq_state *state, u32 *service_found, */ rmb(); - 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); + dev_dbg(state->dev, "%s: %s: %d: pfq %d=%pK %x %x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + state->id, slot_index, data, local->slot_queue_recycle, + slot_queue_available); /* Initialise the bitmask for services which have used this slot */ memset(service_found, 0, length); @@ -982,10 +985,11 @@ 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(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); + dev_dbg(state->dev, + "%s: %s: %d: qm:%d %s,%zx - quota stall (msg %d, slot %d)\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + state->id, service->localport, msg_type_str(type), size, + quota->message_use_count, quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); if (wait_for_completion_interruptible("a->quota_event)) @@ -1075,10 +1079,10 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, spin_unlock("a_spinlock); if (slot_use_count) - 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); + dev_dbg(state->dev, "%s: %s: %d: qm:%d %s,%zx - slot_use->%d (hdr %p)\n", + log_cat(VCHIQ_CORE), log_type(TRACE), state->id, + service->localport, msg_type_str(VCHIQ_MSG_TYPE(msgid)), + size, slot_use_count, header); VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count); VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size); @@ -1207,11 +1211,12 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, svc_fourcc = service ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_trace(state->dev, VCHIQ_SYNC, - "Sent Sync Msg %s(%u) to %p4cc s:%u d:%d len:%d", - msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), - &svc_fourcc, VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid), size); + dev_dbg(state->dev, + "%s: %s: Sent Sync Msg %s(%u) to %p4cc s:%u d:%d len:%d\n", + log_cat(VCHIQ_SYNC), log_type(TRACE), + msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), + &svc_fourcc, VCHIQ_MSG_SRCPORT(msgid), + VCHIQ_MSG_DSTPORT(msgid), size); remote_event_signal(&state->remote->sync_trigger); @@ -1300,11 +1305,12 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, { int status = 0; - 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); + dev_dbg(service->state->dev, + "%s: %s: %d: nb:%d %cx - p=%x rn=%x r=%x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + service->state->id, service->localport, + (queue == &service->bulk_tx) ? 't' : 'r', + queue->process, queue->remote_notify, queue->remove); queue->remote_notify = queue->process; @@ -1427,11 +1433,12 @@ abort_outstanding_bulks(struct vchiq_service *service, { int is_tx = (queue == &service->bulk_tx); - 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); + dev_dbg(service->state->dev, + "%s: %s: %d: aob:%d %cx - li=%x ri=%x p=%x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + 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); @@ -1770,10 +1777,11 @@ 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(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); + dev_dbg(state->dev, "%s: %s: %d: prs:%d %cx li=%x ri=%x p=%x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + state->id, localport, + (type == VCHIQ_MSG_BULK_RX_DONE) ? 'r' : 't', + queue->local_insert, queue->remote_insert, queue->process); DEBUG_TRACE(PARSE_LINE); WARN_ON(queue->process == queue->local_insert); @@ -1786,13 +1794,13 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } break; case VCHIQ_MSG_PADDING: - vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: prs PADDING@%pK,%x", - state->id, header, size); + dev_dbg(state->dev, "%s: %s: %d: prs PADDING@%pK,%x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), state->id, header, size); break; case VCHIQ_MSG_PAUSE: /* If initiated, signal the application thread */ - vchiq_log_trace(state->dev, VCHIQ_CORE, "%d: prs PAUSE@%pK,%x", - state->id, header, size); + dev_dbg(state->dev, "%s: %s: %d: prs PAUSE@%pK,%x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), state->id, header, size); if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { dev_dbg(state->dev, "%s: %s: %d: PAUSE received in state PAUSED\n", log_cat(VCHIQ_CORE), log_type(ERROR), state->id); @@ -1808,8 +1816,8 @@ 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(state->dev, VCHIQ_CORE, "%d: prs RESUME@%pK,%x", - state->id, header, size); + dev_dbg(state->dev, "%s: %s: %d: prs RESUME@%pK,%x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), state->id, header, size); /* Release the slot mutex */ mutex_unlock(&state->slot_mutex); vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); @@ -2048,10 +2056,9 @@ sync_func(void *v) svc_fourcc = service ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_trace(state->dev, VCHIQ_SYNC, - "Rcvd Msg %s from %p4cc s:%d d:%d len:%d", - msg_type_str(type), &svc_fourcc, - remoteport, localport, size); + dev_dbg(state->dev, "%s: %s: Rcvd Msg %s from %p4cc s:%d d:%d len:%d\n", + log_cat(VCHIQ_SYNC), log_type(TRACE), + msg_type_str(type), &svc_fourcc, remoteport, localport, size); if (size > 0) vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); @@ -2076,8 +2083,9 @@ sync_func(void *v) break; case VCHIQ_MSG_DATA: - vchiq_log_trace(state->dev, VCHIQ_SYNC, "%d: sf DATA@%pK,%x (%d->%d)", - state->id, header, size, remoteport, localport); + dev_dbg(state->dev, "%s: %s: %d: sf DATA@%pK,%x (%d->%d)\n", + log_cat(VCHIQ_SYNC), log_type(TRACE), + state->id, header, size, remoteport, localport); if ((service->remoteport == remoteport) && (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC)) { @@ -3128,9 +3136,10 @@ int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, mutex_unlock(&state->slot_mutex); mutex_unlock(&service->bulk_mutex); - 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); + dev_dbg(state->dev, "%s: %s: %d: bt:%d %cx li=%x ri=%x p=%x\n", + log_cat(VCHIQ_CORE), log_type(TRACE), + state->id, service->localport, dir_char, queue->local_insert, + queue->remote_insert, queue->process); waiting: vchiq_service_put(service); @@ -3666,9 +3675,11 @@ void vchiq_log_dump_mem(struct device *dev, const char *label, u32 addr, *s++ = '\0'; if (label && (*label != '\0')) - vchiq_log_trace(dev, VCHIQ_CORE, "%s: %08x: %s", label, addr, line_buf); + dev_dbg(dev, "%s: %s: %s: %08x: %s\n", + log_cat(VCHIQ_CORE), log_type(TRACE), label, addr, line_buf); else - vchiq_log_trace(dev, VCHIQ_CORE, "%s: %08x: %s", label, addr, line_buf); + dev_dbg(dev, "%s: %s: %s: %08x: %s\n", + log_cat(VCHIQ_CORE), log_type(TRACE), 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 80d0100094e6..de0d49e58e39 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -75,10 +75,6 @@ static inline const char *log_type(enum vchiq_log_type t) #define vchiq_log_debug(dev, cat, fmt, ...) \ do { dev_dbg(dev, "%s debug: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) #endif -#ifndef vchiq_log_trace -#define vchiq_log_trace(dev, cat, fmt, ...) \ - do { dev_dbg(dev, "%s trace: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) -#endif #define VCHIQ_SLOT_MASK (VCHIQ_SLOT_SIZE - 1) #define VCHIQ_SLOT_QUEUE_MASK (VCHIQ_MAX_SLOTS_PER_SIDE - 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 76e16128d4b1..7f5bba005653 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -585,10 +585,10 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) long ret = 0; int i, rc; - 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); + dev_dbg(instance->state->dev, "%s: %s: %s - instance %pK, cmd %s, arg %lx\n", + log_cat(VCHIQ_ARM), log_type(TRACE), __func__, instance, + ((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) && (_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ? + ioctl_names[_IOC_NR(cmd)] : "", arg); switch (cmd) { case VCHIQ_IOC_SHUTDOWN: @@ -878,10 +878,11 @@ 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(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); + dev_dbg(instance->state->dev, + "%s: %s: ioctl instance %pK, cmd %s -> status %d\n, %ld\n", + log_cat(VCHIQ_ARM), log_type(TRACE), + instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? + ioctl_names[_IOC_NR(cmd)] : "", status, ret); } return ret; From patchwork Tue Nov 7 09:51:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 96778 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1r0IlN-001iue-FF; Tue, 07 Nov 2023 09:52:50 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233908AbjKGJwt (ORCPT + 1 other); Tue, 7 Nov 2023 04:52:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233843AbjKGJws (ORCPT ); Tue, 7 Nov 2023 04:52:48 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB7BF3 for ; Tue, 7 Nov 2023 01:52:43 -0800 (PST) Received: from umang.jain (unknown [103.251.226.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C8539CC; Tue, 7 Nov 2023 10:52:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699350741; bh=X6Ms63fEvor/4MK9J9V+uHpTsmvqFg52OvqfZuXdfpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H23QUivLZ6ipubycq44pYgwyCopYz6Jbo5W4oIPU7qVzy3AvNBk0ZnICwITPi1nUM JQDJOvqEswHYLV8FMqHBQEa9NC82XccYSKlPe2L4ZfA+pTrUdKCgAObp4r/NdhEoJt gqUZhmk746knaBIqRt4jhDeuSeMo+Emt4XYvPYNM= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Dan Carpenter , Kieran Bingham , Laurent Pinchart , Phil Elwell , Dave Stevenson , Umang Jain Subject: [PATCH 9/9] staging: vc04_services: Drop vchiq_log_debug() in favour of dev_dbg Date: Tue, 7 Nov 2023 04:51:56 -0500 Message-ID: <20231107095156.365492-10-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107095156.365492-1-umang.jain@ideasonboard.com> References: <20231107095156.365492-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Drop vchiq_log_debug() macro which wraps dev_dbg(). Introduce the usage of dev_dbg() directly. Remove the entry from TODO regarding custom logging. VC04 is now aligned according to the standard kernel logging mechanisms. Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/TODO | 5 - .../interface/vchiq_arm/vchiq_arm.c | 53 ++--- .../interface/vchiq_arm/vchiq_core.c | 189 ++++++++++-------- .../interface/vchiq_arm/vchiq_core.h | 5 - .../interface/vchiq_arm/vchiq_dev.c | 43 ++-- 5 files changed, 155 insertions(+), 140 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 5bf22ff8ba83..4a2023919f5f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -311,9 +311,9 @@ create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf, type == PAGELIST_READ, pages); if (actual_pages != num_pages) { - vchiq_log_debug(instance->state->dev, VCHIQ_ARM, - "%s - only %d/%d pages locked", - __func__, actual_pages, num_pages); + dev_dbg(instance->state->dev, "%s: %s: %s - only %d/%d pages locked\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), + __func__, actual_pages, num_pages); /* This is probably due to the process being killed */ if (actual_pages > 0) @@ -556,8 +556,8 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state return -ENXIO; } - vchiq_log_debug(&pdev->dev, VCHIQ_ARM, "vchiq_init - done (slots %pK, phys %pad)", - vchiq_slot_zero, &slot_phys); + dev_dbg(&pdev->dev, "%s: %s: vchiq_init - done (slots %pK, phys %pad)\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), vchiq_slot_zero, &slot_phys); vchiq_call_connected_callbacks(); @@ -727,9 +727,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_debug(instance->state->dev, VCHIQ_ARM, - "bulk_waiter - cleaned up %pK for pid %d", - waiter, waiter->pid); + dev_dbg(instance->state->dev, + "%s: %s: bulk_waiter - cleaned up %pK for pid %d\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), waiter, waiter->pid); kfree(waiter); } } @@ -999,9 +999,8 @@ 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_debug(instance->state->dev, VCHIQ_ARM, - "saved bulk_waiter %pK for pid %d", waiter, - current->pid); + dev_dbg(instance->state->dev, "%s: %s: saved bulk_waiter %pK for pid %d\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), waiter, current->pid); } return status; @@ -1026,12 +1025,12 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, log_cat(VCHIQ_CORE), log_type(TRACE), __func__); DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); if (wait_for_completion_interruptible(&instance->remove_event)) { - vchiq_log_debug(instance->state->dev, VCHIQ_ARM, - "service_callback interrupted"); + dev_dbg(instance->state->dev, "%s: %s: service_callback interrupted\n", + log_cat(VCHIQ_ARM), log_type(DEBUG)); return -EAGAIN; } else if (instance->closing) { - vchiq_log_debug(instance->state->dev, VCHIQ_ARM, - "service_callback closing"); + dev_dbg(instance->state->dev, "%s: %s: service_callback closing\n", + log_cat(VCHIQ_ARM), log_type(DEBUG)); return 0; } DEBUG_TRACE(SERVICE_CALLBACK_LINE); @@ -1136,8 +1135,9 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, instance->completion_remove) < 0) { int status; - vchiq_log_debug(instance->state->dev, VCHIQ_ARM, - "Inserting extra MESSAGE_AVAILABLE"); + dev_dbg(instance->state->dev, + "%s: %s: Inserting extra MESSAGE_AVAILABLE\n", + log_cat(VCHIQ_ARM), log_type(DEBUG)); DEBUG_TRACE(SERVICE_CALLBACK_LINE); status = add_completion(instance, reason, NULL, user_service, bulk_userdata); @@ -1150,14 +1150,15 @@ 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_debug(instance->state->dev, VCHIQ_ARM, - "%s interrupted", __func__); + dev_dbg(instance->state->dev, + "%s: %s: %s interrupted\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); return -EAGAIN; } else if (instance->closing) { - vchiq_log_debug(instance->state->dev, VCHIQ_ARM, - "%s closing", __func__); + dev_dbg(instance->state->dev, "%s: %s: %s closing", + log_cat(VCHIQ_ARM), log_type(DEBUG), __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); return -EINVAL; @@ -1773,8 +1774,9 @@ 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_debug(state->dev, VCHIQ_SUSPEND, "%d: %s->%s", state->id, - get_conn_state_name(oldstate), get_conn_state_name(newstate)); + dev_dbg(state->dev, "%s: %s: %d: %s->%s\n", + log_cat(VCHIQ_SUSPEND), log_type(DEBUG), state->id, + get_conn_state_name(oldstate), get_conn_state_name(newstate)); if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED) return; @@ -1838,9 +1840,8 @@ static int vchiq_probe(struct platform_device *pdev) vchiq_debugfs_init(); - vchiq_log_debug(&pdev->dev, VCHIQ_ARM, - "vchiq: platform initialised - version %d (min %d)", - VCHIQ_VERSION, VCHIQ_VERSION_MIN); + dev_dbg(&pdev->dev, "%s: %s: vchiq: platform initialised - version %d (min %d)\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), 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 f8578d4c81bc..ec02bc9b74f7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -217,10 +217,11 @@ static const char *msg_type_str(unsigned int msg_type) static inline void set_service_state(struct vchiq_service *service, int 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]); + dev_dbg(service->state->dev, "%s: %s: %d: srv:%d %s->%s\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + service->state->id, service->localport, + srvstate_names[service->srvstate], + srvstate_names[newstate]); service->srvstate = newstate; } @@ -245,8 +246,9 @@ find_service_by_handle(struct vchiq_instance *instance, unsigned int handle) return service; } rcu_read_unlock(); - vchiq_log_debug(instance->state->dev, VCHIQ_CORE, - "Invalid service handle 0x%x", handle); + dev_dbg(instance->state->dev, + "%s: %s: Invalid service handle 0x%x\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), handle); return NULL; } @@ -266,8 +268,8 @@ find_service_by_port(struct vchiq_state *state, unsigned int localport) } rcu_read_unlock(); } - vchiq_log_debug(state->dev, VCHIQ_CORE, - "Invalid port %u", localport); + dev_dbg(state->dev, "%s: %s: Invalid port %u\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), localport); return NULL; } @@ -287,8 +289,8 @@ find_service_for_instance(struct vchiq_instance *instance, unsigned int handle) return service; } rcu_read_unlock(); - vchiq_log_debug(instance->state->dev, VCHIQ_CORE, - "Invalid service handle 0x%x", handle); + dev_dbg(instance->state->dev, "%s: %s: Invalid service handle 0x%x\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), handle); return NULL; } @@ -310,8 +312,8 @@ find_closed_service_for_instance(struct vchiq_instance *instance, unsigned int h return service; } rcu_read_unlock(); - vchiq_log_debug(instance->state->dev, VCHIQ_CORE, - "Invalid service handle 0x%x", handle); + dev_dbg(instance->state->dev, "%s: %s: Invalid service handle 0x%x\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), handle); return service; } @@ -483,8 +485,8 @@ vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate) { enum vchiq_connstate oldstate = state->conn_state; - vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: %s->%s", state->id, conn_state_names[oldstate], - conn_state_names[newstate]); + dev_dbg(state->dev, "%s: %s: %d: %s->%s\n", log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, conn_state_names[oldstate], conn_state_names[newstate]); state->conn_state = newstate; vchiq_platform_conn_state_changed(state, oldstate, newstate); } @@ -1029,9 +1031,10 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, int tx_end_index; int slot_use_count; - 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)); + dev_dbg(state->dev, "%s: %s: %d: qm %s@%pK,%zx (%d->%d)\n", + log_cat(VCHIQ_SUSPEND), log_type(DEBUG), + 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)); @@ -1087,9 +1090,10 @@ 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_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)); + dev_dbg(state->dev, "%s: %s: %d: qm %s@%pK,%zx (%d->%d)\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), 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 @@ -1117,11 +1121,10 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, - "Sent Msg %s(%u) to %p4cc s:%u d:%d len:%zu", - msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), - &svc_fourcc, VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid), size); + dev_dbg(state->dev, "%s: %s: Sent Msg %s(%u) to %p4cc s:%u d:%d len:%zu\n", + log_cat(VCHIQ_CORE_MSG), log_type(DEBUG), + msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), + &svc_fourcc, VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid), size); } /* Make sure the new header is visible to the peer. */ @@ -1177,11 +1180,11 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, log_cat(VCHIQ_CORE), log_type(ERROR), state->id, oldmsgid); } - 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)); + dev_dbg(state->dev, "%s: %s: %d: qms %s@%pK,%x (%d->%d)\n", + log_cat(VCHIQ_SYNC), log_type(DEBUG), 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, @@ -1268,9 +1271,10 @@ 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_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); + dev_dbg(state->dev, "%s: %s: %d: %s %d - recycle->%x\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, __func__, SLOT_INDEX_FROM_INFO(state, slot_info), + state->remote->slot_queue_recycle); /* * A write barrier is necessary, but remote_event_signal @@ -1390,8 +1394,9 @@ 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_debug(state->dev, VCHIQ_CORE, "%d: ps - remove %d<->%d", - state->id, service->localport, service->remoteport); + dev_dbg(state->dev, "%s: %s: %d: ps - remove %d<->%d\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, service->localport, service->remoteport); /* * Make it look like a client, because @@ -1403,8 +1408,9 @@ 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_debug(state->dev, VCHIQ_CORE, "%d: ps - terminate %d<->%d", - state->id, service->localport, service->remoteport); + dev_dbg(state->dev, "%s: %s: %d: ps - terminate %d<->%d\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, service->localport, service->remoteport); if (vchiq_close_service_internal(service, NO_CLOSE_RECVD)) request_poll(state, service, VCHIQ_POLL_TERMINATE); } @@ -1457,11 +1463,12 @@ abort_outstanding_bulks(struct vchiq_service *service, if (queue->process != queue->local_insert) { vchiq_complete_bulk(service->instance, bulk); - vchiq_log_debug(service->state->dev, VCHIQ_CORE_MSG, - "%s %p4cc d:%d ABORTED - tx len:%d, rx len:%d", - is_tx ? "Send Bulk to" : "Recv Bulk from", - &service->base.fourcc, - service->remoteport, bulk->size, bulk->remote_size); + dev_dbg(service->state->dev, + "%s: %s: %s %p4cc d:%d ABORTED - tx len:%d, rx len:%d\n", + log_cat(VCHIQ_CORE_MSG), log_type(DEBUG), + is_tx ? "Send Bulk to" : "Recv Bulk from", + &service->base.fourcc, + service->remoteport, bulk->size, bulk->remote_size); } else { /* fabricate a matching dummy bulk */ bulk->data = 0; @@ -1494,8 +1501,9 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) payload = (struct vchiq_open_payload *)header->data; fourcc = payload->fourcc; - vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs OPEN@%pK (%d->'%p4cc')", - state->id, header, localport, &fourcc); + dev_dbg(state->dev, "%s: %s: %d: prs OPEN@%pK (%d->'%p4cc')\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, header, localport, &fourcc); service = get_listening_service(state, fourcc); if (!service) @@ -1641,10 +1649,9 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) svc_fourcc = service ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); - vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, - "Rcvd Msg %s(%u) from %p4cc s:%d d:%d len:%d", - msg_type_str(type), type, &svc_fourcc, - remoteport, localport, size); + dev_dbg(state->dev, "%s: %s: Rcvd Msg %s(%u) from %p4cc s:%d d:%d len:%d\n", + log_cat(VCHIQ_CORE_MSG), log_type(DEBUG), + msg_type_str(type), type, &svc_fourcc, remoteport, localport, size); if (size > 0) vchiq_log_dump_mem(state->dev, "Rcvd", 0, header->data, min(16, size)); @@ -1669,10 +1676,11 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) header->data; service->peer_version = payload->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); + dev_dbg(state->dev, + "%s: %s: %d: prs OPENACK@%pK,%x (%d->%d) v:%d\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + 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); @@ -1686,21 +1694,23 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) case VCHIQ_MSG_CLOSE: WARN_ON(size); /* There should be no data */ - vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs CLOSE@%pK (%d->%d)", - state->id, header, remoteport, localport); + dev_dbg(state->dev, "%s: %s: %d: prs CLOSE@%pK (%d->%d)\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + 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_debug(state->dev, VCHIQ_CORE, "Close Service %p4cc s:%u d:%d", - &service->base.fourcc, - service->localport, service->remoteport); + dev_dbg(state->dev, "%s: %s: Close Service %p4cc s:%u d:%d\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + &service->base.fourcc, service->localport, service->remoteport); break; case VCHIQ_MSG_DATA: - vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs DATA@%pK,%x (%d->%d)", - state->id, header, size, remoteport, localport); + dev_dbg(state->dev, "%s: %s: %d: prs DATA@%pK,%x (%d->%d)\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, header, size, remoteport, localport); if ((service->remoteport == remoteport) && (service->srvstate == VCHIQ_SRVSTATE_OPEN)) { @@ -1719,8 +1729,8 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } break; case VCHIQ_MSG_CONNECT: - vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: prs CONNECT@%pK", - state->id, header); + dev_dbg(state->dev, "%s: %s: %d: prs CONNECT@%pK\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), state->id, header); state->version_common = ((struct vchiq_slot_zero *) state->slot_data)->version; complete(&state->connect); @@ -1772,10 +1782,10 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) bulk->actual = *(int *)header->data; queue->remote_insert++; - 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); + dev_dbg(state->dev, "%s: %s: %d: prs %s@%pK (%d->%d) %x@%pad\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, msg_type_str(type), header, remoteport, + localport, bulk->actual, &bulk->data); dev_dbg(state->dev, "%s: %s: %d: prs:%d %cx li=%x ri=%x p=%x\n", log_cat(VCHIQ_CORE), log_type(TRACE), @@ -2070,9 +2080,10 @@ sync_func(void *v) header->data; service->peer_version = payload->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); + dev_err(state->dev, "%s: %s: %d: sf OPENACK@%pK,%x (%d->%d) v:%d\n", + log_cat(VCHIQ_SYNC), log_type(DEBUG), + 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); @@ -2476,9 +2487,10 @@ vchiq_add_service_internal(struct vchiq_state *state, /* Bring this service online */ set_service_state(service, srvstate); - vchiq_log_debug(state->dev, VCHIQ_CORE_MSG, "%s Service %p4cc SrcPort:%d", - (srvstate == VCHIQ_SRVSTATE_OPENING) ? "Open" : "Add", - ¶ms->fourcc, service->localport); + dev_dbg(state->dev, "%s: %s: %s Service %p4cc SrcPort:%d\n", + log_cat(VCHIQ_CORE_MSG), log_type(DEBUG), + (srvstate == VCHIQ_SRVSTATE_OPENING) ? "Open" : "Add", + ¶ms->fourcc, service->localport); /* Don't unlock the service - leave it with a ref_count of 1. */ @@ -2574,8 +2586,8 @@ release_service_messages(struct vchiq_service *service) int port = VCHIQ_MSG_DSTPORT(msgid); if ((port == service->localport) && (msgid & VCHIQ_MSGID_CLAIMED)) { - vchiq_log_debug(state->dev, VCHIQ_CORE, - " fsi - hdr %pK", header); + dev_dbg(state->dev, "%s: %s: fsi - hdr %pK\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), header); release_slot(state, slot_info, header, NULL); } pos += calc_stride(header->size); @@ -2685,8 +2697,9 @@ 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_debug(state->dev, VCHIQ_CORE, "%d: csi:%d,%d (%s)", service->state->id, - service->localport, close_recvd, srvstate_names[service->srvstate]); + dev_dbg(state->dev, "%s: %s: %d: csi:%d,%d (%s)\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), service->state->id, + service->localport, close_recvd, srvstate_names[service->srvstate]); switch (service->srvstate) { case VCHIQ_SRVSTATE_CLOSED: @@ -2798,8 +2811,9 @@ vchiq_terminate_service_internal(struct vchiq_service *service) { struct vchiq_state *state = service->state; - vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: tsi - (%d<->%d)", state->id, - service->localport, service->remoteport); + dev_dbg(state->dev, "%s: %s: %d: tsi - (%d<->%d)\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + state->id, service->localport, service->remoteport); mark_service_closing(service); @@ -2813,8 +2827,8 @@ vchiq_free_service_internal(struct vchiq_service *service) { struct vchiq_state *state = service->state; - vchiq_log_debug(state->dev, VCHIQ_CORE, "%d: fsi - (%d)", - state->id, service->localport); + dev_dbg(state->dev, "%s: %s: %d: fsi - (%d)\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), state->id, service->localport); switch (service->srvstate) { case VCHIQ_SRVSTATE_OPENING: @@ -2895,8 +2909,9 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) if (!service) return -EINVAL; - vchiq_log_debug(service->state->dev, VCHIQ_CORE, "%d: close_service:%d", - service->state->id, service->localport); + dev_dbg(service->state->dev, "%s: %s: %d: close_service:%d\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + service->state->id, service->localport); if ((service->srvstate == VCHIQ_SRVSTATE_FREE) || (service->srvstate == VCHIQ_SRVSTATE_LISTENING) || @@ -2954,8 +2969,9 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) if (!service) return -EINVAL; - vchiq_log_debug(service->state->dev, VCHIQ_CORE, "%d: remove_service:%d", - service->state->id, service->localport); + dev_dbg(service->state->dev, "%s: %s: %d: remove_service:%d\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + service->state->id, service->localport); if (service->srvstate == VCHIQ_SRVSTATE_FREE) { vchiq_service_put(service); @@ -3099,9 +3115,10 @@ int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, */ wmb(); - 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); + dev_dbg(state->dev, "%s: %s: %d: bt (%d->%d) %cx %x@%pad %pK\n", + log_cat(VCHIQ_CORE), log_type(DEBUG), + 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 de0d49e58e39..d66b60a9f6da 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -71,11 +71,6 @@ static inline const char *log_type(enum vchiq_log_type t) return types_str[t]; }; -#ifndef vchiq_log_debug -#define vchiq_log_debug(dev, cat, fmt, ...) \ - do { dev_dbg(dev, "%s debug: " fmt, log_cat(cat), ##__VA_ARGS__); } while (0) -#endif - #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 7f5bba005653..a64d6333cf0a 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,10 @@ user_service_free(void *userdata) static void close_delivered(struct user_service *user_service) { - vchiq_log_debug(user_service->service->state->dev, VCHIQ_ARM, - "%s(handle=%x)", - __func__, user_service->service->handle); + dev_dbg(user_service->service->state->dev, + "%s: %s: %s(handle=%x)\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), + __func__, user_service->service->handle); if (user_service->close_pending) { /* Allow the underlying service to be culled */ @@ -235,8 +236,9 @@ 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_debug(service->state->dev, VCHIQ_ARM, - "DEQUEUE_MESSAGE interrupted"); + dev_dbg(service->state->dev, + "%s: %s: DEQUEUE_MESSAGE interrupted\n", + log_cat(VCHIQ_ARM), log_type(DEBUG)); ret = -EINTR; break; } @@ -325,8 +327,9 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, ret = -ESRCH; goto out; } - vchiq_log_debug(service->state->dev, VCHIQ_ARM, - "found bulk_waiter %pK for pid %d", waiter, current->pid); + dev_dbg(service->state->dev, "%s: %s: found bulk_waiter %pK for pid %d\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), + waiter, current->pid); userdata = &waiter->bulk_waiter; } else { userdata = args->userdata; @@ -357,8 +360,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_debug(service->state->dev, VCHIQ_ARM, - "saved bulk_waiter %pK for pid %d", waiter, current->pid); + dev_dbg(service->state->dev, "%s: %s: saved bulk_waiter %pK for pid %d\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), waiter, current->pid); ret = put_user(mode_waiting, mode); } @@ -457,8 +460,9 @@ static int vchiq_ioc_await_completion(struct vchiq_instance *instance, mutex_lock(&instance->completion_mutex); if (rc) { DEBUG_TRACE(AWAIT_COMPLETION_LINE); - vchiq_log_debug(instance->state->dev, VCHIQ_ARM, - "AWAIT_COMPLETION interrupted"); + dev_dbg(instance->state->dev, + "%s: %s: AWAIT_COMPLETION interrupted\n", + log_cat(VCHIQ_ARM), log_type(DEBUG)); ret = -EINTR; goto out; } @@ -873,10 +877,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } 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); + dev_dbg(instance->state->dev, + "%s: %s: ioctl instance %pK, cmd %s -> status %d, %ld\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), + instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? + ioctl_names[_IOC_NR(cmd)] : "", status, ret); } else { dev_dbg(instance->state->dev, "%s: %s: ioctl instance %pK, cmd %s -> status %d\n, %ld\n", @@ -1181,7 +1186,8 @@ static int vchiq_open(struct inode *inode, struct file *file) return -ENOTCONN; } - vchiq_log_debug(state->dev, VCHIQ_ARM, "vchiq_open"); + dev_dbg(state->dev, "%s: %s: vchiq_open\n", + log_cat(VCHIQ_ARM), log_type(DEBUG)); instance = kzalloc(sizeof(*instance), GFP_KERNEL); if (!instance) @@ -1211,8 +1217,9 @@ static int vchiq_release(struct inode *inode, struct file *file) int ret = 0; int i; - vchiq_log_debug(state->dev, VCHIQ_ARM, "%s: instance=%lx", __func__, - (unsigned long)instance); + dev_dbg(state->dev, "%s: %s: %s: instance=%lx\n", + log_cat(VCHIQ_ARM), log_type(DEBUG), + __func__, (unsigned long)instance); if (!state) { ret = -EPERM;