From patchwork Mon Oct 21 21:45:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 177137 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3977389ill; Mon, 21 Oct 2019 14:46:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwq94guj34u18inYBlyrx8k0Hv+lRAMTi7rzubk5e+2jeIiffrJl+YDi8uxnoaDi+YwhjO+ X-Received: by 2002:a63:9dc2:: with SMTP id i185mr37474pgd.294.1571694362288; Mon, 21 Oct 2019 14:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571694362; cv=none; d=google.com; s=arc-20160816; b=z/gcnpngfXd+GLwGKjHgLCwQzcxYlvz8jNWEA/KHwit9831jG+NEHcEPfZqsX0/DSP nlupQHdvc3o1ykgdwmlQjOyhVuhalbuGCeRypNsCWaNXHouZqeV+XQDTkCZ36rVUtfwb +JKFNyizHiCtpX10uDu77Za3zcxhSkkBkq0rsWgRXoAl8rcMrSbGjS80fnoSDgWfkRHo L66EBViHW99Uz0gTmX8Io/o/r04Go2lynmKLsGzzPcEJ5o77vNFEqCKofI75VScUk9eF DF/ec1Q12Y+ERkh+DSWHUJYozTFJT688JwpYvrjKtmQmKQ7ck1xgDGPOLy/cZiRPO8P6 MVGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=z3yf036dc7pMKCJhbQtaWCt/MaTaH0GWftJtVG49uY0=; b=Vj1VbNCIWYv4Kn7shARv9daP9pjVXXkG0kqfqLrXmtndS9LrzQ2dvInfi7oZkAorhj GooGxF8z+yJeZ/kNp31AUmB5bVUMody7IRE+okSjmSSdsGsz78OBLC+ZSBAwU94YzP9q n9/C5CYS6vWt+S0Of8qXHgCPxV5d8phh49CgTujb4ha/tBhKPFKBiAVGynzCdMqoWv1+ TQ9f4BOLFlcROj1CyanYtlae38su0y2MKk8eQgm493sAhxTCQtkDZMEQzLfkxggFInwX HAF+QZ7pyLtsn8CCp2+IyWOvAH4b3Om0fbgblZjeC2kTvkkCTx4DXkAkKbdfRpvOMNmz uVLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id y3si14998528pgr.85.2019.10.21.14.46.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Oct 2019 14:46:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FFE46E277; Mon, 21 Oct 2019 21:46:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 300076E277 for ; Mon, 21 Oct 2019 21:45:58 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id g81so12402661oib.8 for ; Mon, 21 Oct 2019 14:45:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TsrtW/3IwxExUlY3NAEem6qIu9cq5ThxwAPMPnLEB1M=; b=KbcvqwPovIyI+sJBE3BeF7+xLfC1MV+hOpmlDAQuKHvSN/AnxtXzqq6x5BybGztEud j1m+ksI6gjEgwwP+S23aqMZpBsd94aEv0wvwBRps8uD753iZW2RaHc0+DP+jc2nB/Viv TfGx75LLeC2prlWqv0u0WzHItAmslmJwWoL9Z4PdFpBLwnUrn0MgYnQ4P12hcmPMBeZx i1aNfm5P7T9WjSxW8MeU55RD5Zx4v8lFAKN1PQWeylnbAO0duiw7ThXRRIEmmt8/LGON ROw/Z3LPLOYKeGc6MO9OuhLrGMCuf13oEYUjaylwvr7xotrj6A8YpNiPRL3vHnQR9fbm SbQg== X-Gm-Message-State: APjAAAX+As3CG9tG8WeG3fJM+rZ+T2CrbAPM7gpXN2qq87z9qSPokJO1 k5A1e4m5mLnUWw1y5X/Cxl3rn4Y= X-Received: by 2002:a54:4182:: with SMTP id 2mr188880oiy.148.1571694357143; Mon, 21 Oct 2019 14:45:57 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:45:56 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/6] drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag Date: Mon, 21 Oct 2019 16:45:46 -0500 Message-Id: <20191021214550.1461-3-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , David Airlie , Liviu Dudau , Laurent Pinchart , Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Kieran Bingham , "James \(Qian\) Wang" , Alexandre Torgue , Chen Feng , linux-mediatek@lists.infradead.org, Matthias Brugger , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Maxime Coquelin , Rongrong Zou Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce a new flag, DRM_MODE_DUMB_KERNEL_MAP, for struct drm_mode_create_dumb. This flag is for internal kernel use to indicate if dumb buffer allocation needs a kernel mapping. This is needed only for CMA where creating a kernel mapping or not has to be decided at allocation time because creating a mapping on demand (with vmap()) is not guaranteed to work. Several drivers are using CMA, but not the CMA helpers because they distinguish between kernel and userspace allocations to create a kernel mapping or not. Update the callers of drm_mode_dumb_create() to set drm_mode_dumb_create.flags to appropriate defaults. Currently, flags can be set to anything by userspace, but is unused within the kernel. Let's force flags to zero (no kernel mapping) for userspace callers by default. For in kernel clients, set DRM_MODE_DUMB_KERNEL_MAP by default. Drivers can override this as needed. Cc: David Airlie Cc: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Signed-off-by: Rob Herring --- drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 ++++- include/uapi/drm/drm_mode.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c index d9a2e3695525..dbfc8061b392 100644 --- a/drivers/gpu/drm/drm_client.c +++ b/drivers/gpu/drm/drm_client.c @@ -264,6 +264,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u dumb_args.width = width; dumb_args.height = height; dumb_args.bpp = info->cpp[0] * 8; + dumb_args.flags = DRM_MODE_DUMB_KERNEL_MAP; ret = drm_mode_create_dumb(dev, &dumb_args, client->file); if (ret) goto err_delete; diff --git a/drivers/gpu/drm/drm_dumb_buffers.c b/drivers/gpu/drm/drm_dumb_buffers.c index d18a740fe0f1..74a13f14c173 100644 --- a/drivers/gpu/drm/drm_dumb_buffers.c +++ b/drivers/gpu/drm/drm_dumb_buffers.c @@ -97,7 +97,10 @@ int drm_mode_create_dumb(struct drm_device *dev, int drm_mode_create_dumb_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - return drm_mode_create_dumb(dev, data, file_priv); + struct drm_mode_create_dumb *args = data; + + args->flags = 0; + return drm_mode_create_dumb(dev, args, file_priv); } /** diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 735c8cfdaaa1..02712f46b94c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -796,6 +796,8 @@ struct drm_mode_crtc_page_flip_target { __u64 user_data; }; +#define DRM_MODE_DUMB_KERNEL_MAP (1<<0) /* For internal kernel use */ + /* create a dumb scanout buffer */ struct drm_mode_create_dumb { __u32 height;