From nobody Mon Nov 25 23:26:17 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 ABB841A725E for ; Wed, 23 Oct 2024 11:04: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=1729681489; cv=none; b=kVAbfXpi8KH2SlwLXsX7TmJtC/OW6VBh4mUjh1E2wZrwC4YUrH1DgvlsQOJVACjZiYK4zHj6jhweP6GzXR1W8cRLUxxiSRWsxgFlo2Bb5I3KrbjFH53h0Bm7bH+I5nIXeVENYEcc21SkjDw+tUMcDtEg5lQTdcTrbTOXElUTcJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729681489; c=relaxed/simple; bh=2LKSIF262z/emv06K71fxiLrd5T72VZ1UM2x5FZ8PVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NEQ7+8tn7RZ/0trL2lHG+SwXMG9R/D7Yu234dm2R49wOCWPpxpOAVrP2jbjnCSbOuqCv3LQlPqu/RzfjKi9syxTmnKWtWb9N+bUGiInVImQglwf5sJBibMKSUlEka4gqXGvyV6047IdQOtKrdZFXD1ZVaell4UP+CmMzHvHiLiU= 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=OuRe4Wnm; 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="OuRe4Wnm" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2533B8A9; Wed, 23 Oct 2024 13:02:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729681379; bh=2LKSIF262z/emv06K71fxiLrd5T72VZ1UM2x5FZ8PVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OuRe4WnmVkamiuzriOZgOd7R6iiohfea88k3o3pLCUXILfP9oZyLvYM4H3RFMtzD8 NB691linWt1Nk7YtH7hMTkwLj0kK3BaEKbamSytFcDBbT302RKsr4RZXOzd5eHNfKh m1OWc4dXO5v1ruJ1zmjLJqCzGz6ELUFomU2vM3vk= 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_arm: Rename a struct vchiq_bulk member Date: Wed, 23 Oct 2024 16:34:01 +0530 Message-ID: <20241023110406.885199-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023110406.885199-1-umang.jain@ideasonboard.com> References: <20241023110406.885199-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" Rename the struct vchiq_bulk's 'data' member to 'dma_addr' for better readability. No functional changes intended in this patch. Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 12 ++++++------ .../vc04_services/interface/vchiq_arm/vchiq_core.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index c2e7c2bd5071..f23d98a1b960 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -587,7 +587,7 @@ 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)bulk_params->data) || + if ((bulk->dma_addr !=3D (dma_addr_t)(uintptr_t)bulk_params->dma_addr) = || (bulk->size !=3D bulk_params->size)) { /* * This is not a retry of the previous one. 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 9e56e34ca4d9..90ab780b7e94 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1369,7 +1369,7 @@ notify_bulks(struct vchiq_service *service, struct vc= hiq_bulk_queue *queue, * Only generate callbacks for non-dummy bulk * requests, and non-terminated services */ - if (bulk->data && service->instance) { + if (bulk->dma_addr && service->instance) { status =3D service_notify_bulk(service, bulk); if (status =3D=3D -EAGAIN) break; @@ -1751,7 +1751,7 @@ vchiq_prepare_bulk_data(struct vchiq_instance *instan= ce, struct vchiq_bulk *bulk if (!pagelistinfo) return -ENOMEM; =20 - bulk->data =3D pagelistinfo->dma_addr; + bulk->dma_addr =3D pagelistinfo->dma_addr; =20 /* * Store the pagelistinfo address in remote_data, @@ -1807,7 +1807,7 @@ abort_outstanding_bulks(struct vchiq_service *service, service->remoteport, bulk->size, bulk->remote_size); } else { /* fabricate a matching dummy bulk */ - bulk->data =3D 0; + bulk->dma_addr =3D 0; bulk->size =3D 0; bulk->actual =3D VCHIQ_BULK_ACTUAL_ABORTED; bulk->dir =3D is_tx ? VCHIQ_BULK_TRANSMIT : @@ -2112,7 +2112,7 @@ parse_message(struct vchiq_state *state, struct vchiq= _header *header) =20 dev_dbg(state->dev, "core: %d: prs %s@%pK (%d->%d) %x@%pad\n", state->id, msg_type_str(type), header, remoteport, - localport, bulk->actual, &bulk->data); + localport, bulk->actual, &bulk->dma_addr); =20 dev_dbg(state->dev, "core: %d: prs:%d %cx li=3D%x ri=3D%x p=3D%x\n", state->id, localport, @@ -3081,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, bulk->size, &bulk->data, bulk->userdata); + dir_char, bulk->size, &bulk->dma_addr, bulk->userdata); =20 /* * The slot mutex must be held when the service is being closed, so @@ -3095,7 +3095,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, if (service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) goto unlock_both_error_exit; =20 - payload[0] =3D lower_32_bits(bulk->data); + payload[0] =3D lower_32_bits(bulk->dma_addr); payload[1] =3D bulk->size; status =3D queue_message(state, NULL, 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 186b1395d3a2..9ba4a2295dc3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -115,7 +115,7 @@ struct vchiq_bulk { short mode; short dir; void *userdata; - dma_addr_t data; + dma_addr_t dma_addr; int size; void *remote_data; int remote_size; --=20 2.45.2 From nobody Mon Nov 25 23:26:17 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 D52631AA786 for ; Wed, 23 Oct 2024 11:04:49 +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=1729681491; cv=none; b=Ch8vqyuos6B7Fe5XheIfA7lF7EG5hRSAADqk/PBF9Wjnyqet13leIGTWRM/TN8DMuKNmPmM3vTMS5fMoGzKbeSWC0Cjwto4vHagamHIX/1MpLH3eINVjDyH7JdBkr6rYozogaQgQfMAU567CsU9cKUuXfvFln91j8xc6h0rYDqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729681491; c=relaxed/simple; bh=KIi8RtAK5zM28t9+jkOUOwbYGCTOpFii6+tjL4MbcHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J327dliCYF9eHNvIIuyL/QxQLAM+N2ll+cxtl5ENHQUiF8nRoslzkARcr9TZcaqaaMpPVC8vJvrJxgDATDy4bcTkULYC9goeFabDdOHyglPXhHnJAMXrkbzowNVupVzH3B4bhqen7pB/Om33VKUBsmV+s4zqTFy6fpAeewe3xpo= 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=RCL5i2Uz; 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="RCL5i2Uz" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BE9B9FC; Wed, 23 Oct 2024 13:02:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729681381; bh=KIi8RtAK5zM28t9+jkOUOwbYGCTOpFii6+tjL4MbcHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCL5i2Uz8D/eOOwy4TGq7fbYtc9RXpNDFGzJJoc/cli0rzE1drvTTVf+0ItLuRJ76 RhttYQVRFn0IS2bfBqqvcHdc4kCp6ctwRWP/N9jWZnUhw4kOOjZJ8SLwiWeuLc57bY 6VKr/l/qCShXZoALwzZ+t3otaMsY70sXP7N5EB1A= 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: Bulk waiter should not piggy back on bulk userdata Date: Wed, 23 Oct 2024 16:34:02 +0530 Message-ID: <20241023110406.885199-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023110406.885199-1-umang.jain@ideasonboard.com> References: <20241023110406.885199-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" Currently, struct bulk_waiter is allocated for VCHIQ_BULK_MODE_BLOCKING bulk transfer and its pointer is assigned to vchiq_bulk->userdata. Avoid this kind of piggybacking and introduce a dedicate 'waiter' member in struct vchiq_bulk. The 'userdata' is meant for VCHIQ_BULK_MODE_CALLBACK mode, to pass user specified parameter to the actual callback function. Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++--- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 11 ++++++----- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 1 + .../vc04_services/interface/vchiq_arm/vchiq_dev.c | 4 ++-- 4 files changed, 12 insertions(+), 10 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 f23d98a1b960..ff627b297bc4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -594,7 +594,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl * Cancel the signal when the transfer completes. */ spin_lock(&service->state->bulk_waiter_spinlock); - bulk->userdata =3D NULL; + bulk->waiter =3D NULL; spin_unlock(&service->state->bulk_waiter_spinlock); } } @@ -604,7 +604,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl return -ENOMEM; } =20 - bulk_params->userdata =3D &waiter->bulk_waiter; + bulk_params->waiter =3D &waiter->bulk_waiter; =20 ret =3D vchiq_bulk_xfer_blocking(instance, handle, bulk_params); if ((ret !=3D -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_= waiter.bulk) { @@ -613,7 +613,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl if (bulk) { /* Cancel the signal when the transfer completes. */ spin_lock(&service->state->bulk_waiter_spinlock); - bulk->userdata =3D NULL; + bulk->waiter =3D NULL; spin_unlock(&service->state->bulk_waiter_spinlock); } kfree(waiter); 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 90ab780b7e94..5e52f8954be7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1330,7 +1330,7 @@ static int service_notify_bulk(struct vchiq_service *= service, struct bulk_waiter *waiter; =20 spin_lock(&service->state->bulk_waiter_spinlock); - waiter =3D bulk->userdata; + waiter =3D bulk->waiter; if (waiter) { waiter->actual =3D bulk->actual; complete(&waiter->event); @@ -3035,7 +3035,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, int payload[2]; =20 if (bulk_params->mode =3D=3D VCHIQ_BULK_MODE_BLOCKING) { - bulk_waiter =3D bulk_params->userdata; + bulk_waiter =3D bulk_params->waiter; init_completion(&bulk_waiter->event); bulk_waiter->actual =3D 0; bulk_waiter->bulk =3D NULL; @@ -3064,6 +3064,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, /* Initiliaze the 'bulk' slot with bulk parameters passed in. */ bulk->mode =3D bulk_params->mode; bulk->dir =3D bulk_params->dir; + bulk->waiter =3D bulk_params->waiter; bulk->userdata =3D bulk_params->userdata; bulk->size =3D bulk_params->size; bulk->offset =3D bulk_params->offset; @@ -3533,7 +3534,7 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *insta= nce, unsigned int handle, */ int vchiq_bulk_xfer_waiting(struct vchiq_instance *instance, - unsigned int handle, struct bulk_waiter *userdata) + unsigned int handle, struct bulk_waiter *waiter) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); struct bulk_waiter *bulk_waiter; @@ -3542,7 +3543,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instan= ce, if (!service) return -EINVAL; =20 - if (!userdata) + if (!waiter) goto error_exit; =20 if (service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) @@ -3551,7 +3552,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instan= ce, if (vchiq_check_service(service)) goto error_exit; =20 - bulk_waiter =3D userdata; + bulk_waiter =3D waiter; =20 vchiq_service_put(service); =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 9ba4a2295dc3..88766c9180a9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -115,6 +115,7 @@ struct vchiq_bulk { short mode; short dir; void *userdata; + struct bulk_waiter *waiter; dma_addr_t dma_addr; int size; void *remote_data; 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 6a9685d9fafc..3d2827446f53 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -307,7 +307,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, bulk_params.mode =3D args->mode; bulk_params.size =3D args->size; bulk_params.dir =3D dir; - bulk_params.userdata =3D &waiter->bulk_waiter; + bulk_params.waiter =3D &waiter->bulk_waiter; =20 status =3D vchiq_bulk_xfer_blocking(instance, args->handle, &bulk_params); @@ -354,7 +354,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, if (waiter->bulk_waiter.bulk) { /* Cancel the signal when the transfer completes. */ spin_lock(&service->state->bulk_waiter_spinlock); - waiter->bulk_waiter.bulk->userdata =3D NULL; + waiter->bulk_waiter.bulk->waiter =3D NULL; spin_unlock(&service->state->bulk_waiter_spinlock); } kfree(waiter); --=20 2.45.2 From nobody Mon Nov 25 23:26:17 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 BBA511A4E9E for ; Wed, 23 Oct 2024 11:04:51 +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=1729681493; cv=none; b=Xt8DYQAghKkv+lYjsFNw9vUNhf5PYsOlm8ILUfCE4nh6EVC2WnHDX/AjlGPUGNcfO0/hUyjAX1oEd+nKIUyD80SodIA2qHi8EGdZT8CPLSM+W0nKCCN52O1nZaGs1tMuFraCnp/l3BceB5biK4HVyvo17WYq8/mPGTrrDBtrszY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729681493; c=relaxed/simple; bh=LkuPDmiNtkyAPKPo4egoogY7JtPMRLPdsJI6n3MyepI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O0kvaGYNT6eVuk1yI00ERonLm0+IPAMtfizW5+Cc5Cbnx2eLQ2oDjFICzGxZ/UWb9PTqXjhEj2Fr549hphx9ydyT15oApsTCKpuw1uPVET3uijAB7ghoyRZLU3RkqFyDSR6REtdx/vafd73Dm1ow+VpnvHigGIiXRCS/SyIj7+4= 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=i930unMx; 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="i930unMx" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FC0C82A; Wed, 23 Oct 2024 13:03:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729681383; bh=LkuPDmiNtkyAPKPo4egoogY7JtPMRLPdsJI6n3MyepI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i930unMxxKJk61w5glqBMGlPx8fpx1QlG296saJ3vVnQXJTohHtxKqTTlMDs7R3+j WEg2ysFoFU+xAZo0jLuvzu81R48FSoSb4mTUfjb0t5AyEGhmuRhYMjgHNMjG73qQCz YVfNkD2EsP7Oi+leWbTKjtV2c7wxtuMDILyIoDqg= 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: vchiq_core: Rename struct vchiq_bulk 'userdata' Date: Wed, 23 Oct 2024 16:34:03 +0530 Message-ID: <20241023110406.885199-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023110406.885199-1-umang.jain@ideasonboard.com> References: <20241023110406.885199-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" Rename the struct vchiq_bulk 'userdata' member to 'cb_data' to clarify its purpose. 'cb_data' is meant to be passed to service callback function in VCHIQ_BULK_MODE_CALLBACK mode. No functional changes in this patch. Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 12 ++++++------ .../vc04_services/interface/vchiq_arm/vchiq_core.h | 2 +- .../vc04_services/interface/vchiq_arm/vchiq_dev.c | 2 +- 4 files changed, 10 insertions(+), 10 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 ff627b297bc4..c06a57ea9cf5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -501,7 +501,7 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, un= signed int handle, const bulk_params.offset =3D (void *)data; bulk_params.mode =3D mode; bulk_params.size =3D size; - bulk_params.userdata =3D userdata; + bulk_params.cb_data =3D userdata; bulk_params.dir =3D VCHIQ_BULK_TRANSMIT; =20 ret =3D vchiq_bulk_xfer_callback(instance, handle, &bulk_params); @@ -536,7 +536,7 @@ int vchiq_bulk_receive(struct vchiq_instance *instance,= unsigned int handle, bulk_params.offset =3D (void *)data; bulk_params.mode =3D mode; bulk_params.size =3D size; - bulk_params.userdata =3D userdata; + bulk_params.cb_data =3D userdata; bulk_params.dir =3D VCHIQ_BULK_RECEIVE; =20 ret =3D vchiq_bulk_xfer_callback(instance, handle, &bulk_params); 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 5e52f8954be7..6095adaf0cf6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -455,15 +455,15 @@ mark_service_closing(struct vchiq_service *service) =20 static inline int make_service_callback(struct vchiq_service *service, enum vchiq_reason rea= son, - struct vchiq_header *header, void *bulk_userdata) + struct vchiq_header *header, void *cb_data) { int status; =20 dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %pK, %pK)\n", service->state->id, service->localport, reason_names[reason], - header, bulk_userdata); + header, cb_data); status =3D service->base.callback(service->instance, reason, header, serv= ice->handle, - bulk_userdata); + cb_data); if (status && (status !=3D -EAGAIN)) { dev_warn(service->state->dev, "core: %d: ignoring ERROR from callback to service %x\n", @@ -1340,7 +1340,7 @@ static int service_notify_bulk(struct vchiq_service *= service, enum vchiq_reason reason =3D get_bulk_reason(bulk); =20 return make_service_callback(service, reason, NULL, - bulk->userdata); + bulk->cb_data); } =20 return 0; @@ -3065,7 +3065,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, bulk->mode =3D bulk_params->mode; bulk->dir =3D bulk_params->dir; bulk->waiter =3D bulk_params->waiter; - bulk->userdata =3D bulk_params->userdata; + bulk->cb_data =3D bulk_params->cb_data; bulk->size =3D bulk_params->size; bulk->offset =3D bulk_params->offset; bulk->uoffset =3D bulk_params->uoffset; @@ -3082,7 +3082,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, bulk->size, &bulk->dma_addr, bulk->userdata); + dir_char, bulk->size, &bulk->dma_addr, bulk->cb_data); =20 /* * The slot mutex must be held when the service is being closed, so 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 88766c9180a9..f9a2268ad47e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -114,7 +114,7 @@ enum vchiq_bulk_dir { struct vchiq_bulk { short mode; short dir; - void *userdata; + void *cb_data; struct bulk_waiter *waiter; dma_addr_t dma_addr; int size; 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 3d2827446f53..c99cd36a2696 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -338,7 +338,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, bulk_params.mode =3D args->mode; bulk_params.size =3D args->size; bulk_params.dir =3D dir; - bulk_params.userdata =3D args->userdata; + bulk_params.cb_data =3D args->userdata; =20 status =3D vchiq_bulk_xfer_callback(instance, args->handle, &bulk_params); --=20 2.45.2 From nobody Mon Nov 25 23:26:17 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 CFFB11AAE33 for ; Wed, 23 Oct 2024 11:04: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=1729681495; cv=none; b=hfp+pMx8ZZKSW73SCzvp6qmCjON12FedDRfOsesalC54ew8Vk/msyQY+CMy8jCJ1j0gvkPkJqDT2UJ25Szknhom++Z6M8XRjq3libz61btk7gGY7aAqXHkjpd5SMNdMdG5vjz4zCzFVnOkWbXcVJoGpmqILptWAO00nhZJ49pFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729681495; c=relaxed/simple; bh=xHdIxr5t+jY9OyJWLgchvzvtGsJl4NVdoLGbuMoHYRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mu4E74MtUxZr8wTj2A0brdIia4BWyAu454ejCkUgrwJZ2aXbzyo7nb/jRI43Boia8A/8VSqbgMoqlTfhntShRFlOroENwwtnVuZFA57Hm7uEoAbmy8gW88pYa0AcVTzuk5iw8bu6X5g4LMmvVItOxDdfYDmqtcrtpGT056NKpxU= 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=K309Z7iB; 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="K309Z7iB" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C43E38A9; Wed, 23 Oct 2024 13:03:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729681385; bh=xHdIxr5t+jY9OyJWLgchvzvtGsJl4NVdoLGbuMoHYRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K309Z7iBlCQIl4pVKDO/iH87GRiGHP+2XDgSd71jOvzw37jnV09aiFPwJ9FxgfS2O MaxBXlc5nVMzurjIR8EVfth49AqTWtWZX3L+/Hcd4vddOZKAZdQo8YmfCdFlhNvL1s n2AVht3QfvxzbS22SbJaVvxIw+kBrzwaDkYOmWeo= 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: vchiq: Rename vchiq_completion_data 'bulk_userdata' Date: Wed, 23 Oct 2024 16:34:04 +0530 Message-ID: <20241023110406.885199-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023110406.885199-1-umang.jain@ideasonboard.com> References: <20241023110406.885199-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" In a previous commit, struct vchiq_bulk 'userdata' got renamed to 'cb_data' since it is the data pointer passed in VCHIQ_BULK_CALLBACK_MODE's callback. Since struct vchiq_completion_data* structs also has 'bulk_userdata' for completion records, rename 'bulk_userdata' member to 'cb_data' for these structs as well. This brings consistency and clarity for the struct members. No functional change in this patch. Signed-off-by: Umang Jain --- .../vc04_services/include/linux/raspberrypi/vchiq.h | 4 ++-- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c | 8 ++++---- .../vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.= h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index 6c40d8c1dde6..9a6ab006bed2 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -64,7 +64,7 @@ struct vchiq_completion_data_kernel { enum vchiq_reason reason; struct vchiq_header *header; void *service_userdata; - void *bulk_userdata; + void *cb_data; }; =20 struct vchiq_service_params_kernel { @@ -73,7 +73,7 @@ struct vchiq_service_params_kernel { enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, - void *bulk_userdata); + void *cb_data); void *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ 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 c06a57ea9cf5..bcfd4ccc8373 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -662,7 +662,7 @@ add_completion(struct vchiq_instance *instance, enum vc= hiq_reason reason, completion->reason =3D reason; /* N.B. service_userdata is updated while processing AWAIT_COMPLETION */ completion->service_userdata =3D user_service->service; - completion->bulk_userdata =3D bulk_userdata; + completion->cb_data =3D bulk_userdata; =20 if (reason =3D=3D VCHIQ_SERVICE_CLOSED) { /* 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 c99cd36a2696..fcdf97391fb6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -414,7 +414,7 @@ struct vchiq_completion_data32 { enum vchiq_reason reason; compat_uptr_t header; compat_uptr_t service_userdata; - compat_uptr_t bulk_userdata; + compat_uptr_t cb_data; }; =20 static int vchiq_put_completion(struct vchiq_completion_data __user *buf, @@ -428,7 +428,7 @@ static int vchiq_put_completion(struct vchiq_completion= _data __user *buf, .reason =3D completion->reason, .header =3D ptr_to_compat(completion->header), .service_userdata =3D ptr_to_compat(completion->service_userdata), - .bulk_userdata =3D ptr_to_compat(completion->bulk_userdata), + .cb_data =3D ptr_to_compat(completion->cb_userdata), }; if (copy_to_user(&buf32[index], &tmp, sizeof(tmp))) return -EFAULT; @@ -550,10 +550,10 @@ static int vchiq_ioc_await_completion(struct vchiq_in= stance *instance, vchiq_service_put(service); =20 /* - * FIXME: address space mismatch, does bulk_userdata + * FIXME: address space mismatch, does cb_data * actually point to user or kernel memory? */ - user_completion.bulk_userdata =3D completion->bulk_userdata; + user_completion.cb_userdata =3D completion->cb_data; =20 if (vchiq_put_completion(args->buf, &user_completion, ret)) { if (ret =3D=3D 0) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.= h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 17550831f86c..afb71a83cfe7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -47,7 +47,7 @@ struct vchiq_completion_data { enum vchiq_reason reason; struct vchiq_header __user *header; void __user *service_userdata; - void __user *bulk_userdata; + void __user *cb_userdata; }; =20 struct vchiq_await_completion { --=20 2.45.2 From nobody Mon Nov 25 23:26:17 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 B18A01AB6C7 for ; Wed, 23 Oct 2024 11:04:56 +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=1729681498; cv=none; b=FTGXLHVSc6K2kvsZv3HJtxo6wImYFpmtGLlRkDg7TCMumzWqpaewqUYYgYmADCfl7EWbXANdlMkb0GEtgt9Ovs4SUTbVBqqYrWSr6dpu6kSkMGoiDV5XiRZwQ1FaCUsSQQZpcdAbXQi9w98vCovcuwzEGB6VbcIYA2AaNuBIvaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729681498; c=relaxed/simple; bh=fvlat9AHEEDf8cSpGbz1hc5d3oS8Gf8tdHnvlCW1ce8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iz0xUwqGpplAOPh8MkMgucUiBY6Sc46v6mhgoFcgKB1tJ8Xy3fMmjGj8Q+LsvuL5H2D+zdJgb1MZkIp5Jl32iQ81gttkhhS9cqX9vTGN1hjRBMjyKdvMOokoogoIMcmHzu/uTfp9UY9xumXsRYGj5cXqHfce2GSrKci8WY8/Iuk= 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=qM2MTKsW; 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="qM2MTKsW" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 076709FC; Wed, 23 Oct 2024 13:03:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729681387; bh=fvlat9AHEEDf8cSpGbz1hc5d3oS8Gf8tdHnvlCW1ce8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qM2MTKsWBIq5UwKpFip16eKxS29ok1aao6A1BS4GeXxgZSiz9Wim9gpWqfsrkzQDb QGioOTRQbxHKQkIkEqDUbjQJ6n+skq1Wm2X61T379uXvFyjLar+6fUGGkB6XFcI9KT MN7ITKrXxZvSTlmS9LVTQgoDL+4FYKG8AmndkRZo= 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: Pass vchiq_bulk pointer to make_service_callback() Date: Wed, 23 Oct 2024 16:34:05 +0530 Message-ID: <20241023110406.885199-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023110406.885199-1-umang.jain@ideasonboard.com> References: <20241023110406.885199-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" Pass struct vchiq_bulk pointer to make_service_callback() instead of just passing the bulk->cb_data. This is a preparatory change when we need to pass the callback data user pointer (__user) in a subsequent commit. Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 13 ++++++++++--- 1 file changed, 10 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 6095adaf0cf6..3c811b8f210c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -455,10 +455,18 @@ mark_service_closing(struct vchiq_service *service) =20 static inline int make_service_callback(struct vchiq_service *service, enum vchiq_reason rea= son, - struct vchiq_header *header, void *cb_data) + struct vchiq_header *header, struct vchiq_bulk *bulk) { + void *cb_data =3D NULL; int status; =20 + /* + * If a bulk transfer is in progress, pass bulk->cb_data to the + * callback function. + */ + if (bulk) + cb_data =3D bulk->cb_data; + dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %pK, %pK)\n", service->state->id, service->localport, reason_names[reason], header, cb_data); @@ -1339,8 +1347,7 @@ static int service_notify_bulk(struct vchiq_service *= service, } else if (bulk->mode =3D=3D VCHIQ_BULK_MODE_CALLBACK) { enum vchiq_reason reason =3D get_bulk_reason(bulk); =20 - return make_service_callback(service, reason, NULL, - bulk->cb_data); + return make_service_callback(service, reason, NULL, bulk); } =20 return 0; --=20 2.45.2 From nobody Mon Nov 25 23:26:17 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 6EF831ABEAC for ; Wed, 23 Oct 2024 11:04:58 +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=1729681500; cv=none; b=J17+rK26Rc1UAZ8Qz/wM7M4VNXxXzFgh8/KMe2dkXgiADIFd0Tqa/4zfJ0aeGRlVa6tINf/sShcSoghQv9NrbUOs6bFjE+X7Fk8qcASLj977NpuNxwk6BFDbU9LcFthIyyhMwFHAp7V8r7bwWAoTvC9t9U1etD/mxzKsooY/39E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729681500; c=relaxed/simple; bh=TNPi62Wih43ydCcvW6KjvjYGbgJFkkVc209bi8iV4bw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=opf/DQmWW8BQ9VUKddXNarX23YeO2Ni6fCsGOKBoGPBAO6IAgW4a7R2WVJrn4oFrxzWJBh8WSf2rZ2mUdK/PmPcfwHxtG2HeauhxswX5zw60MWYqc8isnrnTOZrS/WOvII1Htz7XaY3k0Yi2M+VK1TZ0KTEj4gYtZ8iZ7H4kGSk= 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=D3eG7eOr; 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="D3eG7eOr" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3ED4182A; Wed, 23 Oct 2024 13:03:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729681390; bh=TNPi62Wih43ydCcvW6KjvjYGbgJFkkVc209bi8iV4bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3eG7eOrokVhIeflPyOcA676N9RRGceTdo4hQw3cm1tji4TqxUD9ZFdKkvnvidNn2 5CV/bEZIdL9QjEl1VmKv1UGkjw1tHcoJmF+MLp3mQUIy91nQyNHF3a7dZsMJAahC1i o+EyWUNNzwaEc5/qoIsLOdLQG3IjyJeZ2nYYSxnY= 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_arm: Track bulk user data pointer separately Date: Wed, 23 Oct 2024 16:34:06 +0530 Message-ID: <20241023110406.885199-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023110406.885199-1-umang.jain@ideasonboard.com> References: <20241023110406.885199-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" A bulk callback transfer can be initiated from two places - inside kernel interface or from user interface. However, the callback data pointer 'cb_data' is used for tracking both sets of data pointer. This commit tracks the callback data pointer from user interface (named as 'cb_userdata') separately, in the bulk transfer service callback. This is esentially done by adding a 'void __user *cb_userdata' for tracking __user pointers in vchiq_bulk and vchiq_completion_data structs. Furthermore, the 'cb_userdata' data pointer is appended to the vchiq_service's callback signature. Separating the two callback data pointers ('cb_data' and 'cb_userdata') fixes the sparse warnings around mixing userspace and kernel space pointers. As there are no additional sparse warnings left for vc04_services, drop the relevant entry from the TODO. Signed-off-by: Umang Jain --- .../bcm2835-audio/bcm2835-vchiq.c | 3 ++- .../include/linux/raspberrypi/vchiq.h | 5 ++-- drivers/staging/vc04_services/interface/TODO | 4 --- .../interface/vchiq_arm/vchiq_arm.c | 27 ++++++++++--------- .../interface/vchiq_arm/vchiq_arm.h | 3 ++- .../interface/vchiq_arm/vchiq_core.c | 14 ++++++---- .../interface/vchiq_arm/vchiq_core.h | 1 + .../interface/vchiq_arm/vchiq_dev.c | 8 ++---- .../vc04_services/vchiq-mmal/mmal-vchiq.c | 7 ++--- 9 files changed, 38 insertions(+), 34 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/= drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 133ed15f3dbc..dc0d715ed970 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -96,7 +96,8 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio= _instance *instance, static int audio_vchi_callback(struct vchiq_instance *vchiq_instance, enum vchiq_reason reason, struct vchiq_header *header, - unsigned int handle, void *userdata) + unsigned int handle, + void *cb_data, void __user *cb_userdata) { struct bcm2835_audio_instance *instance =3D vchiq_get_service_userdata(vc= hiq_instance, handle); diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.= h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index 9a6ab006bed2..ee4469f4fc51 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -56,7 +56,7 @@ struct vchiq_service_base { enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, - void *bulk_userdata); + void *cb_data, void __user *cb_userdata); void *userdata; }; =20 @@ -65,6 +65,7 @@ struct vchiq_completion_data_kernel { struct vchiq_header *header; void *service_userdata; void *cb_data; + void __user *cb_userdata; }; =20 struct vchiq_service_params_kernel { @@ -73,7 +74,7 @@ struct vchiq_service_params_kernel { enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, - void *cb_data); + void *cb_data, void __user *cb_userdata); void *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ diff --git a/drivers/staging/vc04_services/interface/TODO b/drivers/staging= /vc04_services/interface/TODO index dfb1ee49633f..2ae75362421b 100644 --- a/drivers/staging/vc04_services/interface/TODO +++ b/drivers/staging/vc04_services/interface/TODO @@ -27,10 +27,6 @@ The code follows the 80 characters limitation yet tends = to go 3 or 4 levels of indentation deep making it very unpleasant to read. This is specially rele= vant in the character driver ioctl code and in the core thread functions. =20 -* Clean up Sparse warnings from __user annotations. See -vchiq_irq_queue_bulk_tx_rx(). Ensure that the address of "&waiter->bulk_wa= iter" -is never disclosed to userspace. - * Fix behavior of message handling =20 The polling behavior of vchiq_bulk_transmit(), vchiq_bulk_receive() and 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 bcfd4ccc8373..505ab32e071c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -632,7 +632,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl static int add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, struct user_service *user_service, - void *bulk_userdata) + void *cb_data, void __user *cb_userdata) { struct vchiq_completion_data_kernel *completion; struct vchiq_drv_mgmt *mgmt =3D dev_get_drvdata(instance->state->dev); @@ -662,7 +662,8 @@ add_completion(struct vchiq_instance *instance, enum vc= hiq_reason reason, completion->reason =3D reason; /* N.B. service_userdata is updated while processing AWAIT_COMPLETION */ completion->service_userdata =3D user_service->service; - completion->cb_data =3D bulk_userdata; + completion->cb_data =3D cb_data; + completion->cb_userdata =3D cb_userdata; =20 if (reason =3D=3D VCHIQ_SERVICE_CLOSED) { /* @@ -693,8 +694,8 @@ add_completion(struct vchiq_instance *instance, enum vc= hiq_reason reason, =20 static int service_single_message(struct vchiq_instance *instance, - enum vchiq_reason reason, - struct vchiq_service *service, void *bulk_userdata) + enum vchiq_reason reason, struct vchiq_service *service, + void *cb_data, void __user *cb_userdata) { struct user_service *user_service; =20 @@ -712,7 +713,7 @@ service_single_message(struct vchiq_instance *instance, dev_dbg(instance->state->dev, "arm: Inserting extra MESSAGE_AVAILABLE\n"); ret =3D add_completion(instance, reason, NULL, user_service, - bulk_userdata); + cb_data, cb_userdata); if (ret) return ret; } @@ -730,7 +731,8 @@ service_single_message(struct vchiq_instance *instance, =20 int service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, - struct vchiq_header *header, unsigned int handle, void *bulk_userdata) + struct vchiq_header *header, unsigned int handle, + void *cb_data, void __user *cb_userdata) { /* * How do we ensure the callback goes to the right client? @@ -769,9 +771,9 @@ service_callback(struct vchiq_instance *instance, enum = vchiq_reason reason, rcu_read_unlock(); =20 dev_dbg(service->state->dev, - "arm: service %p(%d,%p), reason %d, header %p, instance %p, bulk_userdat= a %p\n", + "arm: service %p(%d,%p), reason %d, header %p, instance %p, cb_data %p, = cb_userdata %p\n", user_service, service->localport, user_service->userdata, - reason, header, instance, bulk_userdata); + reason, header, instance, cb_data, cb_userdata); =20 if (header && user_service->is_vchi) { spin_lock(&service->state->msg_queue_spinlock); @@ -783,8 +785,8 @@ service_callback(struct vchiq_instance *instance, enum = vchiq_reason reason, DEBUG_TRACE(SERVICE_CALLBACK_LINE); DEBUG_COUNT(MSG_QUEUE_FULL_COUNT); =20 - ret =3D service_single_message(instance, reason, - service, bulk_userdata); + ret =3D service_single_message(instance, reason, service, + cb_data, cb_userdata); if (ret) { DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); @@ -822,7 +824,7 @@ service_callback(struct vchiq_instance *instance, enum = vchiq_reason reason, return 0; =20 return add_completion(instance, reason, header, user_service, - bulk_userdata); + cb_data, cb_userdata); } =20 void vchiq_dump_platform_instances(struct vchiq_state *state, struct seq_f= ile *f) @@ -909,7 +911,8 @@ static int vchiq_keepalive_vchiq_callback(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, - unsigned int service_user, void *bulk_user) + unsigned int service_user, + void *cb_data, void __user *cb_userdata) { dev_err(instance->state->dev, "suspend: %s: callback reason %d\n", __func__, reason); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index b402aac333d9..e32b02f99024 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -155,7 +155,8 @@ static inline int vchiq_register_chrdev(struct device *= parent) { return 0; } =20 extern int service_callback(struct vchiq_instance *vchiq_instance, enum vchiq_reason = reason, - struct vchiq_header *header, unsigned int handle, void *bulk_userdata); + struct vchiq_header *header, unsigned int handle, + void *cb_data, void __user *cb_userdata); =20 extern void free_bulk_waiter(struct vchiq_instance *instance); 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 3c811b8f210c..064c22fa31c9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -458,20 +458,23 @@ make_service_callback(struct vchiq_service *service, = enum vchiq_reason reason, struct vchiq_header *header, struct vchiq_bulk *bulk) { void *cb_data =3D NULL; + void __user *cb_userdata =3D NULL; int status; =20 /* - * If a bulk transfer is in progress, pass bulk->cb_data to the + * If a bulk transfer is in progress, pass bulk->cb_*data to the * callback function. */ - if (bulk) + if (bulk) { cb_data =3D bulk->cb_data; + cb_userdata =3D bulk->cb_userdata; + } =20 - dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %pK, %pK)\n", + dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %pK, %pK %pK)\n", service->state->id, service->localport, reason_names[reason], - header, cb_data); + header, cb_data, cb_userdata); status =3D service->base.callback(service->instance, reason, header, serv= ice->handle, - cb_data); + cb_data, cb_userdata); if (status && (status !=3D -EAGAIN)) { dev_warn(service->state->dev, "core: %d: ignoring ERROR from callback to service %x\n", @@ -3073,6 +3076,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, bulk->dir =3D bulk_params->dir; bulk->waiter =3D bulk_params->waiter; bulk->cb_data =3D bulk_params->cb_data; + bulk->cb_userdata =3D bulk_params->cb_userdata; bulk->size =3D bulk_params->size; bulk->offset =3D bulk_params->offset; bulk->uoffset =3D bulk_params->uoffset; 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 f9a2268ad47e..fadca7b1b196 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -115,6 +115,7 @@ struct vchiq_bulk { short mode; short dir; void *cb_data; + void __user *cb_userdata; struct bulk_waiter *waiter; dma_addr_t dma_addr; int size; 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 fcdf97391fb6..454f43416503 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -338,7 +338,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, bulk_params.mode =3D args->mode; bulk_params.size =3D args->size; bulk_params.dir =3D dir; - bulk_params.cb_data =3D args->userdata; + bulk_params.cb_userdata =3D args->userdata; =20 status =3D vchiq_bulk_xfer_callback(instance, args->handle, &bulk_params); @@ -549,11 +549,7 @@ static int vchiq_ioc_await_completion(struct vchiq_ins= tance *instance, !instance->use_close_delivered) vchiq_service_put(service); =20 - /* - * FIXME: address space mismatch, does cb_data - * actually point to user or kernel memory? - */ - user_completion.cb_userdata =3D completion->cb_data; + user_completion.cb_userdata =3D completion->cb_userdata; =20 if (vchiq_put_completion(args->buf, &user_completion, ret)) { if (ret =3D=3D 0) diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/driver= s/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 67489c334f7b..3fe482bd2793 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -551,7 +551,8 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *i= nstance, /* incoming event service callback */ static int mmal_service_callback(struct vchiq_instance *vchiq_instance, enum vchiq_reason reason, struct vchiq_header *header, - unsigned int handle, void *bulk_ctx) + unsigned int handle, void *cb_data, + void __user *cb_userdata) { struct vchiq_mmal_instance *instance =3D vchiq_get_service_userdata(vchiq= _instance, handle); u32 msg_len; @@ -626,11 +627,11 @@ static int mmal_service_callback(struct vchiq_instanc= e *vchiq_instance, break; =20 case VCHIQ_BULK_RECEIVE_DONE: - bulk_receive_cb(instance, bulk_ctx); + bulk_receive_cb(instance, cb_data); break; =20 case VCHIQ_BULK_RECEIVE_ABORTED: - bulk_abort_cb(instance, bulk_ctx); + bulk_abort_cb(instance, cb_data); break; =20 case VCHIQ_SERVICE_CLOSED: --=20 2.45.2