From patchwork Thu Oct 17 13:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13840075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68E05D37491 for ; Thu, 17 Oct 2024 13:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=74Q1Z7Gfom6Ew0yL5KozDRqCrbXOjwkaM9uujqxXrmc=; b=DHcH7fSxiTHdEI841GQ+rIbAz6 FxUP89VKIY3vv3JtZS2JagqRJSsdUimbwY7ztSrtEqjj62jswkKp3ZJZVTm/sHgd/XDdfiuvx2dfm 1/KtwPCU5u49oH3EJKuBhn9OWkL4uocDBc4Q9P/+zdLu3oqceDdM6/15UrhwRbfJ13Wl8ZvINR0bp rK6icA4s4R6OscbLjuO1t4d1pev4BvNeMptm4/iQh3EW6iPzgfEy7/0jUsXGHF4TAaavaRE+DeyUH xK57cSzv9Zv/5ZNmNCzultKOFquf0WNKGXCPJlol9YOquIXqNYMSl1CV2TmcUO3db2ag8tNanAfYb 8h42C+rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Qrf-0000000Ezzd-1Ne0; Thu, 17 Oct 2024 13:48:31 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1QgJ-0000000ExN2-0UQk; Thu, 17 Oct 2024 13:36:54 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_063647_338669_902AB341 X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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, unsigned int k) * cached area. */ static struct vchiq_pagelist_info * -create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf, +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, char *buf, char __user *ubuf, drv_mgmt = dev_get_drvdata(instance->state->dev); - if (buf) - offset = (uintptr_t)buf & (PAGE_SIZE - 1); + if (bulk->offset) + offset = (uintptr_t)bulk->offset & (PAGE_SIZE - 1); else - offset = (uintptr_t)ubuf & (PAGE_SIZE - 1); + offset = (uintptr_t)bulk->uoffset & (PAGE_SIZE - 1); num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE); if ((size_t)num_pages > (SIZE_MAX - sizeof(struct pagelist) - @@ -1554,14 +1554,14 @@ create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf, pagelistinfo->scatterlist = scatterlist; pagelistinfo->scatterlist_mapped = 0; - if (buf) { + if (bulk->offset) { unsigned long length = count; unsigned int off = offset; for (actual_pages = 0; actual_pages < num_pages; actual_pages++) { struct page *pg = - vmalloc_to_page((buf + + vmalloc_to_page(((unsigned int *)bulk->offset + (actual_pages * PAGE_SIZE))); size_t bytes = PAGE_SIZE - off; @@ -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 = pin_user_pages_fast((unsigned long)ubuf & PAGE_MASK, num_pages, - type == PAGELIST_READ, pages); + actual_pages = + pin_user_pages_fast((unsigned long)bulk->uoffset & PAGE_MASK, num_pages, + type == PAGELIST_READ, pages); if (actual_pages != num_pages) { dev_dbg(instance->state->dev, "arm: Only %d/%d pages locked\n", @@ -1739,12 +1740,12 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel } 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; - pagelistinfo = create_pagelist(instance, offset, uoffset, size, + pagelistinfo = create_pagelist(instance, bulk, size, (dir == VCHIQ_BULK_RECEIVE) ? PAGELIST_READ : PAGELIST_WRITE); @@ -3070,8 +3071,10 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service, bulk->userdata = userdata; bulk->size = size; bulk->actual = VCHIQ_BULK_ACTUAL_ABORTED; + bulk->offset = offset; + bulk->uoffset = uoffset; - if (vchiq_prepare_bulk_data(service->instance, bulk, offset, uoffset, size, dir)) + if (vchiq_prepare_bulk_data(service->instance, bulk, size, dir)) goto unlock_error_exit; /* 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; }; struct vchiq_bulk_queue { From patchwork Thu Oct 17 13:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13840076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B405D37495 for ; Thu, 17 Oct 2024 13:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kyKigKtFFo2NdsD2vPmK7zQacvtE+E5LdT1/3rMzAsQ=; b=zO3AK5OCrFmiDc3K0ukdJWht6X j1H8IRTXu/IcWLbU0ko4jkYijj+p5YGu5fU5pMs0UmpqCyWVprU1LiCv5U8TrXFM2ShM5G3yrYLSC z4xWMN5pqdMTSZULnc5wbIhuHMGGFGvoBJuRhA3lyuEweIrl0sDks9ZmSMsU3upL7fndVSaGP283s S6Cpqnc+4Ry5/ITKQLOeWSn2Pb+EKo0GeDbeDmu1d7WsOfkBPyFlv0We8gDtbzvQmRjAiXsPecAOY 23V2EyMMoE/ROVWdGu5npq4PEeYAXg61dTbN1csyElozeY+CkaR5VRvSnUZ10Ol9ZVnz5lcH6+ApK ea/1LNcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Qt5-0000000F0E2-38WZ; Thu, 17 Oct 2024 13:49:59 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1QgL-0000000ExNp-34an; Thu, 17 Oct 2024 13:36:55 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_063649_932925_A3DFA7DE X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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, unsigned 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, struct vchiq_bulk *bulk, int dma_buffers; unsigned int cache_line_size; dma_addr_t dma_addr; + size_t count = bulk->size; + unsigned short type = (bulk->dir == VCHIQ_BULK_RECEIVE) + ? PAGELIST_READ : PAGELIST_WRITE; if (count >= INT_MAX - PAGE_SIZE) return NULL; @@ -1740,15 +1742,11 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel } 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; - pagelistinfo = create_pagelist(instance, bulk, size, - (dir == VCHIQ_BULK_RECEIVE) - ? PAGELIST_READ - : PAGELIST_WRITE); + pagelistinfo = create_pagelist(instance, bulk); if (!pagelistinfo) return -ENOMEM; @@ -3074,7 +3072,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service, bulk->offset = offset; bulk->uoffset = uoffset; - if (vchiq_prepare_bulk_data(service->instance, bulk, size, dir)) + if (vchiq_prepare_bulk_data(service->instance, bulk)) goto unlock_error_exit; /* From patchwork Thu Oct 17 13:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13840064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74AF8D37492 for ; Thu, 17 Oct 2024 13:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v93rX+QmPo3I2or08N9IO4rZjy7+HF1625e0XtoLtn4=; b=F6CabEKG9xcwORFrDp2MDdnlag 3w644fXM+yY11aebtohHhR2JRBD+yAOW71XeHx8YZc8tIRLVWNEM1Ue4vluQQP2u2MdqhiEnhU0g4 jPO+xNuNBx1NWxuiwiPF/kNMlqJj6p6E8uhu8pN/FdwIGz4KdQb5FIgiFVlo0032SqS0HutjLwstm o9Jgzp4W6lHf+SF6Na4059JkLvyClXGqFGGku253vYtY0yfeAFRppLSuXjfQaktooqGIvbnMPIIdL RmTvDggXXHvG07/LqLApuXp3YfeH80hNZu+GNkNfJYEBCMd+cVXdJ9zZuNqzZh6laAXRSj3ofrc1b DpbDGqxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1QkX-0000000EynZ-39gl; Thu, 17 Oct 2024 13:41:09 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1QgN-0000000ExO8-2isF; Thu, 17 Oct 2024 13:36:56 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_063651_891253_40CEB9C9 X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 { }; 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); 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 = {}; int ret; switch (mode) { @@ -501,8 +502,12 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const VCHIQ_BULK_TRANSMIT); break; case VCHIQ_BULK_MODE_BLOCKING: - ret = vchiq_blocking_bulk_transfer(instance, handle, (void *)data, size, - VCHIQ_BULK_TRANSMIT); + bulk_params.offset = (void *)data; + bulk_params.mode = mode; + bulk_params.size = size; + bulk_params.dir = VCHIQ_BULK_TRANSMIT; + + ret = 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 = {}; int ret; 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 = vchiq_blocking_bulk_transfer(instance, handle, (void *)data, size, - VCHIQ_BULK_RECEIVE); + bulk_params.offset = (void *)data; + bulk_params.mode = mode; + bulk_params.size = size; + bulk_params.dir = VCHIQ_BULK_RECEIVE; + + ret = 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); 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 = NULL, *iter; @@ -566,7 +576,8 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl if (bulk) { /* This thread has an outstanding bulk transfer. */ /* FIXME: why compare a dma address to a pointer? */ - if ((bulk->data != (dma_addr_t)(uintptr_t)data) || (bulk->size != size)) { + if ((bulk->data != (dma_addr_t)(uintptr_t)bulk_params->data) || + (bulk->size != 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 *instance, unsigned int handl return -ENOMEM; } - ret = vchiq_bulk_xfer_blocking(instance, handle, data, NULL, size, - &waiter->bulk_waiter, dir); + bulk_params->userdata = &waiter->bulk_waiter; + + ret = vchiq_bulk_xfer_blocking(instance, handle, bulk_params); if ((ret != -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { struct vchiq_bulk *bulk = waiter->bulk_waiter.bulk; 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) int vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int handle, - void *offset, void __user *uoffset, int size, - void __user *userdata, enum vchiq_bulk_dir dir) + struct vchiq_bulk *bulk_params) { struct vchiq_service *service = find_service_by_handle(instance, handle); - enum vchiq_bulk_mode mode = VCHIQ_BULK_MODE_BLOCKING; int status = -EINVAL; if (!service) @@ -3484,15 +3482,17 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int handle, if (service->srvstate != VCHIQ_SRVSTATE_OPEN) goto error_exit; - if (!offset && !uoffset) + if (!bulk_params->offset && !bulk_params->uoffset) goto error_exit; if (vchiq_check_service(service)) goto error_exit; - status = vchiq_bulk_xfer_queue_msg_killable(service, offset, uoffset, size, - userdata, mode, dir); + status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offset, + bulk_params->uoffset, bulk_params->size, + bulk_params->userdata, bulk_params->mode, + bulk_params->dir); 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, extern int vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int handle, - void *offset, void __user *uoffset, int size, - void __user *userdata, enum vchiq_bulk_dir dir); + struct vchiq_bulk *bulk); extern int vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle, 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_instance *instance, { struct vchiq_service *service; struct bulk_waiter_node *waiter = NULL, *iter; + struct vchiq_bulk bulk_params = {}; void *userdata; int status = 0; int ret; @@ -303,12 +304,14 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, goto out; } - userdata = &waiter->bulk_waiter; + bulk_params.uoffset = args->data; + bulk_params.mode = args->mode; + bulk_params.size = args->size; + bulk_params.dir = dir; + bulk_params.userdata = &waiter->bulk_waiter; status = vchiq_bulk_xfer_blocking(instance, args->handle, - NULL, args->data, args->size, - userdata, dir); - + &bulk_params); } else if (args->mode == VCHIQ_BULK_MODE_WAITING) { mutex_lock(&instance->bulk_waiter_list_mutex); list_for_each_entry(iter, &instance->bulk_waiter_list, From patchwork Thu Oct 17 13:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13840071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0312D37491 for ; Thu, 17 Oct 2024 13:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=m2kT9NBo3kiaenBbkPJRZcQ3j/MMc0JLWP87BpiAbJk=; b=iLlZ6sEROEbUtPWTpfhc0m7qhq v8Ndj+51vFM0stYMlA05P72wdGfkztp1fZhTigeHNxZEdDVyB6myChygptHx3rzss8Dg7MIAKuQEe 73jo8KMp45el/5byc19f9sYUP4RdHtkcGAhjKeHDpz0TRTf01VprcIe9oe85NvWkpyyf7h5Ca5AhS a6bmZ1yfe+6mWKk0CKDJIj5G/9IFMbw+wsr3PSF5SVRAz7Di7N3pQfj+6uNbr3ndp1V3C2np6moVT Ep8jUgn3eQGz4Vj59eoh/N6VyLdsbR7ieU+yB+vVTXOid+zG+wegW2kgsgMeYhGePKTMCk6TcQ7fQ PG2Lsmlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Qlx-0000000Eyvk-2WMt; Thu, 17 Oct 2024 13:42:37 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1QgP-0000000ExOt-3oIa; Thu, 17 Oct 2024 13:36:58 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_063654_121664_20E080FD X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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, unsigned int handle, const switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: case VCHIQ_BULK_MODE_CALLBACK: - ret = vchiq_bulk_xfer_callback(instance, handle, (void *)data, - NULL, size, mode, userdata, - VCHIQ_BULK_TRANSMIT); + + bulk_params.offset = (void *)data; + bulk_params.mode = mode; + bulk_params.size = size; + bulk_params.userdata = userdata; + bulk_params.dir = VCHIQ_BULK_TRANSMIT; + + ret = vchiq_bulk_xfer_callback(instance, handle, &bulk_params); break; case VCHIQ_BULK_MODE_BLOCKING: bulk_params.offset = (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 = vchiq_bulk_xfer_callback(instance, handle, (void *)data, NULL, - size, mode, userdata, VCHIQ_BULK_RECEIVE); + + bulk_params.offset = (void *)data; + bulk_params.mode = mode; + bulk_params.size = size; + bulk_params.userdata = userdata; + bulk_params.dir = VCHIQ_BULK_RECEIVE; + + ret = vchiq_bulk_xfer_callback(instance, handle, &bulk_params); break; case VCHIQ_BULK_MODE_BLOCKING: bulk_params.offset = (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 *instance, unsigned int handle, int vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle, - 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 = find_service_by_handle(instance, handle); int status = -EINVAL; @@ -3512,21 +3510,22 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle, if (!service) return -EINVAL; - if (mode != VCHIQ_BULK_MODE_CALLBACK && - mode != VCHIQ_BULK_MODE_NOCALLBACK) + if (bulk_params->mode != VCHIQ_BULK_MODE_CALLBACK && + bulk_params->mode != VCHIQ_BULK_MODE_NOCALLBACK) goto error_exit; if (service->srvstate != VCHIQ_SRVSTATE_OPEN) goto error_exit; - if (!offset && !uoffset) + if (!bulk_params->offset && !bulk_params->uoffset) goto error_exit; if (vchiq_check_service(service)) goto error_exit; - status = vchiq_bulk_xfer_queue_msg_killable(service, offset, uoffset, - size, userdata, mode, dir); + status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offset, bulk_params->uoffset, + bulk_params->size, bulk_params->userdata, + bulk_params->mode, bulk_params->dir); 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 *instance, unsigned int handle, extern int vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle, - void *offset, void __user *uoffset, int size, - enum vchiq_bulk_mode mode, void *userdata, - enum vchiq_bulk_dir dir); + struct vchiq_bulk *bulk); 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_instance *instance, status = vchiq_bulk_xfer_waiting(instance, args->handle, userdata); } else { - userdata = args->userdata; - - status = vchiq_bulk_xfer_callback(instance, args->handle, NULL, - args->data, args->size, - args->mode, userdata, dir); + bulk_params.uoffset = args->data; + bulk_params.mode = args->mode; + bulk_params.size = args->size; + bulk_params.dir = dir; + bulk_params.userdata = args->userdata; + status = vchiq_bulk_xfer_callback(instance, args->handle, + &bulk_params); } if (!waiter) { From patchwork Thu Oct 17 13:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13840072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 329B1D37491 for ; Thu, 17 Oct 2024 13:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AZOrD4gmVCS/of4YlkKekCL/PVomK/9pI8m/tArCkSs=; b=OQ5hhty3/5rOehaBeDJKkhUUG2 nixHp3l2nnBphv6g0sGB58Tb/LmrPdXBo6K4qPsDLyNIbBR6J6uhyazkP97ZPm+9fcvKXpV1HoCD5 LDlwErAFft3Yzziwl3pZnqnpFFaLJgH6b+dRVet9ue6hC8Wcgf2Q5asl381yi1rSj9DD6ost4S77b E9sgzjFxEnLI9DYyVRtnGsgZxpPFofOrmYtebFjLOutYRu64D23U5OkmP5JfI/5V4aOp6bgJL0IIg 3IF+6t5kxoJ4zu9dO964vRTev4DZ5dgiAP0JeqPLpZBnuVf4a1IHyWlAvdcA2qRZV3hEakg38jJsd zCzoO/0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1QnN-0000000EzD0-368N; Thu, 17 Oct 2024 13:44:05 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1QgR-0000000ExPg-48fs; Thu, 17 Oct 2024 13:36:59 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_063656_281142_A81CC1E4 X-CRM114-Status: GOOD ( 11.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 *service, 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 = NULL; struct vchiq_bulk *bulk; struct vchiq_state *state = service->state; - const char dir_char = (dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; - const int dir_msgtype = (dir == VCHIQ_BULK_TRANSMIT) ? + const char dir_char = (bulk_params->dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; + const int dir_msgtype = (bulk_params->dir == VCHIQ_BULK_TRANSMIT) ? VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; int status = -EINVAL; int payload[2]; - if (mode == VCHIQ_BULK_MODE_BLOCKING) { - bulk_waiter = userdata; + if (bulk_params->mode == VCHIQ_BULK_MODE_BLOCKING) { + bulk_waiter = bulk_params->userdata; init_completion(&bulk_waiter->event); bulk_waiter->actual = 0; bulk_waiter->bulk = NULL; } - queue = (dir == VCHIQ_BULK_TRANSMIT) ? + queue = (bulk_params->dir == VCHIQ_BULK_TRANSMIT) ? &service->bulk_tx : &service->bulk_rx; if (mutex_lock_killable(&service->bulk_mutex)) @@ -3064,13 +3061,14 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service, bulk = &queue->bulks[BULK_INDEX(queue->local_insert)]; - bulk->mode = mode; - bulk->dir = dir; - bulk->userdata = userdata; - bulk->size = size; + /* Initiliaze the 'bulk' slot with bulk parameters passed in. */ + bulk->mode = bulk_params->mode; + bulk->dir = bulk_params->dir; + bulk->userdata = bulk_params->userdata; + bulk->size = bulk_params->size; + bulk->offset = bulk_params->offset; + bulk->uoffset = bulk_params->uoffset; bulk->actual = VCHIQ_BULK_ACTUAL_ABORTED; - bulk->offset = offset; - bulk->uoffset = uoffset; if (vchiq_prepare_bulk_data(service->instance, bulk)) goto unlock_error_exit; @@ -3083,7 +3081,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service, 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); /* * The slot mutex must be held when the service is being closed, so @@ -3489,10 +3487,7 @@ vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int handle, goto error_exit; - status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offset, - bulk_params->uoffset, bulk_params->size, - bulk_params->userdata, bulk_params->mode, - bulk_params->dir); + status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params); error_exit: vchiq_service_put(service); @@ -3523,9 +3518,7 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle, if (vchiq_check_service(service)) goto error_exit; - status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params->offset, bulk_params->uoffset, - bulk_params->size, bulk_params->userdata, - bulk_params->mode, bulk_params->dir); + status = vchiq_bulk_xfer_queue_msg_killable(service, bulk_params); error_exit: vchiq_service_put(service); From patchwork Thu Oct 17 13:36:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13840073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D4EDD37491 for ; Thu, 17 Oct 2024 13:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NMGGXo+agx9JK+xB7QyB6AjRDuscMcUKuIs+acEYoK4=; b=IycHJ1Eb1IhG7odd0qaZmYN1aZ 6IamV+MMTZqkS55qLA/6YNfjxQ5Z6K5raJ1p19jpPgZkAXIGgETyTzQvxpYxvLdt3SMAEr+fMSyiM uHwv9L0dNwkkimfslgjv4XJTIP9EUJEN8C+19Tl1z7PmYz1o2Ki3r+RpgaAwLsmDuUsCYKsLCNXI0 GW6ienYOamPrhoLB6Vim1XmdH4u2Ci7uA/SSB+b+bIGT52eYuFI/SbUjOFJAMurQlZ9zP/2H9cNbK zqmEP78yb4lVPNxX7WrxU3MWv2XsaZfn38kZ1aYVAjugA53giqODjz+xBkYOQhXNNTmN3Xp8AuF/W yIdQVhcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1Qon-0000000EzQZ-2GC3; Thu, 17 Oct 2024 13:45:33 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1QgU-0000000ExQl-12py; Thu, 17 Oct 2024 13:37:00 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_063658_463836_1CE2259E X-CRM114-Status: UNSURE ( 9.21 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The '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_instance *instance, struct vchiq_service *service; struct bulk_waiter_node *waiter = NULL, *iter; struct vchiq_bulk bulk_params = {}; - void *userdata; int status = 0; int ret; @@ -331,9 +330,9 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, } dev_dbg(service->state->dev, "arm: found bulk_waiter %pK for pid %d\n", waiter, current->pid); - userdata = &waiter->bulk_waiter; - status = vchiq_bulk_xfer_waiting(instance, args->handle, userdata); + status = vchiq_bulk_xfer_waiting(instance, args->handle, + &waiter->bulk_waiter); } else { bulk_params.uoffset = args->data; bulk_params.mode = args->mode;