From patchwork Wed May 29 10:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 10966769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C41E818A6 for ; Wed, 29 May 2019 10:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5ED82873A for ; Wed, 29 May 2019 10:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9C5528785; Wed, 29 May 2019 10:43:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A98F2873A for ; Wed, 29 May 2019 10:43:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45AED6B000D; Wed, 29 May 2019 06:43:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 431846B000E; Wed, 29 May 2019 06:43:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 347876B0010; Wed, 29 May 2019 06:43:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by kanga.kvack.org (Postfix) with ESMTP id EEE5C6B000D for ; Wed, 29 May 2019 06:43:28 -0400 (EDT) Received: by mail-wm1-f69.google.com with SMTP id z202so444905wmc.9 for ; Wed, 29 May 2019 03:43:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=fzpjFpWtW4cn4Ss889ONrxtqSc7C+B6SWSLiGLQnKJA=; b=cbl+fVSvDLV3m4j1iA9TwLisLjP1LZLJO4mdK8NlwjEAyUmZsczONN/1LZOVU0QSGz Q9w4nYjpvW5Cw1Gmruh2004eHun+gM03sMOjllB2tPO8LGP+Gd+iCliK5lXKkKZktLt9 4WIL/uJ0tu7AkTRVXfgD9tBt4fGepBG4Rnr5vaI5N0//rJTVAJ4X7sP4pUdp07nebfXq j/R0JkEf1A1+sT7cLKAFpt93n+CFFRqrhwQuaxfwbNdbrRQ0xSDxw/ewex46UPFN79IV 62RrA4YghIywGP7Hx4S2urZWqU3giGoxtKQAoZ5R+f3nSFu+wpNxbyql5hjnOtSjbckb phkg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de X-Gm-Message-State: APjAAAVogJIqTle5C8NL27L5tAV16ZpI/5MUKojZQhCrdvF8aRLJknZ3 VyPoEpdbKSVaoSooDuXAWLFFWZAyu1mBnATbSbpwrV28BVXqJeZ1MdHIS+a/atw5sC/6BzUBrk/ W4rP2gNtUOZv/q2tGnwF6Yry6GuX7TdiIvSrLusW1ZIbz5Kp8LlPbfiGegz1zsf5pEQ== X-Received: by 2002:a1c:a00a:: with SMTP id j10mr6332411wme.41.1559126608505; Wed, 29 May 2019 03:43:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqziQfF11H3Gmi+ZgFJuKWwoVqTCfCGpw2qbhDt5Ii+tXeOibyE6qjgGr319lyEi5yD1oQ8r X-Received: by 2002:a1c:a00a:: with SMTP id j10mr6332368wme.41.1559126607523; Wed, 29 May 2019 03:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559126607; cv=none; d=google.com; s=arc-20160816; b=DI/kf8jQjxsGE+p0k1VbPLxoVfnhJUuOaRFiPXqEwa3/R0NPFk6SkDMj/ejKyrAVAT v0oV/YRtwrQXsu+VyTEizUolDdEPKZTFq6TJlklManiPwcnTyaHTeh/18b5ct2iMW/9/ lMW/Ce6NExtbYTYHJv2kFEocCH6g2NM9kTIWW8NAKssg5I2WLAAFp9QW+Jef4JX8Fexn MnGHId1hAl1afV9qYovtIgenXUwfO8QYiTOlrevY1zE2M0YC4d3MW1iP5eGZxoE1W2Zs cVUUk+AIVItRp8DJANm1tNFMYGKRkXWlsrpu+nKi+ABdMYq2vi4oGHbjwNVJfQE65WjI jl6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=fzpjFpWtW4cn4Ss889ONrxtqSc7C+B6SWSLiGLQnKJA=; b=MQCD7bF4XqYnZd16D9rC8dvjubfz3SZL5x/egV5P53LVgARZYFnwvU5CcNcGwEzaFR l6wBeS1oGHkuiZFTmvt3N9R2BZjZXPLwnkP11X1QwfshFBE+YmkJ2inDMLb3EK4eOMi8 7drHzYW+YWBgvo2WtohuSsB/upibm4cRRh0wbUoXoq7bf3ZGET8HBCmnMg+evGx8MzNi PEEADXlXtkrGEoPNusbFdzrTMn5aCQu1j0S4+h+3r5IfFiROx1hODYer0xhR9fsMfEyu taJ07a4A3OAL7eVhcMsiimfnVkGuXbhmP8l6bD+kaMLSQJ641s63CHxMx8mMTevNgYQT 4Etg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de. [2001:67c:670:201:290:27ff:fe1d:cc33]) by mx.google.com with ESMTPS id x3si3876195wmc.117.2019.05.29.03.43.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 03:43:27 -0700 (PDT) Received-SPF: pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) client-ip=2001:67c:670:201:290:27ff:fe1d:cc33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1hVw3A-00016K-AI; Wed, 29 May 2019 12:43:16 +0200 From: Lucas Stach To: Andrew Morton , Yue Hu , =?utf-8?q?Micha=C5=82_Nazarewicz?= , Marek Szyprowski , Dmitry Vyukov Cc: etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, kernel@pengutronix.de, patchwork-lst@pengutronix.de Subject: [PATCH 1/2] mm: cma: export functions to get CMA base and size Date: Wed, 29 May 2019 12:43:11 +0200 Message-Id: <20190529104312.27835-1-l.stach@pengutronix.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mm@kvack.org X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Make them usable in modules. Some drivers want to know where their device CMA area is located to make better decisions about the DMA programming. Signed-off-by: Lucas Stach --- mm/cma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/cma.c b/mm/cma.c index 3340ef34c154..191c89bf038d 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -44,11 +44,13 @@ phys_addr_t cma_get_base(const struct cma *cma) { return PFN_PHYS(cma->base_pfn); } +EXPORT_SYMBOL_GPL(cma_get_base); unsigned long cma_get_size(const struct cma *cma) { return cma->count << PAGE_SHIFT; } +EXPORT_SYMBOL_GPL(cma_get_size); const char *cma_get_name(const struct cma *cma) { From patchwork Wed May 29 10:43:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 10966773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 389EB1575 for ; Wed, 29 May 2019 10:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AFCA2873A for ; Wed, 29 May 2019 10:43:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EDA028785; Wed, 29 May 2019 10:43:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30CD62873A for ; Wed, 29 May 2019 10:43:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 654EB6B000E; Wed, 29 May 2019 06:43:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 607F26B0010; Wed, 29 May 2019 06:43:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CE6F6B0266; Wed, 29 May 2019 06:43:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id 041C46B000E for ; Wed, 29 May 2019 06:43:35 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id b79so859103wme.5 for ; Wed, 29 May 2019 03:43:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=We4P0EFUyDAKiCU8ARtGsC7AJfJgPUcMxyrvg+1j4ho=; b=VeD9ZtXtOtnjoWbqnKAKvwlmflNVoFAp2R1fUD6/RI7aVM5QEisV5cEfmYcqmpsdD/ RU2v979h2WoRXB99XPKLvnkDYcJB8hA+rnaTaLbUhecbDzraQnptKZAMiXZR+ExBst8s 71y+qbMEKaFsIhWMybyhIAWtP7dfHbQCZoVHfjR5bsn7190BoMP8l78ED9YKz4eSuJsx scWGTRYwIlQeGehdJQszJ8gU48BK4FHhycqwRN6WMLoJScjPwMKvAfNYA5uDBcW3sEO5 OfkEzi8n+XFxQRodz34f32r1I8byNTx+4D8vCfiHDrGQjR2IhkXvP0vGQ5m8/JGrBmJZ lx1w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de X-Gm-Message-State: APjAAAVaNCV1lLO/fI0X3HVCubdItDJ2zObPx6SktESda5qwE+ozhRAW k4zi3MVg4/LVS5vTPcLwHrnaBhqpx3v7ajhIReju/DPCvQglIbZ/uB1np2jASXL28sy7L/b7NBC g4Qlyv8hjfJDi2/6YYocg3dWB9jsNqTnljsYyKF3bkMTgn5Y1G36fTYuYxWFerE6Ipw== X-Received: by 2002:a5d:4310:: with SMTP id h16mr39666355wrq.331.1559126614489; Wed, 29 May 2019 03:43:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVWhqrvLBKlfqPY1n3xyIHUDHuI0EFq8frkRrMwzsQTWux/huT6PBpDwaCA2avwTBUXYei X-Received: by 2002:a5d:4310:: with SMTP id h16mr39666017wrq.331.1559126608428; Wed, 29 May 2019 03:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559126608; cv=none; d=google.com; s=arc-20160816; b=svEGtgP93A2Z++WxGRbXO4KRCgtHsf6jU68jjvrWO46IAO4aGAtS1wVotCWZFtYMa8 PYMZ4u+zUOcam0x4CLEBxaeLw9thxfPQ88ttCmhGVhA0SNofBJPnnPUQ0CFzyzbaqMXm rbUmyyOCFCUpd/chnKW34htykIjXRaydOk0jZMz+Mv2ZBnTK8aYv6/LqzmfAFlOVJtjc m5+5XHsV959AqGjYiUZBSFQMDtQYnUrbEJeHE2qs1zcXjORkrEYGnHmlFMf1T6rN4SKV CfH9Thr8kebzRyvpa5JoqwxUGS8dbcL31RSV0iH1YCmY8xQL1ZGTsR7fn94/ttipVJ3f Lxhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=We4P0EFUyDAKiCU8ARtGsC7AJfJgPUcMxyrvg+1j4ho=; b=pZYUgTCkvc66G744iyBoYTf7uMuBEbQl54OBojLuLGN1cnaX2lIbs2OsKtoNwU+CWk Wjnpy0ujkGaYln/coDHDfJmeN2pWNeebhesjNV+41yqJLNvxEwQ+feTnbpr8ech1YJ60 SjhMV170/EQlMmjUjsAsO16p9CD7AboaU6Gf9oLURYGPv47ZpKyjp+7oJybC4502ppOw uGXwbdU8CkZSfrlYE6NC5lpniKI61sBx45z3dd+vBRUtkCAFEu21mare26fv8kqeM59V 0HC3UvqhbCgaWYZUxlXg3NKGDpRJiSQatx8QyfKOMHp2zdvSOylSbZNKLFcb0NIJ7K13 +fvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de. [2001:67c:670:201:290:27ff:fe1d:cc33]) by mx.google.com with ESMTPS id o9si2060984wrq.241.2019.05.29.03.43.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 03:43:28 -0700 (PDT) Received-SPF: pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) client-ip=2001:67c:670:201:290:27ff:fe1d:cc33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of l.stach@pengutronix.de designates 2001:67c:670:201:290:27ff:fe1d:cc33 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1hVw3A-00016K-Ch; Wed, 29 May 2019 12:43:16 +0200 From: Lucas Stach To: Andrew Morton , Yue Hu , =?utf-8?q?Micha=C5=82_Nazarewicz?= , Marek Szyprowski , Dmitry Vyukov Cc: etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, kernel@pengutronix.de, patchwork-lst@pengutronix.de Subject: [PATCH 2/2] drm/etnaviv: use CMA area to compute linear window offset if possible Date: Wed, 29 May 2019 12:43:12 +0200 Message-Id: <20190529104312.27835-2-l.stach@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190529104312.27835-1-l.stach@pengutronix.de> References: <20190529104312.27835-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mm@kvack.org X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The dma_required_mask might overestimate the memory size, or might not match up with the CMA area placement for other reasons. Get the information about CMA area placement directly from CMA where it is available, but keep the dma_required_mask as an approximate fallback for architectures where CMA is not available. Signed-off-by: Lucas Stach --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 72d01e873160..b144f1bbbb3c 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -4,7 +4,9 @@ */ #include +#include #include +#include #include #include #include @@ -724,11 +726,18 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) */ if (!(gpu->identity.features & chipFeatures_PIPE_3D) || (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) { - u32 dma_mask = (u32)dma_get_required_mask(gpu->dev); - if (dma_mask < PHYS_OFFSET + SZ_2G) + struct cma *cma = dev_get_cma_area(gpu->dev); + phys_addr_t end_mask; + + if (cma) + end_mask = cma_get_base(cma) - 1 + cma_get_size(cma); + else + end_mask = dma_get_required_mask(gpu->dev); + + if (end_mask < PHYS_OFFSET + SZ_2G) gpu->memory_base = PHYS_OFFSET; else - gpu->memory_base = dma_mask - SZ_2G + 1; + gpu->memory_base = end_mask - SZ_2G + 1; } else if (PHYS_OFFSET >= SZ_2G) { dev_info(gpu->dev, "Need to move linear window on MC1.0, disabling TS\n"); gpu->memory_base = PHYS_OFFSET;