From patchwork Mon Jul 8 10:45:14 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: 168608 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6982888ilk; Mon, 8 Jul 2019 03:45:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4clQj5WEO/xI48l2ZVa1TGny7yfhIbO75JzA+//KVEE3zD81wzegYcaq0NDtZJQH7bBFj X-Received: by 2002:a17:902:b713:: with SMTP id d19mr23893391pls.267.1562582734127; Mon, 08 Jul 2019 03:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582734; cv=none; d=google.com; s=arc-20160816; b=fMiDjuJPUXJOqbeC3lBARORDS1rnf+NDJZPK7/NOqR98x19uIr0yYQ90qyEqBDjTuy 3K3agGyzPJCYoA0d9PzVo75qVQfQlnhvUatdWlj/jYz+fwAYvc05fcD6Dvqc2Atjyzbd mbFYoEB8PeH/GZZLNThgOWpF+qOjSGYqSQbp1mweBU/d+izVn5FeUWYs/jq22/brS0DA SSsrzRhLVHzDzkTTUdmPDh7ohIF5zKMQt3DvfoKRzGy8nt6y2RMEVGKSz/uoHRAIuG7x vZJf++AUHtDkxZ7VbUdsBWAZ2MbiLXj7Faa5Jy0swCEZFryA2Om/SbIBstcpDpsWM3xP GiIw== 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=ROZ7+rwR0zAobFFgPB/bQiHr+SmEwiVByeWJmqfSMDg=; b=GIUVJv9MUNBvP4LFM0kUhdDutQvdeYIzOFwZCLgV7L3Nha4OAf853+S71hfqpILk5Q lR0Z7eg5wHeO9mJSHfFVc6rbB3loCj/8ankTvi/UmcEJtoOujxog/Ih/kQuTSaftX7jY S+ZGpF4q12ygFaYZYHsEG+pZ4BYJWOeg84n+s4m/9nwOILxU3gBe6JcteWQfcVjRyUAt CgPllysy1Z5Uk5An01e9z9jTVWVrOCmCAIsJHSvIUDV8hsUgRBx29UlNJxIkapsdm9RP G/cAbWyqUygmV2A8TcDWMbo6Ze1C6nYhhWiEAfMop2XZoFxcY5YotL4teAXT3dH8mlim vk1Q== 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 x7si18858418pfi.257.2019.07.08.03.45.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:34 -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 2A2B689C68; Mon, 8 Jul 2019 10:45:33 +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 7352D89C68 for ; Mon, 8 Jul 2019 10:45:31 +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 x68AjUVA050868; Mon, 8 Jul 2019 05:45:30 -0500 Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x68AjT1W030529 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:29 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Jul 2019 05:45:29 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Mon, 8 Jul 2019 05:45:29 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x68AjS64094793; Mon, 8 Jul 2019 05:45:29 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 2/8] drm/omap: add omap_gem_unpin_locked() Date: Mon, 8 Jul 2019 12:45:14 +0200 Message-ID: <20190708104520.24217-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582730; bh=BMALSdC3eHlLBbEzztt6cvZKxUhSacOKg+qlcp7idFc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=O4AfInWAcTdAqV3H0atZIMCmmq8eHg13E4oTuUtFfZWDeSgwFI+svJiy07yBxsOfO AGlAAbUHu6UFCGDWiIheY7vOZASoCR/1+b49dAb964ne8AhJ4q0h09LUeoin0M5jRw HIhEXyXAVmjQuSeicyXb1S/SuOiCp5Cxe7ybXqEs= 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: jsarha@ti.com 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 --- drivers/gpu/drm/omapdrm/omap_gem.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 0b6eef120cc9..3071e815da73 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -832,20 +832,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,6 +858,20 @@ void omap_gem_unpin(struct drm_gem_object *obj) } } +/** + * 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 Mon Jul 8 10:45:15 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: 168610 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6983026ilk; Mon, 8 Jul 2019 03:45:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKeDOX7nT8pHzWTRSFQDP1AV4hQEcsVviv1V3jQ+rMkk3IuMYbc3RbW/HkBAYl7OdjevNI X-Received: by 2002:a63:6fcf:: with SMTP id k198mr22537043pgc.276.1562582740669; Mon, 08 Jul 2019 03:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582740; cv=none; d=google.com; s=arc-20160816; b=j+8efnXEkI0V9cHoLvuuaUgm40Vg6TLX7cBG88Wpa8PWQFsg6PwsOa7qfo4h6Pe9KL 7O0+GtM2cvbwfKfnAodV8oGPf7GDdmT3vpVo6e9aarYQwbDng6KFaok8E3zdBnTMcX5e ozZe/qk6r1Q6clF5YPfczdP13WXGHq4XkK1Du7MPsIIS+pvy+DHjxPBK9u9q9Vksuyu6 gL6Aif9ksI7Mk4shq5USRzWUZ6PXQJ/k5fO4IVRfU5K2o2EPi/oFP2G6Xczmj9MiSqdS yraLxbMO73RCsW+g2fp5BgXIM+ZSl/CMXXkMkA3vzkt4A3jPKqtQMLT9wRLYbgbYyliS R+0A== 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=TDHIy4bQRuNHN/UK/UVlmTW3J3+/+T00Q2zpxxYzl9I=; b=GpPi7nQYJ96YpSbS7Lk5whpnjehEesuxTyvLLHgNV/imGm48pc1ur0eitDkBSIlx1n IemcEcn4LVizTMUbuYt2j+xcWF9pSKXg/iIjPOcT2eoGtTVGCMbDpRGbI/4bi6aTGG7H YiqwVAEYL9byS7x4tX1LRvBeniA2jOTqWDUhIZctfXV6atoAmcpAXkX3M2vGkTcSUH2k ZgEB25oATndLBexUJew+joFtml77H4ee6xFx+GD3Bnb76xS49E69kMRvMOpFrrwPPYL6 CC/iw08sh/RTRL3/rXhrBIC83lwJEuVxtxFcghZz3CTccMW1ZA3ViFRgqcl2UQ64Hr2t HqJw== 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 r185si4511062pgr.506.2019.07.08.03.45.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:40 -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 61B6289C84; Mon, 8 Jul 2019 10:45:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by gabe.freedesktop.org (Postfix) with ESMTPS id 619A289C68 for ; Mon, 8 Jul 2019 10:45:32 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x68AjV6T005778; Mon, 8 Jul 2019 05:45:31 -0500 Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x68AjVMf089628 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:31 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Jul 2019 05:45:30 -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; Mon, 8 Jul 2019 05:45:30 -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 x68AjU2J100316; Mon, 8 Jul 2019 05:45:30 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 3/8] drm/omap: accept NULL for dma_addr in omap_gem_pin Date: Mon, 8 Jul 2019 12:45:15 +0200 Message-ID: <20190708104520.24217-4-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582731; bh=jlgb27R7PVNb2+coCp4QHw61HjPEjybhkNB/01z9lz0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=OJN70SUd/N4He42X0nZd9U8Fc0Lvn5y8fuw8IbqYvJ0ffEddbvKGF4YdP2bKd4on9 68NFU/5PxKx31h1LkqCA+o/yXuzsYuQmNkZ+LTKCzQ5yT21RyHkc4LXLDERwJvIFJd BX/rOZDiHEEYdvvoD2akEaf6UH3cXbFEbsY0po8k= 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: jsarha@ti.com 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 --- 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 3071e815da73..2ac83cdbb15a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -817,9 +817,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 Mon Jul 8 10:45:16 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: 168609 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6982971ilk; Mon, 8 Jul 2019 03:45:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLqOzdEJih0FHn3AkWgOpiL8yn/C+DDp5HNWY9ooZ1kXGQ6iprLQUZ7AQbYet24i3XubZF X-Received: by 2002:a63:2784:: with SMTP id n126mr22055384pgn.92.1562582737164; Mon, 08 Jul 2019 03:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582737; cv=none; d=google.com; s=arc-20160816; b=ZbeCEYGsoTCpgmY0/HUkww8dy7zEWulBoks50JnWBLGKIvUrZBBdedD0yXIsy/n8PK f2OtQDuWtka+GSwxrpXv6iO0EtUmA67kvOHItjt6gFmVRJNkBrUG9QalrprH7Ao1JJHC B74b4hdPQzlKwDcfVjczKz2TvJsny5ciavPvuXuoj/D9hKQtZcbnClSV8Xw/zsTjqGer xd1OVdyZIzg2nO+lF8+LlxwWYm+Rdk5YNSHFO9VoeAofHzc9KADR4TYyHXzTvDw8wgxP T0Ah/1GElg7T/DNcVzaDIiMIJyxplgQH5iaE6PafSZ4IDWXTOHG/LNP/9QbMl2BnENeq Mziw== 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=zXGxA+gnJI2q/xJEUcROfLYW0K/ITBz9ud9uQguuX4I=; b=g5cH8Wfs5PDvguX8in55LwIqFd2+YH8aXnZwF6C12PMec35ocsTvmVa8kiNqHkDCnM 7CaIrxVcZFjlp1UsT6179ibkriOk5koXHduumqSJ1sCaAL2pLtGZBsxJEpJkvyuK8/tA W34PdxU6RzpGm7JkUei0szX5xIms29AxSMkkoPvJaDjm2Jxi8Z1iANmTOyKjrB8CsAzq oRReDDruMKak0J/KR+K2B0lA9qdq6J0D0N4XwfsmKXz1GhqG6nKkNZWfx/tax8oVoAZU wRtjkD8C10ifTK5aBSPDfvOks/7xy79MxPJjVM71QXSOYib7UIBqbP41LFgvfW4MFtjD IfEA== 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 w1si13078799pfn.129.2019.07.08.03.45.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:37 -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 BE34389C69; Mon, 8 Jul 2019 10:45:35 +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 A965389C6B for ; Mon, 8 Jul 2019 10:45:33 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x68AjWcg045625; Mon, 8 Jul 2019 05:45:32 -0500 Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x68AjW66002673 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:32 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) 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; Mon, 8 Jul 2019 05:45:32 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Mon, 8 Jul 2019 05:45:32 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x68AjVI8094820; Mon, 8 Jul 2019 05:45:31 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 4/8] drm/omap: cleanup OMAP_BO flags Date: Mon, 8 Jul 2019 12:45:16 +0200 Message-ID: <20190708104520.24217-5-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582732; bh=9EhmjkByqc9yQn1jXmBokEn/jgfmINUvb+h85iVasbk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sapXGWW9BN6FlpSA4P7a/JGCKHcN487Ue0wGRTg40da/mz6kjqCGC+YJx+J423qbD 9MY++DOeHi7gOFXwUt4hYHsLbTfWEp7jLvw6nf5b2yrrnkGs9LL2L2BSaJdVlaCSZH pCz1kTxX8pKWiDDjhUBu5C9bBKckyi5KbCxm5Zlw= 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: jsarha@ti.com 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 --- 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 Mon Jul 8 10:45:17 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: 168614 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6983168ilk; Mon, 8 Jul 2019 03:45:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2kHi55+AuWb0QA64Trtzn89lVPWP0mYGXnp+oM3BHKmlrRnXJyCZc3Z0DrZVbgiDQf+1t X-Received: by 2002:a17:90a:2562:: with SMTP id j89mr24505388pje.123.1562582748408; Mon, 08 Jul 2019 03:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582748; cv=none; d=google.com; s=arc-20160816; b=S/3E0V0t7VJdcGU/cxJ2jv/AvbsrLLD3lWEcwii3hE1dNjOL0E/cxpQKfGoTy3QS59 sErM560iUbQBVEfTRiDZLqnG+aOi2EMjcOdtnxJsoeb7hfNJoGdwT4tckWrNgi0Ow9me k0yAj2m8AaGsyjLCUNtlG7VnI31lapOrDl8057Cl8rMb4WA8dEE0GQBCUuNt4+yibXNd RTDUBUbJGcb0QFsce21IAU9HPbkbbRjyIgEpzk94Yq8NeCU9zZ4vdqTJlEBD4R/0GNnj tAsX2DyoGIIC2jGq5Gd8SSikKF+aNhe14JEnZ3lGvlsKHI8Y7Xq79rWLoCR6WTWQIx0E KCNw== 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=9dLdXMW90pxKGIEc0JJiv1F/24D8Pavp8FvHfto3neE=; b=Yvf13ZJT7P2FH3+j1ApMNw4PddLvBwv9Y7UDotwDw/lh+03RkVQWwd6iX3fJYhFHDI PrwRW42prpgQ+EEeV6GTuDZ2fzJ590NKNVSoT+njvAMJsrBrW6HJy5fTUZOAZmpkDcO4 GqcrpaI7SJeQ3xx8/kWtCUid/u3DaMp/sP8nikIUruXOBV6ZxDzosccz1qlZ9gnMNrP3 s677baDxk5+p1Id/AGnFcbhMEvrPRaxfPkM/RozYtuBcdHhqKpdqdKIkYacdiUUrtHkZ Y8VO62ncXr7vMBnSMdqcFq8C9eCxG3tj/AlWDyq+RQe4CLXNwE4ilcFA2sgcHtMux+Ut O+Nw== 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 p44si8462170pjp.0.2019.07.08.03.45.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:48 -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 4A95389C96; Mon, 8 Jul 2019 10:45:44 +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 58D5D89C69 for ; Mon, 8 Jul 2019 10:45:35 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x68AjXIX045630; Mon, 8 Jul 2019 05:45:33 -0500 Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x68AjXiR089674 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:33 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Jul 2019 05:45:33 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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 via Frontend Transport; Mon, 8 Jul 2019 05:45:33 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x68AjWea094859; Mon, 8 Jul 2019 05:45:32 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 5/8] drm/omap: remove OMAP_BO_TILED define Date: Mon, 8 Jul 2019 12:45:17 +0200 Message-ID: <20190708104520.24217-6-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582733; bh=zdRb4rK2DOyiWxLZjY5g6G12fIVkOwWFrMoPAeGL9VM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HLlPsb5k9O+5qj4Tniqkuy58422bewzYzYmauz8zNghRDuF4cuhDcQsBi10hUn2e2 +l6IYpYGPhAzCQecEWbFeXZZ5eCcAgNWjg0J7WhMgXSha0J1AFdC2Gc+t68v1hiRrl hLTIcwiJw0yuRD/E9oWR8A7/OUi3i6ZkSTHIsLPs= 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: jsarha@ti.com 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 --- 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 1c9048e35d90..e0e8d1cc3862 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -76,7 +76,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 */ @@ -135,7 +135,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; @@ -193,7 +193,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 2ac83cdbb15a..07dba300ec07 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -194,7 +194,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; @@ -322,7 +322,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 @@ -511,7 +511,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); @@ -784,7 +784,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); @@ -890,7 +890,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; } @@ -905,7 +905,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; } @@ -1044,7 +1044,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; @@ -1143,7 +1143,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; @@ -1185,7 +1185,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 07c0b1b486f7..a4a4415e4666 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -64,7 +64,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 Mon Jul 8 10:45:18 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: 168611 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6983058ilk; Mon, 8 Jul 2019 03:45:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkRS/4knEUiO+TMh4WP0PFHiR0blrHeupXB03WL7jLxNgVsi6r+x5crpfV429eT7Dm4QnU X-Received: by 2002:a65:5b8e:: with SMTP id i14mr22338503pgr.188.1562582742714; Mon, 08 Jul 2019 03:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582742; cv=none; d=google.com; s=arc-20160816; b=R1EVbbOzjC0uUr5gR91s707mnyHbDJq6UOqJcRcd7e4tHpdB3HDRGCgAr3QWO5m/xU cXnBOFRa0zSJ6HLYr0KKE0oSLW/H58TKtB8AaVjNsqJkIZzVMTKmo+MjcLKPi+OY+CzF YOqRTJhSdZm5f+sCuJyWETKHj/+WMhmTC+Pu/Srd5s7webfDp9PS2OB4vt9iMLPj7ZdY NODaFQbLSZfOZHVVUqfSrbQgCHTy5saOWBK79k3F7DFaG5TAbmaz1xR4ux5a6drvKl69 iPIZey53pI+j1TbUkaxlrgdkr+fH4Dhstac/3lzV8yoSAtjq2dt9+wvV5zoC1WGShPfP SLYA== 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=hgU/NstP7VOFvoeAy12hsSmFpDbRa4eTawTTL48dplk=; b=Jm2u3rd3vP6YTySpMkVu0bswX2VM5nnE8VQyHbPHeOBNFUg4bsozvS0eP7Xue2UtkJ hX/9tYCvg5S5uZ8Bvp1FyP9c0bmcF10h2aoqbh7/6Lp9Qs8/kPZYm03wG4PF2V5syEnE CWmzkGmJA6npqxOOKqqksK+gjTwMSeEJtFJxcUpxZSfAXVO9RZpihpA81Jqdx/kBb7uk 8hQLS7+iHx8mc2iA2RbNxKs+aqN5byDv2K3RrEbzRIY4qUjVDkVtMPLZlUHsC97HRlym rXj+VRxhSerogEyQwUzEhZYhXzVvjNTyOoLZZikhLdO/AeSR+TqHVz9WuAR6KJPmH0Jr 1KtA== 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 k11si18077783pgb.427.2019.07.08.03.45.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:42 -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 EB99289C82; Mon, 8 Jul 2019 10:45:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D02D89C6E for ; Mon, 8 Jul 2019 10:45:36 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x68AjYHQ005789; Mon, 8 Jul 2019 05:45:34 -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 ESMTPS id x68AjYQ1089707 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:34 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) 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; Mon, 8 Jul 2019 05:45:34 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Mon, 8 Jul 2019 05:45:34 -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 x68AjXYV069997; Mon, 8 Jul 2019 05:45:34 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 6/8] drm/omap: cleanup OMAP_BO_SCANOUT use Date: Mon, 8 Jul 2019 12:45:18 +0200 Message-ID: <20190708104520.24217-7-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582734; bh=SKYZVWcWwJ5ZLLgc5LOACp4zuj8TdGUjmf+/iSNIXL4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=MgWtCpiGe0Ff1JBev6hWBr3jXgSH++mvGhP4zZbUf8pLNFMiYcFvvrNBBRxblGWVP X+IIfvaTdUOoJ/VPqpkq7zoCzsDt9RaevKzwpEEUyy6MxLH35iHvOmxmZ57j1qk078 AZMfgiyTy11ykYZ3z0dmEYzNaoyiSBKaCMaBY73Y= 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: jsarha@ti.com 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 --- 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 07dba300ec07..5c4cdf618347 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1153,7 +1153,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; /* @@ -1164,9 +1163,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 Mon Jul 8 10:45:19 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: 168612 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6983089ilk; Mon, 8 Jul 2019 03:45:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFG6IGIfBLW+BS4gS2xdEVW90nPBw2WDOQz1B7tH482eBFvgWEb01gsjpqFvss6q3AIejo X-Received: by 2002:a17:90a:c481:: with SMTP id j1mr24317215pjt.96.1562582744915; Mon, 08 Jul 2019 03:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582744; cv=none; d=google.com; s=arc-20160816; b=P+379osxEcE1ONShug0nBYbwwPlTiROUpGEV+ABq+GSO/uQRIhvyB32sHrFmZnNGAK 33naxmsFCZVjax1kRLelIHsBz3oK1152owy2+WZTY3UxsqK1hBFnCW2DAwbRe3F1t10W u0A2VdbDbw9vSerwiOIA63mfD7pbwVMLivTj5ZUBFU1WR1/qeuTzavzoOH+uYTP9pcoy YhdIIRM5a6LYWBzQwJbaakCNv+8bE6eYV9xStdbxiN8wa8b5x6ZVY/IaK7SoosEL8pcN hD2e4/NU9KnmM8+V8PF2K+MAfLn/+wBs68xbwtizWgl8yeHt/CPAtkgHtRXiaSJaXVM4 2joQ== 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=JjXOLahFuEpIEhv+Ge+sSS8nO72VPyuwIs1c5/blVqw=; b=hlPcs3IYZ+fK3ARMMnK1nvQvSCWPtra1Htem24hstTuoZW+XAtPkXFLVfKtOm2WEKR HcxnbxMwKV5eMqrjJ6gNLQXhEOUEHdQoXPZ8mszmiqIvscgg2r3Lpm/KlfLDGp36YyhD 4XsN1tS/BO9j3yIGxVKhc4n5ynlx5y+Ad0lV2bTa8Tgj49gKXuX+RWsx+E7AzVXzggTG ekgx5GFQminNNon3B0XT9yfZOZIvsuTdQlmlaUGMqFC8PLeqxrQd27MmMOA5EP/7MKal 4UBw09uSM0k/Ec7JjzbbLSw1Q1bg44jc1ijcOJAIC0HAIk2jmY/2U2sXzALPhDX9ccEO xo5A== 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 l97si17666492pje.6.2019.07.08.03.45.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:44 -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 80D3789C89; Mon, 8 Jul 2019 10:45:43 +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 136A289C82 for ; Mon, 8 Jul 2019 10:45:38 +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 x68Aja1Q045636; Mon, 8 Jul 2019 05:45:36 -0500 Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x68AjaD2031749 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:36 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Jul 2019 05:45:35 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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; Mon, 8 Jul 2019 05:45:35 -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 x68AjYw3052658; Mon, 8 Jul 2019 05:45:35 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 7/8] drm/omap: add omap_gem_validate_flags() Date: Mon, 8 Jul 2019 12:45:19 +0200 Message-ID: <20190708104520.24217-8-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582736; bh=6R45qTVqa1K0ls6ScU6rgzv4DoVIhiFBUKSk72AUW5c=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ImhuiSW1r/m8KeLnXOWXeZWZ4CBGK1WfUrCXt2PRUwFoYG0e1FzK7+tuA6wZ4MQ4D PC1SUVpnb1cGbR3xCg87+xh72k377+uzt6HSfJbehPOHmJTQsuQ60HIUqY3dItvEVK g1tMjj8l75C4SqJ6ss8GOYmJWQlC93Y4npE+7G1A= 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: jsarha@ti.com 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 --- 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 5c4cdf618347..cafa9d0bf3c1 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1131,6 +1131,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) @@ -1142,13 +1174,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 Mon Jul 8 10:45:20 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: 168613 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6983124ilk; Mon, 8 Jul 2019 03:45:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCse7TcyZIoq9SwIO1rCwSPwz83J8C/nwvvfZtwfn56W+Ti79s6pm5kwDqfKrbbevQSZyp X-Received: by 2002:a63:1658:: with SMTP id 24mr23341494pgw.167.1562582746521; Mon, 08 Jul 2019 03:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582746; cv=none; d=google.com; s=arc-20160816; b=xvZM64QLtrgGEGvPEzGfiBkGagPXnomOdVEwjHboD5r6gk/SiegQn3opE9rqqcTiRw p/CSkEeqJbNwMAYQWf6+7pqNq2o29O9oLyf02tdDdBjqLfVOoUpiYqLSdfOcpSM/FEZH hwRiSmSTTmPOXwSVpyh8Assz1/2hysReJES2p1y3DG9xKWlvGTpqGHqMg+biSZxOQzcM wIO0dxRKZ0J2YgVjiejXP83NNP+tH4mNc6+g9xU1fr7nC5vtOq+rPHmh2kwj63W3Z2SB qKm40VyVj3dSA+HNO2aLgoZRJJeYavXhnBJHXOtah+CliEE/ThZLYxqTu+z7XBcNR7cz Iz2w== 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=ErN2nu3P+DXVHkLBVieyQiDBxjcQoIOCOr8ExerI6oc=; b=SCxiLRYUXOLY/CpZiyOme8BoN9ZNUzjfbaVojNUyJlhdtUmQsWUyp2kY1reUfJ3Tyq xo2iaXLsL2Biq7SI2GbaiF4bGPg/qu0t8sGHo8YSB/XlsStnttSQzviazz+lDvyxx1AU 6Q6eaWh0tPh0bDAuw3sp8KWwiMYc5mDq88PBo6DVD+MTN4ltnlX4dsGsS+hj7mJv/B90 cgGzu1fYbPfKERjxP6SNGtQFEyMfz8aMAtzAxAEnzGx/4OAQdw1NU5tQ0n4vU/re47Qc fj8PWzA7dYWCIktlcuEKhwiTcLJk+ChKVPWZ2vojDfLWN58Ws6LlabJhjsqqjQJv1hxn KomA== 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 132si18888174pgc.134.2019.07.08.03.45.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:46 -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 962CC89C93; Mon, 8 Jul 2019 10:45:43 +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 528F789C82 for ; Mon, 8 Jul 2019 10:45:39 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x68AjbNt045641; Mon, 8 Jul 2019 05:45:37 -0500 Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x68AjbTA089738 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:37 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Jul 2019 05:45:37 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) 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; Mon, 8 Jul 2019 05:45:37 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x68AjaQ7094941; Mon, 8 Jul 2019 05:45:36 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 8/8] drm/omap: add OMAP_BO flags to affect buffer allocation Date: Mon, 8 Jul 2019 12:45:20 +0200 Message-ID: <20190708104520.24217-9-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582737; bh=OORlREukRNbyeTO0NT2qFZJ6srIhNzTArbQ7l5ZZpKQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=j88mZJ+RIS6scX9SfozFhlFCrMe51zp/cm7xBe3BAD2KFz0iqYTifXpYpX5cFc1Uc YLoAXKDIzZn04eDPjiuLRYBM2sxNY90Uf3d3HZfAiEIjxQ9C0tg/UfMTFWCkEPGBgC a32WQVVrWKsEgV4ntPfFfo4KX08rEXI+fWA13hrI= 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: jsarha@ti.com 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 --- drivers/gpu/drm/omapdrm/omap_gem.c | 25 ++++++++++++++++++++++++- include/uapi/drm/omap_drm.h | 9 +++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index cafa9d0bf3c1..d744d27e200a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1095,6 +1095,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 @@ -1145,10 +1148,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: @@ -1191,7 +1203,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. @@ -1251,12 +1264,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_writecombine(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