From patchwork Thu Oct 10 09:34:39 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: 175735 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030165ill; Thu, 10 Oct 2019 02:35:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGkD/wryXtIvhNQqdGiVPTBSdhxd8dSLteMT5+5Q2CFJXs4BCQgFiTcYwPEB4yS5IHQRPX X-Received: by 2002:a62:4ed6:: with SMTP id c205mr9327482pfb.208.1570700116360; Thu, 10 Oct 2019 02:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700116; cv=none; d=google.com; s=arc-20160816; b=fxFbITCpiSWNvLWzfTxZWkfHoAkxRaMB7AkiGlgWnxp41b7a/VIBRxg15Z0uRpyjN5 ApFXYzt7hmdCp84EB5uZFlBS9mdRoCWmxbEnS8v/GET3xj/jBI6lweEacnaM29dzDSgX QiAhC4G5lo5IfN2OmsFzp9KgTVU5/V60MeFjhZFK53rEJJ4HJTdhWQOKPBsZBsSgK2QY OXcXomgbOUCBqCxBuVcw54TZe7h0p+RUn4NULJiPcpXigFPwtgymo2KBikYrmUZjd3NG ATi1KzEKjCSKu7RITboYTxXQWmSpXasoU1wtNUEye4T/OBRW7ay87/sM0xnzkFSWXX8n q1Og== 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=Je2BB/VZ9st3/vJiXWxjKzeeB0psD1SDjIWmlklf370=; b=03d7vFUuHPOPdx8QoXHYDGHYoXrGpKIkdZPms6hfcfguMIeWoilRX/IZaIBBF8aXmW OzTyCER3cmEm0fZDw3+df/QU6lut+DuHSfQhfa1ayUCei3Xon605w38+VO+58OsBo0Dn 5rr/mJ5ai2n23c63SiNX8tvE1EHE5azkD7UU7gOeGymvphdBmnuasSOUMXEnGQXwRIpU YU37vZEEvq+G1Pt6KZ6KJKCicQR11AmXc6dAgnUJszTUoa32Dx+qJ/mbXy/xtGCecXK/ X5XPlGcKvrT4BxJ0KIAIJcHO0LQnjme1dwX4xf0kgiOlVeF4k+zp9UpPR7ti2wEHqaoq mniA== 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 l17si5741145pgt.540.2019.10.10.02.35.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:16 -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 CB36E6EADC; Thu, 10 Oct 2019 09:35:12 +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 483076EADE for ; Thu, 10 Oct 2019 09:35:11 +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 x9A9Z9h8010274; Thu, 10 Oct 2019 04:35:09 -0500 Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A9Z9Wh087885 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 04:35:09 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) 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; Thu, 10 Oct 2019 04:35:05 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 04:35:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9A9Z8h6129773; Thu, 10 Oct 2019 04:35:08 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 2/8] drm/omap: add omap_gem_unpin_locked() Date: Thu, 10 Oct 2019 11:34:39 +0200 Message-ID: <20191010093445.11069-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700109; bh=0PpOvCL0mMxzWKvBjDpjKpovRlUYaLcsFQUetpU5AoQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LlJQichuxXMORUEKJmT6I5s3T5hwn+tJh9XaxVFcGpow1YVEEgOYN99QT6/PnWk+x vh2kj+lpRfB3gIVz81Bzgf6Sk6ELBqGbx/8mDsh78XWDvdbK6X2kuLa56xTV6wATRH dDbk7RQ9Zt+uSDRvr788aHvY4e4IwyZdti5saSmk= 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 | 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 5c97ff810b5d..3071e815da73 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -832,20 +832,16 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) } /** - * omap_gem_unpin() - Unpin a GEM object from memory + * omap_gem_unpin_locked() - Unpin a GEM object from memory * @obj: the GEM object * - * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are - * reference-counted, the actualy unpin will only be performed when the number - * of calls to this function matches the number of calls to omap_gem_pin(). + * omap_gem_unpin() without locking. */ -void omap_gem_unpin(struct drm_gem_object *obj) +static void omap_gem_unpin_locked(struct drm_gem_object *obj) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret; - mutex_lock(&omap_obj->lock); - if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) { ret = tiler_unpin(omap_obj->block); if (ret) { @@ -860,7 +856,22 @@ void omap_gem_unpin(struct drm_gem_object *obj) omap_obj->dma_addr = 0; omap_obj->block = NULL; } +} +/** + * omap_gem_unpin() - Unpin a GEM object from memory + * @obj: the GEM object + * + * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are + * reference-counted, the actual unpin will only be performed when the number + * of calls to this function matches the number of calls to omap_gem_pin(). + */ +void omap_gem_unpin(struct drm_gem_object *obj) +{ + struct omap_gem_object *omap_obj = to_omap_bo(obj); + + mutex_lock(&omap_obj->lock); + omap_gem_unpin_locked(obj); mutex_unlock(&omap_obj->lock); } From patchwork Thu Oct 10 09:34:40 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: 175737 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030315ill; Thu, 10 Oct 2019 02:35:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyIYzwYSmvNP87aFuvyezXkhoyJn6yAtbv4lCXIpzOVuUjyBhOKBCFACALpLajp1aAeLa+ X-Received: by 2002:a17:90a:2ec3:: with SMTP id h3mr10349332pjs.131.1570700123648; Thu, 10 Oct 2019 02:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700123; cv=none; d=google.com; s=arc-20160816; b=MBVe+aXkn1cQF1iru6PtA1kVEClvRVoygEYrYxWOY+9nQw5/0rG52JKY9PhJNC45tR ULL11HZuG0mErAOvxKsTZPstzl3PJ5RH+hAzO1x2BQJL6TnLym+mC0H9CGIYwfUqfLfw R3K72OPq3ujD9f7i61buNyPTAO0S/YDnDX3OrKLwfmF2/tvUyB1dE0O7ePBDLLBESzwJ HxF2P5g6P6CzCNgsSUXS/ABk4CddBbFlz4+H+L7Hno+4/yX4uSIx2M2TsoluiRXccQjZ thU/iFccG1Ox1SAtJgVVyUobtBXAOLCTkTEXfsyYwojwvNfUTWoQbI0HiW9jfy8gV0Fr LF3g== 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=68hVYg6DBHDONmzSTFThCTwfh15xAy9D10zk3KcAlp8=; b=xF3tdMwJhNjQSgGZBo7c9C6uKzJ2JFYWDOmHPAJdfHRl41hH2OuUYke0Cq4EHpOZEk QZS9HtGLI0cEoEeTUSIk4mEnleoPYAEmRvZpXLJCQyvOj4NJZbYTlIT2mYyIOVL12T6H 0naIesxQ/eThdBLZuaE7NYkX21kLUi1z9lndFcRntA6x0qHHJ8sb5hrrrYN2M2QgBTNO PycBKZ/krdznOrj+BXz1fJNC0jEcdtYEHuLFVkvqK/ER0eoajddfe7YAOWaABHtyoUiG 6oo/dKOeKiz3TkTXRkDwVDtLpuu5iWH03VBrQrnkRt+CLa/qNG4s4hV6mRIP5db7ZgeF eZdw== 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 99si5460481pld.162.2019.10.10.02.35.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:23 -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 A8B306EAE1; Thu, 10 Oct 2019 09:35:17 +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 7FEAD6EADC for ; Thu, 10 Oct 2019 09:35:12 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9A9ZAoq007940; Thu, 10 Oct 2019 04:35:10 -0500 Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A9ZATj118475 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 04:35:10 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 04:35:10 -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; Thu, 10 Oct 2019 04:35:10 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9A9Z91I013241; Thu, 10 Oct 2019 04:35:10 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 3/8] drm/omap: accept NULL for dma_addr in omap_gem_pin Date: Thu, 10 Oct 2019 11:34:40 +0200 Message-ID: <20191010093445.11069-4-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700110; bh=BGD4E2M5dmRS1t3Z+6V//s+uSJyTYNPcVeFAaQ+oob8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=F9EIsb8UfCCqMFDoXbDkhfpxv2DvPHV/YJK94FpfcZNiicUuQILBMkpzYz+fdpf10 ZBwuYwVzubSPfhGetDA0KW63Cf1e3OIi/pWVG9ncgBBW29v2dBC92c3vc9zGoK8rIH gl49dB5FFj7X7DE3KEnCBzkZopm5sxiepd8vy6KM= 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 3071e815da73..2ac83cdbb15a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -817,9 +817,11 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) refcount_inc(&omap_obj->dma_addr_cnt); } - *dma_addr = omap_obj->dma_addr; + if (dma_addr) + *dma_addr = omap_obj->dma_addr; } else if (omap_gem_is_contiguous(omap_obj)) { - *dma_addr = omap_obj->dma_addr; + if (dma_addr) + *dma_addr = omap_obj->dma_addr; } else { ret = -EINVAL; goto fail; From patchwork Thu Oct 10 09:34:41 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: 175736 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030269ill; Thu, 10 Oct 2019 02:35:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZW0dms4juxT0QREL6UsY9YHIyB0bylk3QE8/i/nCXjI7WL6aluTUiuULae7QsXngPedQv X-Received: by 2002:a63:6949:: with SMTP id e70mr9957171pgc.226.1570700121752; Thu, 10 Oct 2019 02:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700121; cv=none; d=google.com; s=arc-20160816; b=ulHU9URuwWa/LgpbWe9ogBRE4oQcwsXf4DP/4jF2DrfS/jcRtao1w1GujMyBPjI4wd kwd+vDP1wTLPJ2vTuY0kpK0zHP/XGnNI3vVkSmM+7RvFaEV1DfH6kLEl9gvnNACg5o2c iN1nRQ7uFschELcrcpoNYjV/1HV9k2DjYLcMgAC/mtmDB93PvXyNxI1Waf7AceevvEwt saX9uWp7A898wfzZfrvl0vC4Uw9+1hnEamCArxjVbqUgidF6IJ8B+eA9H9Q2tbhqEPLI fgWnBiDaD7ort4h05yNE8+oEBXWuaFszuLWme6ez1Xp/Upbh1K2FhbANr2TEiMZxrD0e Za9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=k9TculPzD9A8ZTxzt/93N0TVz8R91HKZE0f1Wl3SIzM=; b=V8TtXF+AH4PxhR2xqAyyk60NZv0oqhqI7DKCPeIRJIfmhCDSqs+01RwM182TbpmQQT i02xlUydoZAO/YZ1K8BtB4NHQzZ8vxlytgGmg8oM+KknSjJ5qfdsTK7+cMa4dOJnt4di Rlmlvz12VjdqPCfPu72hWgVYeLSyHO7elxtAhRoo/o+1TigVYtu54t9meF/8jcL0Uta3 Igk0QLfMGkNYjD2tJ1nNGab8jdE3FhpqLMRmYSsu96373P8oH9b1z7nR0LainjALF6PR nCbmrJTdkm9YQYz7ZbdJiFEryRISOiq3mm1wceLWac1cI9ty9YO/psUJqDZnYygO5Unw rwCw== 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 b12si5601908plm.393.2019.10.10.02.35.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:21 -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 768E16EAE0; Thu, 10 Oct 2019 09:35:17 +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 3E44B6EAE0 for ; Thu, 10 Oct 2019 09:35:14 +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 x9A9ZCc2013392; Thu, 10 Oct 2019 04:35:12 -0500 Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A9ZC7g087952 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 04:35:12 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) 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; Thu, 10 Oct 2019 04:35:08 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Thu, 10 Oct 2019 04:35:11 -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 x9A9ZBFi101065; Thu, 10 Oct 2019 04:35:11 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 4/8] drm/omap: cleanup OMAP_BO flags Date: Thu, 10 Oct 2019 11:34:41 +0200 Message-ID: <20191010093445.11069-5-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700112; bh=x6CFEyQ5hZGLdJM9om0YP8uZogPODV92P5gME8H8Uq0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hk5quowyQckEgENsR2j6e96a+wewuU+AK5BYPTxtHCx2+NfjRBI3NC3sY/4SfE01j h+g76BS1abI7kVm3Updq2nW/pp2QCed0tWwl63W+mMV6UYU/zn3mJ+tfMgW7y5DNxR F9Tc+YrhnZ0ojE/hlA3qXQgEyZ/6ZizaPjmexlh4= 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 Thu Oct 10 09:34:42 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: 175738 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030335ill; Thu, 10 Oct 2019 02:35:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeP0rwwwo6ne5sgeh1jxDkHhfYaUrIWU1skzFnJ+WkvNkqgeiN8MDe4FLBhmeXVrAZ1TR9 X-Received: by 2002:a63:1160:: with SMTP id 32mr10090196pgr.28.1570700125458; Thu, 10 Oct 2019 02:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700125; cv=none; d=google.com; s=arc-20160816; b=aMbvj9r/SO0e8uRZ4irXQVUqQXp76UizQc67lhINXGN1RfCCf4z5wGCE5bansBanH2 egtHO5ENsEmWn1zZkvWArj9ceHu0dZXp1oBYi4sB1euoXbYG0SGYUESAPDpWQYBycA55 ZcyAienlEC49+MWO25aHCdcBfKqsc2wBhuYe9EaD07MRqdrhzwvehC8/vQzz2yDHYKv3 g/J1UbhpymirLBSsL1JTh0wrwYnrpSyrB146/yuzlADY+P/3/Mt+o9+54X/uE4NJVvPl clYg2ophJuhImqgW/Iu/4y3KM57wbE4K5cG1ltkV6bXo4KdCY7JtTTXUQGUtL3nMD/W6 JQXg== 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=k62/xJ9pMmpup6Spdb78/8SOa2cC5vjYos6OiF7Weo8=; b=mp9Z03udQebJoDcelyhGB8DvH6u1t5UuPu6cNKwoV44fbRL6/KFJ7YfJ8utQDj90bF 6Y+3iRxObv1ildOuQL/+y3X7KHqXQRmkdpXoA8R8tK8XjJ9PdMpbnR4SjrMVjRNNc5Bo AT9SfM0faY83Hxd+NhuHsfEl1lXSGHJ0uz+OgHfcd4yjnTghWBaF6octd66o9YFygGTU z3aU+57j4s4BagZ0CnZcT+eMrdSl9NW8wL2rz8BLR2KmMUkT2YOa7bjZZsjSY8P1RXlh 4LyZQRNx4qFNsl09q7jO75UNBL27JMPCNsHV7hSk8y73/eg2Tv+BPZlNHWARhamlpIlZ gbGg== 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 h2si5142247pjq.78.2019.10.10.02.35.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:25 -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 5C25C6EAE3; Thu, 10 Oct 2019 09:35:18 +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 985526EAE1 for ; Thu, 10 Oct 2019 09:35:15 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9A9ZDDi007958; Thu, 10 Oct 2019 04:35:13 -0500 Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A9ZDAg087995 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 04:35:13 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) 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; Thu, 10 Oct 2019 04:35:09 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 04:35:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9A9ZCOZ129888; Thu, 10 Oct 2019 04:35:12 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 5/8] drm/omap: remove OMAP_BO_TILED define Date: Thu, 10 Oct 2019 11:34:42 +0200 Message-ID: <20191010093445.11069-6-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700113; bh=IZBh1iOCxFwAVDbsHVoq0Tv2w4YrsS4EgZqtBKOeARQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ov11Xm/B5NMXV+bdRF2/yWKYaCCEE6JMQt9NHaF8datMBKq3BG7GzCVCOi1GgR/Oq n+EbQcdh9TjPgiNufC2q5ocwnKTJc6G2HTfALAPnb4vpCdiQqKWk9TzU+VZYlneYET u2At5T6zUwvUd8ZEnyC3bHp4rP4wgQZDqjUGWQWg= 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 7e89e5cb4068..8daf46fd5e05 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 2ac83cdbb15a..07dba300ec07 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -194,7 +194,7 @@ static void omap_gem_evict(struct drm_gem_object *obj) struct omap_gem_object *omap_obj = to_omap_bo(obj); struct omap_drm_private *priv = obj->dev->dev_private; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { enum tiler_fmt fmt = gem2fmt(omap_obj->flags); int i; @@ -322,7 +322,7 @@ size_t omap_gem_mmap_size(struct drm_gem_object *obj) struct omap_gem_object *omap_obj = to_omap_bo(obj); size_t size = obj->size; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { /* for tiled buffers, the virtual size has stride rounded up * to 4kb.. (to hide the fact that row n+1 might start 16kb or * 32kb later!). But we don't back the entire buffer with @@ -511,7 +511,7 @@ vm_fault_t omap_gem_fault(struct vm_fault *vmf) * probably trigger put_pages()? */ - if (omap_obj->flags & OMAP_BO_TILED) + if (omap_obj->flags & OMAP_BO_TILED_MASK) ret = omap_gem_fault_2d(obj, vma, vmf); else ret = omap_gem_fault_1d(obj, vma, vmf); @@ -784,7 +784,7 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) if (ret) goto fail; - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { block = tiler_reserve_2d(fmt, omap_obj->width, omap_obj->height, 0); @@ -890,7 +890,7 @@ int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient, mutex_lock(&omap_obj->lock); if ((refcount_read(&omap_obj->dma_addr_cnt) > 0) && omap_obj->block && - (omap_obj->flags & OMAP_BO_TILED)) { + (omap_obj->flags & OMAP_BO_TILED_MASK)) { *dma_addr = tiler_tsptr(omap_obj->block, orient, x, y); ret = 0; } @@ -905,7 +905,7 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret = -EINVAL; - if (omap_obj->flags & OMAP_BO_TILED) + if (omap_obj->flags & OMAP_BO_TILED_MASK) ret = tiler_stride(gem2fmt(omap_obj->flags), orient); return ret; } @@ -1044,7 +1044,7 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m) refcount_read(&omap_obj->dma_addr_cnt), omap_obj->vaddr, omap_obj->roll); - if (omap_obj->flags & OMAP_BO_TILED) { + if (omap_obj->flags & OMAP_BO_TILED_MASK) { seq_printf(m, " %dx%d", omap_obj->width, omap_obj->height); if (omap_obj->block) { struct tcm_area *area = &omap_obj->block->area; @@ -1143,7 +1143,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, int ret; /* Validate the flags and compute the memory and cache flags. */ - if (flags & OMAP_BO_TILED) { + if (flags & OMAP_BO_TILED_MASK) { if (!priv->usergart) { dev_err(dev->dev, "Tiled buffers require DMM\n"); return NULL; @@ -1185,7 +1185,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, omap_obj->flags = flags; mutex_init(&omap_obj->lock); - if (flags & OMAP_BO_TILED) { + if (flags & OMAP_BO_TILED_MASK) { /* * For tiled buffers align dimensions to slot boundaries and * calculate size based on aligned dimensions. diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 07c0b1b486f7..a4a4415e4666 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -64,7 +64,7 @@ static int omap_gem_dmabuf_begin_cpu_access(struct dma_buf *buffer, { struct drm_gem_object *obj = buffer->priv; struct page **pages; - if (omap_gem_flags(obj) & OMAP_BO_TILED) { + if (omap_gem_flags(obj) & OMAP_BO_TILED_MASK) { /* TODO we would need to pin at least part of the buffer to * get de-tiled view. For now just reject it. */ diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h index d8ee2f840697..5a142fad473c 100644 --- a/include/uapi/drm/omap_drm.h +++ b/include/uapi/drm/omap_drm.h @@ -52,7 +52,6 @@ struct drm_omap_param { #define OMAP_BO_TILED_16 0x00000200 #define OMAP_BO_TILED_32 0x00000300 #define OMAP_BO_TILED_MASK 0x00000f00 -#define OMAP_BO_TILED (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | OMAP_BO_TILED_32) union omap_gem_size { __u32 bytes; /* (for non-tiled formats) */ From patchwork Thu Oct 10 09:34:43 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: 175740 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030378ill; Thu, 10 Oct 2019 02:35:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqws7uijluQQG/m4yFWylkK0hho/j7Rve1rcbzsrLHLTB9K4Srsu9abgujD07QhTxDJpSU4+ X-Received: by 2002:a62:386:: with SMTP id 128mr9900213pfd.110.1570700128524; Thu, 10 Oct 2019 02:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700128; cv=none; d=google.com; s=arc-20160816; b=fA+kCNPidELKOhLz6SCa49bpnDZtbslTesoZeIWOTx0LmGJr27VUwX0GvD40mAQ3vf X1IUDua+VBAHcC8StC4biWjUdkz+ZKh+yLt2c+6Y+f/+rAfOxyB4xEp1UVGN5/0d+kZm dpOnveGBnSaDGPlnBoVe9ZUKzYGyPH1J6bcBzbpRFjo81gVr8awrRD6JTgDJxpz/ZB4k y5ZxnPolcskKPy/QJcYIsVgIPd8Q5qRbH2eFxhG6P1r0J6rZOVYeVItzoCUvmCiOWTCz vKxq8H7wKXi/KLSuYqg2z/Hu8zgyjQN8NCgFSIfKJoX/pVPcaBQsN4ewxYbnwg1M+v3u AWWA== 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=9oMtJYlwWy+rQBXUVjKJ7vCzE5IAPHTOgofQu/AW6VY=; b=wFdwSSufjyS2Y2+VHy2fpIgsd2lknfFz69QhfKGtFAvMqZFDmEObF7XLVQqILcWd00 TIii2uM0xC41RJzQQhLqbE6hVTWfQjTuShNGbmUJRCF+g7EnDIGfhp/QpXInDiSJ4GW0 +Bf40A6GuCl6Q8ikSRGLAqJ9QbvVv8IPoEnjrKlsSwyn/h9eK4kvFKDqY0b4L3nSa+MP yoRxmKQtmeOlw/9L4MVBvwlHC1PnZQZT8PwUvcmu4y1REKwDvWo4QZvVky1mwtbdX32J sqIfW9RdoO4Yp+/kyls2k5y0TCkXjRvV5O1PigM5r4TTFnlv/aFJsSXrli882BlEt/JA /JBw== 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 x7si1058269plv.113.2019.10.10.02.35.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:28 -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 4EBE06EAE6; Thu, 10 Oct 2019 09:35: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 F2FC16EAE1 for ; Thu, 10 Oct 2019 09:35:16 +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 x9A9ZEgg120192; Thu, 10 Oct 2019 04:35:14 -0500 Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9A9ZEnO078376; Thu, 10 Oct 2019 04:35:14 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 04:35:14 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 04:35:14 -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 x9A9ZD9Q101119; Thu, 10 Oct 2019 04:35:13 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 6/8] drm/omap: cleanup OMAP_BO_SCANOUT use Date: Thu, 10 Oct 2019 11:34:43 +0200 Message-ID: <20191010093445.11069-7-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700114; bh=rT7lgp+iPdYWoFNcHP+SFY8dLqrQJTrJ5/YLc1B0CJ4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=dS632yV1TMb1G2dlEWwbMwn21ZUHbUNf9OsuLk8Aoe4hTm+3q1d4OpSlZLru87DrQ u9DJSICgE+/tFuZ+nh+whmarXxgqGNWU2Ek6TjJ/7JQX5KEph731m9CEHqnJpO7Ddx KpU3NeeHRJDz/rt8hw1dgZX063ORvGklznqC4RIY= 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 07dba300ec07..5c4cdf618347 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1153,7 +1153,6 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, * Tiled buffers are always shmem paged backed. When they are * scanned out, they are remapped into DMM/TILER. */ - flags &= ~OMAP_BO_SCANOUT; flags |= OMAP_BO_MEM_SHMEM; /* @@ -1164,9 +1163,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, flags |= tiler_get_cpu_cache_flags(); } else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) { /* - * OMAP_BO_SCANOUT hints that the buffer doesn't need to be - * tiled. However, to lower the pressure on memory allocation, - * use contiguous memory only if no TILER is available. + * If we don't have DMM, we must allocate scanout buffers + * from contiguous DMA memory. */ flags |= OMAP_BO_MEM_DMA_API; } else if (!(flags & OMAP_BO_MEM_DMABUF)) { From patchwork Thu Oct 10 09:34:44 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: 175739 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030356ill; Thu, 10 Oct 2019 02:35:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmW9+B0WJBfRdrCU/UA7opmd+63Bx6A4mCTkzYZ4PMC6N4tEEWD32O+Iz929r+bYZ0Y8Ei X-Received: by 2002:a63:81:: with SMTP id 123mr10259312pga.47.1570700127296; Thu, 10 Oct 2019 02:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700127; cv=none; d=google.com; s=arc-20160816; b=MG2/kh0aP2Z4r8VfSk0mVSdKgx1rG1kD1FXQJ0qktG0prPjTMe6KlC1/FhwyokS0tg rYh1wfpYjyA91YHfoH6Xrvyn/29weN/VILBeVPpewlp2ewKjJuXXzpOABadYsVGGLRql wsAyQs3h8q62pgSv0ft2duCaZdTuAV601kbXNWRVLy3AIuXiPTEZAlFz+R1KMiT9+9Xj TnmlQ/oGGQaQzb8lkqA/fQP89RwFJ/kDDPCq0aSbIA5dwacyzQd5MXzxVmCn+9++x1WQ WmuHExlb4+bjJpHgebgmkBBnrf/bRsEkNPoECnEjSJKPCBnbD55QeLnuh6jNpJvfVykf 0oRw== 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=Ea9JdJlrVh5EsWhc+wDNF1Eg6b2CeZJQ75yJkWvogEg=; b=iG5SFJocLInVbLWK1MBmudoywxE3u4UmR/5TrRkcfJGAUsc5lG/mgX+vrw7R//Yy9l FxkPTXYSx2m7ruU63ou/EOrEVa+ZzSWrZRs/OuRziXJ5fbHHmkt3ehGtsYbQ2gXPt4rq PVK84EuhyhoEY2D3ddnT+nbFyHWQbX1/iPzDB3g78BKeB7MHcGsn4cZU5dkP0VgSpeQg JoT/axTgx77WfxJHdolVX7XS2w0xkePSlI/S49b0wqrpDLj/5SYxTme/KHPhcPiYI8y+ 9wzECdnoEyha8A/M6082LOaGrQjPCr9RwitHtxpuYDBruJtGIN6YWZcDmh1xbXYGXxRo c+PA== 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 i1si5866872pgk.585.2019.10.10.02.35.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:27 -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 CD2406EAE4; Thu, 10 Oct 2019 09:35:21 +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 249CA6EAE3 for ; Thu, 10 Oct 2019 09:35:17 +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 x9A9ZFhj120197; Thu, 10 Oct 2019 04:35:15 -0500 Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A9ZFd0088031 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 04:35:15 -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; Thu, 10 Oct 2019 04:35:11 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Thu, 10 Oct 2019 04:35:11 -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 x9A9ZE8J101134; Thu, 10 Oct 2019 04:35:15 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 7/8] drm/omap: add omap_gem_validate_flags() Date: Thu, 10 Oct 2019 11:34:44 +0200 Message-ID: <20191010093445.11069-8-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700115; bh=FfVnM+Ts4wygP+9UvDY241v6fs0aZrdlSeXVunnk9GE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=jz1Wtyu3CWNNBBn1VqLRnX31t3GCDnURc5MtLJksnsUJCR5ZSLxi70YRWOBRrJjQB dOKCOmjMl3wlxvWEjltI4HVtS0T/Inso7n+QFFKv7e0gQjWHZ94dP7Wul5of3ZPVxK +CJC+ManFc2salHHVkhnR/X/YNMfoaRh88Ha+h4M= 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 5c4cdf618347..cafa9d0bf3c1 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1131,6 +1131,38 @@ void omap_gem_free_object(struct drm_gem_object *obj) kfree(omap_obj); } +static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) +{ + struct omap_drm_private *priv = dev->dev_private; + + switch (flags & OMAP_BO_CACHE_MASK) { + case OMAP_BO_CACHED: + case OMAP_BO_WC: + case OMAP_BO_CACHE_MASK: + break; + + default: + return false; + } + + if (flags & OMAP_BO_TILED_MASK) { + if (!priv->usergart) + return false; + + switch (flags & OMAP_BO_TILED_MASK) { + case OMAP_BO_TILED_8: + case OMAP_BO_TILED_16: + case OMAP_BO_TILED_32: + break; + + default: + return false; + } + } + + return true; +} + /* GEM buffer object constructor */ struct drm_gem_object *omap_gem_new(struct drm_device *dev, union omap_gem_size gsize, u32 flags) @@ -1142,13 +1174,11 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, size_t size; int ret; + if (!omap_gem_validate_flags(dev, flags)) + return NULL; + /* Validate the flags and compute the memory and cache flags. */ if (flags & OMAP_BO_TILED_MASK) { - if (!priv->usergart) { - dev_err(dev->dev, "Tiled buffers require DMM\n"); - return NULL; - } - /* * Tiled buffers are always shmem paged backed. When they are * scanned out, they are remapped into DMM/TILER. From patchwork Thu Oct 10 09:34:45 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: 175741 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030413ill; Thu, 10 Oct 2019 02:35:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4z5N5UcCWbrEgCI89IeQebyJ38OfBSaxt7U7F1rWn+1rsbev9+5fsloDdh11XQmUqbdIW X-Received: by 2002:a17:90a:9f83:: with SMTP id o3mr10141343pjp.66.1570700130089; Thu, 10 Oct 2019 02:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700130; cv=none; d=google.com; s=arc-20160816; b=DArobpGJaj2LrG8Y305glhIlCzBJ5WGG2OcH+6KKT/+DKlF1X2H2QsmTOi658LeZuP ATVj+gSntlbe1s5H/KCP3A9kfZwM5fJ4lIRiGVyGVexCpwetLUl0ko/XFMBtDDmwBQOR vbmDYYhZ8a5sowuKsJDb/HgWVXU5Ij4kweQn4pncE7WJUhxh0CjDC3pLvdcoxQjXW+rp T0zzQEUHyuGsqxyFZZ6yh1tLPf1+wSwfGLzVaqhzAH64dw8B48NVToMA618ZP8CuNT97 a31446bRBR06UZYuI+rUpcEjnGnUiDtjfKUKgv9fEVxVhxBA0HIg5tXtQ3VLVmPN3IOf EujQ== 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=cBMZWzz94fxD1qcef3/Q5qVuCnR6mGY6zTeSdalLd/U=; b=NXtbEktMPrxPt77x620Vs1KcYknnJFvw5cbUpI/zlSPvW9wrjwhHMBipaOtJxOcWfO YahmBPn7AgHcS7FvOant6s79l7P1MUd6jPw/1S5b96AXPzWYd8nUjzSShsT7Ette3gFH AdF5FTnK+KMOMlphuBic8ulgbQrAID2Cpw/gpkt7qYSEBueGDtwnT2NoslL/1eO90vYd rZIeSqJU7wmbzL6bgzIXiD8d4Tk5wGlPoME8QuNaSO0qd2jwrN/D3CC6lmqORuXZwoqg Bj9QpdpriL3dS5pa2v49OxUsfS1gfkyCAgde/9LUJYdVW1ApEkNhd5nr+4ttC8tK6Lnq lK2g== 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 d16si5098151pll.400.2019.10.10.02.35.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:30 -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 DF25A6EAE8; Thu, 10 Oct 2019 09:35:26 +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 C0E046EAE4 for ; Thu, 10 Oct 2019 09:35:18 +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 x9A9ZHmT010317; Thu, 10 Oct 2019 04:35:17 -0500 Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A9ZHC8011208 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 04:35:17 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 04:35:13 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 04:35:13 -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 x9A9ZF62013500; Thu, 10 Oct 2019 04:35:16 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 8/8] drm/omap: add OMAP_BO flags to affect buffer allocation Date: Thu, 10 Oct 2019 11:34:45 +0200 Message-ID: <20191010093445.11069-9-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700117; bh=ZAqIS7IlHV/Rs/JksB/tUhi73GRRzu0oI+4Q+G2obEU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BqVyOwLOkS5AX9AWgAv1LS5H1VvFSpN17aSz25/2fyM3QGgELyzhs7cbJaMuWvsyO rAss2/1pD38DRTdt8+pq+hLmZREcsdzcA+MvL5ZiTAR/VjIoSDiT0GYCGq7VOaoelM cU7Vzh+3jiXo1LmxvZoSLfxOAXEuHbX/ALE41mm0= 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 cafa9d0bf3c1..9af2c9a4bd28 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -1095,6 +1095,9 @@ void omap_gem_free_object(struct drm_gem_object *obj) list_del(&omap_obj->mm_list); mutex_unlock(&priv->list_lock); + if (omap_obj->flags & OMAP_BO_MEM_PIN) + omap_gem_unpin_locked(obj); + /* * We own the sole reference to the object at this point, but to keep * lockdep happy, we must still take the omap_obj_lock to call @@ -1145,10 +1148,19 @@ static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) return false; } + if ((flags & OMAP_BO_MEM_CONTIG) && (flags & OMAP_BO_MEM_DMM)) + return false; + + if ((flags & OMAP_BO_MEM_DMM) && !priv->usergart) + return false; + if (flags & OMAP_BO_TILED_MASK) { if (!priv->usergart) return false; + if (flags & OMAP_BO_MEM_CONTIG) + return false; + switch (flags & OMAP_BO_TILED_MASK) { case OMAP_BO_TILED_8: case OMAP_BO_TILED_16: @@ -1163,7 +1175,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) { @@ -1191,7 +1230,8 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev, */ flags &= ~(OMAP_BO_CACHED|OMAP_BO_WC|OMAP_BO_UNCACHED); flags |= tiler_get_cpu_cache_flags(); - } else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) { + } else if ((flags & OMAP_BO_MEM_CONTIG) || + ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm)) { /* * If we don't have DMM, we must allocate scanout buffers * from contiguous DMA memory. @@ -1251,12 +1291,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