From nobody Wed Nov 27 04:40:37 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 B28C81E495 for ; Sun, 13 Oct 2024 11:21:39 +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=1728818501; cv=none; b=st/03DWxo8/syohJ54nn5PXjZ9X5m6i7vYUuVpwJ5gX6MYF+RqIe19W7Mu8eg4InZ1/ejsZA5iUirlSoW+dUCBl8nefHa5jDW4eGZZ/3gzn8yM72OyR6csn23tNJpnxWwySNPjlWfb/d7nq1yVKYjpgmUBI1D0PoesAB2+QHssc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728818501; c=relaxed/simple; bh=HPzlE9sh1djReKfpWW1YtSaIElNq0n+B+WspYQFZr6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KjBXmrz86cJ+LTWKKmV1VKVCxG6KmX8U3tw0wNgWSrEH0pkLRcTDec8XlX8gzBTSHwchE2VZK3nqkbDOtoDI6uHsvCPPIQd3fv4W1kJ5qmEm9OEfHzycURPr8Ws/j+Y7iju5WYv37N0j3xBNU8kzyR+a64Jq7CbRFUlOuvoxhdA= 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=vYw3yhO2; 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="vYw3yhO2" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F24519EC; Sun, 13 Oct 2024 13:19:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728818397; bh=HPzlE9sh1djReKfpWW1YtSaIElNq0n+B+WspYQFZr6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vYw3yhO26Iu/LwpbMZ1oARAK0UNzWdZqnRiKj+TIRX6iI2/xwE5iKWTmaFXpZR+Gd 4NeY/L4s3kLtsDpKsxBnTGDnGlk2XHbhjgcFE639FC8VoZHMPFZs8Hup8qr06/g3sY q3I/e5YKtUfBXO6nLNsCttwMjc3dSAuTy49DNklY= 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 v4 1/6] staging: vchiq_core: Locally cache cache_line_size information Date: Sun, 13 Oct 2024 16:51:23 +0530 Message-ID: <20241013112128.397249-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241013112128.397249-1-umang.jain@ideasonboard.com> References: <20241013112128.397249-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 Reviewed-by: Dan Carpenter --- .../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 04:40:37 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 772F213F42A for ; Sun, 13 Oct 2024 11:21:41 +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=1728818502; cv=none; b=L8tnLA5Iwh/XKNW3D5PpJQcRYVb3xEEtgZKay4SlmLMKzJ7WkKSVUXvWnY9cfDTGogcTY8T4gxZ5m5RzKaV/Mtv8Dzh18BpPk30yIgeZkcZfKuJzg/nNYBdfkGq0PrNnLFnLrSHA3UOc/YQxBBPP+fQIGOIbLJZEn2/SR4wpSOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728818502; c=relaxed/simple; bh=WBqPaPeDJDpOXJCYWiEMmcPkk6BJUzfDh0i0SctEqUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A/T3y3ps/NOfABh7Oc98x8jUteXdSOjd6IGBX6+cZuAeZndToHYg8ubg9Iysj/GrnX2aroMlNL+phMxWh7aHpJIkJFH6hIwENT5kU5fNdE6M5WOb/IgMFqdX9EMEGfhqEmVx6O78sOj4h/44CBmEd4+meCedONi/MkvytjMYBXI= 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=CHoqoehg; 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="CHoqoehg" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 36B5FA06; Sun, 13 Oct 2024 13:19:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728818400; bh=WBqPaPeDJDpOXJCYWiEMmcPkk6BJUzfDh0i0SctEqUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CHoqoehgZchFDhrfYhe69aLVPhbScnTq53qGu/K8cHxy8nAn7BBqi7OLCEewnUJcD g4ZrJKH8k3C2SyONOJ7L8VrfoTZ4s2saALEfOVm/pw+d80Gyfv8gKICqzDbInLpTht +q1gOJA2OC3qMBdRPHSEHKyAcs9hN/D8BwAalo8g= 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 v4 2/6] staging: vchiq_core: Do not log debug in a separate scope Date: Sun, 13 Oct 2024 16:51:24 +0530 Message-ID: <20241013112128.397249-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241013112128.397249-1-umang.jain@ideasonboard.com> References: <20241013112128.397249-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 Reviewed-by: Dan Carpenter --- .../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 04:40:37 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 70788143C5D for ; Sun, 13 Oct 2024 11:21:43 +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=1728818504; cv=none; b=WbMluGURSeWYKyMt4YGDO+DKVyzj8mbIVqpxwiy2MwbbcEpY84tjeTRv8fYmJ9GGr8ORqiNavsW5s+u9yscpppr5LgsIvZZAGIFFxVvecyWHOML19M8OXZy0cXriPV0tc6wdF8z671RDvCRyaZNbSm8rswrpH/H38JW9fRr6BH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728818504; c=relaxed/simple; bh=ynOxMnbXos2NXkFd5V5zZmg92ZIYEBr+8vmtUcjRTxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ABDk3QkAa5S0hbWYKFuUpnCn9UqsSZhlxAtoS5ohDCTgtwTfD4EZjY6W2jgst/ROVw1HF6XQuMiVDv/9sU/o3bz20t4vr58TW72h24YTrEIoOnR4odNJ63gYlvDAyqQV7C4LVzXQq/xsgq9BIUousTmcss3y+XsVyZ21CVnTjkE= 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=CCxGhpT6; 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="CCxGhpT6" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7059EE7C; Sun, 13 Oct 2024 13:20:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728818402; bh=ynOxMnbXos2NXkFd5V5zZmg92ZIYEBr+8vmtUcjRTxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CCxGhpT6f1QG4SGaoVACtco3Q/MHIDbDjfR06nlHNLSCYbkUDCST1TVIrcZ69EvtO OT6SByUBnpPwN/n/IbqrUx43GoToavYdDe/FDm65HvW9wEnGyngvPjQ+knhw7aS6gw BBuVV+UoecsUlkxD7ubJLXzEpqHUoTIHN3Pkriq4= 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 v4 3/6] staging: vchiq_core: Indent copy_message_data() on a single line Date: Sun, 13 Oct 2024 16:51:25 +0530 Message-ID: <20241013112128.397249-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241013112128.397249-1-umang.jain@ideasonboard.com> References: <20241013112128.397249-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 Reviewed-by: Dan Carpenter --- .../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 04:40:37 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 BADC4145B2D for ; Sun, 13 Oct 2024 11:21:45 +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=1728818507; cv=none; b=JjwGDBfa57CcFEgraYdbYZfkES1AFMhvPXdXtUM8jIZsnTT4oreGsHVgIPVY7+N1nHtjaHRvcXMQ3p8PYgWg5tvd/841EdDDrzWR1QdpI0BARNP1iss6akY1oEValYOT7qSNaDdiFPL9QiYvKng/t/4/lIAh8AKnXmh27Gyem/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728818507; c=relaxed/simple; bh=ksnZnuSUTgdb9waIQ/ooIx0Ymbh3Ba5Bc6L4/3YnmzA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sOsNRGFnWLAUXSVR/d8ivxmLq+ElNDU4JFB60JcNL2/sibxHbRP26bnbY7A2T54VXPqM4TYLo79fjn66v9E/xRkYY0XqLqDW94Q0CDBEHufTqd+ldQotpbcSFA+sn8m29YlOyYObq4X1qZ2FRL8dsbw+owVmmB3QFgv2fWxaPyg= 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=W8xU7gJ5; 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="W8xU7gJ5" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A57499EC; Sun, 13 Oct 2024 13:20:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728818404; bh=ksnZnuSUTgdb9waIQ/ooIx0Ymbh3Ba5Bc6L4/3YnmzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8xU7gJ5dgDUkPxUTx7GfzGBAv6NTqQ1dCAjGzONb7Sru0h2ZggRycOpT7jOqhc1b yDkwNV0uZ6JgqZ4DKR74DRILPRakUvpwPoD+Ud96oRTrte+KpzwFtMR64DuKhqzuRv eT1Od3Qso1hXyYhqGcpvlXUqRXPaR9L8BK9HUXKs= 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 v4 4/6] staging: vchiq_core: Refactor notify_bulks() Date: Sun, 13 Oct 2024 16:51:26 +0530 Message-ID: <20241013112128.397249-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241013112128.397249-1-umang.jain@ideasonboard.com> References: <20241013112128.397249-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 Reviewed-by: Kieran Bingham Reviewed-by: Dan Carpenter --- .../interface/vchiq_arm/vchiq_core.c | 71 +++++++++++-------- 1 file changed, 40 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..d7ddbc97207a 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,43 @@ 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) +{ + 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); + + return make_service_callback(service, reason, NULL, + bulk->userdata); + } + + return 0; +} + /* 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 +1370,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 04:40:37 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 1B6101465B1 for ; Sun, 13 Oct 2024 11:21:47 +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=1728818509; cv=none; b=r4l51kQHkT3HRrL5wA/o1zD1OV3Usj4KdNoRgStQYl6fYvU8+qL9glDwJnlcY6R/LMQO3HMfbwkl+8LrsDt+CSP3VcJU6Gs4yrzHV4wXvWLYpuv6LgdypokX/7WCVYH9Rkmy2iuWFLlrDdTVSucpfrl2dv+BoVSyvdyu3ent6s8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728818509; c=relaxed/simple; bh=FbImpcHzo+priTO3HSnT8Fme67TzQ8Mly/3CasKnaYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z3lNhDS4g0swuVLovYNm1Uf5wco19HNUSANg4tIB3G/g96w5hlwJ6l2RwEORILJkYX8AtqxxJGLa+snn12wR+oDyKeaajYHJjOujaN2fz1DvfnEeuM38jW2IIJYCEH2gJdOu+EEwxdw3DXgUOeFpVgW2NnMJazK4KQ1K60cWGTs= 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=uOYW48eh; 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="uOYW48eh" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E14F582E; Sun, 13 Oct 2024 13:20:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728818406; bh=FbImpcHzo+priTO3HSnT8Fme67TzQ8Mly/3CasKnaYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uOYW48ehfzjQ9rtwlDoEj0y1mMwvU5+yLQdrXjtjwFh6RbmXu7WmfOa+TROqMZ5Ga rgnDLR7HwgupW0TwFsoW+XRYc7CaG5JXorV/8UT4EdHfOX4jMCPTcawf+l9u0Ywqy7 6wTBjpTkGQtIDtNr+68HVcfFLB2WFMk1qb4jt7NY= 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 v4 5/6] staging: vchiq_core: Lower indentation in parse_open() Date: Sun, 13 Oct 2024 16:51:27 +0530 Message-ID: <20241013112128.397249-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241013112128.397249-1-umang.jain@ideasonboard.com> References: <20241013112128.397249-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 Reviewed-by: Dan Carpenter --- .../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 d7ddbc97207a..36f08f078564 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1824,8 +1824,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 @@ -1860,34 +1862,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 04:40:37 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 21B2A146A62 for ; Sun, 13 Oct 2024 11:21:50 +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=1728818511; cv=none; b=BQJmQutpgSy8GRE5GF+1eKa1GW2Hxqu9/+aAnwuPcGjT7XsYC5+xK+cO+qTqVbIY0o35/6lliild45tSMLUd7hzppjkTk4HzIYJzTlAESWUFHCdcj8bvmaxKzpvO8Bgf5bp0cdwVvclGSQf8vUJZonD8n3bq1aiSAiH88f/WK7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728818511; c=relaxed/simple; bh=gS6DbTXaVFqTwbbf8NQXEgOqBrparLUJCPWHfcZcNlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hb8cF5a8+YV0/sUTMmYcv6klqqrMDgxodsFR+3Q93pb6iRbdropSJE7Vwp97mzKpxucO2+UG1hQnShfsDQwK0Qn7cIz51l5SspJPIgRne6mFt1bazfD03VSR6Osn/c8gpLP+hs+dsG3tMjJLInSudlt1RnVLFnTPbPR1h3hgupE= 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=og26mZeB; 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="og26mZeB" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 29415A06; Sun, 13 Oct 2024 13:20:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728818409; bh=gS6DbTXaVFqTwbbf8NQXEgOqBrparLUJCPWHfcZcNlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=og26mZeBEHJ0xo3oWjPowkxPyL1hEons2aKPaWQHlXwaDMAvpM/tU2DI2UNy+SxBO m9IpAre76sK+ZjbLeKPvDdyqsGyanHk/IlD8rZzDjZdwlPrJwE3W8lELKWCrASs1E0 RLJD3crFyR/qnkPM2LMiOrL2bpuGHOAMTCKpkxbM= 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 v4 6/6] staging: vchiq_core: Lower indentation in vchiq_close_service_internal Date: Sun, 13 Oct 2024 16:51:28 +0530 Message-ID: <20241013112128.397249-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241013112128.397249-1-umang.jain@ideasonboard.com> References: <20241013112128.397249-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 Reviewed-by: Dan Carpenter --- .../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 36f08f078564..3d347b425f20 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3163,19 +3163,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