From patchwork Mon Oct 7 11:25:49 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: 175321 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143321ill; Mon, 7 Oct 2019 04:26:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVjdYPkarqGvBeDnHZkBr9nsMYVwz/R6kZoIVUnFPVxbZMifG/LRcYDVH5shm6F3kI5lOQ X-Received: by 2002:a17:902:222:: with SMTP id 31mr29578562plc.167.1570447569056; Mon, 07 Oct 2019 04:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447569; cv=none; d=google.com; s=arc-20160816; b=NGSvmCYre9pmRExS5QpMhrD/W1gvqx6aZF/K1rViy0J8PZi7t074MyQua/kxJvZWfl lg8Wcz4b8DS+ww/CecGh8c64y/4IukP5NtKYgGQw/sZgPEDNCqex/711x2Ftta63vHqC lJbbYLd75+Eq4lcbNq3mnwYR7JOYJIumZ+lffYm8Skh5uf+QW1lIiBiorFaDoZ8T9N8j kqcNAFO7m3wL0u1y9iPyzdZSQfV1WlrDtWbVDhcWhYfQySMD389LL7D+j4B2HVbhotII mTbMZN8T+0rz1caZJsRxtt2IpB/XIKqhIl5S7pil6duhe8QkBtlKxk+aPgRBPfy5hH7C iJsg== 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=fZr/iwo1+X2VLs++bU9UCuLBNhP+Q6iy0u5E6EbIzo4=; b=GXSYopIZpbDrUJJFCZ5c7P+HzySTOOVdxAUlaavJWSZ5V2rZFGSuvqMidBz9cTA2dO /w9m8yRYgxJFnofBuTbNEHdyfY9H7PduQgmHPAyJstIWyx7Au/qbY7RcKBf5igPAXxKw rzyyD+gtXBXzKFF6ZnijcKaqCHmwwwfTh18lueyFGg277QYcXBBaQddskISO2YhWIVnX s7MC2xAovf2c1pTktScoafEngQ1ALNmk22wmun9vDjQ1OQ5yHE7FmC8PDoBRxQHJxrM+ dakYLe8uJvndNsOLP9NqgXIv/4XC8nLQbs/A6tdw4RGHr+TVDLfrpE0PyZr9wN0uVs7Q SIPw== 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 u5si5297143pgc.379.2019.10.07.04.26.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:09 -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 C2FC66E55E; Mon, 7 Oct 2019 11:26:07 +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 26D976E55E for ; Mon, 7 Oct 2019 11:26:06 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x97BQ3Jw012407; Mon, 7 Oct 2019 06:26:03 -0500 Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x97BQ3ge011463 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Oct 2019 06:26:03 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) 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, 7 Oct 2019 06:26:01 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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 via Frontend Transport; Mon, 7 Oct 2019 06:26:03 -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 x97BQ2HY058976; Mon, 7 Oct 2019 06:26:02 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 2/8] drm/omap: add omap_gem_unpin_locked() Date: Mon, 7 Oct 2019 13:25:49 +0200 Message-ID: <20191007112555.25278-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447563; bh=BZ7phGWHu9w3u3UYwxJIySH+VtutbkKNKZ9gvsE7pAE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qk9hkIkm5y8GlLL/YaNMwVY7/XNvymIpNaDFBfxozgOvk/j6d2KomqP8DshzZEb1y a2gFh8n48uXFTydY4Yli250pRpQWYK8/pk7hL2v54ADi0hB5XTd7ooDM6iSOkdeR/L ZLOnskem0s6XtL/AEtcrGVMXtUDvcsB5qDsy4ECA= 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Add omap_gem_unpin_locked() which is a version of omap_gem_unpin() that expects the caller to hold the omap_obj lock. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 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 51ede7777083..9201c21e206f 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -834,20 +834,16 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) } /** - * omap_gem_unpin() - Unpin a GEM object from memory + * omap_gem_unpin_locked() - Unpin a GEM object from memory * @obj: the GEM object * - * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are - * reference-counted, the actualy unpin will only be performed when the number - * of calls to this function matches the number of calls to omap_gem_pin(). + * omap_gem_unpin() without locking. */ -void omap_gem_unpin(struct drm_gem_object *obj) +static void omap_gem_unpin_locked(struct drm_gem_object *obj) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret; - mutex_lock(&omap_obj->lock); - if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) { ret = tiler_unpin(omap_obj->block); if (ret) { @@ -864,6 +860,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 Oct 7 11:25:50 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: 175322 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143403ill; Mon, 7 Oct 2019 04:26:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyB40J3NnEmkGBwVamoRBmQnITO7atYkgc9K+7ti5M5ogmXStsm0BxXa9+/2PylCFaKAmzT X-Received: by 2002:a63:2062:: with SMTP id r34mr30531075pgm.48.1570447573902; Mon, 07 Oct 2019 04:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447573; cv=none; d=google.com; s=arc-20160816; b=vYjXR7MkvfnsS7zSDfVB1ACicQXEOa7ZDHLOKC8e66kLWUhHjnJ1d143/FyWRNfypQ Qmsix8svikpF9u9uRG9+JhBjl86QPrjkyeN/X8bl2+JaOgb7jZFI3G6bANF/i1wqNiMl 65BOkkHWQm6v89kei6CaMQ5vXW9drcOXs0OiPwIMxcPlCMmGukKurHZDo2uo6sr1bNDH 361IhZxGMrHc1N5EhMwswl1xL8nIJnblkGZCjzO+fqtqITsx7hsnmptwwn5TWvzLaDwC weoW74agbfamiLdcZly5fDnAcvFkhrCorS64j3M7d0jjIpGRCtX55vGc5IL6MzuzgjRJ RvWA== 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=uKXNDzZ5ATmh/Zc8k/YJeitCyjYjADagDIDDsar46bs=; b=GAvw30BJQuhy47IHDqx1oTjxYCZiRIrZ/SNbKqisDxKJ9ysdCuIXVaf+6lt0+nWk6p xNkWZpwULOTvscGyE2GUX7OSKYACb2SMFt/Yr7jrYPVuBlclIKuqWE89duXlkNG/i4MD 6D+i1ISVEE7dtuCoBFtAqQVKK1KueDY+qYkjiL29+g+KwXFpcvz4rZDYXMEZkcejko29 zSFyVLQ2uwZS2xrpYPs9/mLOZXY1gWBPd7mDY+1wAInESa60/bT9ax8TuKcs+9cIrD3q AAWrtZsGY57q4eXWnSGQ2pwkkif+U/4hUAU4D4NZ2K+RomzF2cKczwTUO7ztT4Jyv5eI JAnQ== 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 c2si5121719pgw.534.2019.10.07.04.26.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:13 -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 EA68D6E55C; Mon, 7 Oct 2019 11:26:10 +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 455A06E560 for ; Mon, 7 Oct 2019 11:26:06 +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 x97BQ4pT078200; Mon, 7 Oct 2019 06:26:04 -0500 Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x97BQ4YW122236 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Oct 2019 06:26:04 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) 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; Mon, 7 Oct 2019 06:26:04 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) 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 via Frontend Transport; Mon, 7 Oct 2019 06:26:04 -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 x97BQ3R4024262; Mon, 7 Oct 2019 06:26:04 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 3/8] drm/omap: accept NULL for dma_addr in omap_gem_pin Date: Mon, 7 Oct 2019 13:25:50 +0200 Message-ID: <20191007112555.25278-4-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447564; bh=swFCLcggc3PLeThFKmM/gz3kCxyaq2iegVqXvgg6+yE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Ze4KsWBfRiDa4UzJgAaoPSYBZpdzJ5ywP2091bCcdEV7lG0WaHUMJ3xI2GsNzQdPS xwMMG7m3ziQ77puZLiNHTPsfpcr6Yu7lc2aKKmi66AIawm/sYIIIRxuIuj7AGjaC6r cBLkH0Xd+7Gi25bVsXe9zZyb9dtdP9/6Mo0Kx3Xk= 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Allow NULL to be passed in 'dma_addr' for omap_gem_pin(), in case the caller does not need the dma_addr. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 9201c21e206f..a6562d23d314 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -819,9 +819,11 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) refcount_inc(&omap_obj->dma_addr_cnt); } - *dma_addr = omap_obj->dma_addr; + if (dma_addr) + *dma_addr = omap_obj->dma_addr; } else if (omap_gem_is_contiguous(omap_obj)) { - *dma_addr = omap_obj->dma_addr; + if (dma_addr) + *dma_addr = omap_obj->dma_addr; } else { ret = -EINVAL; goto fail; From patchwork Mon Oct 7 11:25:51 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: 175323 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143435ill; Mon, 7 Oct 2019 04:26:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJJ6GjH4GNaDv0LjOQeOi1VqHKs1WdIKWEvLcsxUEpme7JdamubIJHmPaRpHCBc08z0pIW X-Received: by 2002:a62:cd41:: with SMTP id o62mr384733pfg.94.1570447576096; Mon, 07 Oct 2019 04:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447576; cv=none; d=google.com; s=arc-20160816; b=jCL8ZbbGj3ZnKJytMklP5c0TWiA5cQe08Ckfi0HVSPz8JioK5zoo6l3OXSCpz8GQ0C 5ccWvXLBRFyq9tlxpkiN0RucWhK5JjBWk2XDwUlipatEC9MQeqjb2z76/lWmTQaxkzoH XbFgKcS26SoisVSF/esC/D5xfTJlP2+R0Qb2cB04/Fp1QvZCUCBSoL1xCfxXqESN25cz CNeJXGaLeO4+yi+PznuO52WfYwHQ25OQhiQBE3Py9TvifzIsZvHWm9G1RZLgfW0bdb0Z DD4OX8++/Ttn+Gq0uCGVy2Vvx7jS0i2HNUDgK97RWmxO9SjkxmgqXpZfKX+oN/xlEmx5 73vw== 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=c5rVSD6rh+S9BSvY0/Ss1abeO09L/sx3C11WEAMS/oDfuWnUlEXoC4hbyTcoausqlF hZZKuCaMIMHNgRp7dr77glxGu9qPA6xY8FrLq1+xz7I1uOeu3f1rgFEm6DbiajekxOhq zgCnKb0Fkq4RiZUVi+ONiK/ctIvX6kzOh2kpLTZ0n2KxFYuLS3nGOCRJi+pBhaUmRFtb kiVFO4EomSFLWI+RS6r/yK84fOwK0pW2DS1wYqBDujhk1rVsNcnrE/o1dev+ajT4IqOh QrC+MozA8LTXAL0387+f1zbeaL9QuDVgSlw7+8Ia0tgRXJ3s6caIzXjXZX/tNmcTA2vs 8z9w== 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 c9si13700121plr.319.2019.10.07.04.26.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31FD16E566; Mon, 7 Oct 2019 11:26:11 +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 9FDC86E55C for ; Mon, 7 Oct 2019 11:26:07 +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 x97BQ52u122307; Mon, 7 Oct 2019 06:26:05 -0500 Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x97BQ5Uc038045; Mon, 7 Oct 2019 06:26:05 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 7 Oct 2019 06:26:03 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE101.ent.ti.com (157.170.170.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; Mon, 7 Oct 2019 06:26:03 -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 x97BQ4dZ024278; Mon, 7 Oct 2019 06:26:05 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 4/8] drm/omap: cleanup OMAP_BO flags Date: Mon, 7 Oct 2019 13:25:51 +0200 Message-ID: <20191007112555.25278-5-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447565; bh=9EhmjkByqc9yQn1jXmBokEn/jgfmINUvb+h85iVasbk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kTIpXq753ykex2fjw13qmla/WUJSFp0Rb8eQeOfUrJgYoS3JoySfsoXKcgO3ySB/F BuOiGR3aB9Q+vcqom47Bw4uBFUGIh4qYv0/SKRBkxaKCV/twrXhRdv9DLoM6W6qAaG Ux5BjyB12Ho2FsRhbK8kmOdkxzy5LSPsKPHjcHGk= 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Reorder OMAP_BO flags and improve the comments. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- include/uapi/drm/omap_drm.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h index 1fccffef9e27..d8ee2f840697 100644 --- a/include/uapi/drm/omap_drm.h +++ b/include/uapi/drm/omap_drm.h @@ -38,19 +38,20 @@ struct drm_omap_param { __u64 value; /* in (set_param), out (get_param) */ }; -#define OMAP_BO_SCANOUT 0x00000001 /* scanout capable (phys contiguous) */ -#define OMAP_BO_CACHE_MASK 0x00000006 /* cache type mask, see cache modes */ -#define OMAP_BO_TILED_MASK 0x00000f00 /* tiled mapping mask, see tiled modes */ +/* Scanout buffer, consumable by DSS */ +#define OMAP_BO_SCANOUT 0x00000001 -/* cache modes */ -#define OMAP_BO_CACHED 0x00000000 /* default */ -#define OMAP_BO_WC 0x00000002 /* write-combine */ -#define OMAP_BO_UNCACHED 0x00000004 /* strongly-ordered (uncached) */ +/* Buffer CPU caching mode: cached, write-combining or uncached. */ +#define OMAP_BO_CACHED 0x00000000 +#define OMAP_BO_WC 0x00000002 +#define OMAP_BO_UNCACHED 0x00000004 +#define OMAP_BO_CACHE_MASK 0x00000006 -/* tiled modes */ +/* Use TILER for the buffer. The TILER container unit can be 8, 16 or 32 bits. */ #define OMAP_BO_TILED_8 0x00000100 #define OMAP_BO_TILED_16 0x00000200 #define OMAP_BO_TILED_32 0x00000300 +#define OMAP_BO_TILED_MASK 0x00000f00 #define OMAP_BO_TILED (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | OMAP_BO_TILED_32) union omap_gem_size { From patchwork Mon Oct 7 11:25:52 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: 175326 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143534ill; Mon, 7 Oct 2019 04:26:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQ9vX2RVdLQeinL2376c0kMDNVUxerv49vVuRi4jjWUknE2iMtc5/8jxMtA3LGoAi/Ikpv X-Received: by 2002:a63:1765:: with SMTP id 37mr29973199pgx.121.1570447581240; Mon, 07 Oct 2019 04:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447581; cv=none; d=google.com; s=arc-20160816; b=b70l8pAehrqp9uqukbudk6UFsxapYNwGH0+Ka7mnOyx14qKKR1FWKKl2CZncJuchW2 imH7GW4yqpXHHUparyu1CQ5lIPE6YZ7Octiqu/eIfmoJEQLCBSH0faVIYiAHk/Mg0ues K0e49ZXdzadbt41onQ5DtEHQDFoJ2kwDW7XBQ6gbIVcZGP8TwxgVpBeIu0hNKptsR1lW YVbD3FdcUz+a0bxL1gygcyX29PkJ3DUBJCUZGNE/nq92vpSim8RlZWqWTWxZQSynopr3 PPgFyOwDyGVvCa0aV08ZmqvtdBEygKigOBkyrcJq4Cgf51oGNt3OZh8sUGnLYpuJGYsH W3KA== 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=JaQbvSR1JTjT59vdZpff47Hug/otBccDmBWrV+vvZjo=; b=vfpojWUbdZhKu2sWN2frHjXUHY7qGj94X2/Kw6LJzzmnhE3b9jI64Ez/cv7mUD7Mgm Nebdqyla2OtmX2Ef0zL4GWVd0P29869UIgtEK859mIQKs4tJdZzVL5Cl8S96VTKTMY/p Dpp9sd5dvCcNNNvQC/EedTZg7U5w2dYwzVGp4N+ccnpXcIKQq/MC01yLqRiQJUW18LLx L+DDk2mzEs0fJv0h48BlcLrEKIqMkb4ibtIps2wDqMT3c5TnGSciswPKzRmK8zc+PnQ3 alSZ3mMvJ1pw4DgAbSSmqOb/UGu5/5xnKimhr6BXuHWbwF7JiB9p6QrcNE6xT9gjNQaW GxrA== 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 q193si15903065pfq.206.2019.10.07.04.26.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:21 -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 36F076E563; Mon, 7 Oct 2019 11:26:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by gabe.freedesktop.org (Postfix) with ESMTPS id 876CB6E563 for ; Mon, 7 Oct 2019 11:26:08 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x97BQ7w4010008; Mon, 7 Oct 2019 06:26:07 -0500 Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x97BQ7L5124978 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Oct 2019 06:26:07 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) 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, 7 Oct 2019 06:26:04 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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 via Frontend Transport; Mon, 7 Oct 2019 06:26:04 -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 x97BQ6Wi059093; Mon, 7 Oct 2019 06:26:06 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 5/8] drm/omap: remove OMAP_BO_TILED define Date: Mon, 7 Oct 2019 13:25:52 +0200 Message-ID: <20191007112555.25278-6-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447567; bh=xM1LBkpk/70ROrtmJYSvW1SNexpny57j0lKelPiR3mM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bHXMTrHzcoXWa9oR+f4M9E1/vCSiyF0WY+gQniikAzOarGyi2uNONRdJmlAV52Cp5 UQmMRI5ox47Gl1pptj1ns+bTdaHAvqIUmeVionpuSYiLDKRXmXGcrd/6ZXSeBijzWl ONCtWaV62TW4YyJBSbGeOngJZ5j1KfzyAY3PtZHs= 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen OMAP_BO_TILED does not make sense, as OMAP_BO_TILED_* values are not bitmasks but normal values. As we already have OMAP_BO_TILED_MASK for the mask, we can remove OMAP_BO_TILED and use OMAP_BO_TILED_MASK instead. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_dmm_tiler.h | 2 +- drivers/gpu/drm/omapdrm/omap_fb.c | 6 +++--- drivers/gpu/drm/omapdrm/omap_gem.c | 18 +++++++++--------- drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 +- include/uapi/drm/omap_drm.h | 1 - 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h index 835e6654fa82..43c1d096b021 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h @@ -113,7 +113,7 @@ extern struct platform_driver omap_dmm_driver; /* GEM bo flags -> tiler fmt */ static inline enum tiler_fmt gem2fmt(u32 flags) { - switch (flags & OMAP_BO_TILED) { + switch (flags & OMAP_BO_TILED_MASK) { case OMAP_BO_TILED_8: return TILFMT_8BIT; case OMAP_BO_TILED_16: diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 1b8b5108caf8..7403316088b8 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -95,7 +95,7 @@ static u32 get_linear_addr(struct drm_framebuffer *fb, bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb) { - return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED; + return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED_MASK; } /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */ @@ -154,7 +154,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, x = state->src_x >> 16; y = state->src_y >> 16; - if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED) { + if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED_MASK) { u32 w = state->src_w >> 16; u32 h = state->src_h >> 16; @@ -212,7 +212,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, plane = &omap_fb->planes[1]; if (info->rotation_type == OMAP_DSS_ROT_TILER) { - WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED)); + WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED_MASK)); omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2, &info->p_uv_addr); } else { diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index a6562d23d314..4e8fcfdff3a0 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -196,7 +196,7 @@ static void omap_gem_evict(struct drm_gem_object *obj) struct omap_gem_object *omap_obj = to_omap_bo(obj); struct omap_drm_private *priv = obj->dev->dev_private; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { enum tiler_fmt fmt = gem2fmt(omap_obj->flags); int i; @@ -324,7 +324,7 @@ size_t omap_gem_mmap_size(struct drm_gem_object *obj) struct omap_gem_object *omap_obj = to_omap_bo(obj); size_t size = obj->size; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { /* for tiled buffers, the virtual size has stride rounded up * to 4kb.. (to hide the fact that row n+1 might start 16kb or * 32kb later!). But we don't back the entire buffer with @@ -513,7 +513,7 @@ vm_fault_t omap_gem_fault(struct vm_fault *vmf) * probably trigger put_pages()? */ - if (omap_obj->flags & OMAP_BO_TILED) + if (omap_obj->flags & OMAP_BO_TILED_MASK) ret = omap_gem_fault_2d(obj, vma, vmf); else ret = omap_gem_fault_1d(obj, vma, vmf); @@ -786,7 +786,7 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) if (ret) goto fail; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { block = tiler_reserve_2d(fmt, omap_obj->width, omap_obj->height, 0); @@ -892,7 +892,7 @@ int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient, mutex_lock(&omap_obj->lock); if ((refcount_read(&omap_obj->dma_addr_cnt) > 0) && omap_obj->block && - (omap_obj->flags & OMAP_BO_TILED)) { + (omap_obj->flags & OMAP_BO_TILED_MASK)) { *dma_addr = tiler_tsptr(omap_obj->block, orient, x, y); ret = 0; } @@ -907,7 +907,7 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret = -EINVAL; - if (omap_obj->flags & OMAP_BO_TILED) + if (omap_obj->flags & OMAP_BO_TILED_MASK) ret = tiler_stride(gem2fmt(omap_obj->flags), orient); return ret; } @@ -1046,7 +1046,7 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m) refcount_read(&omap_obj->dma_addr_cnt), omap_obj->vaddr, omap_obj->roll); - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { seq_printf(m, " %dx%d", omap_obj->width, omap_obj->height); if (omap_obj->block) { struct tcm_area *area = &omap_obj->block->area; @@ -1145,7 +1145,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, int ret; /* Validate the flags and compute the memory and cache flags. */ - if (flags & OMAP_BO_TILED) { + if (flags & OMAP_BO_TILED_MASK) { if (!priv->usergart) { dev_err(dev->dev, "Tiled buffers require DMM\n"); return NULL; @@ -1187,7 +1187,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, omap_obj->flags = flags; mutex_init(&omap_obj->lock); - if (flags & OMAP_BO_TILED) { + if (flags & OMAP_BO_TILED_MASK) { /* * For tiled buffers align dimensions to slot boundaries and * calculate size based on aligned dimensions. diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index e8c3ae7ac77e..7344bb61936c 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -67,7 +67,7 @@ static int omap_gem_dmabuf_begin_cpu_access(struct dma_buf *buffer, { struct drm_gem_object *obj = buffer->priv; struct page **pages; - if (omap_gem_flags(obj) & OMAP_BO_TILED) { + if (omap_gem_flags(obj) & OMAP_BO_TILED_MASK) { /* TODO we would need to pin at least part of the buffer to * get de-tiled view. For now just reject it. */ diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h index d8ee2f840697..5a142fad473c 100644 --- a/include/uapi/drm/omap_drm.h +++ b/include/uapi/drm/omap_drm.h @@ -52,7 +52,6 @@ struct drm_omap_param { #define OMAP_BO_TILED_16 0x00000200 #define OMAP_BO_TILED_32 0x00000300 #define OMAP_BO_TILED_MASK 0x00000f00 -#define OMAP_BO_TILED (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | OMAP_BO_TILED_32) union omap_gem_size { __u32 bytes; /* (for non-tiled formats) */ From patchwork Mon Oct 7 11:25:53 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: 175325 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143496ill; Mon, 7 Oct 2019 04:26:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxi5QCgTAckn1ZXBpgKUEPjl2NP9aKc8w01EnDkS8nHAmNXhc0sy48wjAhXDFz6QnsdpWla X-Received: by 2002:a62:5a85:: with SMTP id o127mr33339138pfb.212.1570447579394; Mon, 07 Oct 2019 04:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447579; cv=none; d=google.com; s=arc-20160816; b=cfFeRIlX4ggmJfXx8IbiPIZel2V76ryCpVxObGOHRihNfXmXbXBIqcSLDdIu5k7jwy 6GmqQm/I1j4LAaVBfvZ2HsOj7YE0QmSg3s79mkCiBicLJVgiluteRMlxkbfK0DqxfXZl mfqOiv/KY6XQFapdvb9XuG+3lD/3juOO531QNs6CARdGhpFYKGKTqSXFIaoY9fL71H1o vlgIxnEHP7EN8DdVh2XO6+9Q6RXMMxQuAz16g1bxc5+ok31itKAUQkNQEmQPTJ7rAJMa eg5V8nLx/t2op9D+h5k7fFU1XybuuRdKZ9io2mIPr1s+o3McTVFY5HXaBmpmaKFrGJqo H1kQ== 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=NucwM2FILWLZwbb9OaIqxUZPc4VAv22BPMwZxCCKKS8=; b=YBMtQWVJQilzlaTvh4kJqUbyAa/bWqnbWA9TPCFQL2lc51gy8R2m68oT8d9Vhqu9lS +YYaBWPh0zDnt39FSDSZPAsPOwP3hzO5WUw74G3e8KSnHB5XwuqB7POW/BZ5lcdDu11a THL8Mu6EMHZDyNem0EmykqDJXqWPgDsi2ZSzVgKu0+mFiqHyrajW4PpV3e9yY1Ess1DA DroYS81pLw1naeYnjXDRLlc1y+OKGXMcVBsONPEFJn6TETWoNwxCua+g/hgVW709Z+ED Lqp95Ug/fiSFy2/+uA3AA5DPCeRJPU2ZPg0/n8+lHQ+uLRla2C+HqUBYKUdagowqyC60 PWBg== 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 l17si8327900pgt.540.2019.10.07.04.26.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:19 -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 AB8B16E570; Mon, 7 Oct 2019 11:26:13 +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 162A26E55C for ; Mon, 7 Oct 2019 11:26:10 +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 x97BQ8GM012430; Mon, 7 Oct 2019 06:26:08 -0500 Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x97BQ83u124991 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Oct 2019 06:26:08 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) 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; Mon, 7 Oct 2019 06:26:05 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE113.ent.ti.com (157.170.170.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, 7 Oct 2019 06:26:05 -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 x97BQ7x8112537; Mon, 7 Oct 2019 06:26:07 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 6/8] drm/omap: cleanup OMAP_BO_SCANOUT use Date: Mon, 7 Oct 2019 13:25:53 +0200 Message-ID: <20191007112555.25278-7-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447568; bh=CbuNmEnB2erZcSKsNRA3W8NuhRVjnNwkokITxNfB2pE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=uc0+Wdm5t5Pg/vz4t9p6ULRCA5pRQ/TSj0nQePXnS6uiaZL6OKTs+Fl0cVK3q50o8 Cyjy188eePKKT+cboHEukDwVpaU7LCR7Rb3fW9AlNYiKo1PKRS73JvvFdeTSeoC/hx Um68OnyeTVMZlPFwBlPZaCom6ouKQdyRzbCBzePI= 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen omap_gem_new() has a comment about OMAP_BO_SCANOUT which does not make sense. Also, for the TILER case, we drop OMAP_BO_SCANOUT flag for some reason. It's not clear what the original purpose of OMAP_BO_SCANOUT is, but presuming it means "scanout buffer, something that can be consumed by DSS", this patch cleans up the above issues. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 4e8fcfdff3a0..27e0a2f8508a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1155,7 +1155,6 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, * Tiled buffers are always shmem paged backed. When they are * scanned out, they are remapped into DMM/TILER. */ - flags &= ~OMAP_BO_SCANOUT; flags |= OMAP_BO_MEM_SHMEM; /* @@ -1166,9 +1165,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, flags |= tiler_get_cpu_cache_flags(); } else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) { /* - * OMAP_BO_SCANOUT hints that the buffer doesn't need to be - * tiled. However, to lower the pressure on memory allocation, - * use contiguous memory only if no TILER is available. + * If we don't have DMM, we must allocate scanout buffers + * from contiguous DMA memory. */ flags |= OMAP_BO_MEM_DMA_API; } else if (!(flags & OMAP_BO_MEM_DMABUF)) { From patchwork Mon Oct 7 11:25:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175324 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143466ill; Mon, 7 Oct 2019 04:26:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3ZOF/3EB6uosB7yS78bOFxN2ma6Rccn8GyOYn/0sG0YXS7l2e31TA/7GNQHVYmEqZdybA X-Received: by 2002:a17:90b:f11:: with SMTP id br17mr32823835pjb.80.1570447577741; Mon, 07 Oct 2019 04:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447577; cv=none; d=google.com; s=arc-20160816; b=ZdvnvPp9fk7ougNKhOX5Z5nk3LERGvk+WguLiVwN4AaFhf86mEjog01jerdRU0CxJ7 zi7GeJPplrMLYEr0SbkDIoeIkZ6zTYdSm8Hc49R9P8wm9ehEZk0vk8lNlNDNB9btaL0L ZgUd31//mkypRK0fHPFDO41coDIPaZK0MG5YPOdQcqY9sif9L4Pqcwf+G4Y/+DpBijT7 016I2s3kraqftQV4hFr85Tpv/4P/BucU8rsYT+58+ddgE0izVGyEdwKmucj5ZV43QsJV px0IGHpeGHwSSJKI2g6VJZrztPhkh1yVUTj/4yEXuH82KWm+0f7V+u6BwN0V2SDdReF5 IA0w== 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=MbhFYFtXKYppCW9i69n//JrDd1pH4tT7gxLGMgw3RSc=; b=axfZuJweu7yeCipFdBPhaXy1b4O7Hy8wgsqmKZqyJwDoszYuYgwT4vuHo5PwqefS9L k2eW5f0oYx1Uj2N/65lCoLZ/uDF+sMlgHsr0D9ZbIVWNpJdhqyj5YlYf82ScEvq6mnS8 xUBzhjppwbP9mlXhDVxCrxAzijeHyIS+yzbh9/BXZe5s4Xnae2UCQDXr/iipo5qfRLIy g9oITmfqi/jyLslOQA6vFQvDhBULZu57pt3/4LvE1C55PRNcFES+Lq5WRik0BL33iw5E 7zVoZS2ucMEm945FTvqkdDOxjd+Hu6o4a15SNHbVqf50c/0iUy9/SPd5PVEXAWjLSg3E a9eQ== 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 r10si15629970pfl.141.2019.10.07.04.26.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D36F6E56D; Mon, 7 Oct 2019 11:26:13 +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 14F0C6E563 for ; Mon, 7 Oct 2019 11:26:11 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x97BQ96o122326; Mon, 7 Oct 2019 06:26:09 -0500 Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x97BQ9pW122338 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Oct 2019 06:26:09 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 7 Oct 2019 06:26:09 -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; Mon, 7 Oct 2019 06:26:07 -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 x97BQ893059149; Mon, 7 Oct 2019 06:26:08 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 7/8] drm/omap: add omap_gem_validate_flags() Date: Mon, 7 Oct 2019 13:25:54 +0200 Message-ID: <20191007112555.25278-8-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447569; bh=pycRfH8VPF2OS9FSA4yi7t+1mn2Akj4iv8sbt8eEBUQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=crieUR4VTMHOBzx7HS/kyReSWohncGqXpJX3+C7qEvqEM2+PxvYwH8ffXaGYwp5HT NJ5Iykb9zdY+8c1wHhB9yVEERqCJIdMTq4K7bsN/aCwIaRtpOaAQ+w6/QADlN3w/+4 JMtvYtRAIDcM9a0qwnQRWoL9ZYFsNQfhbvaaAUI0= 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Add a helper function omap_gem_validate_flags() which validates the omap_bo flags passed from the userspace. Also drop the dev_err() message, as the userspace can cause that at will. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 40 ++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 27e0a2f8508a..e518d93ca6df 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1133,6 +1133,38 @@ void omap_gem_free_object(struct drm_gem_object *obj) kfree(omap_obj); } +static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) +{ + struct omap_drm_private *priv = dev->dev_private; + + switch (flags & OMAP_BO_CACHE_MASK) { + case OMAP_BO_CACHED: + case OMAP_BO_WC: + case OMAP_BO_CACHE_MASK: + break; + + default: + return false; + } + + if (flags & OMAP_BO_TILED_MASK) { + if (!priv->usergart) + return false; + + switch (flags & OMAP_BO_TILED_MASK) { + case OMAP_BO_TILED_8: + case OMAP_BO_TILED_16: + case OMAP_BO_TILED_32: + break; + + default: + return false; + } + } + + return true; +} + /* GEM buffer object constructor */ struct drm_gem_object *omap_gem_new(struct drm_device *dev, union omap_gem_size gsize, u32 flags) @@ -1144,13 +1176,11 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, size_t size; int ret; + if (!omap_gem_validate_flags(dev, flags)) + return NULL; + /* Validate the flags and compute the memory and cache flags. */ if (flags & OMAP_BO_TILED_MASK) { - if (!priv->usergart) { - dev_err(dev->dev, "Tiled buffers require DMM\n"); - return NULL; - } - /* * Tiled buffers are always shmem paged backed. When they are * scanned out, they are remapped into DMM/TILER. From patchwork Mon Oct 7 11:25:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175327 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143567ill; Mon, 7 Oct 2019 04:26:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqygJxMUx3wb3STxDxlk08/dQxSwHOElVIgv+r2MxAihhSU7pIG63zFbTLH2CKJpCed7B3m0 X-Received: by 2002:a17:90a:ff18:: with SMTP id ce24mr32559008pjb.123.1570447582409; Mon, 07 Oct 2019 04:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447582; cv=none; d=google.com; s=arc-20160816; b=kIYTJOkKtXnym/EJBQICdrJpy+Dpt2GcqsKntcK05trY6cDDI9pk5b8LfVQoMBVNJy 5CRLzSQaftnc1rVEvELpIUcqP3zpqURpycIcrJpyo44Vp8IisIpjFKsWSpKX5PK5fKFn U71mKhPPWoLk59/Ka/UC8PNZKpjP2v5TQGgzC97btUtYos8KoWvIeXc6ww8Blr5Krq1X 0iWbQk0Iv7mXzDu1w2ZmQwNw6DI0WjIxi9S1SLQDPs/oqXdbBwqM5f26FnnhduytyJya dMXQIVGlDQE+OYo3lCUlkTbzY5/Drbhq6zbt3tt8T6ZPVfuo4Xi7J31vOpvkiUdL5CRD GsLg== 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=VJMLpT78JBJuMIyyaFO87oqosLgK+yvNK53R6Y2Iuzs=; b=Ml3jLMOJ8Tb3pFSPmWC32dhTpC1eBf43wzpHoPdPQu0K1dUtcW3usR/F9uL+eIBWCv GMnESNkty2gpN32s8h5H4kCUor7EB+u2K1y0CBYcUFk82arGNBKpoBMDlGKhbpap3PRx 9ebfs5xyuYJS2AZ6lwOFAd8IW/Obsdfq2vdgL3c7a5ltb+5ZPgLI3h9gRc3aJobXkncM mqlqBxdj9uxm1RA29qkT58Ok8V9FV74VAlJrdO+8kp5y1okz/2fyCT9A3jvrfLDoDDED fTD9VtS5DCVEwcRwfbgxshJe4MRKoCslRwekroaOusloFV5fXZcdRPgwSsye1OHmRi4A r0Qg== 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 192si15752361pfb.86.2019.10.07.04.26.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:22 -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 400D56E573; Mon, 7 Oct 2019 11:26:18 +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 8FCE66E563 for ; Mon, 7 Oct 2019 11:26:12 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x97BQALx010035; Mon, 7 Oct 2019 06:26:10 -0500 Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x97BQAX7122383 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Oct 2019 06:26:10 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) 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, 7 Oct 2019 06:26:08 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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, 7 Oct 2019 06:26:08 -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 x97BQ9l5004235; Mon, 7 Oct 2019 06:26:10 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 8/8] drm/omap: add OMAP_BO flags to affect buffer allocation Date: Mon, 7 Oct 2019 13:25:55 +0200 Message-ID: <20191007112555.25278-9-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447570; bh=/mxRqevYL274kcscmq+ERlrnJL+IWNmOay5DKh+rNsM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=d2r0rFw7dYSOvoQocSdz4SEkoKS8dWA9rgPSnNIjTCMXeaxGTLUUyLAvOpxLJCe9u V3H6zklHEnpHmgIXoXjd1tr1FNx7mxwHbFeIIbkZm/C1MCemqCa5aTT7xTlqa+4CHk 9qlFOSwsoiAhsb/RLD8uQga31jyfI6JI+V3+++SA= 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, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen On SoCs with DMM/TILER, we have two ways to allocate buffers: normal dma_alloc or via DMM (which basically functions as an IOMMU). DMM can map 128MB at a time, and we only map the DMM buffers when they are used (i.e. not at alloc time). If DMM is present, omapdrm always uses DMM. There are use cases that require lots of big buffers that are being used at the same time by different IPs. At the moment the userspace has a hard maximum of 128MB. This patch adds three new flags that can be used by the userspace to solve the situation: OMAP_BO_MEM_CONTIG: The driver will use dma_alloc to get the memory. This can be used to avoid DMM if the userspace knows it needs more than 128M of memory at the same time. OMAP_BO_MEM_DMM: The driver will use DMM to get the memory. There's not much use for this flag at the moment, as on platforms with DMM it is used by default, but it's here for completeness. OMAP_BO_MEM_PIN: The driver will pin the memory at alloc time, and keep it pinned. This can be used to 1) get an error at alloc time if DMM space is full, and 2) get rid of the constant pin/unpin operations which may have some effect on performance. If none of the flags are given, the behavior is the same as currently. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 54 ++++++++++++++++++++++++++++-- include/uapi/drm/omap_drm.h | 9 +++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index e518d93ca6df..bf18dfe2b689 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1097,6 +1097,9 @@ void omap_gem_free_object(struct drm_gem_object *obj) list_del(&omap_obj->mm_list); mutex_unlock(&priv->list_lock); + if (omap_obj->flags & OMAP_BO_MEM_PIN) + omap_gem_unpin_locked(obj); + /* * We own the sole reference to the object at this point, but to keep * lockdep happy, we must still take the omap_obj_lock to call @@ -1147,10 +1150,19 @@ static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) return false; } + if ((flags & OMAP_BO_MEM_CONTIG) && (flags & OMAP_BO_MEM_DMM)) + return false; + + if ((flags & OMAP_BO_MEM_DMM) && !priv->usergart) + return false; + if (flags & OMAP_BO_TILED_MASK) { if (!priv->usergart) return false; + if (flags & OMAP_BO_MEM_CONTIG) + return false; + switch (flags & OMAP_BO_TILED_MASK) { case OMAP_BO_TILED_8: case OMAP_BO_TILED_16: @@ -1165,7 +1177,34 @@ static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) return true; } -/* GEM buffer object constructor */ +/** + * omap_gem_new() - Create a new GEM buffer + * @dev: The DRM device + * @gsize: The requested size for the GEM buffer. If the buffer is tiled + * (2D buffer), the size is a pair of values: height and width + * expressed in pixels. If the buffers is not tiled, it is expressed + * in bytes. + * @flags: Flags give additionnal information about the allocation: + * OMAP_BO_TILED_x: use the TILER (2D buffers). The TILER container + * unit can be 8, 16 or 32 bits. Cache is always disabled for + * tiled buffers. + * OMAP_BO_SCANOUT: Scannout buffer, consummable by the DSS + * OMAP_BO_CACHED: Buffer CPU caching mode: cached + * OMAP_BO_WC: Buffer CPU caching mode: write-combined + * OMAP_BO_UNCACHED: Buffer CPU caching mode: uncached + * OMAP_BO_MEM_CONTIG: The driver will use dma_alloc to get the memory. + * This can be used to avoid DMM if the userspace knows it needs + * more than 128M of memory at the same time. + * OMAP_BO_MEM_DMM: The driver will use DMM to get the memory. There's + * not much use for this flag at the moment, as on platforms with + * DMM it is used by default, but it's here for completeness. + * OMAP_BO_MEM_PIN: The driver will pin the memory at alloc time, and + * keep it pinned. This can be used to 1) get an error at alloc + * time if DMM space is full, and 2) get rid of the constant + * pin/unpin operations which may have some effect on performance. + * + * Return: The GEM buffer or NULL if the allocation failed + */ struct drm_gem_object *omap_gem_new(struct drm_device *dev, union omap_gem_size gsize, u32 flags) { @@ -1193,7 +1232,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, */ flags &= ~(OMAP_BO_CACHED|OMAP_BO_WC|OMAP_BO_UNCACHED); flags |= tiler_get_cpu_cache_flags(); - } else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) { + } else if ((flags & OMAP_BO_MEM_CONTIG) || + ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm)) { /* * If we don't have DMM, we must allocate scanout buffers * from contiguous DMA memory. @@ -1253,12 +1293,22 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, goto err_release; } + if (flags & OMAP_BO_MEM_PIN) { + ret = omap_gem_pin(obj, NULL); + if (ret) + goto err_free_dma; + } + mutex_lock(&priv->list_lock); list_add(&omap_obj->mm_list, &priv->obj_list); mutex_unlock(&priv->list_lock); return obj; +err_free_dma: + if (flags & OMAP_BO_MEM_DMA_API) + dma_free_wc(dev->dev, size, omap_obj->vaddr, + omap_obj->dma_addr); err_release: drm_gem_object_release(obj); err_free: diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h index 5a142fad473c..842d3180a442 100644 --- a/include/uapi/drm/omap_drm.h +++ b/include/uapi/drm/omap_drm.h @@ -47,6 +47,15 @@ struct drm_omap_param { #define OMAP_BO_UNCACHED 0x00000004 #define OMAP_BO_CACHE_MASK 0x00000006 +/* Force allocation from contiguous DMA memory */ +#define OMAP_BO_MEM_CONTIG 0x00000008 + +/* Force allocation via DMM */ +#define OMAP_BO_MEM_DMM 0x00000010 + +/* Pin the buffer when allocating and keep pinned */ +#define OMAP_BO_MEM_PIN 0x00000020 + /* Use TILER for the buffer. The TILER container unit can be 8, 16 or 32 bits. */ #define OMAP_BO_TILED_8 0x00000100 #define OMAP_BO_TILED_16 0x00000200