Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp539802lqb; Wed, 29 May 2024 03:37:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUX8/iKZodGkndzZs7Vpl6fjQHV799AfnJdGnn1b0bDsYNRza+oN89x9myj5AWQj9/n4c4DNyTRRwr+h3tdVraD6ZgPZ5Uo3PZduQp+DQ== X-Google-Smtp-Source: AGHT+IF+2PrESuY5wUdmmV1OQNEN76Q3Hk65GDYzOGA97MZQafPqGD/0rwCKBAgPHtFtYtG60JqC X-Received: by 2002:a50:8ad8:0:b0:578:61c6:1cd0 with SMTP id 4fb4d7f45d1cf-57861c6944bmr8518530a12.21.1716979075656; Wed, 29 May 2024 03:37:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716979075; cv=pass; d=google.com; s=arc-20160816; b=OkeU6AHhaOce1o/SnEY3zVpMMDdSRcJ7S05DsV2QbPbEEnl6dg/f0iBnkLE1Tb1ebN /V31dInGYrmvOEwDnXReiJil8yhmRcxXZk6cqicphhopKK2BjTLv5GJaChuhVio542Yd NDtVpex9jNSaG+of+NuTH3ivxDYPI7Sd5uefOhkzySGHoBlC4sVbRkJH87kkSDFCKpDn bmdLpqv7Dl7qd26/7E8dl5UJhiDdgSeziDOAQEThY72xHH8Jea213sT+EPd1QydY0q5/ UMvF2aDiAU1O/iRsmkGsmo+7NBJP9N9NlZ4U8A2SsjCXF+ezzebFZGIMrAAZtM9e5/E3 M8mQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=8T+4C++Ip51NQNCNOm8O3oTdvMVRbk5XM6uYT3Xq7q4=; fh=aKNR0jmZSHxe/5pL9rL+fcf0c6UC9bEQDzLjs2VrgGk=; b=Kcf4ICeU5DL1MB2YOE8BdkslG3PXdaD3P43xREQu3HSISjEe6Fq/PVOO7+xBSH+khh wAKHJQpbqfjdkigbUIls3citsA1Nq0DVuHhQcOl0kJceOjnXZlvjlseWU0Seto9oexKb D768ezVt4HxmSz3hiBMAr0WTTE4wh66rkGF7rbWkdicX8S1TaPs4iE5rRMh7CATTpriC jz28T4RlP70oTov0eYS3nv5qBGS/PVvFT6EwG6KSSwrb4UGnQQwvbrx2EPpefM+LjLge 5MG9C5TgAtIUteQBscc+X6OyC29+quEIDHrAzNRIiCxvKvXG0jVAH763zmVnHcgVmKr4 Y+lw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MzNXaqIB; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-193964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a07a46625si577840a12.369.2024.05.29.03.37.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 03:37:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MzNXaqIB; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-193964-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193964-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D31D11F2729A for ; Wed, 29 May 2024 10:32:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B28F117BB0D; Wed, 29 May 2024 10:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MzNXaqIB" Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BE5217F36E for ; Wed, 29 May 2024 10:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716978697; cv=none; b=dO+yjpK6yITTIEBJ11ZkrBFXZALCTILT5tnBTM4/RGXfNDpwd5XNyfAT3get2arxO+nFhiOXRTXpFMbj9h3Yoya1ZqgjTsnpHWjPkhH2+AMkQxAgO6Oz1P8G2i8DUw+Pn6L9gZxmBt7+llpS2VKi5gnyr7KW2nqRlhmJl/0iBKQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716978697; c=relaxed/simple; bh=DS+16H0AoYGVFQHMjyOcarJ501kZjn4XcqcccgjkI58=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YpYtwssuWRbbbsO6o3r99Gb0aRK2PJefBXT3bELUMylMilfWATHcsmxhuT7LvgYdcsjiZ8Q3pKuqqD3M7CRfmCfCGqjO2K2LEeR00EyC7ZW0rxB4v6GwQyO1Ek7qA1ZrVU8/X8JZwvQDz3vBMiwuc4XmNjEhmBQfyzbjztPDM+A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MzNXaqIB; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-42012c85e61so65485e9.0 for ; Wed, 29 May 2024 03:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716978694; x=1717583494; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8T+4C++Ip51NQNCNOm8O3oTdvMVRbk5XM6uYT3Xq7q4=; b=MzNXaqIBR/0xwGgjUKeChJoLpQncynqZ7lvM+p6bSvkUATTGovQ8V16IxcIhjAriRS sAEkmzwJLmjZdew093p/qXys6dvtpHljdqCfFb/MsWHZuB8tKA8BNw4HGViDFewVgv2c vIFye8uYVb+UNlrj3AGodxUZJn92UA1Bxgm4X+pprEij/AzwIZGqtPD2eJbs/XlqmkFr Boixuvy87GkUAEcoSF6vHW0SeX6L2erjQyXoh9LmGlbI5h6tc+PcO6A+b1RjZaYrPcCk 4SAkypvQgoJRSjFIVU83Sg6mfEF5EF9rz5/4kCTxqp6BuJrv2Rbtd/Qx956YRPfkcNXA JTWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716978694; x=1717583494; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8T+4C++Ip51NQNCNOm8O3oTdvMVRbk5XM6uYT3Xq7q4=; b=STJs47WvOa2uph7u7vEr/AeAstEshbWaAaBcgmOeVknCD+Z9UYWV/lG86BSC35GBKq bgv8DD8t8Yf3Bxrez0IdosGztVeyWAaXh0i4eVU92Ioo01Z9Ly9eNQpc0ImJupHaVwTr YMKNiLc7TdFaEXoZjFf1S0RlPwQDDJRRL2igFmTwWFSngY/rdulfWWP/fAfSdEtLGlkX QsBrjCB13g2sff7VGXi/7tfs9lQJF0NdQl/v5+7anmTvEZMMe88NpGoP2vFPNMKhsoN3 pWpPpidK1gmPPf+ZMvF46Aj+2qOXoctF5HWyduQzT0SGpcL5ms5j5OlcWeLicf/5b/vl 0CSw== X-Forwarded-Encrypted: i=1; AJvYcCVEIhmT+VbnmricwfippptKM6kBIT23fbFbn8Or5ASEjHjtCqmYRD52nzjGnb8JViV3XOtkiQW2xjxGqh/Hl4qxnkNK3aBrSZryQHx/ X-Gm-Message-State: AOJu0Yw/3jY+muflvzIkvglNpkSdKXO4xgXC552WA6JKQZAtLNfHAvjl dkAZ6PQTrRimvsyV4QO/tTvNNHZW+SElY31WP1mMTFKTXgM2KhtxlURsUkY+rUohsc5Nuqd0f+P LgveX6gg0//gA5B3bw/cWJkwlStLsYOLph0GCaXld4OLv0svVlxk= X-Received: by 2002:a05:600c:3b18:b0:41f:a15d:2228 with SMTP id 5b1f17b1804b1-42122909a1cmr1457685e9.0.1716978694494; Wed, 29 May 2024 03:31:34 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240522090158.121797-1-21cnbao@gmail.com> In-Reply-To: <20240522090158.121797-1-21cnbao@gmail.com> From: John Stultz Date: Wed, 29 May 2024 03:31:22 -0700 Message-ID: Subject: Re: [RFC PATCH] dma-buf: align fd_flags and heap_flags with dma_heap_allocation_data To: Barry Song <21cnbao@gmail.com> Cc: sumit.semwal@linaro.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, benjamin.gaignard@collabora.com, Brian.Starkey@arm.com, tjmercier@google.com, christian.koenig@amd.com, Barry Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 22, 2024 at 2:02=E2=80=AFAM Barry Song <21cnbao@gmail.com> wrot= e: > > From: Barry Song > > dma_heap_allocation_data defines the UAPI as follows: > > struct dma_heap_allocation_data { > __u64 len; > __u32 fd; > __u32 fd_flags; > __u64 heap_flags; > }; > > However, dma_heap_buffer_alloc() casts them into unsigned int. It's uncle= ar > whether this is intentional or what the purpose is, but it can be quite > confusing for users. > > Adding to the confusion, dma_heap_ops.allocate defines both of these as > unsigned long. Fortunately, since dma_heap_ops is not part of the UAPI, > it is less of a concern. > > struct dma_heap_ops { > struct dma_buf *(*allocate)(struct dma_heap *heap, > unsigned long len, > unsigned long fd_flags, > unsigned long heap_flags); > }; > > I am sending this RFC in hopes of clarifying these confusions. > > If the goal is to constrain both flags to 32 bits while ensuring the stru= ct > is aligned to 64 bits, it would have been more suitable to define > dma_heap_allocation_data accordingly from the beginning, like so: > > struct dma_heap_allocation_data { > __u64 len; > __u32 fd; > __u32 fd_flags; > __u32 heap_flags; > __u32 padding; > }; So here, if I recall, the intent was to keep 64bits for potential future heap_flags. But your point above that we're inconsistent with types in the non UAPI arguments is valid. So I think your patch makes sense. Thanks for raising this issue! Acked-by: John Stultz