From patchwork Thu Nov 2 21:06:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13444202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47D9BC4332F for ; Thu, 2 Nov 2023 21:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dVZrFSMvPTJ8oHIjlHfqzWM84bwMhk/r8NiuzOAu5gc=; b=A6rAj2hfpf7LGA 0XP5gCVQEZ0ECt55FPDF0DMrzKqszOLEmQ5PlJ0binWMZxzr2PQ+xPkVYk8AvwnSx/gnJHO5gaqrY rEnO7BIP0dsYmLA7Z7pB94NIZ65GmpLsQpKdPVD1WpIkHoJblkl+skPchpYW+4iGoNjaz+LepChUP PfBBaBOqLo8gs6rTubyPZFIvlTVZliZUH5iIJKOxLD5N98a3bzRkiOOwHi1oUwhO7W0lv//MN3qdL SU+anP8z1ZHpJdbl1IyJ3FPEHACUrw8U9cVGDZgjtPQflISfn6j65jKcY1a61HAOXJbZ2PxFNLEAj 7OhMuJQS9cDxkjwmFvQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyetU-00AHy3-0A; Thu, 02 Nov 2023 21:06:24 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyetO-00AHt7-1X; Thu, 02 Nov 2023 21:06:22 +0000 Received: from umang.jain (unknown [103.86.18.252]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BEA878C2; Thu, 2 Nov 2023 22:05:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698959157; bh=Xf7dJFzb0qM5K2nV1aafE0Mnl/RJXFGyi+hAmDPmjjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rybdSYwf6MSzyhGZuKydECbcz9x2JFOKCYEQtrVKdJP5EIJv86OHsbi7fv+Her/Aq Ckor+z8DEYls606w8rwbOFaUvm0Jc0yjg1Jpb1ZjHMMKOsgg+n5LhffBfS5PMr4YYx VrmG17sDBmO5yWSL2jLhwFOKPX5U0trHAz6AtXbw= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Kieran Bingham , Dan Carpenter , Phil Elwell , Dave Stevenson , "Ricardo B . Marliere" , Umang Jain Subject: [PATCH 1/3] staging: vc04_services: vchiq_core: Log through struct vchiq_instance Date: Thu, 2 Nov 2023 17:06:01 -0400 Message-ID: <20231102210603.1201311-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231102210603.1201311-1-umang.jain@ideasonboard.com> References: <20231102210603.1201311-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231102_140618_672543_3542124F X-CRM114-Status: UNSURE ( 8.77 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The handle_to_service() helper can return NULL, so service pointer can indeed be set to NULL. Hence, do not log through service pointer, use the vchiq_instance function argument to get access to the struct device. Signed-off-by: Umang Jain --- .../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 Thu Nov 2 21:06:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13444204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6A4CC4332F for ; Thu, 2 Nov 2023 21:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EKTHfunKv5EXilKXvgf+X+6mrLXmktdpXK/KoM4rFDI=; b=RMo9fiVESnArdq claTot1WE4Kb5heGjc678yYTn5sgQxbjhK9OyQarrA/JZg5ud9bQqTUtu4f3IwO2ZaMDp/GBKCIcE toYBWoYvUVb98bI4wfQgiL0q5aK/tg1ZvmcjL6wMtrrHcZH2s5RZjCY8YQe+fvclDlUqu5BJVDC2J iPK+hY0MT1iWDK87H6o4KFXMJ2z1cL/BqrrDDFzSP/8j+7l8IVp+eSGODFXaZMdkRouoQ4QFZx+To k1St3k8flzyMRs9iWWPM2n7zru+qEpFsn7xs2aBfgXElpHcYTCJX2NrN6lUnhl3xb0hDw1hxHyM/w LpUqkSqTBqXD6XDY69HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyetX-00AI06-2r; Thu, 02 Nov 2023 21:06:27 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyetP-00AHw2-2K; Thu, 02 Nov 2023 21:06:25 +0000 Received: from umang.jain (unknown [103.86.18.252]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E335C58; Thu, 2 Nov 2023 22:05:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698959160; bh=g9HzfZmE3ZTc4WYjPHq8NUaGArWYbSyR+SDvRDMfWbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f34InSJ4zuWTnqz8o3vseg3vLJLp6bKr8J12nENr+rN6xNpRYdO5J34VhW+qvFn3X JwCwYbCDrBKvJe5sbs7Wv196g87asy6/U4Hy5x/OyuIhGg9vjU4oKPQDHeU+TRjQry z7oFkUj8S8TErHvJmzNHxFFsuTf2UDU2pSoFv2t0= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Kieran Bingham , Dan Carpenter , Phil Elwell , Dave Stevenson , "Ricardo B . Marliere" , Umang Jain Subject: [PATCH 2/3] staging: vc04_services: Log using pr_err() when vchiq_state is unset Date: Thu, 2 Nov 2023 17:06:02 -0400 Message-ID: <20231102210603.1201311-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231102210603.1201311-1-umang.jain@ideasonboard.com> References: <20231102210603.1201311-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231102_140619_896434_4671993B X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- .../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 Thu Nov 2 21:06:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13444205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8E35C4167D for ; Thu, 2 Nov 2023 21:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ac4PnercJLGIUNmI+IUGaCrWHzTLLpFqWXGbcl6ZmrM=; b=cz0G3vV2t60EAw B7XjQ2pplNd69r0dftJoGUv9tUWcnVDlQ8+lCl0SQeMJ88Rd75o3aSR2wPPcGilZqqPhlN41FyhKN n6ppldXPLJxqRYbDu2dpefAT6Kkqq2lPFFcOuY40Z1+DgWN2liDlMhB/OiiV4UG1YF8fGKHydyk2G 6iGUGxTNtIfh6u5CXQp5yNCBdsjEjcGWeyCD6FTu4wEbERrAkDsOkDbcnBG1iSREnsqg8TAk8lJai Dc+QMcar5rx0SqlWO01zD4VWpcZcajaU+Tvvj57pmxH1mDZNuLApwq2Q+G9PGf4Yu2W20IK+ubzsG DT5bSJzOULOyhE4A6wcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qyetZ-00AI0p-0W; Thu, 02 Nov 2023 21:06:29 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qyetT-00AHxC-0N; Thu, 02 Nov 2023 21:06:27 +0000 Received: from umang.jain (unknown [103.86.18.252]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 724401BA7; Thu, 2 Nov 2023 22:06:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698959164; bh=a8iH5jRb/j16EMTGAIMJg3wp3R1ruC0yTIPb19rETiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXAgfxKjs6P8SqBk+OKGcFnl2ihyJw3GuOdg8DAHA1GsX2CqzcN6adqSbNCbwOW/f mRmeDLCJnvk2zxnDhk24yEV1v2ufJ06cmY/rUQ5eS+pTIdiPfrT3BGmeevuwqqhIzS W2O1hO82BLwhFgCgiWHcV27bMuJLJZjbKGV/CygM= From: Umang Jain To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Stefan Wahren , Greg Kroah-Hartman , Kieran Bingham , Dan Carpenter , Phil Elwell , Dave Stevenson , "Ricardo B . Marliere" , Umang Jain Subject: [PATCH 3/3] staging: vc04_services: bcm2835-camera: Remove redundant null check Date: Thu, 2 Nov 2023 17:06:03 -0400 Message-ID: <20231102210603.1201311-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231102210603.1201311-1-umang.jain@ideasonboard.com> References: <20231102210603.1201311-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231102_140623_299099_7BF28856 X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- .../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; }