From nobody Tue Nov 26 13:17:34 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 96D081DE2DD for ; Thu, 17 Oct 2024 13:36:53 +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=1729172218; cv=none; b=hTENnJ1Dr02IHNNKLLhItdniZpNwRjMw/LM4VErjGm344qRuPzjEz4ujWNcfIVxfGFYbEnrqTZhRcI4fQ4v3Zl+h9ytGKxhEqYof+QW9EPRmdMh+jRFeghQIEpkNm3HLsKWVLjyEcMrVUnoCuiN8B+S5hGR0INUudrHPPGVbZkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729172218; c=relaxed/simple; bh=VVbdhvswgcK0hNwOCk9Bu1h2AYBoxHKL9pS7jwGQ1eQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IiD3yNT2XEqKU3vKrns95tIz971yPcYuFzKq6y5pf4PLxACjLJswPSAoUJUuVLhztCAsmJljzpXie2aDyhQCwO97wu9QECXxg2vZVv2O/CyVGG3pEe8uRqgKFm+gghhlm/n92m4OTB00WzI87b3hjnqiq+U93CNQ63IWAKNgm4I= 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=aTsekc2Z; 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="aTsekc2Z" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E8D54827; Thu, 17 Oct 2024 15:35:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729172102; bh=VVbdhvswgcK0hNwOCk9Bu1h2AYBoxHKL9pS7jwGQ1eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aTsekc2Zd5wf34cDRNnf+deotirBwDGPBXhkcDPfGzlf7OcMWc8ryPij7ge94cxXU mVLXeq4ycV0a3nAzaPoNFKssy2RP2m85Q19enOvqxdNO4RJhSFtawWnw+l9AiGj3sd fuXWCIKfUqyKmhucXU3+hsezKTK/rvD4LAQVRZVM= 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, Dan Carpenter , Kieran Bingham , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain Subject: [PATCH 1/6] staging: vchiq_core: Subsume 'offset' in struct vchiq_bulk Date: Thu, 17 Oct 2024 19:06:24 +0530 Message-ID: <20241017133629.216672-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017133629.216672-1-umang.jain@ideasonboard.com> References: <20241017133629.216672-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" Subsume offset and uoffset inside struct vchiq_bulk instead of open-coding them in vchiq_prepare_bulk_data() function. It helps in reducing function parameters and can be easily retrieved from the struct vchiq_bulk pointer for creating pagelist. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_core.c | 27 ++++++++++--------- .../interface/vchiq_arm/vchiq_core.h | 2 ++ 2 files changed, 17 insertions(+), 12 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 3d347b425f20..7c6f09a9d917 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1482,7 +1482,7 @@ is_adjacent_block(u32 *addrs, dma_addr_t addr, unsign= ed int k) * cached area. */ static struct vchiq_pagelist_info * -create_pagelist(struct vchiq_instance *instance, char *buf, char __user *u= buf, +create_pagelist(struct vchiq_instance *instance, struct vchiq_bulk *bulk, size_t count, unsigned short type) { struct vchiq_drv_mgmt *drv_mgmt; @@ -1503,10 +1503,10 @@ create_pagelist(struct vchiq_instance *instance, ch= ar *buf, char __user *ubuf, =20 drv_mgmt =3D dev_get_drvdata(instance->state->dev); =20 - if (buf) - offset =3D (uintptr_t)buf & (PAGE_SIZE - 1); + if (bulk->offset) + offset =3D (uintptr_t)bulk->offset & (PAGE_SIZE - 1); else - offset =3D (uintptr_t)ubuf & (PAGE_SIZE - 1); + offset =3D (uintptr_t)bulk->uoffset & (PAGE_SIZE - 1); num_pages =3D DIV_ROUND_UP(count + offset, PAGE_SIZE); =20 if ((size_t)num_pages > (SIZE_MAX - sizeof(struct pagelist) - @@ -1554,14 +1554,14 @@ create_pagelist(struct vchiq_instance *instance, ch= ar *buf, char __user *ubuf, pagelistinfo->scatterlist =3D scatterlist; pagelistinfo->scatterlist_mapped =3D 0; =20 - if (buf) { + if (bulk->offset) { unsigned long length =3D count; unsigned int off =3D offset; =20 for (actual_pages =3D 0; actual_pages < num_pages; actual_pages++) { struct page *pg =3D - vmalloc_to_page((buf + + vmalloc_to_page(((unsigned int *)bulk->offset + (actual_pages * PAGE_SIZE))); size_t bytes =3D PAGE_SIZE - off; =20 @@ -1578,8 +1578,9 @@ create_pagelist(struct vchiq_instance *instance, char= *buf, char __user *ubuf, } /* do not try and release vmalloc pages */ } else { - actual_pages =3D pin_user_pages_fast((unsigned long)ubuf & PAGE_MASK, nu= m_pages, - type =3D=3D PAGELIST_READ, pages); + actual_pages =3D + pin_user_pages_fast((unsigned long)bulk->uoffset & PAGE_MASK, num_pages, + type =3D=3D PAGELIST_READ, pages); =20 if (actual_pages !=3D num_pages) { dev_dbg(instance->state->dev, "arm: Only %d/%d pages locked\n", @@ -1739,12 +1740,12 @@ free_pagelist(struct vchiq_instance *instance, stru= ct vchiq_pagelist_info *pagel } =20 static int -vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk= *bulk, void *offset, - void __user *uoffset, int size, int dir) +vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk= *bulk, + int size, int dir) { struct vchiq_pagelist_info *pagelistinfo; =20 - pagelistinfo =3D create_pagelist(instance, offset, uoffset, size, + pagelistinfo =3D create_pagelist(instance, bulk, size, (dir =3D=3D VCHIQ_BULK_RECEIVE) ? PAGELIST_READ : PAGELIST_WRITE); @@ -3070,8 +3071,10 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_serv= ice *service, bulk->userdata =3D userdata; bulk->size =3D size; bulk->actual =3D VCHIQ_BULK_ACTUAL_ABORTED; + bulk->offset =3D offset; + bulk->uoffset =3D uoffset; =20 - if (vchiq_prepare_bulk_data(service->instance, bulk, offset, uoffset, siz= e, dir)) + if (vchiq_prepare_bulk_data(service->instance, bulk, size, dir)) goto unlock_error_exit; =20 /* 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 400472f1aa06..05ef0666c2b3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -120,6 +120,8 @@ struct vchiq_bulk { void *remote_data; int remote_size; int actual; + void *offset; + void __user *uoffset; }; =20 struct vchiq_bulk_queue { --=20 2.45.2 From nobody Tue Nov 26 13:17:34 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 158571DE3AC for ; Thu, 17 Oct 2024 13:36:55 +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=1729172221; cv=none; b=SbO0MP/fKJIkiBrm4WbDuyFdn5J1o8IT2AzN4/i0CP1awR/1EtAHZuiij88l9iKuXxlMEjydySM9MDJVvTUNMJKdmB7arUNG322DqZFBtDZn5U/dAq+a7N1TlQgJ7x0vI0KD/QvnMeDXfoBEXC4B5PIdIEfLJjBmLyQIdR3jJUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729172221; c=relaxed/simple; bh=EqLwRX+3J2XHSyc5StHZnS7+pkIcemBGni0Mlp9KqUs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j5YYph8mZJEk4r7JMwgDPf5tYJyiOjG4bxTemc3waQbjYYAhjFFPVMfjAvhMGh0JPt45F9xby3fGZO+/X0V9X32vePpuQWHYgG7gIHRtUaNPj2N1C3+xVDdDkg41MNAkIkpkIdpcmh39/wSH1LUOEd535CRJasOCmH9fcfU8RV4= 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=jeVauZPE; 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="jeVauZPE" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 363641014; Thu, 17 Oct 2024 15:35:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729172105; bh=EqLwRX+3J2XHSyc5StHZnS7+pkIcemBGni0Mlp9KqUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jeVauZPE3eVeXIH3E0eI+TpcpsbCnzB72b+bMD5lG3s8JKvW+NFxFD7NOb6CvqCZj YkVm14DFh6GBWwD/oCRc90N+tVzXn6gWCMUoSEfY5UiEgrkB/rE2wwNQy1dqNgS0Tv ZcizDZSdluNmSidsz4BtIIBNPeOC5HAMk6rt7zPw= 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, Dan Carpenter , Kieran Bingham , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain Subject: [PATCH 2/6] staging: vchiq_core: Simplify bulk data preparatory functions Date: Thu, 17 Oct 2024 19:06:25 +0530 Message-ID: <20241017133629.216672-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017133629.216672-1-umang.jain@ideasonboard.com> References: <20241017133629.216672-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" Two functions create_pagelist() and vchiq_prepare_bulk_data() open code bulk data arguments ('size' and 'dir') in their function signatures which can easily be obtained by struct vchiq_bulk pointer. Retrieve the arguments from vchiq_bulk pointer instead and reduce the number of arguments passed in create_pagelist() and vchiq_bulk_prepare_data(). No functional changes intended in this patch. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 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 7c6f09a9d917..62356a165696 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1482,8 +1482,7 @@ is_adjacent_block(u32 *addrs, dma_addr_t addr, unsign= ed int k) * cached area. */ static struct vchiq_pagelist_info * -create_pagelist(struct vchiq_instance *instance, struct vchiq_bulk *bulk, - size_t count, unsigned short type) +create_pagelist(struct vchiq_instance *instance, struct vchiq_bulk *bulk) { struct vchiq_drv_mgmt *drv_mgmt; struct pagelist *pagelist; @@ -1497,6 +1496,9 @@ create_pagelist(struct vchiq_instance *instance, stru= ct vchiq_bulk *bulk, int dma_buffers; unsigned int cache_line_size; dma_addr_t dma_addr; + size_t count =3D bulk->size; + unsigned short type =3D (bulk->dir =3D=3D VCHIQ_BULK_RECEIVE) + ? PAGELIST_READ : PAGELIST_WRITE; =20 if (count >=3D INT_MAX - PAGE_SIZE) return NULL; @@ -1740,15 +1742,11 @@ free_pagelist(struct vchiq_instance *instance, stru= ct vchiq_pagelist_info *pagel } =20 static int -vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk= *bulk, - int size, int dir) +vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk= *bulk) { struct vchiq_pagelist_info *pagelistinfo; =20 - pagelistinfo =3D create_pagelist(instance, bulk, size, - (dir =3D=3D VCHIQ_BULK_RECEIVE) - ? PAGELIST_READ - : PAGELIST_WRITE); + pagelistinfo =3D create_pagelist(instance, bulk); =20 if (!pagelistinfo) return -ENOMEM; @@ -3074,7 +3072,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, bulk->offset =3D offset; bulk->uoffset =3D uoffset; =20 - if (vchiq_prepare_bulk_data(service->instance, bulk, size, dir)) + if (vchiq_prepare_bulk_data(service->instance, bulk)) goto unlock_error_exit; =20 /* --=20 2.45.2 From nobody Tue Nov 26 13:17:34 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 DEF051DE3B0 for ; Thu, 17 Oct 2024 13:36:59 +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=1729172223; cv=none; b=WAZFXtf2V6W2vK+N2FRzJh3oUp/WhIYiVh559tl09DZkK63/Z35RMmmxSUJDLGeehhX8YG/1gPUayusJ5vfc8g6u58R7eogQlOXHtpX7Jr4HKfd0AnCmbSNSTsA6Ez96o7jWbDy3HpFopOqLXn2yBY4OFLysd0aImuyQ/klsSfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729172223; c=relaxed/simple; bh=TL6ZIgNYIKhO2ZRFDwsreyN+JUnPagCHOgWraaahB/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dRK68LNmjI3RkS/JZasvLZO/KJiM/aR6aCtRolAK1HihQ1m6WuflyNZU6gWRLsCAke//xVJb9sMwJZDAwSFa3XJ/xDoIiPM/AEmLXW52KIzGZ3gAvZFlejFXF1qLSQ2PDhf8oXIeRZyInvi/q8heMoHZf2ZPpTS9M5LXMB810DE= 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=wlel4X1+; 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="wlel4X1+" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7EC6FFF1; Thu, 17 Oct 2024 15:35:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729172107; bh=TL6ZIgNYIKhO2ZRFDwsreyN+JUnPagCHOgWraaahB/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wlel4X1+RK/6mX1msusJlIhm8u66RAg5v0vasnIZC2rml/JhCCct09VJ7cEEIpcs4 7BU9fFiI0qsuG7KTwt0gmWzmCbPKSqyk9TaCLLsHVAI51wrKc9Z74JQ0X73BnwQ8Pw QPYCTx9K//mfBAgpkuiDxkHb5a9KPVOTWm+4MtEw= 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, Dan Carpenter , Kieran Bingham , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain Subject: [PATCH 3/6] staging: vc04_services: Simplify block bulk transfer code paths Date: Thu, 17 Oct 2024 19:06:26 +0530 Message-ID: <20241017133629.216672-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017133629.216672-1-umang.jain@ideasonboard.com> References: <20241017133629.216672-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" Blocking bulk transfer functions tend to open-code every function parameter needed to initiate the bulk transfer. Instead of doing that, simply pass a populated struct vchiq_bulk down the function chain. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 34 +++++++++++++------ .../interface/vchiq_arm/vchiq_core.c | 12 +++---- .../interface/vchiq_arm/vchiq_core.h | 3 +- .../interface/vchiq_arm/vchiq_dev.c | 11 +++--- 4 files changed, 37 insertions(+), 23 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 af623ad87c15..90b5ce5ee429 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -107,8 +107,8 @@ struct vchiq_arm_state { }; =20 static int -vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int= handle, void *data, - unsigned int size, enum vchiq_bulk_dir dir); +vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int= handle, + struct vchiq_bulk *bulk_params); =20 static irqreturn_t vchiq_doorbell_irq(int irq, void *dev_id) @@ -491,6 +491,7 @@ int vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, = const void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { + struct vchiq_bulk bulk_params =3D {}; int ret; =20 switch (mode) { @@ -501,8 +502,12 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, u= nsigned int handle, const VCHIQ_BULK_TRANSMIT); break; case VCHIQ_BULK_MODE_BLOCKING: - ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, siz= e, - VCHIQ_BULK_TRANSMIT); + bulk_params.offset =3D (void *)data; + bulk_params.mode =3D mode; + bulk_params.size =3D size; + bulk_params.dir =3D VCHIQ_BULK_TRANSMIT; + + ret =3D vchiq_blocking_bulk_transfer(instance, handle, &bulk_params); break; default: return -EINVAL; @@ -516,6 +521,7 @@ int vchiq_bulk_receive(struct vchiq_instance *instance,= unsigned int handle, void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { + struct vchiq_bulk bulk_params =3D {}; int ret; =20 switch (mode) { @@ -525,8 +531,12 @@ int vchiq_bulk_receive(struct vchiq_instance *instance= , unsigned int handle, size, mode, userdata, VCHIQ_BULK_RECEIVE); break; case VCHIQ_BULK_MODE_BLOCKING: - ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, siz= e, - VCHIQ_BULK_RECEIVE); + bulk_params.offset =3D (void *)data; + bulk_params.mode =3D mode; + bulk_params.size =3D size; + bulk_params.dir =3D VCHIQ_BULK_RECEIVE; + + ret =3D vchiq_blocking_bulk_transfer(instance, handle, &bulk_params); break; default: return -EINVAL; @@ -537,8 +547,8 @@ int vchiq_bulk_receive(struct vchiq_instance *instance,= unsigned int handle, EXPORT_SYMBOL(vchiq_bulk_receive); =20 static int -vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int= handle, void *data, - unsigned int size, enum vchiq_bulk_dir dir) +vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int= handle, + struct vchiq_bulk *bulk_params) { struct vchiq_service *service; struct bulk_waiter_node *waiter =3D NULL, *iter; @@ -566,7 +576,8 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl if (bulk) { /* This thread has an outstanding bulk transfer. */ /* FIXME: why compare a dma address to a pointer? */ - if ((bulk->data !=3D (dma_addr_t)(uintptr_t)data) || (bulk->size !=3D s= ize)) { + if ((bulk->data !=3D (dma_addr_t)(uintptr_t)bulk_params->data) || + (bulk->size !=3D bulk_params->size)) { /* * This is not a retry of the previous one. * Cancel the signal when the transfer completes. @@ -582,8 +593,9 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl return -ENOMEM; } =20 - ret =3D vchiq_bulk_xfer_blocking(instance, handle, data, NULL, size, - &waiter->bulk_waiter, dir); + bulk_params->userdata =3D &waiter->bulk_waiter; + + ret =3D vchiq_bulk_xfer_blocking(instance, handle, bulk_params); if ((ret !=3D -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_= waiter.bulk) { struct vchiq_bulk *bulk =3D waiter->bulk_waiter.bulk; =20 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 62356a165696..6c52827868d5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3471,11 +3471,9 @@ vchiq_remove_service(struct vchiq_instance *instance= , unsigned int handle) =20 int vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int han= dle, - void *offset, void __user *uoffset, int size, - void __user *userdata, enum vchiq_bulk_dir dir) + struct vchiq_bulk *bulk_params) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); - enum vchiq_bulk_mode mode =3D VCHIQ_BULK_MODE_BLOCKING; int status =3D -EINVAL; =20 if (!service) @@ -3484,15 +3482,17 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *ins= tance, unsigned int handle, if (service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) goto error_exit; =20 - if (!offset && !uoffset) + if (!bulk_params->offset && !bulk_params->uoffset) goto error_exit; =20 if (vchiq_check_service(service)) goto error_exit; =20 =20 - status =3D vchiq_bulk_xfer_queue_msg_killable(service, offset, uoffset, s= ize, - userdata, mode, dir); + status =3D vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offse= t, + bulk_params->uoffset, bulk_params->size, + bulk_params->userdata, bulk_params->mode, + bulk_params->dir); =20 error_exit: vchiq_service_put(service); 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 05ef0666c2b3..82d27788b10b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -501,8 +501,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instance= , unsigned int handle, =20 extern int vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int han= dle, - void *offset, void __user *uoffset, int size, - void __user *userdata, enum vchiq_bulk_dir dir); + struct vchiq_bulk *bulk); =20 extern int vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int han= dle, 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 aca237919696..8043974f8893 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -288,6 +288,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, { struct vchiq_service *service; struct bulk_waiter_node *waiter =3D NULL, *iter; + struct vchiq_bulk bulk_params =3D {}; void *userdata; int status =3D 0; int ret; @@ -303,12 +304,14 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_in= stance *instance, goto out; } =20 - userdata =3D &waiter->bulk_waiter; + bulk_params.uoffset =3D args->data; + bulk_params.mode =3D args->mode; + bulk_params.size =3D args->size; + bulk_params.dir =3D dir; + bulk_params.userdata =3D &waiter->bulk_waiter; =20 status =3D vchiq_bulk_xfer_blocking(instance, args->handle, - NULL, args->data, args->size, - userdata, dir); - + &bulk_params); } else if (args->mode =3D=3D VCHIQ_BULK_MODE_WAITING) { mutex_lock(&instance->bulk_waiter_list_mutex); list_for_each_entry(iter, &instance->bulk_waiter_list, --=20 2.45.2 From nobody Tue Nov 26 13:17:34 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 A23AE1DE4CD for ; Thu, 17 Oct 2024 13:37:03 +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=1729172229; cv=none; b=dMGbeaCoBUu91NYSp+6NkXIJL0WoR8a6QJzIHG70ticSkR3CugVnMC3BPPjbkDRm7eISjfnCLMzkAM4JPSPJC7TwkM75KmzLKejkKafuod7VHwHG+SaidIJoEnVYF7kynyj5Dp4x2GwcwjAylH6Lt0ozScS6EBKOn61KCPIIrGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729172229; c=relaxed/simple; bh=7FmiJpS58px7WK9bLlNddRfh4cPoo5zN7ciSpgUvPHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BJj18cPYOEhmOm5r57/bq/2LC9BcZ2u183977HomfH4aMlmDCwOTrZBesgJyaXdKvywjV4FsFVtail9chJEbuGiQUZEL3lYuJIH2FPy46VA2B4js0aZvr7eDKaYzL1gqZFVoekiv+LoVI43KqoNM/Efx4lpnJVESajHHj7X+B4w= 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=Pt4HuMel; 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="Pt4HuMel" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C73FC12E9; Thu, 17 Oct 2024 15:35:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729172109; bh=7FmiJpS58px7WK9bLlNddRfh4cPoo5zN7ciSpgUvPHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pt4HuMeloxDnodpvy50inHq7YbhniLx14a8r3BEmbwO5kwE5PjJJKfnHGrd6n8Q9P 7uipWG6vQnKiSf61tXlOQnkDlwc4HozYtggFA/Ij7ByuhNGl5hQqtvWQekXadVDL4J QSm4PO68ZRcSDf1/raoEjaOpZh/YBa3X0HlSOq1M= 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, Dan Carpenter , Kieran Bingham , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain Subject: [PATCH 4/6] staging: vc04_services: Simplify (no)callback bulk transfer code paths Date: Thu, 17 Oct 2024 19:06:27 +0530 Message-ID: <20241017133629.216672-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017133629.216672-1-umang.jain@ideasonboard.com> References: <20241017133629.216672-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" The (no)callback mode bulk transfer tends to open-code every function parameter needed to initiate the bulk transfer. Instead of doing that, simply pass a populated struct vchiq_bulk down the function chain. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++----- .../interface/vchiq_arm/vchiq_core.c | 15 +++++++------ .../interface/vchiq_arm/vchiq_core.h | 4 +--- .../interface/vchiq_arm/vchiq_dev.c | 12 ++++++----- 4 files changed, 31 insertions(+), 21 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 90b5ce5ee429..c2e7c2bd5071 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -497,9 +497,14 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, u= nsigned int handle, const switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: case VCHIQ_BULK_MODE_CALLBACK: - ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, - NULL, size, mode, userdata, - VCHIQ_BULK_TRANSMIT); + + bulk_params.offset =3D (void *)data; + bulk_params.mode =3D mode; + bulk_params.size =3D size; + bulk_params.userdata =3D userdata; + bulk_params.dir =3D VCHIQ_BULK_TRANSMIT; + + ret =3D vchiq_bulk_xfer_callback(instance, handle, &bulk_params); break; case VCHIQ_BULK_MODE_BLOCKING: bulk_params.offset =3D (void *)data; @@ -527,8 +532,14 @@ int vchiq_bulk_receive(struct vchiq_instance *instance= , unsigned int handle, switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: case VCHIQ_BULK_MODE_CALLBACK: - ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, NULL, - size, mode, userdata, VCHIQ_BULK_RECEIVE); + + bulk_params.offset =3D (void *)data; + bulk_params.mode =3D mode; + bulk_params.size =3D size; + bulk_params.userdata =3D userdata; + bulk_params.dir =3D VCHIQ_BULK_RECEIVE; + + ret =3D vchiq_bulk_xfer_callback(instance, handle, &bulk_params); break; case VCHIQ_BULK_MODE_BLOCKING: bulk_params.offset =3D (void *)data; 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 6c52827868d5..bb46aa20bdb4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3502,9 +3502,7 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *insta= nce, unsigned int handle, =20 int vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int han= dle, - void *offset, void __user *uoffset, int size, - enum vchiq_bulk_mode mode, void *userdata, - enum vchiq_bulk_dir dir) + struct vchiq_bulk *bulk_params) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); int status =3D -EINVAL; @@ -3512,21 +3510,22 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *ins= tance, unsigned int handle, if (!service) return -EINVAL; =20 - if (mode !=3D VCHIQ_BULK_MODE_CALLBACK && - mode !=3D VCHIQ_BULK_MODE_NOCALLBACK) + if (bulk_params->mode !=3D VCHIQ_BULK_MODE_CALLBACK && + bulk_params->mode !=3D VCHIQ_BULK_MODE_NOCALLBACK) goto error_exit; =20 if (service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) goto error_exit; =20 - if (!offset && !uoffset) + if (!bulk_params->offset && !bulk_params->uoffset) goto error_exit; =20 if (vchiq_check_service(service)) goto error_exit; =20 - status =3D vchiq_bulk_xfer_queue_msg_killable(service, offset, uoffset, - size, userdata, mode, dir); + status =3D vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offse= t, bulk_params->uoffset, + bulk_params->size, bulk_params->userdata, + bulk_params->mode, bulk_params->dir); =20 error_exit: vchiq_service_put(service); 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 82d27788b10b..186b1395d3a2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -505,9 +505,7 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *instanc= e, unsigned int handle, =20 extern int vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int han= dle, - void *offset, void __user *uoffset, int size, - enum vchiq_bulk_mode mode, void *userdata, - enum vchiq_bulk_dir dir); + struct vchiq_bulk *bulk); =20 extern void vchiq_dump_state(struct seq_file *f, struct vchiq_state *state); 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 8043974f8893..f56057e17963 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -335,12 +335,14 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_in= stance *instance, =20 status =3D vchiq_bulk_xfer_waiting(instance, args->handle, userdata); } else { - userdata =3D args->userdata; - - status =3D vchiq_bulk_xfer_callback(instance, args->handle, NULL, - args->data, args->size, - args->mode, userdata, dir); + bulk_params.uoffset =3D args->data; + bulk_params.mode =3D args->mode; + bulk_params.size =3D args->size; + bulk_params.dir =3D dir; + bulk_params.userdata =3D args->userdata; =20 + status =3D vchiq_bulk_xfer_callback(instance, args->handle, + &bulk_params); } =20 if (!waiter) { --=20 2.45.2 From nobody Tue Nov 26 13:17:34 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 48BE91DE4DC for ; Thu, 17 Oct 2024 13:37:05 +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=1729172231; cv=none; b=vECEoDcKkjW1atfe4yQW/+bHRF7Ghk0B7h6yh8bGjU533jrFfqRv3hf63Gu3TJeCUIflPKVdCjRntFCVEk+dDQhZckemJyF89DU/wno5lE1a/alq9ryh3H7sNHnqR6GVNxg/4KKmZwcflAYmD4pUdjibyMyiuA5Rgaq+Ew6nAzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729172231; c=relaxed/simple; bh=Zu496OQEDTWTNvz56oSeQb4zdJxLuEzbNXwR6ZUzPSo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pljcaTwlDUhgol9veUQdrC2JbFsBABedDeitSJpIzgIMM1BaCjcNO0OFIdXRMz1v4Xfsyiu86vEcONxBhSgSWp3/nP0LLd/FKXdSdmkYLB0bX4W2JdETI/vR5MmkCLA5z2207JzR5BQBT4bg3jo6Wxbz6L25ySF7oGHgXh0xh9I= 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=Onb+sOEv; 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="Onb+sOEv" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 19128173E; Thu, 17 Oct 2024 15:35:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729172112; bh=Zu496OQEDTWTNvz56oSeQb4zdJxLuEzbNXwR6ZUzPSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Onb+sOEvIR7BLeu7MPWWIbk8SMQeFMv7jCTh0zfpimKnRO82aiWiyzQBkhf8O7+KZ kX28kSUbZnTJArTRhpzCneVphJd0gMUvu2u8tvdhmGQRK53LtU/culAIf6fu426jy8 oMleqOzDzbMzC31svm9rFXpfWEkatoOZ4++13+7s= 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, Dan Carpenter , Kieran Bingham , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain Subject: [PATCH 5/6] staging: vchiq_core: Simplify bulk transfer queue message function Date: Thu, 17 Oct 2024 19:06:28 +0530 Message-ID: <20241017133629.216672-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017133629.216672-1-umang.jain@ideasonboard.com> References: <20241017133629.216672-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" vchiq_bulk_xfer_queue_msg_killable() is a common function between various bulk transfer code paths (blocking, callback and no-callback). These code paths were simplified earlier by passing a populated struct vchiq_bulk pointer in order to avoid open-coding the parameters required to initiate a bulk transfer. Now simplify the vchiq_bulk_xfer_queue_msg_killable() in a similar way i.e. avoid open-coding the function parameters and pass the struct vchiq_bulk pointer directly, coming from the various bulk transfer code paths. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_core.c | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 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 bb46aa20bdb4..9e56e34ca4d9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3022,29 +3022,26 @@ close_service_complete(struct vchiq_service *servic= e, int failstate) */ static int vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service, - void *offset, void __user *uoffset, - int size, void *userdata, - enum vchiq_bulk_mode mode, - enum vchiq_bulk_dir dir) + struct vchiq_bulk *bulk_params) { struct vchiq_bulk_queue *queue; struct bulk_waiter *bulk_waiter =3D NULL; struct vchiq_bulk *bulk; struct vchiq_state *state =3D service->state; - const char dir_char =3D (dir =3D=3D VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; - const int dir_msgtype =3D (dir =3D=3D VCHIQ_BULK_TRANSMIT) ? + const char dir_char =3D (bulk_params->dir =3D=3D VCHIQ_BULK_TRANSMIT) ? '= t' : 'r'; + const int dir_msgtype =3D (bulk_params->dir =3D=3D VCHIQ_BULK_TRANSMIT) ? VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; int status =3D -EINVAL; int payload[2]; =20 - if (mode =3D=3D VCHIQ_BULK_MODE_BLOCKING) { - bulk_waiter =3D userdata; + if (bulk_params->mode =3D=3D VCHIQ_BULK_MODE_BLOCKING) { + bulk_waiter =3D bulk_params->userdata; init_completion(&bulk_waiter->event); bulk_waiter->actual =3D 0; bulk_waiter->bulk =3D NULL; } =20 - queue =3D (dir =3D=3D VCHIQ_BULK_TRANSMIT) ? + queue =3D (bulk_params->dir =3D=3D VCHIQ_BULK_TRANSMIT) ? &service->bulk_tx : &service->bulk_rx; =20 if (mutex_lock_killable(&service->bulk_mutex)) @@ -3064,13 +3061,14 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_ser= vice *service, =20 bulk =3D &queue->bulks[BULK_INDEX(queue->local_insert)]; =20 - bulk->mode =3D mode; - bulk->dir =3D dir; - bulk->userdata =3D userdata; - bulk->size =3D size; + /* Initiliaze the 'bulk' slot with bulk parameters passed in. */ + bulk->mode =3D bulk_params->mode; + bulk->dir =3D bulk_params->dir; + bulk->userdata =3D bulk_params->userdata; + bulk->size =3D bulk_params->size; + bulk->offset =3D bulk_params->offset; + bulk->uoffset =3D bulk_params->uoffset; bulk->actual =3D VCHIQ_BULK_ACTUAL_ABORTED; - bulk->offset =3D offset; - bulk->uoffset =3D uoffset; =20 if (vchiq_prepare_bulk_data(service->instance, bulk)) goto unlock_error_exit; @@ -3083,7 +3081,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, =20 dev_dbg(state->dev, "core: %d: bt (%d->%d) %cx %x@%pad %pK\n", state->id, service->localport, service->remoteport, - dir_char, size, &bulk->data, userdata); + dir_char, bulk->size, &bulk->data, bulk->userdata); =20 /* * The slot mutex must be held when the service is being closed, so @@ -3489,10 +3487,7 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *inst= ance, unsigned int handle, goto error_exit; =20 =20 - status =3D vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offse= t, - bulk_params->uoffset, bulk_params->size, - bulk_params->userdata, bulk_params->mode, - bulk_params->dir); + status =3D vchiq_bulk_xfer_queue_msg_killable(service, bulk_params); =20 error_exit: vchiq_service_put(service); @@ -3523,9 +3518,7 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *insta= nce, unsigned int handle, if (vchiq_check_service(service)) goto error_exit; =20 - status =3D vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offse= t, bulk_params->uoffset, - bulk_params->size, bulk_params->userdata, - bulk_params->mode, bulk_params->dir); + status =3D vchiq_bulk_xfer_queue_msg_killable(service, bulk_params); =20 error_exit: vchiq_service_put(service); --=20 2.45.2 From nobody Tue Nov 26 13:17:34 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 3E8951DE4FA for ; Thu, 17 Oct 2024 13:37:11 +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=1729172236; cv=none; b=QthOTGrB7sbWSZWDOKK7I5LsJue8ZLJYUmhnXwH2Gmxex7H5meC9SIRsy5cOL8Vhn6eN9K8rv4Pk6JqYd2JWuK5xr8EapjPQwoX7gCazO3/1IxZYYUomrHp3dW6cCxDSkQugukpdvaqyfD9MuPP2nyZST/sQmQQkx+RAyC7/Ty0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729172236; c=relaxed/simple; bh=dS4uASWxwyiXNL8/Q5N7rvqc7RgiswAf7xz30dE+mG0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fAKVqhcD6Pw49I0c1YsggfpBEJzgZZUMYcq77rcfOIlfjrk4t0yP/PfrW0AcoqIkCJ010KU2x6N/Eowx1ykfRipW96FBTTjTUoCMh1U94MouFSV9cRUgAlgwvCCQWejTEHIaW3z+REqfGVdcV4lN5HnIyFqGrCiyI/oJrbAchq0= 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=YoEVG+BO; 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="YoEVG+BO" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 61390195A; Thu, 17 Oct 2024 15:35:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729172114; bh=dS4uASWxwyiXNL8/Q5N7rvqc7RgiswAf7xz30dE+mG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YoEVG+BOTSGL884vjYG7dq5gaa4M1CKbduLrPRFnRCRfi/k8ztEkvVyigrKVkukft 4Ne3Oi+l8CUwe9G7mJuYnj1GFrruq8eg50oLfERjRQkTf9sxDXreTD2WadzMAgz14/ QTP6mhs4lWLAx02vm4/gAAndF5+/HTDhFGMKu57Y= 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, Dan Carpenter , Kieran Bingham , Laurent Pinchart , Stefan Wahren , kernel-list@raspberrypi.com, Umang Jain Subject: [PATCH 6/6] staging: vchiq_dev: Drop userdata local pointer Date: Thu, 17 Oct 2024 19:06:29 +0530 Message-ID: <20241017133629.216672-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017133629.216672-1-umang.jain@ideasonboard.com> References: <20241017133629.216672-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" The 'userdata' local pointer can be dropped which is set to bulk_waiter. We can directly pass the waiter->bulk_waiter pointer to vchiq_bulk_xfer_waiting(). Signed-off-by: Umang Jain --- .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 f56057e17963..6a9685d9fafc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -289,7 +289,6 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, struct vchiq_service *service; struct bulk_waiter_node *waiter =3D NULL, *iter; struct vchiq_bulk bulk_params =3D {}; - void *userdata; int status =3D 0; int ret; =20 @@ -331,9 +330,9 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, } dev_dbg(service->state->dev, "arm: found bulk_waiter %pK for pid %d\n", waiter, current->pid); - userdata =3D &waiter->bulk_waiter; =20 - status =3D vchiq_bulk_xfer_waiting(instance, args->handle, userdata); + status =3D vchiq_bulk_xfer_waiting(instance, args->handle, + &waiter->bulk_waiter); } else { bulk_params.uoffset =3D args->data; bulk_params.mode =3D args->mode; --=20 2.45.2