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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 46546C4332F for ; Tue, 22 Nov 2022 18:32:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB42610E19F; Tue, 22 Nov 2022 18:32:17 +0000 (UTC) Received: from aposti.net (aposti.net [89.234.176.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EC0F10E19F for ; Tue, 22 Nov 2022 18:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1669141933; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=ls59NSxoowl1YHzKUqoYm3Umwpb9DLx70E9cFNt3ycM=; b=r42SA0DwiOL65+NfArUpGDbV6z+GbEWK2qOdJkFc2XomKCrLE6QgFb7RQKQsNb20YWjEfE u51qN4XQx66gPijxZteWQnSXznbXx05uhctrb/D0NYVfRyilu+s7PANoEubQfVyKUG81dt D1TocMiLfCqWaA5mwGK+Yq/E6IlZFIc= Date: Tue, 22 Nov 2022 18:32:04 +0000 From: Paul Cercueil Subject: Running into problems with UDMABUF To: Gerd Hoffman Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Gerd, I'm running into a problem trying to use UDMABUF and I'm not sure if it's a bug in udmabuf, or I'm just using it wrong. I create a UDMABUF in userspace, enable CPU access to it, copy some data, disable CPU access, then register it with the IIO subsystem using an ioctl I'm working on (not yet upstream). In udmabuf.c, the "get_sg_table" function is first called by the "begin_cpu_udmabuf", and then called a second time by "map_udmabuf" when the IIO subsystem creates a dma_buf_attachment then maps it. Now the behaviour I'm seeing, is that the first call to "dma_map_sgtable" in get_sg_table sets sg->nents == 1 which is equal to sg_nents(sg->sgl) and as such is the expected value, but the second call to "dma_map_sgtable" will set sg->nents == 0 and I don't understand why. I wonder if you are seeing this behaviour as well? Cheers, -Paul