From patchwork Thu Oct 10 11:59:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175773 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181543ill; Thu, 10 Oct 2019 05:00:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaJvE2SC+V75Oi8UBz7SnfMwaa+icDX//9fW2JFebc5jIUbeAcjMqRaTrQIdl5Sc5EUHau X-Received: by 2002:aa7:9832:: with SMTP id q18mr10193147pfl.102.1570708816324; Thu, 10 Oct 2019 05:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708816; cv=none; d=google.com; s=arc-20160816; b=wPbhZkS19kmWMWdyB4HMtCTFLfRT+d/4ipgmfAfHNPvchZrRaseQFoAU3mH12oGVh0 uo7Q+/ej5Fk2NXJXPvNN/CpUhOCri79BLdWotfoC3HPBK4cVAWetm0zYYciWpURSul8M T/cK/Us8SfMqzl0oRw4znJxOPt5lu0w2hj5BWViwOouc0cJpdnDRMbH6r/D55Oog56ol 0mtnQIdqJOeKpkB8eNugigGhwDeOHjgnU3o7A5DjCJW9/R3yV4fwP7DNuSOcWEehZbLw OVr1kl/8Tui7/jRZGwnw6GznmsRwnbGAiB8yODg2/ga8zVarbWGyxevZoFZmOXLUXriU gpgw== 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=jUoUPWa1RSzZ4shrii/uS/eemSGvXD2MygQHBOPr2is=; b=kpxfa4pmfWqeMXYbP7K0Dhna9tWxwEErJa7NHkR16IsnB8U+KC34GOJQO9uSR8+WEx CoK2QcpM7SO5hsW4MhK7HwvM4Rl+n/ZDV96WsSa861O1v0MOaTTlUpzzzeTAzxBnwxh4 WD3SANG50Nif5z6/snD3PsAYjraMuX/SYPpptzWhHNg6uXEWINWQXOhOEc9uwz2a7I1d QEX4j3B7IRe0GybfFXZjiVvUijuYHGkuxoWElYKgWu45r0Lgw+EzMxjK5MQKNMzsiJxp qbb+1Bzm3FwEYqSiqC/JGwJu+kxCvJR+sxdgVhCuxIxRtQjicWGm0Yiy4NcAW79wVr2F 343A== 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 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id p22si5537721plo.32.2019.10.10.05.00.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 980886EB0B; Thu, 10 Oct 2019 12:00:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by gabe.freedesktop.org (Postfix) with ESMTPS id BAEE16EB0B for ; Thu, 10 Oct 2019 12:00:11 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0ASx043470; Thu, 10 Oct 2019 07:00:10 -0500 Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0AYq016934; Thu, 10 Oct 2019 07:00:10 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:06 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC08ij121674; Thu, 10 Oct 2019 07:00:09 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 2/8] drm/omap: add omap_gem_unpin_locked() Date: Thu, 10 Oct 2019 13:59:54 +0200 Message-ID: <20191010120000.1421-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708810; bh=jURwAB1QUaF+ZHV6PUO9XNEuGkNY8qCFsc3a86GgHpk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yxPr4tvfzc8NfGW4k1/XcSIKBIijhvPaYLWAQcZO75/C55P+17SakiePzH1ea1WEJ kBIN7vBylbxBya0StWqzXaLijKNdmYhDQOKtHjLXSWbmirGI1VsND+X0N5vLb95UAj gDYYD/Q1VPvKDhrv6cxgt2vtD+wFms5n36q0caX0= 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: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Add omap_gem_unpin_locked() which is a version of omap_gem_unpin() that expects the caller to hold the omap_obj lock. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 61caa7a1a24b..9201c21e206f 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -834,20 +834,16 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) } /** - * omap_gem_unpin() - Unpin a GEM object from memory + * omap_gem_unpin_locked() - Unpin a GEM object from memory * @obj: the GEM object * - * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are - * reference-counted, the actualy unpin will only be performed when the number - * of calls to this function matches the number of calls to omap_gem_pin(). + * omap_gem_unpin() without locking. */ -void omap_gem_unpin(struct drm_gem_object *obj) +static void omap_gem_unpin_locked(struct drm_gem_object *obj) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret; - mutex_lock(&omap_obj->lock); - if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) { ret = tiler_unpin(omap_obj->block); if (ret) { @@ -862,7 +858,22 @@ void omap_gem_unpin(struct drm_gem_object *obj) omap_obj->dma_addr = 0; omap_obj->block = NULL; } +} +/** + * omap_gem_unpin() - Unpin a GEM object from memory + * @obj: the GEM object + * + * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are + * reference-counted, the actual unpin will only be performed when the number + * of calls to this function matches the number of calls to omap_gem_pin(). + */ +void omap_gem_unpin(struct drm_gem_object *obj) +{ + struct omap_gem_object *omap_obj = to_omap_bo(obj); + + mutex_lock(&omap_obj->lock); + omap_gem_unpin_locked(obj); mutex_unlock(&omap_obj->lock); } From patchwork Thu Oct 10 11:59:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175774 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181576ill; Thu, 10 Oct 2019 05:00:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/LDSXhFPFmt/rFQkShab72PrO2H/aTC/iE1brE4ROBgkKzUkDPStJnxGw1L3KW9IMSN6m X-Received: by 2002:a62:5ec6:: with SMTP id s189mr10020104pfb.169.1570708817701; Thu, 10 Oct 2019 05:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708817; cv=none; d=google.com; s=arc-20160816; b=NyIpS1rTiNWhs3Kb76SuW5xD61LUVbHqXwdukbsHcFnxTCjugkBtLyIm87XNV5a++y T6rmix4Kj0nULXbirc1APsnE6liLKmyUZym9+Ey3aHxJWS2yDkLGbfE0xczdiVnpzClL GLepvsijAMvuxhwJ8/+MsyfnR4/fih21mvCJquyd9X0Z3XVbSJN9TRhrqqfCmZrgc9nx j3F6FOrZ8D984gi5/Iw1MczsPhPxXFyOV8XLJjJpR/0TpM59QkIlDvECCGHAWCysLm1O 0MxMQGcQELg9hI72cUQSZwb/RbyQApyNo0g3lEm10R//wBJrEGQg11gJiweNy1mzGMO5 TMnQ== 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=BzmDpkRUuUoZQOsR8MTTTDEtDyyz0Z+lWGiOl3CT+TM=; b=F0k0D372J83mjCCbh5zb3BktEtxzjOdvY23laL+Dlf6H7WAMHTT3J3dibRN1qWpQV+ K//y8JypGyGxQGEw1G6gMP5kmHFVHj1K7opqetmRZqZWltZr8XOuDfQu6YtjIgT9hOg/ xP/z/b+YOMHgOw5XptMlUndGvcDIwZn7BchKoC/u9LW9yuH0ZRKUo5BsoGhgamMwQHrT Fd7ofhUKUpVaJoKEyW3TQ7cUPo89eCLPHMXEsepF8atLDnMyay76ciQJFeF8yeTreA4z yrMeepD0vBikXfI66ihPB0c5u8b954iRwQytDzWX4Lyri1vSRHRMIStvG6R/YNvR2GUb JYSg== 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id x22si5891241pgk.86.2019.10.10.05.00.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:17 -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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C283C6EB0C; Thu, 10 Oct 2019 12:00:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id A542E6EB0C for ; Thu, 10 Oct 2019 12:00:12 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0BqL041446; Thu, 10 Oct 2019 07:00:11 -0500 Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9AC0BDW059156 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 07:00:11 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:07 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:10 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0AXv108678; Thu, 10 Oct 2019 07:00:10 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 3/8] drm/omap: accept NULL for dma_addr in omap_gem_pin Date: Thu, 10 Oct 2019 13:59:55 +0200 Message-ID: <20191010120000.1421-4-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708811; bh=xIiunsjj3AVSyCcVA+1k58+E1fmCTUOfcOOacQw/xYM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gDP956vsHlORt0uo9oDvNXSKnvvcXWjYU6uiuGlFDoTs3XMQxbIdACuHPI45o7Y56 EZ3boKbx3XTTCRsfsA4E0LTr9gZbK8xGDKi87hFACjpQdK0VuVm8/zc7sf0ZXrenum 1tvQAt0eD9ZdrCe3aueDMVqJPGSjEvndpOxslB8w= 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: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Allow NULL to be passed in 'dma_addr' for omap_gem_pin(), in case the caller does not need the dma_addr. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 9201c21e206f..a6562d23d314 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -819,9 +819,11 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) refcount_inc(&omap_obj->dma_addr_cnt); } - *dma_addr = omap_obj->dma_addr; + if (dma_addr) + *dma_addr = omap_obj->dma_addr; } else if (omap_gem_is_contiguous(omap_obj)) { - *dma_addr = omap_obj->dma_addr; + if (dma_addr) + *dma_addr = omap_obj->dma_addr; } else { ret = -EINVAL; goto fail; From patchwork Thu Oct 10 11:59:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175775 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181694ill; Thu, 10 Oct 2019 05:00:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzi3LKCSM4QbXaLcgy3W/0QE548XDWaJLbA+gZFqeW2wc7gPfdv/8eXly3Z8NkU1+XjkS/h X-Received: by 2002:a63:9c2:: with SMTP id 185mr10428238pgj.175.1570708822891; Thu, 10 Oct 2019 05:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708822; cv=none; d=google.com; s=arc-20160816; b=HBlxT23NlstiolapIIe0OFueKzWYaLtzDkcZkpTmA7jovgkhplg8RZR/N0ENn7dRbP V1hL4EkPp1/iMRYqxj1l+/O6DfjBcP1OmkB/diUfJSiBw/ihZie9DPcdPGNqREkMc6gh qxwAapLpuWemC7qBl2ZFYJO5l5xdnoK2VHyC9zD1Wf9yzwwKInAf7J8bjIh5WFGj10HW WQBIZMHtN9i0QKZjnU0mCxaua5RGkGwF6nEZVeUWVxFlM1n8aA2ADdZHXS5/A2ARwtNz dq1osdfk74xd2C60wib3kNiV3viS62/lxjlhr93zg4giKRixQqupGRh2kR77DmlnC8Ai SHiw== 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=k9TculPzD9A8ZTxzt/93N0TVz8R91HKZE0f1Wl3SIzM=; b=QVnj6s6GqcvBDOYKUdJfKZt9DMUJzFf8303cDdfdS8S7K+OSvxt7QjWBGe/AzM+9U2 y/LrEGJMAc8HoywfpfbDNOKCQ/f42IljrTSS7Fkt8fuHrlD/muXM6evrgjLCH51dKHmQ sHdc7Iqv+BjMZbg3QtSzUjzGb8S6/LaRigVkLqGqpAgt0K8bPuoCfhU4Uu9jzYcJPNJg OR0bV1DLWyZTm+iPXnQnyvut6JmpUnc6H2UoSg5/6qbtxdrDur/kgIJW8ughflp2d+70 tS4It2DSYf6hO5hVhtXZCjYj1wuew+wbfkyPQMZzXvusSAPz+QTSx3eu+jZLUBiUHv8i fcGw== 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 11si5995398pfn.70.2019.10.10.05.00.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:22 -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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FC7988FE2; Thu, 10 Oct 2019 12:00:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by gabe.freedesktop.org (Postfix) with ESMTPS id 523EE6EB0B for ; Thu, 10 Oct 2019 12:00:14 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0ChJ023050; Thu, 10 Oct 2019 07:00:12 -0500 Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9AC0Cpp059183 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 07:00:12 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:11 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:12 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0BmU121753; Thu, 10 Oct 2019 07:00:11 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 4/8] drm/omap: cleanup OMAP_BO flags Date: Thu, 10 Oct 2019 13:59:56 +0200 Message-ID: <20191010120000.1421-5-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708812; bh=x6CFEyQ5hZGLdJM9om0YP8uZogPODV92P5gME8H8Uq0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=QJiFMdLVNl+Wn0kqmvKb6NlXoNgJdVip8K1b+/ZHZLRT1IbfZ6Jly/lmoMhA2/oO1 P1mVITbQMEQOxKvacO3TsLcMIZASjY5A7y8kOdbyAbpWC4BbqM6eQJOmwZzKo1Hcbu Vt4FoVBvWOBZnBhPYKnih2oIJ+TNwzYjrP0UBo5o= 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: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Reorder OMAP_BO flags and improve the comments. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- include/uapi/drm/omap_drm.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h index 1fccffef9e27..d8ee2f840697 100644 --- a/include/uapi/drm/omap_drm.h +++ b/include/uapi/drm/omap_drm.h @@ -38,19 +38,20 @@ struct drm_omap_param { __u64 value; /* in (set_param), out (get_param) */ }; -#define OMAP_BO_SCANOUT 0x00000001 /* scanout capable (phys contiguous) */ -#define OMAP_BO_CACHE_MASK 0x00000006 /* cache type mask, see cache modes */ -#define OMAP_BO_TILED_MASK 0x00000f00 /* tiled mapping mask, see tiled modes */ +/* Scanout buffer, consumable by DSS */ +#define OMAP_BO_SCANOUT 0x00000001 -/* cache modes */ -#define OMAP_BO_CACHED 0x00000000 /* default */ -#define OMAP_BO_WC 0x00000002 /* write-combine */ -#define OMAP_BO_UNCACHED 0x00000004 /* strongly-ordered (uncached) */ +/* Buffer CPU caching mode: cached, write-combining or uncached. */ +#define OMAP_BO_CACHED 0x00000000 +#define OMAP_BO_WC 0x00000002 +#define OMAP_BO_UNCACHED 0x00000004 +#define OMAP_BO_CACHE_MASK 0x00000006 -/* tiled modes */ +/* Use TILER for the buffer. The TILER container unit can be 8, 16 or 32 bits. */ #define OMAP_BO_TILED_8 0x00000100 #define OMAP_BO_TILED_16 0x00000200 #define OMAP_BO_TILED_32 0x00000300 +#define OMAP_BO_TILED_MASK 0x00000f00 #define OMAP_BO_TILED (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | OMAP_BO_TILED_32) union omap_gem_size { From patchwork Thu Oct 10 11:59:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175779 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181881ill; Thu, 10 Oct 2019 05:00:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7bz2M0hA3LYTnJI/WvagglEh5mp7EB+OT9+8dDqwGFMTRYw9Ec68IY0ajXx3CZg1PQQI7 X-Received: by 2002:a62:7516:: with SMTP id q22mr10175494pfc.53.1570708830770; Thu, 10 Oct 2019 05:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708830; cv=none; d=google.com; s=arc-20160816; b=Qh0EXGf29MyoDJG1Ez1BRtpGLfv/xKS+dCMHfdnuElqfswsJUIcvHMMCT5zLpOj8JM RxajPU8nDqJCevLtTHgCNvHEhT/F/pOdZ7m1x8IQ1PlosA2XJylcMsFE8eGYT/UBTfc8 uj72OksTWTbAwqEL6cUgpkO8ZMwH+PakNAFymDX4Ko2ahsU5UEVjeJfh7uhuCxh362Th 0ku9MrRMDelpHLvL54IzqdXkJgSNzHwGtXTsLWaZsx0X5dTZlcQdpCIfQyf47f8ZiTgj 1xKhObikbjIMQCoNC9Nq4QdqCOUky9MCr1xvVwiUWguzAC5tcWtfLVV4pwGsP0D78rVG Dv+w== 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=G+F5cgzOBEnfDpseudAY8qV3CT2wT8Z1M4Q8OtAqlSs=; b=ChOF5H2iHPJaeCcb2qwLrkYu0QsS4HbsnXqvg7Ldj68CMPhzNn7Ba47hnEmh46+AYI 2dyR15Tv2eQtPotsWeqpRhpWUw8Z0ivDKrggQAfeBqNwXKaTaAGgBlvybqI5EMWu8Ksb WEcR8dtVgR2aU3n9bgtT0UcsB+VYUHOvr05WtC3iCOYWd19fAnvd+BXUFiTFwkNhDFOT +NAivwqCUY/TP1xryGF3TEiWaPVIgRvZ4RjfHXT4bHj5tS/HnNI2Y7eKqnaC0LP8wJPI Mk+EiwnfIobfkrq/f4AAKS/apO0adjAYDdQr589hbH9aYNCCPbJKyFB1lmjO5ttdsFlo 3/4Q== 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 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id y15si5844872pfe.274.2019.10.10.05.00.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FC606EB15; Thu, 10 Oct 2019 12:00:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by gabe.freedesktop.org (Postfix) with ESMTPS id 329186EB13 for ; Thu, 10 Oct 2019 12:00:15 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0DNF043500; Thu, 10 Oct 2019 07:00:13 -0500 Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9AC0DdD086453 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 07:00:13 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:09 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0Cat108768; Thu, 10 Oct 2019 07:00:12 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 5/8] drm/omap: remove OMAP_BO_TILED define Date: Thu, 10 Oct 2019 13:59:57 +0200 Message-ID: <20191010120000.1421-6-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708813; bh=W/uKqEj615tAXg+efvrMdXYDa5lcw3Qinob+RXKb3EY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=P9NmCASTUfIsp5s/qHmggfaiFRAd4I4E/TlM+B7sLPKMkW4bVsFHDZOAt4lOa4jNj eovDNtnK8p/2oLNGnv63tQDQEEVbjwC0cje1SKhI87v6rZXR4RAfdNm5by8oL86v69 EkwGdbdT86087lvp6n3O4sO7Uy0E3Yb9JECW+648= 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: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen OMAP_BO_TILED does not make sense, as OMAP_BO_TILED_* values are not bitmasks but normal values. As we already have OMAP_BO_TILED_MASK for the mask, we can remove OMAP_BO_TILED and use OMAP_BO_TILED_MASK instead. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_dmm_tiler.h | 2 +- drivers/gpu/drm/omapdrm/omap_fb.c | 6 +++--- drivers/gpu/drm/omapdrm/omap_gem.c | 18 +++++++++--------- drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 +- include/uapi/drm/omap_drm.h | 1 - 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h index 835e6654fa82..43c1d096b021 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h @@ -113,7 +113,7 @@ extern struct platform_driver omap_dmm_driver; /* GEM bo flags -> tiler fmt */ static inline enum tiler_fmt gem2fmt(u32 flags) { - switch (flags & OMAP_BO_TILED) { + switch (flags & OMAP_BO_TILED_MASK) { case OMAP_BO_TILED_8: return TILFMT_8BIT; case OMAP_BO_TILED_16: diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 1b8b5108caf8..7403316088b8 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -95,7 +95,7 @@ static u32 get_linear_addr(struct drm_framebuffer *fb, bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb) { - return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED; + return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED_MASK; } /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */ @@ -154,7 +154,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, x = state->src_x >> 16; y = state->src_y >> 16; - if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED) { + if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED_MASK) { u32 w = state->src_w >> 16; u32 h = state->src_h >> 16; @@ -212,7 +212,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, plane = &omap_fb->planes[1]; if (info->rotation_type == OMAP_DSS_ROT_TILER) { - WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED)); + WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED_MASK)); omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2, &info->p_uv_addr); } else { diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index a6562d23d314..4e8fcfdff3a0 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -196,7 +196,7 @@ static void omap_gem_evict(struct drm_gem_object *obj) struct omap_gem_object *omap_obj = to_omap_bo(obj); struct omap_drm_private *priv = obj->dev->dev_private; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { enum tiler_fmt fmt = gem2fmt(omap_obj->flags); int i; @@ -324,7 +324,7 @@ size_t omap_gem_mmap_size(struct drm_gem_object *obj) struct omap_gem_object *omap_obj = to_omap_bo(obj); size_t size = obj->size; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { /* for tiled buffers, the virtual size has stride rounded up * to 4kb.. (to hide the fact that row n+1 might start 16kb or * 32kb later!). But we don't back the entire buffer with @@ -513,7 +513,7 @@ vm_fault_t omap_gem_fault(struct vm_fault *vmf) * probably trigger put_pages()? */ - if (omap_obj->flags & OMAP_BO_TILED) + if (omap_obj->flags & OMAP_BO_TILED_MASK) ret = omap_gem_fault_2d(obj, vma, vmf); else ret = omap_gem_fault_1d(obj, vma, vmf); @@ -786,7 +786,7 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) if (ret) goto fail; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { block = tiler_reserve_2d(fmt, omap_obj->width, omap_obj->height, 0); @@ -892,7 +892,7 @@ int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient, mutex_lock(&omap_obj->lock); if ((refcount_read(&omap_obj->dma_addr_cnt) > 0) && omap_obj->block && - (omap_obj->flags & OMAP_BO_TILED)) { + (omap_obj->flags & OMAP_BO_TILED_MASK)) { *dma_addr = tiler_tsptr(omap_obj->block, orient, x, y); ret = 0; } @@ -907,7 +907,7 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret = -EINVAL; - if (omap_obj->flags & OMAP_BO_TILED) + if (omap_obj->flags & OMAP_BO_TILED_MASK) ret = tiler_stride(gem2fmt(omap_obj->flags), orient); return ret; } @@ -1046,7 +1046,7 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m) refcount_read(&omap_obj->dma_addr_cnt), omap_obj->vaddr, omap_obj->roll); - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { seq_printf(m, " %dx%d", omap_obj->width, omap_obj->height); if (omap_obj->block) { struct tcm_area *area = &omap_obj->block->area; @@ -1145,7 +1145,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, int ret; /* Validate the flags and compute the memory and cache flags. */ - if (flags & OMAP_BO_TILED) { + if (flags & OMAP_BO_TILED_MASK) { if (!priv->usergart) { dev_err(dev->dev, "Tiled buffers require DMM\n"); return NULL; @@ -1187,7 +1187,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, omap_obj->flags = flags; mutex_init(&omap_obj->lock); - if (flags & OMAP_BO_TILED) { + if (flags & OMAP_BO_TILED_MASK) { /* * For tiled buffers align dimensions to slot boundaries and * calculate size based on aligned dimensions. diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index e8c3ae7ac77e..7344bb61936c 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -67,7 +67,7 @@ static int omap_gem_dmabuf_begin_cpu_access(struct dma_buf *buffer, { struct drm_gem_object *obj = buffer->priv; struct page **pages; - if (omap_gem_flags(obj) & OMAP_BO_TILED) { + if (omap_gem_flags(obj) & OMAP_BO_TILED_MASK) { /* TODO we would need to pin at least part of the buffer to * get de-tiled view. For now just reject it. */ diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h index d8ee2f840697..5a142fad473c 100644 --- a/include/uapi/drm/omap_drm.h +++ b/include/uapi/drm/omap_drm.h @@ -52,7 +52,6 @@ struct drm_omap_param { #define OMAP_BO_TILED_16 0x00000200 #define OMAP_BO_TILED_32 0x00000300 #define OMAP_BO_TILED_MASK 0x00000f00 -#define OMAP_BO_TILED (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | OMAP_BO_TILED_32) union omap_gem_size { __u32 bytes; /* (for non-tiled formats) */ From patchwork Thu Oct 10 11:59:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175776 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181730ill; Thu, 10 Oct 2019 05:00:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXdD9uPXXy3J1pP61O+jBpCX+A7fZPT7B9MfI1APC/F9oyAYZVElSE5pvOBnZckPNWqTOO X-Received: by 2002:a17:902:6acb:: with SMTP id i11mr8772807plt.273.1570708824934; Thu, 10 Oct 2019 05:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708824; cv=none; d=google.com; s=arc-20160816; b=xQpn+mDwE358/NXuYr0RjkT9P5+B8XdUAkZY9adC59+2uy5byubhW/PdyZnMted8M4 N6sXFJROOGdu6RMo1PwVVKQ9TCzNdiiHRE807uBZn+RLp4V0M4dcslXM9CFq5+pDhrDW fhzvFcnodAW9WcaVwQdTpemAJXJNBoW0qReVizRKCJ5WrhUf0/CZH/zgMAMtdHTcuulr ttG5S96M+LwjOX5NxFOBcjo0YNxfLHtiTbelepEninVdmQ6BaB/+fKeAsW6pRPCjjMlE 3v35c843gYR3cCGC+UXZKADmAYv+ov6K/CA8Vb0UlAfpFOl+FQB3bLQsFzIeTaUNA3l/ X8bA== 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=Uno8w35FnwFjAAWqWtcRMV0auUG/TUfnImT+tXNes6o=; b=exzetoL9/9jNofkLijg2dYkCniYXD0MXqw1Dbxo4HDvo6DFeYlPby4mA3ftTD2R8Oq 5hTXdKhf5UqHnfRACsGySv5c7UqXCr+/54BjxWobJXah4Cln1jS4voGYkUFlV9FzBOEQ OXkvxQpcw4fWj5kMgbDxvf/xi0ydXO5uQEuw5TZf4lX32CsttzRxC4Y3g7xjtzQ5nMuG HEdtphdcylvnv+dPEZpXilbD6FWppIonQgD8vKPT081jRga1nkxzBt7cWS1+nqeyZcbh i7aZv+yCoeLoge4jz691b1qHjZjO8T9hjqQl7n6so/0Oyk/u/UE0g4o5w+5qkFvz75Nm YD2g== 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id h27si3660125pgm.481.2019.10.10.05.00.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:24 -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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7017F893E8; Thu, 10 Oct 2019 12:00:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by gabe.freedesktop.org (Postfix) with ESMTPS id C4ECD6EB21 for ; Thu, 10 Oct 2019 12:00:18 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0E20043506; Thu, 10 Oct 2019 07:00:14 -0500 Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9AC0Eia029493 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 07:00:14 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:14 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:10 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0DMT121821; Thu, 10 Oct 2019 07:00:14 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 6/8] drm/omap: cleanup OMAP_BO_SCANOUT use Date: Thu, 10 Oct 2019 13:59:58 +0200 Message-ID: <20191010120000.1421-7-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708814; bh=WO7S52qVjOi/md3ys9yvPOEVZOSvBlURQm/5m1MTQPg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=duHllezZz41eIOIGAyDjySC+OV8vVcUsgn/glW5Zfyu9V+e0NVSEPO3niXzc9sVYu qOjDtCjg0wEuCAamXjbnuDqLbMLTsrCOr4UZ0vNgb7mhgrSLlt3pdBv9QGcpHwn1Do KSBRUcvI3cia/pit05hWCSj+JfvnWEL5YhJfJw98= 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: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen omap_gem_new() has a comment about OMAP_BO_SCANOUT which does not make sense. Also, for the TILER case, we drop OMAP_BO_SCANOUT flag for some reason. It's not clear what the original purpose of OMAP_BO_SCANOUT is, but presuming it means "scanout buffer, something that can be consumed by DSS", this patch cleans up the above issues. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 4e8fcfdff3a0..27e0a2f8508a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1155,7 +1155,6 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, * Tiled buffers are always shmem paged backed. When they are * scanned out, they are remapped into DMM/TILER. */ - flags &= ~OMAP_BO_SCANOUT; flags |= OMAP_BO_MEM_SHMEM; /* @@ -1166,9 +1165,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, flags |= tiler_get_cpu_cache_flags(); } else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) { /* - * OMAP_BO_SCANOUT hints that the buffer doesn't need to be - * tiled. However, to lower the pressure on memory allocation, - * use contiguous memory only if no TILER is available. + * If we don't have DMM, we must allocate scanout buffers + * from contiguous DMA memory. */ flags |= OMAP_BO_MEM_DMA_API; } else if (!(flags & OMAP_BO_MEM_DMABUF)) { From patchwork Thu Oct 10 11:59:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175778 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181828ill; Thu, 10 Oct 2019 05:00:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwC/WExVe3Pkyo19B7fDruLf2A8ppQNlKk1//Miq5sWGQl+yClvK9juhGYzMio4Pco/Ecfk X-Received: by 2002:aa7:8b4d:: with SMTP id i13mr10215696pfd.29.1570708829141; Thu, 10 Oct 2019 05:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708829; cv=none; d=google.com; s=arc-20160816; b=Y0xUyrcPT8cUifyt3SAzzp8jKXLaWKRWWHEJ45jGSeqZkbH72R+US+V6c6Vmbh+Mz0 DgQ+bqEr4ECimyOvZgPO0J/8iFi+jGmJeeBvvChOYI6vEu/s3ksMvlIDkLRN3KbOtbas 0lshrjP63OqhGyw0WiCMHC4v3oe4bMQvlO5vbaEd7kKJn8woVXDoLBNH6fCyaJGyLBRD Rhge3BTi88tIGAzYkzWtkvQbd/Kvat9JvX5HHROYHjK70mmd/fzLJy2ARZET/igSlpWP CqV9jQrQl/XamOohgleohW/gs0E/XQFVeC90HNI8rTCDnhluCjxncMMf2EfWjjTtSNCI 6Irg== 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=dkArxskwvSlOwoavMXdmQXxlW3C6jKbtcLLKNUggyEA=; b=xMdw90aub+r2Kh0YDiwmxXlFl1MrhWnxEwBHX7ArxNRnaFzpQp/umec8p+yBHhSLww 0oZZoNRwN3XZjD3067V2BXbm5o2A3OCBmahDwfpacymyHUhtkLH6hHgf24MNW9KT+q7n xDmDEoWh26WEorwYeZNO4iUVO0YQpomixa3eU57DX9qSlaVtb4ub2SDAgrPkJGwMfDUs vxoPgIImHEEwMdjn1VX86X28XktvpZGq3R3DpdK15880vBIxJdWaG975DYBOLOHVORwA RD3EiyY4CO7B7KUnRAM5rXqMD1iAzg9q/7wltnO0iMXNdTmirG3MNNG7MTDfYsa1hZqU OBTw== 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 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id g10si5376984pll.173.2019.10.10.05.00.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A2C506EB11; Thu, 10 Oct 2019 12:00:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0AE0089686 for ; Thu, 10 Oct 2019 12:00:18 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0G4C041475; Thu, 10 Oct 2019 07:00:16 -0500 Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9AC0GQX059314 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 07:00:16 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:15 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:12 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0EA8121926; Thu, 10 Oct 2019 07:00:15 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 7/8] drm/omap: add omap_gem_validate_flags() Date: Thu, 10 Oct 2019 13:59:59 +0200 Message-ID: <20191010120000.1421-8-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708816; bh=hgiOK3v3py7fj6u+5PXs9D8dCCW3BjQ3YCS1fnNsvV8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=pimc5pGk7rQS1u2C217P/RpLldR9bHM/UzLV2kLPby5a46J07W4cyXttQsLRcru7c 5/buruJRn46FTyxVdBkjSHse8mpuEvjH9F2oBLpxirUw5sxLmuohFUXVi/0FVeJeL0 iuG0KErGMFlxbvCJvkqknRZMXDD0GFX+2l4Sr+24= 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: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Add a helper function omap_gem_validate_flags() which validates the omap_bo flags passed from the userspace. Also drop the dev_err() message, as the userspace can cause that at will. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 40 ++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 27e0a2f8508a..e518d93ca6df 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1133,6 +1133,38 @@ void omap_gem_free_object(struct drm_gem_object *obj) kfree(omap_obj); } +static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) +{ + struct omap_drm_private *priv = dev->dev_private; + + switch (flags & OMAP_BO_CACHE_MASK) { + case OMAP_BO_CACHED: + case OMAP_BO_WC: + case OMAP_BO_CACHE_MASK: + break; + + default: + return false; + } + + if (flags & OMAP_BO_TILED_MASK) { + if (!priv->usergart) + return false; + + switch (flags & OMAP_BO_TILED_MASK) { + case OMAP_BO_TILED_8: + case OMAP_BO_TILED_16: + case OMAP_BO_TILED_32: + break; + + default: + return false; + } + } + + return true; +} + /* GEM buffer object constructor */ struct drm_gem_object *omap_gem_new(struct drm_device *dev, union omap_gem_size gsize, u32 flags) @@ -1144,13 +1176,11 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, size_t size; int ret; + if (!omap_gem_validate_flags(dev, flags)) + return NULL; + /* Validate the flags and compute the memory and cache flags. */ if (flags & OMAP_BO_TILED_MASK) { - if (!priv->usergart) { - dev_err(dev->dev, "Tiled buffers require DMM\n"); - return NULL; - } - /* * Tiled buffers are always shmem paged backed. When they are * scanned out, they are remapped into DMM/TILER. From patchwork Thu Oct 10 12:00:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175777 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181790ill; Thu, 10 Oct 2019 05:00:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCDDiJ8ESGixp+DXZh9SXhY4axHJOCXh7QfF8uflHGYcjZ4xmF5EwboONj/MZxlC9qlYks X-Received: by 2002:a65:5345:: with SMTP id w5mr1859368pgr.213.1570708827202; Thu, 10 Oct 2019 05:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708827; cv=none; d=google.com; s=arc-20160816; b=va/8jadMG/WCM5ijG7aAipGd+U7RENHXcs1X/9eeEwDtt9OhVH9sVzaDInE8IHWnNZ pXs+jSI6wtDuIsp4/G0qhppr5mNK4PgYmdvV5aeI1V3XLWo1ljXg+ZW9dTpe6x+1WFSY VJt8KU6BycubyI6hpb1kVgBuczJONI6NSE3L1p+Qez4358moO9ozxjXZgTeoTVmxZMX6 ukEx5mDSUeD3TnqreecxqMwTxV8AwBdmOLspTjP7+Sp7VzbOcaXR2AxPkaEQVoU91p5b Pr5TwJwGSrvmdQF4xNRmmrUvL5B4eJQ5TClg7/x5rrr56JfiyulLHvZ6dSMmRxVM4Atq o4xA== 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=y5r7AIs3okQ0nOCahuQuN82THojyU/8iL2ipw89K2l0=; b=TyjoYbI7LX3WaXygEMwgNdkravaq7E2wZH7iV8sSJXby8ePD7eUVCQH16qrRj4T9s6 xK6MwskL61Iq3NP0TEX2DouREwUp2QirKZR7N9e/B6hnYehkiek/A6xL/afJw+fseiZk TVMApCYt1shZz62H9NvXoc4NT6VelozCAjmECE5P3vZf7VM7NOeybVtgIoVUx9joa1Ho 8VDsqjb+tfRMSiya+lyRcp8NXyhaxDXDxnQXaG/p1jyke+YKbIOGJnIqHYp5YqZPgOqS qMnznZQKT32gLPLbI4nye2+OSD/5O9NB0eLF6l/cq/TP5fH1iL+71rezuLxMTO0hz0nS UMSw== 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 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id d13si5896321pgj.29.2019.10.10.05.00.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A52C36EB13; Thu, 10 Oct 2019 12:00:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7EC2F6EB11 for ; Thu, 10 Oct 2019 12:00:20 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0Hdi041480; Thu, 10 Oct 2019 07:00:17 -0500 Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9AC0HYp059393 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 07:00:17 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:13 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:13 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0GJ8103666; Thu, 10 Oct 2019 07:00:16 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 8/8] drm/omap: add OMAP_BO flags to affect buffer allocation Date: Thu, 10 Oct 2019 14:00:00 +0200 Message-ID: <20191010120000.1421-9-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708817; bh=+kg9/XC9t2SIj2CnnGwkyDzT7fuNxD+qtu3RH8dB76w=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=c2XbizhnBCAY0ukeAGnh/zF9N++yZ3JMbF8WUhX/dyM9u1bpP9JHK7O0dVGRgcWdt 7z03dboX6UIYxYp1xle/dVZuMeSLdlT4TjyW7zmGvHv7Tf/9yjZkuybHSKFQ+zEMCX Aec8RFE34cWmgtKlyZUHBAow1B2QPqudzQadAaEE= 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: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen On SoCs with DMM/TILER, we have two ways to allocate buffers: normal dma_alloc or via DMM (which basically functions as an IOMMU). DMM can map 128MB at a time, and we only map the DMM buffers when they are used (i.e. not at alloc time). If DMM is present, omapdrm always uses DMM. There are use cases that require lots of big buffers that are being used at the same time by different IPs. At the moment the userspace has a hard maximum of 128MB. This patch adds three new flags that can be used by the userspace to solve the situation: OMAP_BO_MEM_CONTIG: The driver will use dma_alloc to get the memory. This can be used to avoid DMM if the userspace knows it needs more than 128M of memory at the same time. OMAP_BO_MEM_DMM: The driver will use DMM to get the memory. There's not much use for this flag at the moment, as on platforms with DMM it is used by default, but it's here for completeness. OMAP_BO_MEM_PIN: The driver will pin the memory at alloc time, and keep it pinned. This can be used to 1) get an error at alloc time if DMM space is full, and 2) get rid of the constant pin/unpin operations which may have some effect on performance. If none of the flags are given, the behavior is the same as currently. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 54 ++++++++++++++++++++++++++++-- include/uapi/drm/omap_drm.h | 9 +++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index e518d93ca6df..bf18dfe2b689 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1097,6 +1097,9 @@ void omap_gem_free_object(struct drm_gem_object *obj) list_del(&omap_obj->mm_list); mutex_unlock(&priv->list_lock); + if (omap_obj->flags & OMAP_BO_MEM_PIN) + omap_gem_unpin_locked(obj); + /* * We own the sole reference to the object at this point, but to keep * lockdep happy, we must still take the omap_obj_lock to call @@ -1147,10 +1150,19 @@ static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) return false; } + if ((flags & OMAP_BO_MEM_CONTIG) && (flags & OMAP_BO_MEM_DMM)) + return false; + + if ((flags & OMAP_BO_MEM_DMM) && !priv->usergart) + return false; + if (flags & OMAP_BO_TILED_MASK) { if (!priv->usergart) return false; + if (flags & OMAP_BO_MEM_CONTIG) + return false; + switch (flags & OMAP_BO_TILED_MASK) { case OMAP_BO_TILED_8: case OMAP_BO_TILED_16: @@ -1165,7 +1177,34 @@ static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) return true; } -/* GEM buffer object constructor */ +/** + * omap_gem_new() - Create a new GEM buffer + * @dev: The DRM device + * @gsize: The requested size for the GEM buffer. If the buffer is tiled + * (2D buffer), the size is a pair of values: height and width + * expressed in pixels. If the buffers is not tiled, it is expressed + * in bytes. + * @flags: Flags give additionnal information about the allocation: + * OMAP_BO_TILED_x: use the TILER (2D buffers). The TILER container + * unit can be 8, 16 or 32 bits. Cache is always disabled for + * tiled buffers. + * OMAP_BO_SCANOUT: Scannout buffer, consummable by the DSS + * OMAP_BO_CACHED: Buffer CPU caching mode: cached + * OMAP_BO_WC: Buffer CPU caching mode: write-combined + * OMAP_BO_UNCACHED: Buffer CPU caching mode: uncached + * OMAP_BO_MEM_CONTIG: The driver will use dma_alloc to get the memory. + * This can be used to avoid DMM if the userspace knows it needs + * more than 128M of memory at the same time. + * OMAP_BO_MEM_DMM: The driver will use DMM to get the memory. There's + * not much use for this flag at the moment, as on platforms with + * DMM it is used by default, but it's here for completeness. + * OMAP_BO_MEM_PIN: The driver will pin the memory at alloc time, and + * keep it pinned. This can be used to 1) get an error at alloc + * time if DMM space is full, and 2) get rid of the constant + * pin/unpin operations which may have some effect on performance. + * + * Return: The GEM buffer or NULL if the allocation failed + */ struct drm_gem_object *omap_gem_new(struct drm_device *dev, union omap_gem_size gsize, u32 flags) { @@ -1193,7 +1232,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, */ flags &= ~(OMAP_BO_CACHED|OMAP_BO_WC|OMAP_BO_UNCACHED); flags |= tiler_get_cpu_cache_flags(); - } else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) { + } else if ((flags & OMAP_BO_MEM_CONTIG) || + ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm)) { /* * If we don't have DMM, we must allocate scanout buffers * from contiguous DMA memory. @@ -1253,12 +1293,22 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, goto err_release; } + if (flags & OMAP_BO_MEM_PIN) { + ret = omap_gem_pin(obj, NULL); + if (ret) + goto err_free_dma; + } + mutex_lock(&priv->list_lock); list_add(&omap_obj->mm_list, &priv->obj_list); mutex_unlock(&priv->list_lock); return obj; +err_free_dma: + if (flags & OMAP_BO_MEM_DMA_API) + dma_free_wc(dev->dev, size, omap_obj->vaddr, + omap_obj->dma_addr); err_release: drm_gem_object_release(obj); err_free: diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h index 5a142fad473c..842d3180a442 100644 --- a/include/uapi/drm/omap_drm.h +++ b/include/uapi/drm/omap_drm.h @@ -47,6 +47,15 @@ struct drm_omap_param { #define OMAP_BO_UNCACHED 0x00000004 #define OMAP_BO_CACHE_MASK 0x00000006 +/* Force allocation from contiguous DMA memory */ +#define OMAP_BO_MEM_CONTIG 0x00000008 + +/* Force allocation via DMM */ +#define OMAP_BO_MEM_DMM 0x00000010 + +/* Pin the buffer when allocating and keep pinned */ +#define OMAP_BO_MEM_PIN 0x00000020 + /* Use TILER for the buffer. The TILER container unit can be 8, 16 or 32 bits. */ #define OMAP_BO_TILED_8 0x00000100 #define OMAP_BO_TILED_16 0x00000200