From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 9D9D1370D47 for ; Thu, 2 Apr 2026 11:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775131004; cv=none; b=NivaSba3S+ZCfeku9VpzMhZdHQB2UBGVm+c80xhhKI4E310jUF88Clxmy3+g6Bt1RRJ+JnO9XFpPIdXBmR9c4MUnomfMUsdh1/NcsH1ste0VNBy5BbAXMkPl1QWnDNFexOA/ObdSQVzCtxfuqWyzBjkEcSEVDVSIprTgVGbLe8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775131004; c=relaxed/simple; bh=0hhpUie3lopwdf2kqOxnj7Te7az2UkNJRTHQmk5UaW4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mrIBXs0iytJXqcFSWns4vXHXziCNLdWZtn/F/SyiSOrD9i5/tUj2BitSOVpO3s5rxkoUVxhk9HAOCJNUFK7AtRN8+ihS0HUMphU/wvQQVwUEDrKohf4SfEk8VIvXoV6GmbUDx/GQN4VcFlHajih9f2650MELadhToNtj6fb8jlc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=NjaTrbs5; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="NjaTrbs5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1775130999; bh=0hhpUie3lopwdf2kqOxnj7Te7az2UkNJRTHQmk5UaW4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NjaTrbs5C60sH5YHp4CHk7C6WkI0BVcauRvLpfDhfMNLj5n6rtW9n3shMyNk/QO/q sEWvMG5fWsUGQEN3hxL+9svpOntVg1i4kpCaE8NVv+YR7O+uOpE5dNTj2FEpkjZXTX I2xLgPp7ZcSN+rUy1t1ZDhTCVuJuY/vFT9HNcwi/JIrtuo1r1SeKM7UezEcSpvQvuY +xJWmsMPub6YvoN0/ZrhcYPrKfN+SHdQagZ1plfKwf1diSgqWiwVNc3tbeFT2Af/xs /lGkPBTJAUsL+fwii3NohWp+jfJHjhN3Uzt//YjmzYkch90GlRyRoPtbgmFQTcwrUo vvRzxEUx1Ww4A== Received: from [10.40.0.100] (185-67-175-126.lampert.tv [185.67.175.126]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mriesch) by bali.collaboradmins.com (Postfix) with ESMTPSA id B24E017E7C56; Thu, 2 Apr 2026 13:56:38 +0200 (CEST) Message-ID: <25492190-7f46-40c8-8d90-ff53168d3971@collabora.com> Date: Thu, 2 Apr 2026 13:56:37 +0200 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 10/22] media: v4l2-subdev: Refactor returning routes To: Sakari Ailus , linux-media@vger.kernel.org Cc: hans@jjverkuil.nl, laurent.pinchart@ideasonboard.com, Prabhakar , Kate Hsuan , Dave Stevenson , Tommaso Merciai , Benjamin Mugnier , Sylvain Petinot , Christophe JAILLET , Julien Massot , Naushir Patuck , "Yan, Dongcheng" , "Cao, Bingbu" , "Qiu, Tian Shu" , Stefan Klug , Mirela Rabulea , =?UTF-8?Q?Andr=C3=A9_Apitzsch?= , Heimir Thor Sverrisson , Kieran Bingham , Mehdi Djait , Ricardo Ribalda Delgado , Hans de Goede , Jacopo Mondi , Tomi Valkeinen , David Plowman , "Yu, Ong Hock" , "Ng, Khai Wen" , Jai Luthra References: <20260325105818.1176816-1-sakari.ailus@linux.intel.com> <20260325105818.1176816-11-sakari.ailus@linux.intel.com> Content-Language: en-US From: Michael Riesch In-Reply-To: <20260325105818.1176816-11-sakari.ailus@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Sakari, On 3/25/26 11:58, Sakari Ailus wrote: > Refactor returning the routes by adding a new function that essentially > does a memcopy and sets the number of the routes in the routing table. > > Signed-off-by: Sakari Ailus Reviewed-by: Michael Riesch Thanks and best regards, Michael > --- > drivers/media/v4l2-core/v4l2-subdev.c | 34 +++++++++++++-------------- > 1 file changed, 16 insertions(+), 18 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index 831c69c958b8..f8fde395a53a 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -629,6 +629,19 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh, > v4l2_subdev_get_unlocked_active_state(sd); > } > > +static void copy_routes_state_to_routing(struct v4l2_subdev_routing *routing, > + const struct v4l2_subdev_state *state) > +{ > + struct v4l2_subdev_route *routes = > + (struct v4l2_subdev_route *)(uintptr_t)routing->routes; > + u32 copy_routes = min(routing->len_routes, state->routing.num_routes); > + > + for (u32 i = 0; i < copy_routes; i++) > + routes[i] = state->routing.routes[i]; > + > + routing->num_routes = state->routing.num_routes; > +} > + > static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, > struct v4l2_subdev_state *state) > { > @@ -1000,7 +1013,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, > > case VIDIOC_SUBDEV_G_ROUTING: { > struct v4l2_subdev_routing *routing = arg; > - struct v4l2_subdev_krouting *krouting; > > if (!v4l2_subdev_enable_streams_api) > return -ENOIOCTLCMD; > @@ -1010,13 +1022,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, > > memset(routing->reserved, 0, sizeof(routing->reserved)); > > - krouting = &state->routing; > - > - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, > - krouting->routes, > - min(krouting->num_routes, routing->len_routes) * > - sizeof(*krouting->routes)); > - routing->num_routes = krouting->num_routes; > + copy_routes_state_to_routing(routing, state); > > return 0; > } > @@ -1084,11 +1090,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, > * the routing table. > */ > if (!v4l2_subdev_has_op(sd, pad, set_routing)) { > - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, > - state->routing.routes, > - min(state->routing.num_routes, routing->len_routes) * > - sizeof(*state->routing.routes)); > - routing->num_routes = state->routing.num_routes; > + copy_routes_state_to_routing(routing, state); > > return 0; > } > @@ -1102,11 +1104,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, > if (rval < 0) > return rval; > > - memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, > - state->routing.routes, > - min(state->routing.num_routes, routing->len_routes) * > - sizeof(*state->routing.routes)); > - routing->num_routes = state->routing.num_routes; > + copy_routes_state_to_routing(routing, state); > > return 0; > }