Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp6086501pxb; Thu, 27 Jan 2022 06:16:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWXGbG03rqtpkfOfhdA0saL4Ag7FVY/BdZ4w1JFMQkVhYEuFm7HOjD42gvANPm7OTgzGF5 X-Received: by 2002:a17:907:c0c:: with SMTP id ga12mr3175176ejc.592.1643293000098; Thu, 27 Jan 2022 06:16:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643293000; cv=pass; d=google.com; s=arc-20160816; b=QHeMdTdPJ8lnZVuB/xUFgS1mv5befOi/e+KFF2wAJHiAU80va2aBJx8VN29k/UUpTW Dd8/IXVL/8Ys/sZVlDTF7K15+RIEOQSTAe7bLDiV/xvX/Am+qYY2L7Xv8XXPupJgAGJP wafRmFHCu1OSXqoDcys3tRHtlkqus20umMKFYkwXxl2Q4g5dXRhdWk6X2nkTSppPA1aZ U8sZtHz4pZc6JUqQYHmeCQnwQ45uLvBBSFmBlu+qmEaUyEQumNTH4UCUyen58LsIfDfP Yc88p+8cLO7Cd2JEPN3HE4MaEvfojkxfHBvQKJVxCwX5of+RH4FAufPaC94NjBP5UsPG DLOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=AR+EDFGOzsUW5LhvTdY3qjkB58bO4nC39U+i2bVySE0=; b=rzptGbyuhyK3NUBTTNttw4j50uExCyaBZbl+TMHtkVlzOPzu3dqCQSC8ITrT7X73Qk xipkCXDjnImsD9A7hwDlF9NeCdxGVoxigM4skHwbdztSFsS54LKvE7cD+4xC6lTvb/Jw EoMwb4V409CZl+A5o5D8K2IcRz5tPan1HvpJMWw2Z/WCQP9Ke24HfD3X6P3v7bAJXaKo 9ZPfajAJepVcMG45Ha4jsTMTyYLmog0SkxEw9hcgROQSGs9rtfaZFKcgJBedXgJW5G30 8IGlQxveev8yDJszyigtniWcwMIKTpG69nM0pkHTXVIrDUcT0ALKCiV1Z2cMPlyS9RLY XDfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=kk8bFkFc; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt22si1461695ejc.562.2022.01.27.06.16.13; Thu, 27 Jan 2022 06:16:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=kk8bFkFc; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237607AbiA0IDK (ORCPT + 99 others); Thu, 27 Jan 2022 03:03:10 -0500 Received: from mail-bn8nam12on2074.outbound.protection.outlook.com ([40.107.237.74]:28640 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229656AbiA0IDJ (ORCPT ); Thu, 27 Jan 2022 03:03:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SuTRizXua4ajtOax59GcvnydUvJFTGU5ajOyzMqR+BOtbACbr37AOHJZq+y/JlJAsaaonb81cvx4R1iwc40GFsSFfaX5mra3kUTy4ljd+4t7JO80gmwb+13XrmIKwTeHN8lenUHY5bfoMPUj8EiBXEuNkDM5bP9FQjkb1UFRBGlPwzq2FLQfgZ2q2/IM9PGW6/YorRgygk6pRpQkSfV9Wwwy+cCcQfeMoyY9p9UMl9vNI2WvRpTnKtp3xyNBe9u0bTsgjSXgnH54hj2dx+GI8ZQXxoFVUVHiXdn1vPichc6TM/jHXIDiplifb66s1outTjZvZ23lYyCfU13mkg/67w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AR+EDFGOzsUW5LhvTdY3qjkB58bO4nC39U+i2bVySE0=; b=XPNIYS5gszOwOrSfb+xa7MuEElMPwtp+wobYff+kupiDypnUcby70BwDODypeh/yF9LVg5CU9lr3wsAOmkAGduhLNOQZM8dTcAQXqekNOmVhlmteX6r8+UzzJf6Jh80Sn4N/fZScXq8WG9BcrjE/exs+dCqzcUv3m5bFYMKHopUm6sM6wtvVhKkhQ37pG+XhvgxF58sKfZcg4krfRQC6l/Uh+OXqedJDeJSHsulygm7ZZ4SpzgoFrGN0HJmdJLLeib07aVv9nZvNoWkDUj60F7UFcB4ciSvQP8gV2skcA8e3Hxpxs0n3mY+UDl0uiDhPQbpQCAB9V1OIeL+PhhfoKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AR+EDFGOzsUW5LhvTdY3qjkB58bO4nC39U+i2bVySE0=; b=kk8bFkFcOFFlpb3qCJpRv5DuEZ86rLUk0+UfHBys+MkpsOeuU/dOGRCAycZlcQpBI55W3IsQP+XvLmHy5nP2x6R/im0nf/3OKDRL24MyLimTunSI9da/pvGdZVLsw7qulk/F8z45cgQBjh5GEU/FSNuyjB4G9GNQmsyuXJe3biY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by CO6PR12MB5473.namprd12.prod.outlook.com (2603:10b6:303:13e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 08:03:06 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::d8e7:e6b0:d63c:4a21]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::d8e7:e6b0:d63c:4a21%5]) with mapi id 15.20.4909.019; Thu, 27 Jan 2022 08:03:06 +0000 Message-ID: <3066c6a7-fc73-d34d-d209-a3ff6818dfb6@amd.com> Date: Thu, 27 Jan 2022 09:02:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 02/19] dma-buf-map: Add helper to initialize second map Content-Language: en-US To: Lucas De Marchi Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org References: <20220126203702.1784589-1-lucas.demarchi@intel.com> <20220126203702.1784589-3-lucas.demarchi@intel.com> <20220127075728.ygwgorhnrwaocdqv@ldmartin-desk2> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220127075728.ygwgorhnrwaocdqv@ldmartin-desk2> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AS8P250CA0029.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::34) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9e0245dc-f281-44e1-032e-08d9e16b735e X-MS-TrafficTypeDiagnostic: CO6PR12MB5473:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LX8U+OTeYsy2Visv2MIflc5t5HOnB1qYPCwWEL3dn92t2debJgxL/q3CASlBXj8MSRpGs3Z8fpFtaIv05OlRgsHQb1D3QppAmEHUXpEHVZ5/RDq0fnPx3LONfMZxQdyexz/7h8YYqqh69fVUst6UHBmZM6PoCJur/fDIc0CdsRHp2KbI20ZnpWXp0t1AzvtUHPXwVsEWf3tYPF6UdYFj1ujDCFSKmvEwO5AzA4bWqMi94CrOq75kta/v/bOJB9EORhk4ogK6AbVnPoDjZHLPJ6PB9RgG8TOLtJeBM9D2TEOgWbVlM6aWmqJT6sUbcM/y2VpZRyI1zkkWgqUAClCNXtw1nJQYN/hSZtQLem1ALJtYH333Ita7KojyKr3+8u3cx4iHn3OagaCPdkibi9C9CA149XeZAgajpbFXBPIIl9+TzLlmieyP/JZcgGOkDYNL8hYn8QQVzhgX9nf5IQBycVinVtY9AFsERV8VV5WuKFF9PmwfEPL+qnMSLH06szigE1v6wShUECYIDHxykd1aEaXhelrqh9Dvn9C6SFAgBnNjJ8U0VgH51Yp8nN8p2qr5Toho2cTYwK3b7hwOc/U+uK2ODWOwsutHdnDq2e8I9Z1MqVV4+hqRPBEWnwSoUshykPchr0Hrp6DyvMTTLQQUTfj+vEo4+hxxei6T9huoxuMbDeuJnbRtiljR/UyWKtKrxFP8C/xw0PAkEJDXv4QnTFoOeaoo6tdgoo5YjvBdcARjxyJifpIC6njt/MBuVMUT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(2616005)(66556008)(66476007)(186003)(8936002)(8676002)(316002)(66946007)(6506007)(2906002)(31696002)(38100700002)(86362001)(31686004)(36756003)(6486002)(5660300002)(66574015)(508600001)(6916009)(6512007)(4326008)(6666004)(43740500002)(45980500001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TE0xUVJYMFRvVnY3TzRLWjFSLzQvUmRiRWlJZzd4ZVM0anRHb0hsMWVkVVFo?= =?utf-8?B?NFZxeWZ2NFM1ZDBQeDB3QTBnUVlXNzFVSWxGa3I2N0ZXNjIxUXR0WXNrUm41?= =?utf-8?B?YzFHNlBBbWh1NWJRV0ZvTnV3S2FWdHVRMjJCM0trcHdEV2tlTzgwT1hWWE8z?= =?utf-8?B?WkoxTjVrSElrNG5XSkthWDZ1NlRnZVhRUDVQbDVZQWg3aVdNZ2d6aWswWFZF?= =?utf-8?B?d1prNXVEL1N1R0RoVktyeVc0UEorTWhmV0R6aUo2QzBPNzRlenBnMDhISFBC?= =?utf-8?B?SWgzaTN1M21VSDIwTTEyRmxadTlUTSt5Mmo4c0h5YXRjQk5UV05VYmYyZmJz?= =?utf-8?B?cVNJekF3WHFJTTBzWTc1aTdkYmlkbzV3dFN6ZURTN00zR2xBTUxQa3dwU0pM?= =?utf-8?B?YXVKUmNsSEdXbjdsby9xaUlUMnhqMzlVNngxRFM5eFZ6YzV2N0NET2RGNm1N?= =?utf-8?B?OW5wYlMyZFEvMmFmck5SRVo1NE5heHBISnBCVWpScXNva3pmN3A5WXpTUWcr?= =?utf-8?B?cHFXQU1BMVdEME9BZzc3aHl5VzZnK3NKcTZNaEpCNXB6UEEvcTZvUHdyY3pG?= =?utf-8?B?TTl5Wm10ZXBHQSt1N1VQaDlpaWQ5ek1RS2NqQWZza0NSRHhOb3o2aG9ZVDVE?= =?utf-8?B?VFVwM0pVMnJF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rTlh0SVdVZkptMW5EU3dZeW5jU1A4OGd2WXZ4MGJ1dUNVdXBDU0h4MEJu?= =?utf-8?B?UTFJNzI4eHFNNVpJMTNzVlJ1UTl2RnplV3B6TnZoTjdyaDNWWmQ0b1M2ald3?= =?utf-8?B?dzQ5eVFiWkVmcGJoclZlTkZTMmFQd1VQZkxTQ2lhVGl6NHdQSEltRURrbTRx?= =?utf-8?B?QzdtZ1l1dUVML1VITkFzRTNaTWx5eWF5K3VrV0ZSd3dOVU96ZlpoY2VZMC9H?= =?utf-8?B?RXl6bnAwSXFweVlsTzRWdWQxTjZBMWcvUkhzRFNlTlg1UjladHZLK3B3RTYz?= =?utf-8?B?SDhlbDdHQ3VBYXBGOENyN3IvRFRLM3ZtMm1UUEIyUnJVV2pOaDIwYVMyUEhU?= =?utf-8?B?TGZoWVdDNTJlejI1a0dBWmdzcG1aU29YbDdWMnVrV0dBUHZpejFXd2lWVGt2?= =?utf-8?B?akRWeEU4c2ZiMkcwQUcyV0x6R0NUd09ibjNUelNoa01aUlZMQ1ZsUjF0N2Zy?= =?utf-8?B?YzJvcVhod2NrempyOExrdTMzc095Vm8rd0phYXcyQmhhenlRaERQbEw2SUtG?= =?utf-8?Q?S9Cc=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e0245dc-f281-44e1-032e-08d9e16b735e X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 08:03:06.4802 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ev7j0D85yEiTy+bY73916INA6q54x5FghEEwvXHcvtxFMo+fWkrbRtMUowMpQ/DU X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5473 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 27.01.22 um 08:57 schrieb Lucas De Marchi: > On Thu, Jan 27, 2022 at 08:27:11AM +0100, Christian König wrote: >> Am 26.01.22 um 21:36 schrieb Lucas De Marchi: >>> When dma_buf_map struct is passed around, it's useful to be able to >>> initialize a second map that takes care of reading/writing to an offset >>> of the original map. >>> >>> Add a helper that copies the struct and add the offset to the proper >>> address. >> >> Well what you propose here can lead to all kind of problems and is >> rather bad design as far as I can see. >> >> The struct dma_buf_map is only to be filled in by the exporter and >> should not be modified in this way by the importer. > > humn... not sure if I was  clear. There is no importer and exporter here. Yeah, and exactly that's what I'm pointing out as problem here. You are using the inter driver framework for something internal to the driver. That is an absolutely clear NAK! We could discuss that, but you guys are just sending around patches to do this without any consensus that this is a good idea. Regards, Christian. > There is a role delegation on filling out and reading a buffer when > that buffer represents a struct layout. > > struct bla { >     int a; >     int b; >     int c; >     struct foo foo; >     struct bar bar; >     int d; > } > > > This implementation allows you to have: > >     fill_foo(struct dma_buf_map *bla_map) { ... } >     fill_bar(struct dma_buf_map *bla_map) { ... } > > and the first thing these do is to make sure the map it's pointing to > is relative to the struct it's supposed to write/read. Otherwise you're > suggesting everything to be relative to struct bla, or to do the same > I'm doing it, but IMO more prone to error: > >     struct dma_buf_map map = *bla_map; >     dma_buf_map_incr(map, offsetof(...)); > > IMO this construct is worse because at a point in time in the function > the map was pointing to the wrong thing the function was supposed to > read/write. > > It's also useful when the function has double duty, updating a global > part of the struct and a table inside it (see example in patch 6) > > thanks > Lucas De Marchi