From patchwork Tue Mar 7 14:25:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asahi Lina X-Patchwork-Id: 65604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2472003wrd; Tue, 7 Mar 2023 06:50:50 -0800 (PST) X-Google-Smtp-Source: AK7set9lvBHOJHGQrFIcos2dkf4egph+YjxWO+cV90bLbxNiMSeOplv8yAgIai3rpLtr8kuZvsPI X-Received: by 2002:a17:90b:1b10:b0:237:40a5:7acf with SMTP id nu16-20020a17090b1b1000b0023740a57acfmr16255778pjb.33.1678200649784; Tue, 07 Mar 2023 06:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678200649; cv=none; d=google.com; s=arc-20160816; b=hjDiiyFLGbKmMBofpC84GvVoAI1Ebxsu1OEdSMvfxIfNJkrT8/JgyuAhk3XQ9HRBda nkFXHlJMu6PWJYOTILUS41dDk+JoDlVvpxLR9RN28CIYcfaNRDvdjU+UII6tL59LOWqV RleEK4zbx5+TZdO6KpYQPV2DXbMoWdmrHc7a0nkZK7Jou24HZZRdKGLu9MCCvZDuVC/s 8Q8cK42Bvl/ETkkQqtdGzz2p5s9JSGVQoCJKmOupo7WL+Vbwz4FFgFzTyojtc5IclJOf FpumgDXx84VzLHA7Q9PuTXuyIN0zRbtkMPYMbP1Dd5po5T/p3JNClkcMR0ayilJ8y7ZD nJyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ae0xN4ZhygWIFwkIVpq4PyGSVV/2nWIU0LZUXawX0Yg=; b=C7ZHiSSptTGWhxslG2h52OGXInUF15x4ZrHtF3WSSuJlgBw8hroilbc9wTVnm6+qw8 91elyTgAUjbaRyZf3/rE6PhFEN6vXxdTxbYl9hBbOs/a8L7prp1ohk+mKHX6wMfOPO/L YZuxelw2yxBapeeqm7NHt2qg81kT4LJnWrR5hwSvYrBtavbRsnkPH1V83QKgoH6+eOIA fNmUyc1StQ/3yUShbyMAGqRIjR0JW2qP4AzWn0Eti/fFg44dlCZ3cs1KU3C5BYvQ8ghR ujVPRyT8nMjpCSdPsb+6BNXjGgyJN2X4nM2RjwKeffF5WYpD6X6N/M4N10N4LFB5uDV1 CblQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=NzazbWrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020a635d01000000b004fb9579eefcsi11889711pgb.766.2023.03.07.06.50.21; Tue, 07 Mar 2023 06:50:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=NzazbWrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231436AbjCGOeK (ORCPT + 99 others); Tue, 7 Mar 2023 09:34:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjCGOd2 (ORCPT ); Tue, 7 Mar 2023 09:33:28 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF4DC7A90F; Tue, 7 Mar 2023 06:28:26 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: linasend@asahilina.net) by mail.marcansoft.com (Postfix) with ESMTPSA id 7AEE7426E8; Tue, 7 Mar 2023 14:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1678199305; bh=PLNwTx966zByawYI9/x7zPg7nR2YAfsS2pH/0itkzOI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=NzazbWrvDmMavYRtui5Bhfs+u+J04jGyXpZVZtoYyF3xQqMtKMYT2GZx5PvDRsm/e w3R2yDcXKlby6CeAko/nDjv33/b+TqqkjCDjjxqGZoryIAT09hbYc5lBBtC20slhoX PM4NsdCzE/6fPFfIZtI5Y8URge/uP2kj2LHqzKFieNg37kJBpwG8nP7nzj51FgWN4C /0LfQa+Re1R9H4/EB2yMqoE8dZhcitUfrwcLo44JkslEVJTwgQ14i+xnO3BdHQL0/N jIi1IOSkF6gG/2F2gFlcWSoWYUqhIkf2J8wOoWwGFMv5Qm1HHamYDJ81VZKLDWzQLY SFVO72HCjH8eA== From: Asahi Lina Date: Tue, 07 Mar 2023 23:25:39 +0900 Subject: [PATCH RFC 14/18] rust: drm: gem: Add set_exportable() method MIME-Version: 1.0 Message-Id: <20230307-rust-drm-v1-14-917ff5bc80a8@asahilina.net> References: <20230307-rust-drm-v1-0-917ff5bc80a8@asahilina.net> In-Reply-To: <20230307-rust-drm-v1-0-917ff5bc80a8@asahilina.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Luben Tuikov , Jarkko Sakkinen , Dave Hansen Cc: Alyssa Rosenzweig , Karol Herbst , Ella Stanforth , Faith Ekstrand , Mary , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-sgx@vger.kernel.org, asahi@lists.linux.dev, Asahi Lina X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1678199191; l=1043; i=lina@asahilina.net; s=20230221; h=from:subject:message-id; bh=PLNwTx966zByawYI9/x7zPg7nR2YAfsS2pH/0itkzOI=; b=MjFE04ydpFUIDjxSVNQLI84A5BtCxwGQPMyQgPalsSvbYqggHyxs6a9C0P0EIP/PLFM9RVKhD fHOskSTk3+WA8ZFMMr/ZHXxfKAlDqdNPAOYtZsZ2Vxzc7VvQoLpGV/a X-Developer-Key: i=lina@asahilina.net; a=ed25519; pk=Qn8jZuOtR1m5GaiDfTrAoQ4NE1XoYVZ/wmt5YtXWFC4= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759720924838888844?= X-GMAIL-MSGID: =?utf-8?q?1759720924838888844?= This allows drivers to control whether a given GEM object is allowed to be exported via PRIME to other drivers. --- rust/kernel/drm/gem/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index e66bdef35c2e..196252a25b5a 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -135,6 +135,13 @@ pub trait BaseObject: IntoGEMObject { self.gem_ref().size } + /// Sets the exportable flag, which controls whether the object can be exported via PRIME. + fn set_exportable(&mut self, exportable: bool) { + // SAFETY: gem_obj() is valid per the type invariant, and this is safe to write if we + // are the only holder (mutable ref). + unsafe { (*self.gem_obj()).exportable = exportable }; + } + /// Creates a new reference to the object. fn reference(&self) -> ObjectRef { // SAFETY: Having a reference to an Object implies holding a GEM reference