From nobody Wed Nov 27 06:42:06 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B030D217308 for ; Fri, 11 Oct 2024 12:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648626; cv=none; b=uCVnuIggpk9b/erYbILyE0G+OWTbARyR9p+9HO4WQmuM7T24G9K3pDMtWTOiEgvJ4KpWOtXlguYdQWlr/d1TCYbvwZOL7Mhmhlq3iXVuvDqrTHm618lp0RBncF/AellVJ9zzUxsvdRHUorJkytgPbBPz1+N1gdqbhpGwo86INZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648626; c=relaxed/simple; bh=HPzlE9sh1djReKfpWW1YtSaIElNq0n+B+WspYQFZr6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TYVbXANp+62m1bznN8PtktwKTIlV9YSYfVnOsuslLPmxlG8HJvicz4ovNNaxXtsyx2ZD5nLDSc5AjcFCuxyh+Z/k6sXtg5Gmw34KOPkLFk9Lndd3cWFgwkEzHq62dK16G9FKlUtdnvx3gc89JgUgAxjZDcNICk8IBGhd622HeDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=ICyiPHdU; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ICyiPHdU" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A2788CDB; Fri, 11 Oct 2024 14:08:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728648523; bh=HPzlE9sh1djReKfpWW1YtSaIElNq0n+B+WspYQFZr6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICyiPHdU6z78Hq/RQKLF0mAAgd0rhXGCfJHmoeyrzMaWbe78bggGlDy4QUNXyFkBw 0jN17O+Z3o3zmSSNYfjzgxXvhjWjFijKSSTbCMtAdCCwakhnx0NttnNDdk53aqiip6 bQsV1DkQNbYxtSIdGIQ8HF+VMvcDUsWzNcXgks5Y= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Umang Jain Subject: [PATCH v2 1/6] staging: vchiq_core: Locally cache cache_line_size information Date: Fri, 11 Oct 2024 17:39:05 +0530 Message-ID: <20241011120910.74045-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011120910.74045-1-umang.jain@ideasonboard.com> References: <20241011120910.74045-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Locally cache 'cache_line_size' information in a variable instead of repeatedly accessing it from drv_mgmt->info. This helps to reflow lines under 80 columns. No functional change intended in this patch. Signed-off-by: Umang Jain Reviewed-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 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 1e4b2978c186..e9b60dd8d419 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1490,6 +1490,7 @@ create_pagelist(struct vchiq_instance *instance, char= *buf, char __user *ubuf, size_t pagelist_size; struct scatterlist *scatterlist, *sg; int dma_buffers; + unsigned int cache_line_size; dma_addr_t dma_addr; =20 if (count >=3D INT_MAX - PAGE_SIZE) @@ -1638,10 +1639,10 @@ create_pagelist(struct vchiq_instance *instance, ch= ar *buf, char __user *ubuf, } =20 /* Partial cache lines (fragments) require special measures */ + cache_line_size =3D drv_mgmt->info->cache_line_size; if ((type =3D=3D PAGELIST_READ) && - ((pagelist->offset & (drv_mgmt->info->cache_line_size - 1)) || - ((pagelist->offset + pagelist->length) & - (drv_mgmt->info->cache_line_size - 1)))) { + ((pagelist->offset & (cache_line_size - 1)) || + ((pagelist->offset + pagelist->length) & (cache_line_size - 1)))) { char *fragments; =20 if (down_interruptible(&drv_mgmt->free_fragments_sema)) { @@ -1671,6 +1672,7 @@ free_pagelist(struct vchiq_instance *instance, struct= vchiq_pagelist_info *pagel struct pagelist *pagelist =3D pagelistinfo->pagelist; struct page **pages =3D pagelistinfo->pages; unsigned int num_pages =3D pagelistinfo->num_pages; + unsigned int cache_line_size; =20 dev_dbg(instance->state->dev, "arm: %pK, %d\n", pagelistinfo->pagelist, a= ctual); =20 @@ -1685,16 +1687,17 @@ free_pagelist(struct vchiq_instance *instance, stru= ct vchiq_pagelist_info *pagel pagelistinfo->scatterlist_mapped =3D 0; =20 /* Deal with any partial cache lines (fragments) */ + cache_line_size =3D drv_mgmt->info->cache_line_size; if (pagelist->type >=3D PAGELIST_READ_WITH_FRAGMENTS && drv_mgmt->fragmen= ts_base) { char *fragments =3D drv_mgmt->fragments_base + (pagelist->type - PAGELIST_READ_WITH_FRAGMENTS) * drv_mgmt->fragments_size; int head_bytes, tail_bytes; =20 - head_bytes =3D (drv_mgmt->info->cache_line_size - pagelist->offset) & - (drv_mgmt->info->cache_line_size - 1); + head_bytes =3D (cache_line_size - pagelist->offset) & + (cache_line_size - 1); tail_bytes =3D (pagelist->offset + actual) & - (drv_mgmt->info->cache_line_size - 1); + (cache_line_size - 1); =20 if ((actual >=3D 0) && (head_bytes !=3D 0)) { if (head_bytes > actual) @@ -1707,8 +1710,8 @@ free_pagelist(struct vchiq_instance *instance, struct= vchiq_pagelist_info *pagel (tail_bytes !=3D 0)) memcpy_to_page(pages[num_pages - 1], (pagelist->offset + actual) & - (PAGE_SIZE - 1) & ~(drv_mgmt->info->cache_line_size - 1), - fragments + drv_mgmt->info->cache_line_size, + (PAGE_SIZE - 1) & ~(cache_line_size - 1), + fragments + cache_line_size, tail_bytes); =20 down(&drv_mgmt->free_fragments_mutex); --=20 2.45.2 From nobody Wed Nov 27 06:42:06 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DED921733B for ; Fri, 11 Oct 2024 12:10:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648627; cv=none; b=ZuRNyEaQwcXDzJiqVudPT2y8cKWm0PnvDoDftM5SpNsZY5g4bDYHwpQMJuoRosomyAs/jc/WAL5SX1wDqtv0dUQQpBiS0M1tU3xEzJjdihrt7M123SbvJNxpeHGxOLn/GEAtPb28d4CrUXUzkxtaBavSj8GbVog7gVDW6L3usUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648627; c=relaxed/simple; bh=WBqPaPeDJDpOXJCYWiEMmcPkk6BJUzfDh0i0SctEqUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IS60iSmiI8KEApVfmMfCtvcb0Zely/YhstYS/eh9/N2+SMwZXH4GVjeLqzjUqgWX8tj33iXYg7U+BjvGeJ9/MyiAjpNsP/vjjT2tvVz240d1/jSxspNGmeOXp/KLjCfVZYQTOTs+35oNYGJm+IcmQhu9LJ1ndumCR8wVHRjr+88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=cahST3Yt; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cahST3Yt" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 04FABD8B; Fri, 11 Oct 2024 14:08:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728648526; bh=WBqPaPeDJDpOXJCYWiEMmcPkk6BJUzfDh0i0SctEqUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cahST3YtkY1BxWTrohz9PNGvVxR/kKsj35FE0zk/Hn3/RjOOQxTtzWPjiRp3p73v9 FJpvhB6iKw8ruuaGfEy+LVtgxGCw0JnFtvQtHDGhGGZNNcxHGjstz8fKEX8oilh0Wt a/sXZSPRqC7ImIJOeZqZdKBUWRDfA484yp9qYs44= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Umang Jain Subject: [PATCH v2 2/6] staging: vchiq_core: Do not log debug in a separate scope Date: Fri, 11 Oct 2024 17:39:06 +0530 Message-ID: <20241011120910.74045-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011120910.74045-1-umang.jain@ideasonboard.com> References: <20241011120910.74045-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Do not log a dev_dbg() with a separate scope. Drop the {..} scope and align the dev_dbg() to make it more readable. No functional changes intended in this patch. Signed-off-by: Umang Jain Reviewed-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_core.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 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 e9b60dd8d419..0324dfe59dca 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -936,6 +936,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, struct vchiq_service_quota *quota =3D NULL; struct vchiq_header *header; int type =3D VCHIQ_MSG_TYPE(msgid); + int svc_fourcc; =20 size_t stride; =20 @@ -1128,17 +1129,13 @@ queue_message(struct vchiq_state *state, struct vch= iq_service *service, header->msgid =3D msgid; header->size =3D size; =20 - { - int svc_fourcc; - - svc_fourcc =3D service - ? service->base.fourcc - : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); + svc_fourcc =3D service ? service->base.fourcc + : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); =20 - dev_dbg(state->dev, "core_msg: Sent Msg %s(%u) to %p4cc s:%u d:%d len:%z= u\n", - 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, "core_msg: Sent Msg %s(%u) to %p4cc s:%u d:%d len:%zu= \n", + msg_type_str(VCHIQ_MSG_TYPE(msgid)), + VCHIQ_MSG_TYPE(msgid), &svc_fourcc, + VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid), size); =20 /* Make sure the new header is visible to the peer. */ wmb(); --=20 2.45.2 From nobody Wed Nov 27 06:42:06 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5073A21791B for ; Fri, 11 Oct 2024 12:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648629; cv=none; b=AqjqXNtnaUe3oR0zGKWuiSsmohd3c0MIW/pXe2n9WZ01U6WdknYjOueB1gosjGuaPgkJI2EzsoEspH6IwbqgHk+3qyl/KQM7JcUqnjeM6xkfKk6jL9WeL8CzOnCh3EL+8W2zrauORRJOgU9YcXpPjTB/Jm59Lgi6ElAxW5vG3ec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648629; c=relaxed/simple; bh=ynOxMnbXos2NXkFd5V5zZmg92ZIYEBr+8vmtUcjRTxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F5cTxqWJeP0jWrnz72LXoAjAO5mb2RJTJxW2QQDI8CKntZWsRfWCnbkYQo3V5LtGbA+qvD1JkGwXKAjAndf6XYfODx+hrYOyPFnV8+dFWrWpM835jjpV/GckKDuVT2WivrBBAu2t3fiDiuqU6RLrot173eZWrhq3pcFiguGdQcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=t2mqG7Jh; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="t2mqG7Jh" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D0D6E79; Fri, 11 Oct 2024 14:08:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728648528; bh=ynOxMnbXos2NXkFd5V5zZmg92ZIYEBr+8vmtUcjRTxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2mqG7JhlbMkdoQD6Onw2vMvAoXPykaMyqP6bVjkzT4qFPp5S2JFBk51SOlK2ffrN J5akYsbt4gZak0JB5r/EVIagPtHrTy9NosTFa5sRJWQtI+0IxZ2jGF64R0OPcMglyL bGt2rnhvP4iSd/bFsL96zHaVpswa/R3lqDNAjiNc= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Umang Jain Subject: [PATCH v2 3/6] staging: vchiq_core: Indent copy_message_data() on a single line Date: Fri, 11 Oct 2024 17:39:07 +0530 Message-ID: <20241011120910.74045-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011120910.74045-1-umang.jain@ideasonboard.com> References: <20241011120910.74045-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix the copy_message_data() indentation in queue_message_sync(). Signed-off-by: Umang Jain Reviewed-by: Stefan Wahren --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 5 ++--- 1 file changed, 2 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 0324dfe59dca..e9cd012e2b5f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1197,9 +1197,8 @@ queue_message_sync(struct vchiq_state *state, struct = vchiq_service *service, state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); =20 - callback_result =3D - copy_message_data(copy_callback, context, - header->data, size); + callback_result =3D copy_message_data(copy_callback, context, + header->data, size); =20 if (callback_result < 0) { mutex_unlock(&state->slot_mutex); --=20 2.45.2 From nobody Wed Nov 27 06:42:06 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0979218D7F for ; Fri, 11 Oct 2024 12:10:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648632; cv=none; b=iEu7iFdLOSY6aGWubZ3zdsBEJquDjlh5PtmMx5iGoQ3m9Yc2+1F0awE/B0KSVwbYu1LH+XTfcU/pEpYSI8UdlXzwp3laDYoeh2+x+CBT2bfl7+RpXrkNDwkc1gijfdAsG+4TSquNZpX2K7rvyNEIZy/xmCGqO0YJ7nPpmIE0qII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648632; c=relaxed/simple; bh=01ajFvAti3hY90IDMC7z1QMppAuqhsOts5Y1hvRhhiE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qISobEiTQUiG4VCJzmNgRtD6dZTcU3rSbojh9TyiywovQiBwYotpwpr2t2+B08gXKdl5C9AWr/MDEWYxlexIqr3YFiwl0dS5laFuHltgPZT+8+nUFvCIzK41XjANE6B3nuOl1NZNCUSiRWpOozPhn9Ar9Gb5CfiHlTdS7xhfx3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=PFBWefsC; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PFBWefsC" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B5A328D4; Fri, 11 Oct 2024 14:08:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728648530; bh=01ajFvAti3hY90IDMC7z1QMppAuqhsOts5Y1hvRhhiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PFBWefsCxxHXpDkzJwngc0rFH5bOexpy6rQD/zs+78cXwIv6c0kuq3+EvIxn0EGb6 mrbeeJCWAp/RU4+sRgbqconFtU5ZA46NEYb9idiRrNj2dmIuZzyuecRq4a2fKws4qz THB1fbvg95cblEnVoPDz74Iy9Hp51HUHO9+oerVE= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Umang Jain Subject: [PATCH v2 4/6] staging: vchiq_core: Refactor notify_bulks() Date: Fri, 11 Oct 2024 17:39:08 +0530 Message-ID: <20241011120910.74045-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011120910.74045-1-umang.jain@ideasonboard.com> References: <20241011120910.74045-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the statistics and bulk completion events handling to a separate function. This helps to improve readability for notify_bulks(). No functional changes intended in this patch. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_core.c | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 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 e9cd012e2b5f..5509f8b1061a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1309,6 +1309,48 @@ get_bulk_reason(struct vchiq_bulk *bulk) return VCHIQ_BULK_RECEIVE_DONE; } =20 +static int service_notify_bulk(struct vchiq_service *service, + struct vchiq_bulk *bulk) +{ + int status =3D -EINVAL; + + if (!service || !bulk) + return status; + + if (bulk->actual !=3D VCHIQ_BULK_ACTUAL_ABORTED) { + if (bulk->dir =3D=3D VCHIQ_BULK_TRANSMIT) { + VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count); + VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes, + bulk->actual); + } else { + VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count); + VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes, + bulk->actual); + } + } else { + VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count); + } + + if (bulk->mode =3D=3D VCHIQ_BULK_MODE_BLOCKING) { + struct bulk_waiter *waiter; + + spin_lock(&service->state->bulk_waiter_spinlock); + waiter =3D bulk->userdata; + if (waiter) { + waiter->actual =3D bulk->actual; + complete(&waiter->event); + } + + spin_unlock(&service->state->bulk_waiter_spinlock); + } else if (bulk->mode =3D=3D VCHIQ_BULK_MODE_CALLBACK) { + enum vchiq_reason reason =3D get_bulk_reason(bulk); + status =3D make_service_callback(service, reason, NULL, + bulk->userdata); + } + + return status; +} + /* Called by the slot handler - don't hold the bulk mutex */ static int notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, @@ -1333,37 +1375,9 @@ notify_bulks(struct vchiq_service *service, struct v= chiq_bulk_queue *queue, * requests, and non-terminated services */ if (bulk->data && service->instance) { - if (bulk->actual !=3D VCHIQ_BULK_ACTUAL_ABORTED) { - if (bulk->dir =3D=3D VCHIQ_BULK_TRANSMIT) { - VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count); - VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes, - bulk->actual); - } else { - VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count); - VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes, - bulk->actual); - } - } else { - VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count); - } - if (bulk->mode =3D=3D VCHIQ_BULK_MODE_BLOCKING) { - struct bulk_waiter *waiter; - - spin_lock(&service->state->bulk_waiter_spinlock); - waiter =3D bulk->userdata; - if (waiter) { - waiter->actual =3D bulk->actual; - complete(&waiter->event); - } - spin_unlock(&service->state->bulk_waiter_spinlock); - } else if (bulk->mode =3D=3D VCHIQ_BULK_MODE_CALLBACK) { - enum vchiq_reason reason =3D - get_bulk_reason(bulk); - status =3D make_service_callback(service, reason, NULL, - bulk->userdata); - if (status =3D=3D -EAGAIN) - break; - } + status =3D service_notify_bulk(service, bulk); + if (status =3D=3D -EAGAIN) + break; } =20 queue->remove++; --=20 2.45.2 From nobody Wed Nov 27 06:42:06 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 086A1218D98 for ; Fri, 11 Oct 2024 12:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648634; cv=none; b=krh5yxCM8mXVj4KKezZDiweG68XrAAHhKFFm6Y2RDsDAAAFyuPUOfGCRB5qXPNGSMo430WnlxPGhx8ZLhHlYslAGNKKtzZ9cgORLr+2QozcI4V5Pv9CcXGtG7YwUs6uM152kBsygg4y1uUKRNOdABtuxsmIkKjuhoXsOygfKBB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648634; c=relaxed/simple; bh=K8/PYdHZ3L7Li1BEbSRjHfmt4+8f7SQOKzrR14S2wCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eAE4BVsmpkYQ35ofdra8Dc0EqSxS3N6arzWI7iI+I4E1q7/R8UUcZo7k+QROejWgDJIYQ1inNjti0YwGIBdwTZ+Il8HAZuQX97CsQSVX3MkRLqcRu2eoiBbQda5eyNPod/W/PWmXDg1Y8jRIIk1o2rlwo8JqCqxER1aHnETioyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=vWFb19TG; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vWFb19TG" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E74ECDB; Fri, 11 Oct 2024 14:08:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728648533; bh=K8/PYdHZ3L7Li1BEbSRjHfmt4+8f7SQOKzrR14S2wCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vWFb19TGiDy+x4oPopwjeNyVebQ2cGv2ywUZlGnVpiK7gAqa8iPFT7TmrXxmrV7V7 v8tAFb58YCbeNkxYfb3KNf8YCdmUq1xUAwU1V/oGj3StjSz0HlvkHK1kT6KPVzjxr0 3bEqFMPYr47qdjlvma0iMhSB6krTpJrXc1tEE0eE= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Umang Jain Subject: [PATCH v2 5/6] staging: vchiq_core: Lower indentation in parse_open() Date: Fri, 11 Oct 2024 17:39:09 +0530 Message-ID: <20241011120910.74045-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011120910.74045-1-umang.jain@ideasonboard.com> References: <20241011120910.74045-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the service is not in VCHIQ_SRVSTATE_LISTENING state, it is implied that the message is dealt with and parse_open() should return. If this is the case, simply jump the code flow to return site using 'goto done;' statement. This helps to lower the indentation of if (service->srvstate =3D=3D VCHIQ_SRVSTATE_LISTENING) conditional branch. No functional changes intended in this patch. Signed-off-by: Umang Jain Reviewed-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_core.c | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 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 5509f8b1061a..135b7b9b01ee 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1829,8 +1829,10 @@ static int parse_open(struct vchiq_state *state, struct vchiq_header *header) { const struct vchiq_open_payload *payload; + struct vchiq_openack_payload ack_payload; struct vchiq_service *service =3D NULL; int msgid, size; + int openack_id; unsigned int localport, remoteport, fourcc; short version, version_min; =20 @@ -1865,34 +1867,36 @@ parse_open(struct vchiq_state *state, struct vchiq_= header *header) } service->peer_version =3D version; =20 - if (service->srvstate =3D=3D VCHIQ_SRVSTATE_LISTENING) { - struct vchiq_openack_payload ack_payload =3D { - service->version - }; - int openack_id =3D MAKE_OPENACK(service->localport, remoteport); + if (service->srvstate !=3D VCHIQ_SRVSTATE_LISTENING) + goto done; =20 - if (state->version_common < - VCHIQ_VERSION_SYNCHRONOUS_MODE) - service->sync =3D 0; + ack_payload.version =3D service->version; + openack_id =3D MAKE_OPENACK(service->localport, remoteport); =20 - /* Acknowledge the OPEN */ - if (service->sync) { - if (queue_message_sync(state, NULL, openack_id, memcpy_copy_callback, - &ack_payload, sizeof(ack_payload)) =3D=3D -EAGAIN) - goto bail_not_ready; + if (state->version_common < VCHIQ_VERSION_SYNCHRONOUS_MODE) + service->sync =3D 0; =20 - /* The service is now open */ - set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); - } else { - if (queue_message(state, NULL, openack_id, memcpy_copy_callback, - &ack_payload, sizeof(ack_payload), 0) =3D=3D -EINTR) - goto bail_not_ready; + /* Acknowledge the OPEN */ + if (service->sync) { + if (queue_message_sync(state, NULL, openack_id, + memcpy_copy_callback, + &ack_payload, + sizeof(ack_payload)) =3D=3D -EAGAIN) + goto bail_not_ready; =20 - /* The service is now open */ - set_service_state(service, VCHIQ_SRVSTATE_OPEN); - } + /* The service is now open */ + set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); + } else { + if (queue_message(state, NULL, openack_id, + memcpy_copy_callback, &ack_payload, + sizeof(ack_payload), 0) =3D=3D -EINTR) + goto bail_not_ready; + + /* The service is now open */ + set_service_state(service, VCHIQ_SRVSTATE_OPEN); } =20 +done: /* Success - the message has been dealt with */ vchiq_service_put(service); return 1; --=20 2.45.2 From nobody Wed Nov 27 06:42:06 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 729312194AC for ; Fri, 11 Oct 2024 12:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648637; cv=none; b=iKhIfut+K8ua/12/XhMj+DpOB/6rvJBU34jAbRB98NN45a0XDc6xOUKJmltOfsIQujfyAFhmiNMH/v9DghOAcdGTXSlQh3oVOaUCZ4ARbKbY9wVqmeEZnVcOpkhhTCWatDZd/TCx0gaCgVER4wIyfPSco8CQht5tiByM585ZU80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728648637; c=relaxed/simple; bh=8lOj1aYnprRGk3+3bdbZuZ5MZEhtNLGjYMC9xY60S3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l9y8y+2OK3swbGoYA7lKilRxBiUiiVXBvsJh3Kq4lfFq7crMyDpc7j6k7ESerJNGEDP3QFl2WJsofj2LeyhCQctG0fTh9TLWg3y9RjZH1eAdw7R3jYaOjXADBlbWiyXCop6ylOIqbfI3QmYxZ9zCKePAe3iltClq1UM3yE7Fw0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=bn2TPZx8; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bn2TPZx8" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 77C45D8B; Fri, 11 Oct 2024 14:08:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728648535; bh=8lOj1aYnprRGk3+3bdbZuZ5MZEhtNLGjYMC9xY60S3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bn2TPZx8FRU6tC4x7WIXmFDAt3otB1OLutN2kJ5AOKcxKqK5Audr8OA4LVgsqPvSo C+mx6jp9LpQLs9eUHHJ8yhygXylPd5AD9QvGx4iyr8TvAuHddHHkN1/o8+UJZrD+Tl udK/dOxVHDl7JQ7PtUyqq5QtFiEOy1QuzzAp8kf4= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Umang Jain Subject: [PATCH v2 6/6] staging: vchiq_core: Lower indentation in vchiq_close_service_internal Date: Fri, 11 Oct 2024 17:39:10 +0530 Message-ID: <20241011120910.74045-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011120910.74045-1-umang.jain@ideasonboard.com> References: <20241011120910.74045-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reduce indentation of the conditional nesting in vchiq_close_service_internal() switch case by checking the error paths first and break early. This helps to reduce conditional branching and reduce indentation levels. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_core.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 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 135b7b9b01ee..7c9ecf7bcb3d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3168,19 +3168,21 @@ vchiq_close_service_internal(struct vchiq_service *= service, int close_recvd) if (close_recvd) { dev_err(state->dev, "core: (1) called in state %s\n", srvstate_names[service->srvstate]); - } else if (is_server) { - if (service->srvstate =3D=3D VCHIQ_SRVSTATE_LISTENING) { - status =3D -EINVAL; - } else { - service->client_id =3D 0; - service->remoteport =3D VCHIQ_PORT_FREE; - if (service->srvstate =3D=3D VCHIQ_SRVSTATE_CLOSEWAIT) - set_service_state(service, VCHIQ_SRVSTATE_LISTENING); - } - complete(&service->remove_event); - } else { + break; + } else if (!is_server) { vchiq_free_service_internal(service); + break; + } + + if (service->srvstate =3D=3D VCHIQ_SRVSTATE_LISTENING) { + status =3D -EINVAL; + } else { + service->client_id =3D 0; + service->remoteport =3D VCHIQ_PORT_FREE; + if (service->srvstate =3D=3D VCHIQ_SRVSTATE_CLOSEWAIT) + set_service_state(service, VCHIQ_SRVSTATE_LISTENING); } + complete(&service->remove_event); break; case VCHIQ_SRVSTATE_OPENING: if (close_recvd) { --=20 2.45.2