Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp6065612pxb; Thu, 27 Jan 2022 05:52:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxASKEO/HzNen1950pLCJiI8z4SApRk7qminGfBGKpCH3Qg7tFXAju/n/JydC3vus0QAe1 X-Received: by 2002:a17:90b:38d1:: with SMTP id nn17mr1344251pjb.219.1643291563554; Thu, 27 Jan 2022 05:52:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643291563; cv=pass; d=google.com; s=arc-20160816; b=RCzXwoqzg04fANbkt3yhROo9g+shgikj+O57bJRlfg/YOelrYRoXf+LC9/zUrp+afp ldw5zU46IQaF3GjlRyVFwkR9nrPRP1F29bRndW5Bc6RWcsIeuwgSkYR6d3ymIjAP9xRO nCkPp66T/5fXXb+0zNfxPRIFiy6sYpawcZasO4Qr7gyMNgj3TU2UOjMnMY3q3MMAxjdv 2Y88IS9M44tcQUo6cR9loV+6EnRSV6g9cWqxrc5wZhuliRLmf3a1sX2FjwkjkLlzsN55 LT18eNyE3EZPCjiZcExDM2RsUmUkxsLkswOhaB5pLyBov683/D9pE9xHwvbXyCzzqfRO Z1jQ== 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=WAyxq43yKpnPAdn+/QR3a/24qkATUY3MSXD/g0pPkSs=; b=pe+v12eLSRwHlu56Mgi7RXC0ny2VoOH0lqEG6pBZQykqrsG6lKjoosGXCqhGUpIMzl WXz1hB4hrgus+09S+jewuPlBD3wvCHNQnDbW+oz64697z03kws1/oa77rnxUMKldFj/M wMVQNNWy1SbRUzUFHUUXFLsA7gam7blikU4EERgWeDoqHoRAOGCt0uYgN5KPrEUEe5pV x6eauB3FVlXFryN2l3w5ALKjL7MW6eIk6tG54kEU7WpqK89ua3dxxdPXndBfiFR0f1HN 5FcGj8LYZEjedlFc/ygL0uVViz3RAXWmjxIziSSHRCu43PzpwE/g4iTxGkekIJgYth8O 2eyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=cCNanOCY; 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 b8si2061996plg.363.2022.01.27.05.52.03; Thu, 27 Jan 2022 05:52:43 -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=cCNanOCY; 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 S237251AbiA0H1U (ORCPT + 99 others); Thu, 27 Jan 2022 02:27:20 -0500 Received: from mail-bn7nam10on2061.outbound.protection.outlook.com ([40.107.92.61]:17760 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237192AbiA0H1T (ORCPT ); Thu, 27 Jan 2022 02:27:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ewdATfFs8IjT/e+aGVdXQJXOwxtpHxevN4Wj0BzSUyE8rhI8QSW/m5T5Lkr2deG9xBD1o6ZVFR9b1ttgEqeC0QmUCUcUc/gjGjaW2D9eex3lG0NdfTUBlL5SKP7z9A9MOqa8TA5ulbkoolwWMTWRpV1+rjTUIhbTpMdh1C1lr7ZybV6JBKH0OUtzGLK7A2h2Z99zN9FIeOJ20q+kNochokDueIsbucbdQBsQz/+1WlKpjXbonZIwfTTR+pX2yQ0l9JdSR/5L+wXu9eVvs5HNMwma6NYKP5/RBZd7n+PAgjgS2zx5QwrELI40eLfI4TXS6Fsmdo4PpsKeLv/OFAQyww== 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=WAyxq43yKpnPAdn+/QR3a/24qkATUY3MSXD/g0pPkSs=; b=oEP//wfdi3bTeTxj1wkCFhGPFT7LdyWx9TlDfoNXJpqp0dyK2hxUsiV1U/a2ZZdTGOrAy7E6pBGFyRDuaEFGff0hD3scKAYEwYDg61qtBeBhk8wV+x3/1N7UGK4Z7nwZGZAPVQQqm8xZcfXSUjBj8KyMjIosCTLlRD/59yQW62HKZ+wqtqz7RjxeTS4mt5Rgba1kYlve5O2DMEMeYc4TPwSruVJlSVR8uVx3DQ4rZUE976cv7h9hnI92pv8XhcwO7z8cSCrnFnjM10cOvBJxc7YIoc+sTrEhYWTIzaNmBm3LJZp8hJ5xXdqlzZ5PvyznKF9apYMhvdZZ2l0yXs0+QA== 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=WAyxq43yKpnPAdn+/QR3a/24qkATUY3MSXD/g0pPkSs=; b=cCNanOCYh2nA4oFcM4j6wyu3JyWaRkxf1nwubTxs3Mvo0NFC3NFPKmtkgL7BiFj/VzIGEKhvkE8rM45VIHRUu9e96ecL/w0KdUADqa5Wd+Nm6Fww6icVPd7r3CsdVOxClD4kWOx7HxLg0K9PpyoOjUo3fUT0LZr4UcdebLcHZDE= 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 (20.178.210.205) by DM6PR12MB2603.namprd12.prod.outlook.com (20.176.116.84) 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 07:27:16 +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 07:27:16 +0000 Message-ID: Date: Thu, 27 Jan 2022 08:27:11 +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 , intel-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, Matt Roper , Sumit Semwal , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org References: <20220126203702.1784589-1-lucas.demarchi@intel.com> <20220126203702.1784589-3-lucas.demarchi@intel.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220126203702.1784589-3-lucas.demarchi@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AM6P191CA0100.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::41) 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: d481c12f-3a39-425a-5287-08d9e1667206 X-MS-TrafficTypeDiagnostic: DM6PR12MB2603: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: qdUT8mdwGgzFGIZkwxj2kvS+CFEhlpkHPxUWvprinf/Q+xGgqqEkcrp6Hlr35ZV65FZLKxN5mCNSTsdzYvdOeYvnt2Cxe8UvrGbl/E3FIGxZ84XkbU8TeqYukirFV/yXIgEk6jwX+BTTSs/3TQUYehm25Gb5Sb1hLOX4hwSubK08hs2kkkQhaH+zQy4lo9PVwDz5AjR74jxoA93h2gwS8+RR3ndWJ7z+u/0lq1yKruZiaFJTfd1j2VPqwdezzKimXQA3yvj0vdSXWmsFuWo1XGWuzvC2lh3Rkn94hXGG5oPtxRwbY7m5NtmjPOWEQp1ijVKWxvK/KLMvZwEjReY1DzdW51w9BuPxKpb0bFodsWAWtEUnJJ1TfGXwGTfnDmD5ZaqEjbr+emZFtZzrVx91Mm6BnsqAnfAA0kML3j/3hPXtr2Y/yBk/JJlbQdW3MAJXk8zfI3iBvqaKsiA+MDO/6QFNJRrfBb9Htwc5FWLyUlv1pw9AZrsD5KPGn2NJCSuooVMYXRoZd+IIbmH8w1SUjFckuwWdksNVWir0c0ffEAzBvNUGyU8iVtxNck9r1TKuXysNBAA8fUhyT6ch05qyP2yRTGQeeC5PG2PrXAlK3MqcTgD2rqLy6O5nVVG25XBsCP7gZRTKtAYYsvf6hNiDcFWvLUG9QUNM/XY5r68GN0cKpam50wA2qrurmGcRANp4fatdQxVciVWgTkf01+7/vXkxHMQ4YMNapCsmsejKSMTaW2kBy9dgJVvxPMPqU6wm 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)(54906003)(38100700002)(5660300002)(66946007)(31696002)(2906002)(66476007)(8936002)(8676002)(316002)(66556008)(6666004)(31686004)(86362001)(4326008)(66574015)(508600001)(2616005)(83380400001)(6512007)(26005)(6506007)(6486002)(36756003)(186003)(45980500001)(43740500002)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?L1BNS0xoR2lDM0pLSUFhRkxWK0R6R0xKUGVnL0tvWU5OTndtQXNINVZVTm1D?= =?utf-8?B?QkM2MnUrdjVWaS9rVVJHbDIxV0ZaTUtJZnNUeDU5cVl3UGdTZjlYdEhhQlU3?= =?utf-8?B?TlhzZm1VSU94SXVUNm1UY0tKcU45V2k4amhINWVoUzVWaml5aHRudTJ0QW8r?= =?utf-8?B?dGFhSWhjcElUNXRPOUYzZEN6TndwTjJxTmFMMGcxN0gzQkRLeWxKSnBVNjBo?= =?utf-8?B?V24yNkpPbG9mMmJsaFBrL0phYWUwWW1EMkl2RThlbFI1TFYvZ1UzTGd6UXdE?= =?utf-8?B?QklOeGsrMWZ0ejRSVWE4WEtzb3JOejVZb25Ta2c1c0JpZCt6MHgwWjFMQU9I?= =?utf-8?B?M3M4Q1R2UXhKTFJkVDZqcE5hYWdOOFBYRW9FeWhOUkdMb0oxWHdBVnNXdlNr?= =?utf-8?B?Q3ZKR1JLK05JTDl2bitDL1JRWXAzNmJFODg1STY1SkVuYm9laVJOUzJ6MnNY?= =?utf-8?B?cmMwRFk4SklMVlVKM1VQRWlCd24rVVErLzN2ZWNxQ2V1U3pKUGRyeDZESjZm?= =?utf-8?B?OWMwVDJyVTlZNFY1VVJJWVlIOFdjVE0weXpiRGtZTS90QVIrQmQ5MHpUeS9C?= =?utf-8?B?Mk96eGovR0d0SjdnWldGVWxtUWdheDhQeURYMUJYbG94eUZmR1ZyVFJ1V3pG?= =?utf-8?B?Ui9VR1ZBa3hoS29vcEJicVRqOE5URzhzYWdVbWtIb2FyeTlGbS9VRnljZUg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dHZwUmtIenZPdHlsNnhvMDlFUTZj?= =?utf-8?B?ck1MaFo5ay81REdkUlR2OXVuVm9BRFlrSW5NRjh1QlZBZUtvNER5NUFWak5E?= =?utf-8?B?STNJRE5mT3l1cFIrVlZRSTVsYXgvRWZLVThrRlNzaldsbVU1Y0ZYdTNSVWg3?= =?utf-8?B?MjBOZjFqbm5iS2gzWkZ6NTFoL21iT3hZdVFHaUtFTit0YlJmN3FTcnhvTi8r?= =?utf-8?B?V3Nrc1cxYWU4RkdKQnF2L0wzWkw4THR4OVJXdVVDMEh6aThvSXRaeXVTSTRi?= =?utf-8?B?aW42OSt6cldjVlpLck5zMXlJblpFVUNaRlgxb1VWVnhycjBrSExLRURVZ0FD?= =?utf-8?B?U3lrTDVYZEhicXZJNVdWUEVpdVlZQ1NZOTJXeU1DRzJDUzRaZ2lpUGl0ZlJG?= =?utf-8?B?Um1YK2Q4eGJGbzduNHpDOHM1VStrRHZmZ3BvTUVBZk9YZnRHYXc2NlEyU00v?= =?utf-8?B?eTVRTmlBMFRuejJRS3hjMW1zc2lRWjdTcWZRMVJLM1lVaTZzNWRDM1hMTjdW?= =?utf-8?Q?DcAI=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d481c12f-3a39-425a-5287-08d9e1667206 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:27:16.7285 (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: qTeNZA25bCsp6F6Bu4QZ6LPuOXo8IuwLb5ZyzhycE+6kwzYXhSwxy9ifbedTjLrC X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2603 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. If you need to copy only a certain subset of the mapping use the functions you added in patch #1. Regards, Christian. > > Cc: Sumit Semwal > Cc: Christian König > Cc: linux-media@vger.kernel.org > Cc: dri-devel@lists.freedesktop.org > Cc: linaro-mm-sig@lists.linaro.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Lucas De Marchi > --- > include/linux/dma-buf-map.h | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h > index 65e927d9ce33..3514a859f628 100644 > --- a/include/linux/dma-buf-map.h > +++ b/include/linux/dma-buf-map.h > @@ -131,6 +131,35 @@ struct dma_buf_map { > .is_iomem = false, \ > } > > +/** > + * DMA_BUF_MAP_INIT_OFFSET - Initializes struct dma_buf_map from another dma_buf_map > + * @map_: The dma-buf mapping structure to copy from > + * @offset: Offset to add to the other mapping > + * > + * Initializes a new dma_buf_struct based on another. This is the equivalent of doing: > + * > + * .. code-block: c > + * > + * dma_buf_map map = other_map; > + * dma_buf_map_incr(&map, &offset); > + * > + * Example usage: > + * > + * .. code-block: c > + * > + * void foo(struct device *dev, struct dma_buf_map *base_map) > + * { > + * ... > + * struct dma_buf_map = DMA_BUF_MAP_INIT_OFFSET(base_map, FIELD_OFFSET); > + * ... > + * } > + */ > +#define DMA_BUF_MAP_INIT_OFFSET(map_, offset_) (struct dma_buf_map) \ > + { \ > + .vaddr = (map_)->vaddr + (offset_), \ > + .is_iomem = (map_)->is_iomem, \ > + } > + > /** > * dma_buf_map_set_vaddr - Sets a dma-buf mapping structure to an address in system memory > * @map: The dma-buf mapping structure