From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 155221F4E32 for ; Wed, 8 Jan 2025 18:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736359714; cv=none; b=KhnfMFjPRvYBfGj8auy1IlvjQpyOfx/xdo+nVNFhMo5I+etWb1E2HxQwJnay9g0UUlrSLEkqvfMh+geFO4TmPZ9j6CFdOS6TtPsyjQlxXmyBKJqgpXQyU6IT+wCiobRbEAHyAqYINOcQXvP6wsPXcRcJTfzI9nmZ29J0fNza1/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736359714; c=relaxed/simple; bh=E7MMhTekMnQL1NJh37hwISSn2L9xkDLjeShEJFzqNq0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eaY70pwvLFvi+5uhLx++mwtr6bGOFNfGB/60k+VWceD1L+O2C8riuImnZinY6V741a1vLItYqCgVq+RDJYL1DnxBNidnT65ld5SLjTDKXYJ0FundjZBVrJjeGN946FzzYtnvNYkv8QnJUoJaWRXDTJpWJrzBOSsMbL0KN/31ZvM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sedlak.dev; spf=none smtp.mailfrom=sedlak.dev; dkim=pass (2048-bit key) header.d=sedlak-dev.20230601.gappssmtp.com header.i=@sedlak-dev.20230601.gappssmtp.com header.b=oEpoor2W; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sedlak.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=sedlak.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sedlak-dev.20230601.gappssmtp.com header.i=@sedlak-dev.20230601.gappssmtp.com header.b="oEpoor2W" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43621d27adeso884815e9.2 for ; Wed, 08 Jan 2025 10:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sedlak-dev.20230601.gappssmtp.com; s=20230601; t=1736359711; x=1736964511; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=7HilkiTTLf9cVUbCyXpjrscybDeaKlWfm6LTEslw4II=; b=oEpoor2WNSTKoHbf2ffG+qkS1pTDmz3l0+j9fSUu0jbLh/nds0yPk5hUccCBeKDONU yNtdsAyrF6RHMQLZOqLUWxd4R2FQ33ArSx0E4LQ5ZyLPYHOmPvJeQCfCz9lpo5+4KW65 R04a2VfTPxtCln+0xIL3z9SStqa5+piLWn08b/MoDyijxNSVLsXTlCwCdbaWbtbrZldF J4TYlNSMSPTEoA+rD83d9YhvsRtlfWwusmdldQwcNyyDBBQuH+81ja4ErCUFufEgr0Vq MC1VBvEadGUS4Xw9ToJnICpN1Ux1FVB4A+eMO3pBZhUFn/PiZMrXnCSvN3C0lZDHuOkb rzog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736359711; x=1736964511; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7HilkiTTLf9cVUbCyXpjrscybDeaKlWfm6LTEslw4II=; b=mJ63SRU4XaNQptsoiH9AaxEzAUuosgTFmjHV8v5kiHJPqhrGOPIZkFc7wjfvp+6wuc rAI0Rg/4WnRsMtWXlYgoYLnZaMLOSpJjNiSplBYrqWA17mV4h8JcSCGEfewQrXv8Gu4H cv3jvtmC+k0Uk25tvI5Zd4HOfaWa/9BbMdCkt8HmA7uY8FV7xfb8LIc/Jv5XmLhT3zeL MyPMKNcQj4bswiae9KwMDqMDC61uX+cJvCrR2SKmJTAF+Ho8bJrURSGtk3hcW37odevs OtvE3AjRnoqc8zp0g9QEvpzSnYsRoUTN2rr3A9lQm+9s7vX2SlUqNY0FBquEqigg3kBe 2vHw== X-Forwarded-Encrypted: i=1; AJvYcCUxm9PIrmrNjOvDeqKsB7MYNXKCq8M9aX1gpW0EOyaa6utQ9M1zouRiOPNeyckR4GaVrC6i/LXmJRJw+7E=@vger.kernel.org X-Gm-Message-State: AOJu0YxrDi38mnWsO5DX/mlVzVHvE80Gtn0OwcquWPNsL3+5ISLXG4xF W73bxsRh86vCueHHrrzwWfKBgPI48cdxNdABOdV+/K7Eymct/PGZ8HUGVvS5JKI= X-Gm-Gg: ASbGncuMaT9MqTvsnacmUZyYJhHrTPM8DncHM9p6y93oWw+u3YXdtn5aeJMCCbYCaLe ZXB9ogMRiamNRJATAOMbXeNzU7IGEHG+9ZBW6wNQPtLDua5TAoliQcsUI+z/DdjN5qjZPThZywf iHwDmqmbEwyt+CPDBankONbqd0Omx/kRhhctcz4t7W4HZKBfsU1xud9Bid0jmj+ViMJjb2PVwdM NFVjnaCxSHxCT+tcGXgxgsTkbWOWlGJyyNXxlOHrPvYagu4dJtEQ9pJPw== X-Google-Smtp-Source: AGHT+IHlheQWH+MHSVCHWYXlmi7X7VEgIEttRToULqF7IDKXgbJyihsbnt6QC2q5b8CdCUMs66DdDQ== X-Received: by 2002:a05:600c:5491:b0:434:f7f0:1880 with SMTP id 5b1f17b1804b1-436e26ec32amr29456375e9.32.1736359711133; Wed, 08 Jan 2025 10:08:31 -0800 (PST) Received: from [192.168.88.249] ([95.85.217.110]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2c27b54sm28695265e9.0.2025.01.08.10.08.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jan 2025 10:08:30 -0800 (PST) Message-ID: <588af6c5-02cf-437a-a909-c22744a6df1c@sedlak.dev> Date: Wed, 8 Jan 2025 19:08:29 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 2/2] rust: add dma coherent allocator abstraction. To: Abdiel Janulgue , daniel.almeida@collabora.com, aliceryhl@google.com, robin.murphy@arm.com, rust-for-linux@vger.kernel.org Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Valentin Obst , open list , Christoph Hellwig , Marek Szyprowski , airlied@redhat.com, "open list:DMA MAPPING HELPERS" References: <20250108122825.136021-1-abdiel.janulgue@gmail.com> <20250108122825.136021-3-abdiel.janulgue@gmail.com> Content-Language: en-US From: Daniel Sedlak In-Reply-To: <20250108122825.136021-3-abdiel.janulgue@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/8/25 1:27 PM, Abdiel Janulgue wrote: > +/// Possible attributes associated with a DMA mapping. > +/// > +/// They can be combined with the operators `|`, `&`, and `!`. > +/// > +/// Values can be used from the [`attrs`] module. > +#[derive(Clone, Copy, PartialEq)] > +pub struct Attrs(pub u32); Shouldn't this be non-pub? It seems unfortunate to leak C representation to the Rust world and allow its construction without going through constructor method. Also #[repr(transparent)] may be well suited? [1] Link: https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent [1] > + > +impl Attrs { > + /// Get the raw representation of this attribute. > + pub(crate) fn as_raw(self) -> usize { > + self.0.try_into().unwrap() > + } Shouldn't be the return type u32 instead of usize? Or at least to my understanding the raw means C representation which should be the type that bindgen generates. > + > + /// Check whether `flags` is contained in `self`. > + pub fn contains(self, flags: Attrs) -> bool { > + (self & flags) == flags > + } > +} Daniel