From patchwork Wed Jul 3 15:55:30 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: 168454 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1912217ilk; Thu, 4 Jul 2019 00:26:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsUyOzd26xsXNwND7fxIqExc1PDT+wHHfux+HLaZHYjRhVEUtEFdwXfrNPLdnAHYkmQtOe X-Received: by 2002:a17:90a:d983:: with SMTP id d3mr17759509pjv.88.1562225161635; Thu, 04 Jul 2019 00:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225161; cv=none; d=google.com; s=arc-20160816; b=zOw8BVh4/HUgrwhd1HsT7nOlCkH2X9K5/jOxsgzwNcT5PFXCUnXzFO5gCdW///EDQX VavQF+8lk/z2TqhZghylzMYPD9TD8o2BtAtHB/qDlzUsAeNE1ZQ33da3HdHkun80r8+B UYRc5umALND4XLInTJU5Rdbzy/96o6cqJEAi694rS2HNy/9D0axIjWNtl6JfXGZNOnuB iekRx8XgbrMRrMNldp3btdi66KQHGJ6kcet598SbvLFZ5KGCjeDzZb0YNgn7A3zg+6+T LTtfYEvZJR1Qyen09friqJxioVp7sGj++65lXIONmgmC3atnTOTyTpiVdsOY67PnqWtz HR/A== 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=QwCYlpB1+/blPCu3RDN+fF8pFpV5Pf4ryK914UBoh7s=; b=prMOVOm77CRCsxwdlCgaeaRcJU0R2PomUkmQoczpYnF0DWV7Oog320ENG3E30z17eX zR6bqi82R1Sv+t3hzTpiabE6r04XMvys+4Z1OwecoDc3v0lK/h5nlWyHeGWI+IeJ3ZwI k4il3Nz1/knkgz1NCSuMggS+ngs5o0sRHTyIkemyTimj6AtiOC2mFIpF5rJdlwx6203U EUEVSg64ixd3w5hpSSHj8EFucfmvTxGlZO4DXhlX9bb2ramC8mIG+9j9rOURo1qLH8tL Dn4F2/N2EtqcU2RZv6UpNOMb8rfYbTIKnWkz5wej3jIL4zdSE8w4DJ25R1BeoZvOuBJm L92g== 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 m71si4414239pjb.26.2019.07.04.00.26.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:26:01 -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 514666E28B; Thu, 4 Jul 2019 07:25:17 +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 9DB166E15A for ; Wed, 3 Jul 2019 15:55:46 +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 x63FtiVI015509; Wed, 3 Jul 2019 10:55:44 -0500 Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x63Ftiea064846 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:44 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) 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; Wed, 3 Jul 2019 10:55:44 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) 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; Wed, 3 Jul 2019 10:55:44 -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 x63Fth81001306; Wed, 3 Jul 2019 10:55:43 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 2/8] drm/omap: add omap_gem_unpin_locked() Date: Wed, 3 Jul 2019 17:55:30 +0200 Message-ID: <20190703155536.28339-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169344; bh=TvaYb0Rh4N6CqRqeNnFVOyMwXm8L1ETqUol/LNEx+cY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YIqBq7K9C5RUfWBiNTCe4F6sIm0xv5ZCRdOUxjXw4Pl/VDCIXwbclosEg6XbyWh0M DgtOnCbsKXGY5UcSi+7SiKqDTlYbT+/R9DpvDngct7FZQUHwY0pM8Hbe1bskEtZWAN x7RVNrQ/nM5e7fjRbEEto2j3pJIL7noCIEZwYMZk= 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 | 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 e8aafcf0f209..2b745b0cfb73 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -830,20 +830,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) { @@ -859,7 +855,22 @@ void omap_gem_unpin(struct drm_gem_object *obj) 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 Wed Jul 3 15:55:31 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: 168455 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1912336ilk; Thu, 4 Jul 2019 00:26:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzaVbODorXU+0IKWYG7FqvydBrxptOJKcDVcjTYbuQxKj9cB1vBOzuLfIU1Jt773KqREnJ X-Received: by 2002:a17:902:ba8b:: with SMTP id k11mr47602825pls.107.1562225169796; Thu, 04 Jul 2019 00:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225169; cv=none; d=google.com; s=arc-20160816; b=REPrDVEBNtACi7T88zS5PZbf7dl0RnFGaZ5GWsUvBXYXqcblQJn/BGLUabcZN4yjR8 ldJyUU0Lb1lIus4dE2MIbah2icD5jaPQ02dY6MzaGlLe16lsZ108LCT9Jl+5f10478B6 MgBqdPhKuLuP0bUJ/nmxLU3mdDHLbSkit9kncJ2XetxcF3NWKqpJPF/Mukw0EfbkKCws h5hQ//kuiAK1/nPeGVUwnP8P+VPDhwB4xFwhM3J3N3/go3BiKRcm+48091uWeW7/mhW5 wQsA4zSlXZgdCDNry2mxX40lHSPby9mNFBZ8Bx2ZJvpY6MHh2+2qp6pFefdoihaB+V/X LCjw== 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=tkrvNLUK+6YfX1/y/V/4N0XaX/C/LxM6s5IHK1MREyw=; b=z/isoafC+XjcoZogI5E0PW7xYUZa1fkHAHRO8ei9O/Y/DJ5g1NkGI0SheHN+x5LvBS pC3geb43bn7BigWfjkh8T+M9BKti3uBsxCxa+H7OigYbXzwxx8fiZ+8wFQdpQuwFdA+G 7VkKrTT6+9hGSOMwegvbh2gwqT2HIlp2/b8i+LDoAGTnKby/O48l7fit6Sv6LyksS63t y1mdocKDF39n4zwSKXdDbTAO9hFjYLVlt6tkF4MIhYIw2t/HkYkAOE7seAQ+L78YTBp6 A8OCKfW3JikRuTEwYdPPtOGRNMdchDQ6TdotX2Zgntws6GtnGvVjx2ghgWVTzP39AK0y OTOw== 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 l66si4594018plb.221.2019.07.04.00.26.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:26:09 -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 B493B6E285; Thu, 4 Jul 2019 07:25:16 +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 85F6C6E15A for ; Wed, 3 Jul 2019 15:55:47 +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 x63FtjZS059883; Wed, 3 Jul 2019 10:55:45 -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 x63FtjsX001476 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:45 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) 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; Wed, 3 Jul 2019 10:55:45 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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 via Frontend Transport; Wed, 3 Jul 2019 10:55:45 -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 x63FtidQ070121; Wed, 3 Jul 2019 10:55:45 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 3/8] drm/omap: accept NULL for dma_addr in omap_gem_pin Date: Wed, 3 Jul 2019 17:55:31 +0200 Message-ID: <20190703155536.28339-4-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169345; bh=mP6F39u6phwbe5nSbxR5D0TFXwCp5NMy1PkRGxhClQk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=g5iZWIkMXiOvS0tNZZ8TqMLV7bjikfg2EzyHuH/iaLJojNvTWoNjuAbjAAN6Du8Nt LfuZmTIxLYVXaL2ARizzoMWy2cTucZUHTKoVcxixieUQpDJ7lZZVp84qlG0uZNO3GW wVT+Xr4tBkoZ3aqXjOw5tjAeDLb9TwDyK0nq/Br8= 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 2b745b0cfb73..5293535e02ee 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -815,9 +815,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 Wed Jul 3 15:55:32 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: 168453 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1911833ilk; Thu, 4 Jul 2019 00:25:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPgOmgKlivvAy24kFzst7RocVyLoPxo/kFZ7g6JGlzFbNgRmXxH9thhPzaAQuR7gfMPd9b X-Received: by 2002:a63:f4e:: with SMTP id 14mr41989946pgp.58.1562225136389; Thu, 04 Jul 2019 00:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225136; cv=none; d=google.com; s=arc-20160816; b=PNNoDMsq9QnrhyXDaJmSlJpnYltDvPaYlfdCumbrgfplB4XV+2Uvc0wE32T62P3Mq/ rOr+BEDhOPw6Q2DYH6OfScyk1+OZsmpiQ6vr5lqFSaprwKh0E9DbZS5UHpfx2WC2Kg2W h1qQsyNM3xnFEuGmKGg/rnHPpClTbxgKk1zzPxrOqHPoIGjJcFE3lG9+vaPScP9aZB/p feD5j9kqLHSPjY17Vlt6A86InFvHEgVYqj9X/4KREc44KsyTaia+0jJeb0uVHTYvsN4l gZoyiWwgb7KjArQyIQMTI8sYFVXO5Dk9yoBA9hM/FTpiU6GsX5dHZFMZ2YaTYhopPTz8 VFPw== 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=UjATW2mn24onBPHiIel2/sQvnumTYbQXZ38r9dHAL6lVlGu0mTl69ThOvrRADOhtx1 Ea0tiHpSLhXgH6mSV1S5wB/pO8UcrJYV9mmSAAguO+QVajE3TjqUakX8lDt6CmYRy1rs WAYYI18X/1GuqNLhGZhas/GaTdH1P0+uAR1adO6rPk1hWJvGdL+beCGXUmxN0QBrfak+ 7ZKMSXbjvu7WOGYgDzGMdQ3L6X89zBBWQp3LSh74wmORLT4910xvqCOP87XYZCu+Lvgy 4MwBl627SchKe+9fFQkTKrOJfdcjr/wGssufgPio7JPzpBdP/jzb6FmGE2Q4ovh/xwcV 87Ig== 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 l184si4808210pge.286.2019.07.04.00.25.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:25:36 -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 1F6566E280; Thu, 4 Jul 2019 07:25:15 +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 E384D6E16D for ; Wed, 3 Jul 2019 15:55:48 +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 x63Ftlk4059892; Wed, 3 Jul 2019 10:55:47 -0500 Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x63Ftla1099237 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:47 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) 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; Wed, 3 Jul 2019 10:55:46 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Wed, 3 Jul 2019 10:55:46 -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 x63FtjGt122082; Wed, 3 Jul 2019 10:55:46 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 4/8] drm/omap: cleanup OMAP_BO flags Date: Wed, 3 Jul 2019 17:55:32 +0200 Message-ID: <20190703155536.28339-5-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169347; bh=9EhmjkByqc9yQn1jXmBokEn/jgfmINUvb+h85iVasbk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=QKqFj6bRArg3JZr8rqhZbCLKXBOjJa+M4wcd8Dg3sTolzEzsz3rv653JmWtyEdN1h FLgHikn2QD1KVO1gzo9fIeOqziQPVCTPDGE9QzaRGixZleRiz+A/uaBL0gG0CtC29Y tlS3/toML3EVj4zKozSXOLOx8EuQ3bCGrmg8n4+4= 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 Wed Jul 3 15:55:33 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: 168457 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1912758ilk; Thu, 4 Jul 2019 00:26:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwK+EHxJQFwpHEd3cQTYfWomLxtLaBtewxAQGJRMNODH/EwPTRnHeg+rEGWwkcg5wOCtaAY X-Received: by 2002:a17:902:9f81:: with SMTP id g1mr31095099plq.17.1562225196803; Thu, 04 Jul 2019 00:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225196; cv=none; d=google.com; s=arc-20160816; b=QuoqspuqGjLLHKP9msDkG8kirCA3pJ6lI/PadMzzUWj5anraIb5TWbUYCRYoLz440w kw3losy1pGPriu9Bd1RlVj0XKMyJM5AGpi2Hh3C1379Z3JpgOKAJtQIwAE+1phB4rWd1 QXHWQ2HSX9dzIltxV5rKQm1nEPPaZb73+RdKAFE6Wyqwzvau0KoX+Nnz9BFub9Xw24z2 JODp3sj0+jTPyWhdB1hQqyEIKbzm0l4cpljJjJI4vyG/Fw+u2ORLCBo8B5gtuZfVvXPT rXhTBd6yob1rGqeZ4nEPSkB6jiAJjxcZBjJZqfwTE8Qvjq+gexgwPW/TAEdpWptW3yBd Cuew== 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=YGMIksvHZW6k1MTErec1xMLHZN50kzOYPM1MyjQ5y/k=; b=TM7QDYDUvQ/Nkn65ntdQvCZMJ5dHEzsu0cQs8JyB8yV3El88a335qhNLguJVwMwx0G fnw5phbEb72uZaWMg3YUgymsfSX2GrqTONTo4DzmotTf1ME7RvFjHk2oBgBYl9rS23Z3 yb3g5ZNxIjuHLhSj4YtvfP+XgCktMkhn99hFZM2RHDO1Q9n3HdIBWszJYboMM/UBARy8 RVTm4dmQZLWSgq1mRp2l+IJjHxq0UyjcwsOMaLfRLoURYicsVQo5q6U1YD1bzSztCw4P hcnH1KaI+bTi6UeCaAt6jvPNx7TdyLbFbK5cJVI+Y+DwdXWANW/c4NZKngXuhzUZa5EN xtGQ== 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 j192si5067031pge.393.2019.07.04.00.26.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:26:36 -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 0F9B76E2CA; Thu, 4 Jul 2019 07:25:22 +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 39FAF6E16D for ; Wed, 3 Jul 2019 15:55:49 +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 x63Ftme7007294; Wed, 3 Jul 2019 10:55:48 -0500 Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x63FtmcJ001484 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:48 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 3 Jul 2019 10:55:47 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Wed, 3 Jul 2019 10:55:47 -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 x63Ftls7122097; Wed, 3 Jul 2019 10:55:47 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 5/8] drm/omap: remove OMAP_BO_TILED define Date: Wed, 3 Jul 2019 17:55:33 +0200 Message-ID: <20190703155536.28339-6-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169348; bh=Sw2KbItWOeFcJlws4jid3jl44eNBvcxFH0236jWv5d8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PvVDrCOwJKEayzlGp+ZMk7SKsdq8DYCFheGHZk2aM3WNaZug3Bj1c9Iutor+ZJGul i6yqCr8uJiEB4GGP79+Pr1C0zVJhL3lqgc/k1taSENJiPDU1xMnW80+xlCRzjQ4Lse rYiL1M5rEQ+1eN/Ci7+QNGwdtNCdEgTcbw2+xtYQ= 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 5293535e02ee..f6a4d1a70bf6 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); @@ -782,7 +782,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); @@ -889,7 +889,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; } @@ -904,7 +904,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; } @@ -1043,7 +1043,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; @@ -1142,7 +1142,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; @@ -1184,7 +1184,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 Wed Jul 3 15:55:34 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: 168459 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1913092ilk; Thu, 4 Jul 2019 00:26:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDO066Al86nJV1n/+yKsARvAAyVjTVrQpP5I6LbG3+h38Hop+2RzxrQ1QSB2GsBmNw15Qk X-Received: by 2002:a17:902:145:: with SMTP id 63mr2365318plb.55.1562225219808; Thu, 04 Jul 2019 00:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225219; cv=none; d=google.com; s=arc-20160816; b=0k28LGvvfCP4P2xc7H/fPi1HLVLlJxbZ3aUICVh+GSluwNM3Aw8qWzCCdrbUQplVHA DyBzdxdMVZJbojLnHbLR+JzuEIO8pm/j4gmtRk/kfF09nE7p+rSipiCBU/7xaNKPO6vB ySCDYKCIIVFHUoLVUMssQD4j/0nEBfsazMpz9xmYgSipmGCSGcErLZIIIfuz/gpyjkbz 0otyccJ0bQcavWHRKNMmPikCvRDRiLQ7pLcNn6gxjCA5+tLLJd29bfAIfzH4hE013l65 vFR4HTKhVj+a5CEtN0fXIP/8TPKNAgF72dI62gzr3lFK51ccOgVoSUqCoEkdakGeEpu8 3/mw== 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=xQyQQ+zT78T4zTZuaPio8lLVny8n5pOY39necmc700I=; b=Vm3cvqQBtreJZkAfLyi/7NAKn/l0cNChOCZ0vol923Xe+KhBWza6RdAk8sOPjUeqUg NFfZsjMlmGnRxPx8MqIV2YKJq87+T5B3gLDRIJ2baIgvEN1XgBCcFLq5/ueReXNJ6UBO XniFhlkdKncVXbBuy0oKKox5cW9MpZ0jGllVALAZx2YMEPPWW5FkkUDBM0Tj/9iiY+wL SdB1p0J5FEdiT7jnhJWCH+PTGsFU9+2+/2aq5T+D8X90aFGiQZLhm2O87SSBoL4z2zJC GFQq7OKQy2jnuvlBZKIWDbaV/Se/4TrLLKPS2sn9rqd8T8jYz9T/w6OXYkh53Qm3eI67 jAlg== 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 u141si4908630pgb.317.2019.07.04.00.26.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:26:59 -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 95D516E2C7; Thu, 4 Jul 2019 07:25:57 +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 7B8936E170 for ; Wed, 3 Jul 2019 15:55:50 +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 x63FtnSY059912; Wed, 3 Jul 2019 10:55:49 -0500 Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x63FtnS1099253 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:49 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 3 Jul 2019 10:55:49 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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; Wed, 3 Jul 2019 10:55:49 -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 x63Ftmfh070173; Wed, 3 Jul 2019 10:55:48 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 6/8] drm/omap: cleanup OMAP_BO_SCANOUT use Date: Wed, 3 Jul 2019 17:55:34 +0200 Message-ID: <20190703155536.28339-7-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169349; bh=7UwLPsTaqTpgEG43Nf3PGzeENx2dY3tR3yya2Cm0naI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=D5Ap1g8AkIuLLtwXoXjBdRcSGtFBLR9H3FfIKnuxpXmHUTZa25V4VNOBr/yxc4aH9 NpsvaxArF7nnKYFbFznDVh9pddJp4s8nSUT4MnJPORee8o6LOjx9OeKfGLS+WyKfO2 eHElgSKvNG1N7JVno+S9+ISZJymAoI+Vw8pmFqq4= 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 f6a4d1a70bf6..539eec05b1c2 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1152,7 +1152,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; /* @@ -1163,9 +1162,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 Wed Jul 3 15:55:35 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: 168458 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1913068ilk; Thu, 4 Jul 2019 00:26:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyIL2tHGiLN4rENTE9byL2bQONEeoviVCEP+F0O3g4nKA8D6pDz1H03oAYDirIvMgHmHCT X-Received: by 2002:a65:5901:: with SMTP id f1mr41364759pgu.84.1562225218075; Thu, 04 Jul 2019 00:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225218; cv=none; d=google.com; s=arc-20160816; b=0MBilRZpNvTJt3B4Mm3u7z1Lh+9jQxBgAY2d1wm8uUnVEVi+RbsS2ZMMs230+r3A9Y eqdTvzHn7U4wXADCjsCSqN/ks5q19Gp5s/3DL5dlKmbLx/5qvZfrv1haUrHZV9vhnDaG oSAjiNa9O6fYcOeQJ8ZCYTPMF6mk6I05hTY/JGZarls4fKTteLGPTiezyhkPosP3ZNAS OVlB5tz8ocHcc73RTwb1lbwgRj8ElrR8o+eisOaaUox6oqMsUzuTIZ8XVz3GA/CqT6tX hgjliISU5MDM82lO7xZ77QJThFkCBvvBTe/kZQLqShY8h8QlV33OVI2adsf8U7H2mflA vVQA== 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=7aj6dcitBuaRQVD5ne/0TdD/SVP/wUQJBMIkyNYh3h0=; b=LWIPWpIjKNjFCHBv2LIuS0HeVuckpGxSRJ9G/ux0WYVWUUsBAUkBtYAJYEmn3GyYOZ 6veNkIlGC1s+i91WSEbulEIs+US/1G+/yKvd2OKb9l2cGQFSnuXgYQtZzifNbiAwxGx3 AEIi04y5ysPWAHZsq52Mj8YCAxFAvfun+s+EfMdW3uPP+F8TDI9IHL3xuTsD7SmKDrGZ zXDc+Jb2gHXdlXk3n84ohjReWazgc1VHEg0VHEC8jzQRAYj2NN9zM272IoqTvBy5Ftcv kAxJB2SnzjgKEIcVwr8FepSwcCbXVh8HzX75lVMKRFkWyADM0uaf6uS+nbl3XO3tx0Oq oa6w== 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 x70si4915062pgd.311.2019.07.04.00.26.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:26:58 -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 2AC466E2CE; Thu, 4 Jul 2019 07:25:58 +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 13A476E175 for ; Wed, 3 Jul 2019 15:55:52 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x63Ftoeq071814; Wed, 3 Jul 2019 10:55:50 -0500 Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x63FtopX016540 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:50 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 3 Jul 2019 10:55:50 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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; Wed, 3 Jul 2019 10:55:50 -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 x63FtnHl052650; Wed, 3 Jul 2019 10:55:49 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 7/8] drm/omap: add omap_gem_validate_flags() Date: Wed, 3 Jul 2019 17:55:35 +0200 Message-ID: <20190703155536.28339-8-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169350; bh=5iqsAmmbxUMc7EK2WjMB3guYcr3nfMA9sGZSKGIK9fI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LHR4D4fhjmWwJiWLeYH4uRWX/jic62fOA+CSQTa5UdZnG4KJaCIhHMqeDusRi++Qr vysK6biOXEIusvfi6qbgp1JbRrzTn4Eg2IdYvQ1dNEonPIyhXmS8QVaXH/ZABZzkCe 0FOgileCJOwVDbgjiPcmvXIq3N6WwSVS8gdP7hr4= 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 539eec05b1c2..705403825e9d 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1130,6 +1130,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) @@ -1141,13 +1173,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 Wed Jul 3 15:55:36 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: 168456 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1912538ilk; Thu, 4 Jul 2019 00:26:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOICF/glkn2zXq55CD0hPFkJ8U35Kdf9Asb+Xd6OKSI/5Wz8pUvCm98mEWdDVYCdmHodbT X-Received: by 2002:a63:56:: with SMTP id 83mr42836995pga.145.1562225182176; Thu, 04 Jul 2019 00:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225182; cv=none; d=google.com; s=arc-20160816; b=GQ+H+fH+iFUYlOV/r9FbQ/Iu2tbp6zKuK7wTGBcfyTwvlSvVeKxsqTFPeGE5LPYSbp IeXBeftajQ2P2159TnWECVTayyIxp9wHSbx10f5fAS3mXIRoGNTKhNNdUyswd5KiF4+g bw5Qkbd3I8/XbV8TBJGrfzTvFY/kFjwkv+FpGlTJBsFdxmvJu3lJIZoV2bt3mwREJDmj DsJif3nnIpHfpsdKE1CG+5Omuz4aZSa/MSiPBiN5EfiU760DmW7rRz3heDyk3tMrl//p 5aiMMKYAr8FeH11wuAvjyNqG+dNow/lw4YKz/BarhtpGf7/Slc09Mr+PnnMMi9LBPfkM N+vw== 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=AG+qg+Fm07Z1ukt/1mUkJDI0KKBAhYeHrIG300RBFgQ=; b=Gzs0nZ1YEIAI0oqPel2mc1a0wmGprKGp7gGxTOZb3nryCDCZZEMpkia/cn1Pmu/h0w aSbb2Cl/BGBEQW72JiOFnpab8JoTGkOGuc9qXfc7l9xMNJ7tk+bwd0H6R5TFjR8cWaCc K9Jjo88l5iFbtwROS38tPVFLceXacdJ7HWM3epyf/JQuzdHSdXJD7IHfGDIzqKKu0PF3 5tPK9W5oSIiDDV9UpLfuweLIzDTPNWyqc75IaBFuB8hrHNBSRM4CcsCCK2RGyp+rfS/L DJccwV5oMQ96u1x9sWMsaWfsCANzruJpci/GRaTwJy32haLB+acrPT8oRVFDEXnHR3nh oBww== 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 x9si4439462plv.182.2019.07.04.00.26.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:26: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 8B7AA6E28F; Thu, 4 Jul 2019 07:25:17 +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 56CD86E176 for ; Wed, 3 Jul 2019 15:55:53 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x63FtpgU007305; Wed, 3 Jul 2019 10:55:51 -0500 Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x63Ftpg5099276 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:51 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 3 Jul 2019 10:55:51 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE111.ent.ti.com (10.64.6.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; Wed, 3 Jul 2019 10:55:51 -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 x63Ftodt070204; Wed, 3 Jul 2019 10:55:51 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 8/8] drm/omap: add OMAP_BO flags to affect buffer allocation Date: Wed, 3 Jul 2019 17:55:36 +0200 Message-ID: <20190703155536.28339-9-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169351; bh=KVgZvfoe9n//YsJnk0GnMzmqna4ecdpjyzZOgi1IAmk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PO75P8ygtPFYL4nsEWesOUlwDAlxbWj94YiyxCYSESa0mx8s6fmMoW7tsop+OZAz8 l77H9/vPpWvOJ2h8Fm151K8EvD4x1dhG3ghYj+UOKCWEXi1+dzfSgQDBD34mwt5mRE BMhpHPMD/KYR5Fk5wK/dbBZaNJFGIX1tZHS+dZlA= 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 705403825e9d..001a1da92caf 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1094,6 +1094,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 @@ -1144,10 +1147,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: @@ -1190,7 +1202,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. @@ -1250,12 +1263,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