From patchwork Fri Aug 2 19:51:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170445 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223054ile; Fri, 2 Aug 2019 12:51:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyok5rnJqHcjL+rN/HzS//hUT4WIkhAGZsZVnAGSHffGOGg33KTjoAs60pPu2knNRYdY/8a X-Received: by 2002:a17:90a:8c0c:: with SMTP id a12mr5849246pjo.67.1564775518870; Fri, 02 Aug 2019 12:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775518; cv=none; d=google.com; s=arc-20160816; b=B3HzjvAnI/tkW4si9OA4Dw9VAfbLbu9MXOE8sHKxsgXs3E01aaXdVQvpxnpl1taOl0 blcaS15QqEywFBGeqPsKKhLkATjyx8cS25/VhYVP6QQsUCcnd6GOwOL1plcpX3wUxEzY VoJh6T9rkjrpYSGy11PetIpTs57dYibyVsCGUBhHSfKq68dJlYilRDkc01Ktyy/inLqd y4fAmkzRcZfwYenR3J/asxtBDtpnGhLPhGjR01XqabxHDFEm6KW2DFWRFWnMYMjA1a4H u+lkx9LGEnmjEQT0fESUcF5JTeub97aH6DnDgxFSmvGU15Tdf01X5k04/nf0aRNv6Rl4 HtAw== 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=p69VusyH6Lz5s8Hvk421lhlfBM2CXGP3pyayg0dgues=; b=Ej4AVddOULhBeRdU3lPYQHMTPti6iqtM6KsUVgNWTRl4g1kXzE1zldi5Xc6zVhpC9u fkR4ou6w+ZAZV/Zz+D1Rlc0HQ4myi+hpYtaQJsIYJTReZObXMcbmBWlyjkmx/XdrGdQA rXRjbVDt1VpKWO2kUOkeSXM8KpLe91k+SbSnRxShwVJ9bZzjVdBvPEJFpt4B13cG0GFR IjbJ2i8egoLVpmF7IuR2zaV/5nDRpc6no0qZdseCNpwuaQQvihaV6jiYQbTtCrfJ+fbL qwEDKzqCNbvREpc5h3nTxmfsQr8k1ChVZDnA+W7HpTWLWZaPkLu0pYJ3V8I3aJ7eZqqE L/lA== 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=NONE sp=NONE dis=NONE) header.from=kernel.org 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 c12si5210676pgq.148.2019.08.02.12.51.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:51:58 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EADF6E5BB; Fri, 2 Aug 2019 19:51:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC5356E5BB for ; Fri, 2 Aug 2019 19:51:54 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id g20so154705157ioc.12 for ; Fri, 02 Aug 2019 12:51:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3p4cBswFFRoKy6tEpknmdkGW5IPNEAcVsUIZqRHEvng=; b=ImfLIJuNGazzxPJ0pHHSu8rCY98jzTP1xZA9DPSMxAkG6SUp5HviR5xY8vORaGk68k G5xMBtCjnnAi++pKzlM5rGAjZX3TuICnfOy/CHNDjZsohCKXUtwfMpwi+t/tNPhoFGj8 ytxzIUliwzOnyk9Dh+akBdA63zULgJmHuRbYbHN+VuyStNgvDCHG2mmHGOG9UGp3Vi0l GaHfbQEP7hQDT0Ojo5pBDvMpfxte4DmDf7sGcLx5kCVIzdmKmAGkkhwEkpQD77vHyDOv emGHJjtnfrxN06XAw7c85EZ2QIlEcbAYolQFgS439Pu/1Lxqne/DXcLY3P8PfyJVNizS 7rLQ== X-Gm-Message-State: APjAAAVxRV9hCQfIGFBQ9FTCedkkv38tcXxnN+CSCgLl81+vb5KzKEQH BRV6pekKWAu2q5Epe2cepqCqE7Q= X-Received: by 2002:a02:b016:: with SMTP id p22mr56289915jah.121.1564775513702; Fri, 02 Aug 2019 12:51:53 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:53 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 1/8] drm/gem: Allow sparsely populated page arrays in drm_gem_put_pages Date: Fri, 2 Aug 2019 13:51:43 -0600 Message-Id: <20190802195150.23207-2-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Panfrost has a need for pages allocated on demand via GPU page faults. When releasing the pages, the only thing preventing using drm_gem_put_pages() is needing to skip over unpopulated pages, so allow for skipping over NULL struct page pointers. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Reviewed-by: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring --- drivers/gpu/drm/drm_gem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 243f43d70f42..db373c945f16 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -633,6 +633,9 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, pagevec_init(&pvec); for (i = 0; i < npages; i++) { + if (!pages[i]) + continue; + if (dirty) set_page_dirty(pages[i]); From patchwork Fri Aug 2 19:51:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170446 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223083ile; Fri, 2 Aug 2019 12:52:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqJUX76I399XKJQS/X9TsJorc4coNlsKz29usP+0MuV3KeIh+YmVWI2tF7oVYqgsY/wzri X-Received: by 2002:a17:90a:d997:: with SMTP id d23mr5631252pjv.84.1564775521102; Fri, 02 Aug 2019 12:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775521; cv=none; d=google.com; s=arc-20160816; b=L6bmT1KvByjASdYMhQqqMUj1NQCT0LciFxotT9/wmtUVs2ASSFZ+VBlsbDIQrOldVc YIfBmw4YsoQnpgZChbHWtHxCdtMSd5NJiYcyue56nInuuhjR3plBdtjg8J67o6DyPm14 tEzyIKSsr3xjV7Bpi0yFZuj2etBUgCitBFTgJRiEHj7qbceo/xwfbJ5ageCtR9t4zD7o VERN1XyDwF203VwZrqJiWDR9Bh7CwjJgkNFVjI4BIY6bS4F2dz6Ppl1XpEkEIoBNi0/L oWRLESnNha8HMf8kWaGOGKBByRmamdLuVsH056wuteqCRcccVNh+2MZXRT+0a8WNNzdY 4Ecw== 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=fWd3AhBFV218/gqZRYdVkqdgDKemrSLvu5MCyL5Mvdc=; b=mRtaMKQtb523nDQNP4hW/5WWsbwQYRFO2v9EhCSd0aFadbPGQhFO9Je0SvE3878MkA 8cXPZOHc6DTJBQxn2jzZ4fyMGpsiiVipdzuT3yQ0smOfg6L7t5lr0EUKFN2cs0Bp3YGP GJa4XcgZiZMtETIRso/tZG8THczmFC9kEvfvTRa3pwzTerQ5kgCuRc1z2BEGXC82V/j2 W40uZbalmBxI58C/KPgCG1lsiE89sbQ5zQze8MISxYBdsOuc3PZ6fpRd5nDuL6f1wLUc puPZSGgodC8lGScUygK93fh3q4Qfl4UH0PK8dMSPngu2jF1KyCwcARJkdNmaulQQGZGI 4urQ== 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=NONE sp=NONE dis=NONE) header.from=kernel.org 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 h15si36704017plk.74.2019.08.02.12.52.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:01 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B8C76ED66; Fri, 2 Aug 2019 19:51:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04CC16E5BB for ; Fri, 2 Aug 2019 19:51:56 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id f4so154739285ioh.6 for ; Fri, 02 Aug 2019 12:51:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DsLdLXwkKyVix7l/rZud1QvU7xBYPQX9vimqxkDxj0k=; b=CIK59CFgeIDT/zt4QFu0YkOt1SJAjpKzzwJ5pVJkE6pDf7z3nepcoR+rVcPptjVIfV 2oNM9Wzn3c3Y3IelgX3jQOLeNSxd9tm9sBQhgmkeeEPxlG8baNB9c59qKSkmtuxV4nuc KlD3HJSmBah2XM3f2AD/zPVjmMYMq8cJiTnknsQw11nEDYjybA6WeV4feyDapYS98J2G gqgDP8AaM/uOcG1Bru+d12zPSBCfz9Nk6BIWbUsMWuBkObqCw/kOYowdqmZsQHLwfj+b a4VCsMvf0WO9NBKusBlVjldni/N08Gy1CqIeSk4FuiEzLW+EaSg8In2Uiv1E4aRFi1et VSNQ== X-Gm-Message-State: APjAAAVUvnXUDA6GzrR+PmdbrYiAd6oWILLKOAU3D2H1Bhr5Bje+ncgS R01I5SftEM2Jcm/CMDBHGxEP1bI= X-Received: by 2002:a05:6602:1d2:: with SMTP id w18mr9841177iot.157.1564775515011; Fri, 02 Aug 2019 12:51:55 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:54 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 2/8] drm/shmem: Put pages independent of a SG table being set Date: Fri, 2 Aug 2019 13:51:44 -0600 Message-Id: <20190802195150.23207-3-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If a driver does its own management of pages, the shmem helper object's pages array could be allocated when a SG table is not. There's not really any good reason to tie putting pages with having a SG table when freeing the object, so just put pages if the pages array is populated. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: Eric Anholt Reviewed-by: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring --- drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 2f64667ac805..477e4cc50f7a 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -118,11 +118,11 @@ void drm_gem_shmem_free_object(struct drm_gem_object *obj) if (shmem->sgt) { dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl, shmem->sgt->nents, DMA_BIDIRECTIONAL); - - drm_gem_shmem_put_pages(shmem); sg_free_table(shmem->sgt); kfree(shmem->sgt); } + if (shmem->pages) + drm_gem_shmem_put_pages(shmem); } WARN_ON(shmem->pages_use_count); From patchwork Fri Aug 2 19:51:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170447 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223113ile; Fri, 2 Aug 2019 12:52:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCR8j/Z7TYZj9Ord+7r6nuIhWSOKHkYsY+FEcqXGFAYcakS4cbjr96ynvFp81OsgHnOfk5 X-Received: by 2002:a62:7d96:: with SMTP id y144mr61477245pfc.156.1564775523011; Fri, 02 Aug 2019 12:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775523; cv=none; d=google.com; s=arc-20160816; b=wzeDE6FKpg5eJlzxYWNEZMPufZDiE2XPFpKnrun8K8HrTDZnrkkaf+vCokgX/UOsMi dJgpwlTMR5vLAsXP4lk664gMjmNUeANoT2mL5lKvkoLWkTHd1b3cta8R0lsKg/smExSd dhtWL1UBI6sr542LiaYe0989B7nc5fvA8kNTY3CsSUtJy499OYW6lALNnwPbx85aV/IB IMdpTFZ47v/jd2asdPFzH49u5XkZlurNpkIPj3Izu+Xq3lpy65vWZuSdMoXURynXmiGd Cy3wfuomuO1mHokletVtFELi6558maJcd+rQMSkr592PydheOUSeklbHNMu6y9VN4RBz Kx+Q== 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=7ju+Z1cGBPKfqF/9cWBs2FKPD8JWAMQ7GN2MUy4XrAA=; b=Y83z3tfd7i8KNmfU2sEn6RlXx2MbA2RLybo1xYRZMTFdY9QcNvhOvgQgW4rZqIdPLg 5MrAIDWgW/WkvKP/Nqb+cBSkbIsvNdzrFhcYBMoppL3aAXRqk12PwIkeLFo4w4/Ngcpo amk0B1HtQSmoGO1rWdKm7oOuVDGOeh8ZW/cKZGdsplW3HNEOdRONgxaQQONq/azNw0lU bY45JVQpUOla4QlpyQBjJMpC7sl/f2/bYS9uj47RnVEicSxOY9NfTuHY9NHheAmp/f/f qgVHphqzItc9+3rBP0I3p36KG0PG5OsPaQfOVzk2KOXpboYr/cU43BmKbJgYMFLvrwWs NUuw== 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=NONE sp=NONE dis=NONE) header.from=kernel.org 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 q85si38621946pfc.85.2019.08.02.12.52.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:02 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E1A26EDCF; Fri, 2 Aug 2019 19:51:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 63A076ED66 for ; Fri, 2 Aug 2019 19:51:57 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id s7so154530803iob.11 for ; Fri, 02 Aug 2019 12:51:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SaYhROACR2dssgwk3Hl51LbYYnpqdMCiJZJ/cUAtONI=; b=PvWzxHSXXdH8W7V7NQ5Gd6urua4woMUw5cgSwctTEB3ioTdnKM66jwA1Ov6vy1zvI6 Tf6lWNsSeWR+zTkfm5v1XCmHK4GtoXrHSwliqnDn3hRxfDMmVhcMS7GW+g2gasG8uXCn UAiRoozw+jcU+jNl2InTJIpUli8LwxoPLegxQjMLZsZ8YCDkvKUo3+CW6AeEqOh9VIYB UVIUgq5cQ00VFZt9upksyiw4PYRtPjNaPE1085i8HM+a3BPVfFXeLNIZhc/vVBQkeh8o IZqs7saN0lmj9SoASlEbIsgLUPd3sOVD+MhugvjuC/wzaQU2CToCBOurWQPzzSvw3g+t xFwg== X-Gm-Message-State: APjAAAXUtdYW3pgVCUUrGVjHxkIp07CkTeU7VlvIbf6DeUEKLQoiCdlk qeQeB3xk1TDGsF6Nb2azsbMBxF4= X-Received: by 2002:a6b:da1a:: with SMTP id x26mr101070747iob.285.1564775516386; Fri, 02 Aug 2019 12:51:56 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:55 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 3/8] drm/panfrost: Restructure the GEM object creation Date: Fri, 2 Aug 2019 13:51:45 -0600 Message-Id: <20190802195150.23207-4-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Setting the GPU VA when creating the GEM object doesn't allow for any conditional adjustments. In preparation to support adjusting the mapping, restructure the GEM object creation to map the GEM object after we've created the base shmem object. Cc: Tomeu Vizoso Cc: Boris Brezillon Cc: Robin Murphy Reviewed-by: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring --- drivers/gpu/drm/panfrost/panfrost_drv.c | 21 +++------ drivers/gpu/drm/panfrost/panfrost_gem.c | 58 ++++++++++++++++++++----- drivers/gpu/drm/panfrost/panfrost_gem.h | 5 +++ 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index cb43ff4ebf4a..d354b92964d5 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -46,29 +46,20 @@ static int panfrost_ioctl_get_param(struct drm_device *ddev, void *data, struct static int panfrost_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *file) { - int ret; - struct drm_gem_shmem_object *shmem; + struct panfrost_gem_object *bo; struct drm_panfrost_create_bo *args = data; if (!args->size || args->flags || args->pad) return -EINVAL; - shmem = drm_gem_shmem_create_with_handle(file, dev, args->size, - &args->handle); - if (IS_ERR(shmem)) - return PTR_ERR(shmem); - - ret = panfrost_mmu_map(to_panfrost_bo(&shmem->base)); - if (ret) - goto err_free; + bo = panfrost_gem_create_with_handle(file, dev, args->size, args->flags, + &args->handle); + if (IS_ERR(bo)) + return PTR_ERR(bo); - args->offset = to_panfrost_bo(&shmem->base)->node.start << PAGE_SHIFT; + args->offset = bo->node.start << PAGE_SHIFT; return 0; - -err_free: - drm_gem_handle_delete(file, args->handle); - return ret; } /** diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c index 543ab1b81bd5..df70dcf3cb2f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -23,7 +23,8 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj) panfrost_mmu_unmap(bo); spin_lock(&pfdev->mm_lock); - drm_mm_remove_node(&bo->node); + if (drm_mm_node_allocated(&bo->node)) + drm_mm_remove_node(&bo->node); spin_unlock(&pfdev->mm_lock); drm_gem_shmem_free_object(obj); @@ -50,10 +51,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = { */ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t size) { - int ret; - struct panfrost_device *pfdev = dev->dev_private; struct panfrost_gem_object *obj; - u64 align; obj = kzalloc(sizeof(*obj), GFP_KERNEL); if (!obj) @@ -61,20 +59,52 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t obj->base.base.funcs = &panfrost_gem_funcs; - size = roundup(size, PAGE_SIZE); - align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0; + return &obj->base.base; +} + +static int panfrost_gem_map(struct panfrost_device *pfdev, struct panfrost_gem_object *bo) +{ + int ret; + size_t size = bo->base.base.size; + u64 align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0; spin_lock(&pfdev->mm_lock); - ret = drm_mm_insert_node_generic(&pfdev->mm, &obj->node, + ret = drm_mm_insert_node_generic(&pfdev->mm, &bo->node, size >> PAGE_SHIFT, align, 0, 0); spin_unlock(&pfdev->mm_lock); + if (ret) + return ret; + + return panfrost_mmu_map(bo); +} + +struct panfrost_gem_object * +panfrost_gem_create_with_handle(struct drm_file *file_priv, + struct drm_device *dev, size_t size, + u32 flags, + uint32_t *handle) +{ + int ret; + struct panfrost_device *pfdev = dev->dev_private; + struct drm_gem_shmem_object *shmem; + struct panfrost_gem_object *bo; + + size = roundup(size, PAGE_SIZE); + + shmem = drm_gem_shmem_create_with_handle(file_priv, dev, size, handle); + if (IS_ERR(shmem)) + return ERR_CAST(shmem); + + bo = to_panfrost_bo(&shmem->base); + + ret = panfrost_gem_map(pfdev, bo); if (ret) goto free_obj; - return &obj->base.base; + return bo; free_obj: - kfree(obj); + drm_gem_handle_delete(file_priv, *handle); return ERR_PTR(ret); } @@ -83,8 +113,10 @@ panfrost_gem_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, struct sg_table *sgt) { + int ret; struct drm_gem_object *obj; struct panfrost_gem_object *pobj; + struct panfrost_device *pfdev = dev->dev_private; obj = drm_gem_shmem_prime_import_sg_table(dev, attach, sgt); if (IS_ERR(obj)) @@ -92,7 +124,13 @@ panfrost_gem_prime_import_sg_table(struct drm_device *dev, pobj = to_panfrost_bo(obj); - panfrost_mmu_map(pobj); + ret = panfrost_gem_map(pfdev, pobj); + if (ret) + goto free_obj; return obj; + +free_obj: + drm_gem_object_put_unlocked(obj); + return ERR_PTR(ret); } diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h index 6dbcaba020fc..ce065270720b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.h +++ b/drivers/gpu/drm/panfrost/panfrost_gem.h @@ -22,6 +22,11 @@ struct panfrost_gem_object *to_panfrost_bo(struct drm_gem_object *obj) struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t size); +struct panfrost_gem_object * +panfrost_gem_create_with_handle(struct drm_file *file_priv, + struct drm_device *dev, size_t size, u32 flags, + uint32_t *handle); + struct drm_gem_object * panfrost_gem_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, From patchwork Fri Aug 2 19:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170448 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223146ile; Fri, 2 Aug 2019 12:52:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQJJgEuyvO07yXg45tdI/WFZYWI+khMxpd9TDIJLvPlQGdEzwE9U/D9FtnARtFmTXCYCXq X-Received: by 2002:a62:fb18:: with SMTP id x24mr59920928pfm.231.1564775524838; Fri, 02 Aug 2019 12:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775524; cv=none; d=google.com; s=arc-20160816; b=KKsAF0aqf+AsC/8Eraa02G5Ck+6Tc3Zo5a4nlRi8m/SlRFSz9k7Ina07ygY7BrXK5+ iWq2/a49y19IvAGPR89MMuwHM+aVv7AoVrelmIYrRqqOA2F9gu+yeWLnpFESdLFCNh0f IHo00PVqyEhtdoR5T2PGNBuHUSVMowbT4gLJp/rpmEdXUfT2laGkf4IJpFlMYdK1XZhu fFp/F3davdfhehW1ojrb+lcfOmTmUBLAKVeuNnESDH9M8bLMmUK+KELPuhWl7rBk+f9H WD2Vz8Nl0GccPnC8B6U21Nc1m8I6A07WMg2UxFcm2yC/SryLZPI+yYtVZfpNU06xpMvI ovWg== 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=nEwBkDz5OdxwyI/pRV4kWJbsrPIunm4+1m68xc+eLfQ=; b=qH3C4d2V/nocHWoBjN8aic66HpsoFyPPxO7dv9u21LgAMi4YJZNyEy0RKwQFaDHCb4 L7PUJnJKCZGgdhyXZf2uuP+Oa0cZBItQ38iRYavPt1YkUyEA0FTh5j8I7lz0Nf8CGlkM oKFpqapL2qG5dUf4kTUY902LsGwTMrZFijaC2tdumSYOSvITQrnURI8SoHQXLmBNh7hc TKoXoPyaAX8Unxmgrm0To12oGMYY9vBBu4zV/dsTAjgU5AfaUrXAhaNyL0Rcux3DGIzx mPc2iuSn9Kn774BFiJ2RpV/LiEd5QFEv0sz4fqIMs3s8lMfVDuc95g1F/npWCqRD3jfq W4nA== 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=NONE sp=NONE dis=NONE) header.from=kernel.org 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 bx21si7043923pjb.21.2019.08.02.12.52.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:04 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0609A6EDD0; Fri, 2 Aug 2019 19:52:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 778916ED77 for ; Fri, 2 Aug 2019 19:51:58 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id j6so34879387ioa.5 for ; Fri, 02 Aug 2019 12:51:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l6R0Kh/pwj1cRdwpfVM4GshO3ikYF6B47tkVOltQGdk=; b=jFM8LRNIH4Gc5BfOXxA1YdRltwTXgYZlI2Tuo5VX7Oof6kSnO//FDauzyHSo3JQmtu Hj19iTKBA0FLtfHrRCGr9mFgMZQeapLvwGj36AJN+wm8ZMGny8Z8K+CxxQbaDljAMRsp 00OqNSDPFtWaY9tuVAfVjwV0ideZVlLMgH2GWNcTUiSHOLpqJLJLxXmvW19wKJwgMyll lSKqGEbRnfjlnqukZixvOBJYjM1VxY2eFBtexJruA2krlJzDSIw8MCrn2HJuGDeDmKtr 5zilxVMPHB2xQQlL1AG0WPTkd1R+XOky5/N1Dugh9oiBR3gMxGiJUReO0Si9H6lliujt 3JuQ== X-Gm-Message-State: APjAAAWt0nkONM5msL59/tKj6r7bcU/bqyUaoWC5nZ+JvhiT8Ca/4/Oa 9EK0MCPwx1WgU0OsbbqUFI8KnHk= X-Received: by 2002:a6b:7311:: with SMTP id e17mr82855629ioh.112.1564775517465; Fri, 02 Aug 2019 12:51:57 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:57 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 4/8] drm/panfrost: Split panfrost_mmu_map SG list mapping to its own function Date: Fri, 2 Aug 2019 13:51:46 -0600 Message-Id: <20190802195150.23207-5-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In preparation to create partial GPU mappings of BOs on page faults, split out the SG list handling of panfrost_mmu_map(). Cc: Tomeu Vizoso Cc: Boris Brezillon Cc: Robin Murphy Cc: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 52 +++++++++++++++---------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 92ac995dd9c6..b4ac149b2399 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -145,27 +145,13 @@ static size_t get_pgsize(u64 addr, size_t size) return SZ_2M; } -int panfrost_mmu_map(struct panfrost_gem_object *bo) +static int mmu_map_sg(struct panfrost_device *pfdev, u64 iova, + int prot, struct sg_table *sgt) { - struct drm_gem_object *obj = &bo->base.base; - struct panfrost_device *pfdev = to_panfrost_device(obj->dev); - struct io_pgtable_ops *ops = pfdev->mmu->pgtbl_ops; - u64 iova = bo->node.start << PAGE_SHIFT; unsigned int count; struct scatterlist *sgl; - struct sg_table *sgt; - int ret; - - if (WARN_ON(bo->is_mapped)) - return 0; - - sgt = drm_gem_shmem_get_pages_sgt(obj); - if (WARN_ON(IS_ERR(sgt))) - return PTR_ERR(sgt); - - ret = pm_runtime_get_sync(pfdev->dev); - if (ret < 0) - return ret; + struct io_pgtable_ops *ops = pfdev->mmu->pgtbl_ops; + u64 start_iova = iova; mutex_lock(&pfdev->mmu->lock); @@ -178,18 +164,42 @@ int panfrost_mmu_map(struct panfrost_gem_object *bo) while (len) { size_t pgsize = get_pgsize(iova | paddr, len); - ops->map(ops, iova, paddr, pgsize, IOMMU_WRITE | IOMMU_READ); + ops->map(ops, iova, paddr, pgsize, prot); iova += pgsize; paddr += pgsize; len -= pgsize; } } - mmu_hw_do_operation(pfdev, 0, bo->node.start << PAGE_SHIFT, - bo->node.size << PAGE_SHIFT, AS_COMMAND_FLUSH_PT); + mmu_hw_do_operation(pfdev, 0, start_iova, iova - start_iova, + AS_COMMAND_FLUSH_PT); mutex_unlock(&pfdev->mmu->lock); + return 0; +} + +int panfrost_mmu_map(struct panfrost_gem_object *bo) +{ + struct drm_gem_object *obj = &bo->base.base; + struct panfrost_device *pfdev = to_panfrost_device(obj->dev); + struct sg_table *sgt; + int ret; + int prot = IOMMU_READ | IOMMU_WRITE; + + if (WARN_ON(bo->is_mapped)) + return 0; + + sgt = drm_gem_shmem_get_pages_sgt(obj); + if (WARN_ON(IS_ERR(sgt))) + return PTR_ERR(sgt); + + ret = pm_runtime_get_sync(pfdev->dev); + if (ret < 0) + return ret; + + mmu_map_sg(pfdev, bo->node.start << PAGE_SHIFT, prot, sgt); + pm_runtime_mark_last_busy(pfdev->dev); pm_runtime_put_autosuspend(pfdev->dev); bo->is_mapped = true; From patchwork Fri Aug 2 19:51:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170450 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223189ile; Fri, 2 Aug 2019 12:52:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMjpTdKCqeRkjW6Gb/QGDfGYke61HpbZn8YCs+WQRiS268inCJ2DZ8kclF3HSjZuFlc0ON X-Received: by 2002:a63:4404:: with SMTP id r4mr123742024pga.245.1564775528237; Fri, 02 Aug 2019 12:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775528; cv=none; d=google.com; s=arc-20160816; b=Qqw7v0ZmEQr2iIRchCOUszd7IO10vdFz1A6xvrBV8AyRkvYu5/BZ5+V1WtjoCpyZ8Y 9KeEsshhdMRzcVVD4qHScFfxwXVPqvk+S0q2SgzJGTf1IYkjLuP6zZqAOh0jlt4wdddn LI7lkGtJjDgq7NRphHObMBzYKRQng9tK64GF0Rk/VdI8wHyTPlL9uMT5jATz9hjIQswj V5fg8m/oa8ONdHPUxSiuX4ZOv5+3T/e0k+EvLxNNccjmow2AzmxH1We98Perg/7XExgD Z05i3rhpxZ8LUKka8WSDf/wrWubVNJdkJ7RXSuf0+9vlR1jUfDVHl+VxLZVXdq7OMFlz 0NWg== 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=2OMkWvWucXvxkrKStU9S2WLgx992rjvei2VlSl6j6Yc=; b=LQfq+y/JmU5IyXD7Fg2IZZ4YbMuQqQqf6VJ83t6gyvImG+Pl3Q/xNmoZAng+YluAMl AJT9ywa/NDXRBxrjc0yEmDYE8aO4mTcclQF8OGz7DyG67IHVeEDJ/NFIE45Z3hbAOW6P YymSSAUPy/E5ZXA5YKvczpTr+4wbIXFnPzEUBv2KaTXZNQyC6oJYutXWIckX2X7EOFIg kQ3oE2o1k44N7QchkM5wgBZYCsSNCqxkXM/xx8Wyacj7XWWbHReKgWQPQyvC3m69CvwH 2Zknt04kjufSoIjiwe1ImjbfNIbYFbwnXPsvTFEmGltdfczqSvotcPkbLA7hexfn6WCe I1+A== 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=NONE sp=NONE dis=NONE) header.from=kernel.org 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 i21si28189557pgj.37.2019.08.02.12.52.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:08 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0AAD96EDD3; Fri, 2 Aug 2019 19:52:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41B266ED77 for ; Fri, 2 Aug 2019 19:52:00 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id h6so29497737iom.7 for ; Fri, 02 Aug 2019 12:52:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0B7YsWfa7Gubc5+AucI1/YcPyBYyFfn+BChBWv9hC7o=; b=Duccol9b5qpWaWNe/O573sHH6zYAdV1pkLNDsKlGv3LTbLP8RpuzDLNGcuyxWM0vZt 1qbbxyWrzfBy2ewDV31ARXzHQFuDWU6Mtvn2mLBIJ4xOf9q8Hk9vs1RCz+R4LIuEmYhi q3aAdQ5+P4DaDbm1It41pSHbRXZqZRC/EBrc3+lv/BsAxE56lE2wI0RvdhPPO54Ih7QS 52PJ9bw4vKgzacxzZ86N7WtuA4OF52CqufBcQZwZOia+5wFoZIOf99ZQ1OYfkP6cnjQd JLQoO7rnsgk4yRDYphyUWlFLCEbLfM5ZK70WNmCDJ69Okc7dYLKIEhS6Kx2Pmgd/loUc ztKQ== X-Gm-Message-State: APjAAAVnEjB+IszK8Ybbzv+EP7om8pl94jvesnERrvB1mdEZVD58TJaF IT9Vl7Xh7eiLTEGRMFDUd7f3U60= X-Received: by 2002:a6b:ce19:: with SMTP id p25mr14425741iob.201.1564775518805; Fri, 02 Aug 2019 12:51:58 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:58 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 5/8] drm/panfrost: Add a no execute flag for BO allocations Date: Fri, 2 Aug 2019 13:51:47 -0600 Message-Id: <20190802195150.23207-6-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Executable buffers have an alignment restriction that they can't cross 16MB boundary as the GPU program counter is 24-bits. This restriction is currently not handled and we just get lucky. As current userspace assumes all BOs are executable, that has to remain the default. So add a new PANFROST_BO_NOEXEC flag to allow userspace to indicate which BOs are not executable. There is also a restriction that executable buffers cannot start or end on a 4GB boundary. This is mostly avoided as there is only 4GB of space currently and the beginning is already blocked out for NULL ptr detection. Add support to handle this restriction fully regardless of the current constraints. For existing userspace, all created BOs remain executable, but the GPU VA alignment will be increased to the size of the BO. This shouldn't matter as there is plenty of GPU VA space. Cc: Tomeu Vizoso Cc: Boris Brezillon Cc: Robin Murphy Reviewed-by: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring --- drivers/gpu/drm/panfrost/panfrost_drv.c | 30 ++++++++++++++++++++++++- drivers/gpu/drm/panfrost/panfrost_gem.c | 18 +++++++++++++-- drivers/gpu/drm/panfrost/panfrost_gem.h | 3 ++- drivers/gpu/drm/panfrost/panfrost_mmu.c | 3 +++ include/uapi/drm/panfrost_drm.h | 2 ++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index d354b92964d5..7ebd82d8d570 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -49,7 +49,8 @@ static int panfrost_ioctl_create_bo(struct drm_device *dev, void *data, struct panfrost_gem_object *bo; struct drm_panfrost_create_bo *args = data; - if (!args->size || args->flags || args->pad) + if (!args->size || args->pad || + (args->flags & ~PANFROST_BO_NOEXEC)) return -EINVAL; bo = panfrost_gem_create_with_handle(file, dev, args->size, args->flags, @@ -367,6 +368,32 @@ static struct drm_driver panfrost_drm_driver = { .gem_prime_mmap = drm_gem_prime_mmap, }; +#define PFN_4G (SZ_4G >> PAGE_SHIFT) +#define PFN_4G_MASK (PFN_4G - 1) +#define PFN_16M (SZ_16M >> PAGE_SHIFT) + +static void panfrost_drm_mm_color_adjust(const struct drm_mm_node *node, + unsigned long color, + u64 *start, u64 *end) +{ + /* Executable buffers can't start or end on a 4GB boundary */ + if (!(color & PANFROST_BO_NOEXEC)) { + u64 next_seg; + + if ((*start & PFN_4G_MASK) == 0) + (*start)++; + + if ((*end & PFN_4G_MASK) == 0) + (*end)--; + + next_seg = ALIGN(*start, PFN_4G); + if (next_seg - *start <= PFN_16M) + *start = next_seg + 1; + + *end = min(*end, ALIGN(*start, PFN_4G) - 1); + } +} + static int panfrost_probe(struct platform_device *pdev) { struct panfrost_device *pfdev; @@ -394,6 +421,7 @@ static int panfrost_probe(struct platform_device *pdev) /* 4G enough for now. can be 48-bit */ drm_mm_init(&pfdev->mm, SZ_32M >> PAGE_SHIFT, (SZ_4G - SZ_32M) >> PAGE_SHIFT); + pfdev->mm.color_adjust = panfrost_drm_mm_color_adjust; pm_runtime_use_autosuspend(pfdev->dev); pm_runtime_set_autosuspend_delay(pfdev->dev, 50); /* ~3 frames */ diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c index df70dcf3cb2f..63731f6c5223 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -66,11 +66,23 @@ static int panfrost_gem_map(struct panfrost_device *pfdev, struct panfrost_gem_o { int ret; size_t size = bo->base.base.size; - u64 align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0; + u64 align; + unsigned long color = bo->noexec ? PANFROST_BO_NOEXEC : 0; + + /* + * Executable buffers cannot cross a 16MB boundary as the program + * counter is 24-bits. We assume executable buffers will be less than + * 16MB and aligning executable buffers to their size will avoid + * crossing a 16MB boundary. + */ + if (!bo->noexec) + align = size >> PAGE_SHIFT; + else + align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0; spin_lock(&pfdev->mm_lock); ret = drm_mm_insert_node_generic(&pfdev->mm, &bo->node, - size >> PAGE_SHIFT, align, 0, 0); + size >> PAGE_SHIFT, align, color, 0); spin_unlock(&pfdev->mm_lock); if (ret) return ret; @@ -96,6 +108,7 @@ panfrost_gem_create_with_handle(struct drm_file *file_priv, return ERR_CAST(shmem); bo = to_panfrost_bo(&shmem->base); + bo->noexec = !!(flags & PANFROST_BO_NOEXEC); ret = panfrost_gem_map(pfdev, bo); if (ret) @@ -123,6 +136,7 @@ panfrost_gem_prime_import_sg_table(struct drm_device *dev, return ERR_CAST(obj); pobj = to_panfrost_bo(obj); + pobj->noexec = true; ret = panfrost_gem_map(pfdev, pobj); if (ret) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h index ce065270720b..132f02399b7b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.h +++ b/drivers/gpu/drm/panfrost/panfrost_gem.h @@ -11,7 +11,8 @@ struct panfrost_gem_object { struct drm_gem_shmem_object base; struct drm_mm_node node; - bool is_mapped; + bool is_mapped :1; + bool noexec :1; }; static inline diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index b4ac149b2399..eba6ce785ef0 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -190,6 +190,9 @@ int panfrost_mmu_map(struct panfrost_gem_object *bo) if (WARN_ON(bo->is_mapped)) return 0; + if (bo->noexec) + prot |= IOMMU_NOEXEC; + sgt = drm_gem_shmem_get_pages_sgt(obj); if (WARN_ON(IS_ERR(sgt))) return PTR_ERR(sgt); diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h index b5d370638846..17fb5d200f7a 100644 --- a/include/uapi/drm/panfrost_drm.h +++ b/include/uapi/drm/panfrost_drm.h @@ -82,6 +82,8 @@ struct drm_panfrost_wait_bo { __s64 timeout_ns; /* absolute */ }; +#define PANFROST_BO_NOEXEC 1 + /** * struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs. * From patchwork Fri Aug 2 19:51:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170449 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223170ile; Fri, 2 Aug 2019 12:52:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQOTQnrb2RvSNxUGvEC8k1ZqPbwtKra8fjtiGOh5IUxwAGcZ3mO0TqNLls8AnpTEeRHGt/ X-Received: by 2002:a17:90a:30e4:: with SMTP id h91mr5676914pjb.37.1564775526537; Fri, 02 Aug 2019 12:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775526; cv=none; d=google.com; s=arc-20160816; b=prF/cC4HY85w2Q3jS4BhmDgTY6VPMFPSvOTagUw6SZNDbA3ccklrvDiI4SV96w0WhQ H3XNoZCzjFqLiuGVuQ+2srH7vHcgUhqiO3+T3Wud6SsWT+kvrMuQGTXXsadZhixNfTIm na4oN/9ukgH3Z8zSD1O9goPxbdQHgQ/7cq5pAg5qxWvpkaIc7gpb2y5Zsb1Bua481hYB ZDyUQ8tLIFffeVqbjNvIDQg1LWnA7ij+htz6UBfRzNMbNoqEEMjWch0WSH0j9JKCURhw kJtc79dRR0wkjcRgGoLi+UMmWAZdWofBv0PR4yPU2vgGzPQnEPEb49OrehN0dVZy5kHu 2zjg== 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=K4Fn1u901w0mLvO9WOb9z3aV1FI1MT9IqPNoow5/Cq8=; b=oBjhbq+6B13bWd2SxRVI3vezo+eW7XzCAQKcS3TKNWztj8yfIG0EfDxdXioe7uhYkf Ja7S4kUJN7G8l+0JpjLrRIbM6OzP5PqgiB3uH9NKwGIwn3WbGlqPzgtQmOtQraFupF6w W53Oaa3uTntXdrzGpMHxmS0kMNf/47iHKraaLmIqJMO8r1nTqLjNJPHQmeLqMJYBXGe3 FjKk8c2n60WFsfeBLbBwwFCMLCcs7E7a4/MTjiAj5Oe4AMTiU06/qEN1kBgYTffGLXPC U3qf2JkrNzZeJjjUdDiBrfTmaFc7SVDW0OVfvc5imOMnmCgHMcdHpaQMlnwr5L+2FlAX ZOPw== 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id u15si40276708pfh.213.2019.08.02.12.52.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:06 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F8486EE62; Fri, 2 Aug 2019 19:52:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 27F476EDD3 for ; Fri, 2 Aug 2019 19:52:01 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id z3so13548441iog.0 for ; Fri, 02 Aug 2019 12:52:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bxVSBC926M3SRnMO8CwUdz8aDNatmwoyY19OmNEvvRc=; b=nxA/eKhqAtBLF6MZk2bfRNmHEQ/nDsUhgCKdejQYMOdKlOHPNxWiT2g/e4fxo0GLSE smZD2LFGEKkkzXYw2c+IE7xJtwE2Ff5TB3b4BOosCs1IVK2mDsmF9zbjd4IFgv5ofjpT DwsUwdFFjOeOW2pPYFSbxYlwSXaxssWcpC8HbpsqVnACDWd0mid+5wYiL8/flhvdP3ME 6OplG76AHUM3kDPwgEnnXBkeCsB6ys2zNTAlXf//sWmlYluZT/NiLSLwJwwuoNt2rIWD dK5qYYuKLvTP3t5+arJav+xvpvWo4nXS5EWuqGjim9lkVvcbeNI8hP5Co5y5dU2stpoc OAHA== X-Gm-Message-State: APjAAAXS21K+UKg8qr4xaSUaqJivhTFNMXa8++7Qn1QFITkmvqUFbXKN zXg/HjKbAUf+q8xWX2auBxraK6k= X-Received: by 2002:a6b:cd86:: with SMTP id d128mr126555145iog.234.1564775520066; Fri, 02 Aug 2019 12:52:00 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:59 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 6/8] drm/panfrost: Convert MMU IRQ handler to threaded handler Date: Fri, 2 Aug 2019 13:51:48 -0600 Message-Id: <20190802195150.23207-7-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In preparation to handle mapping of page faults, we need the MMU handler to be threaded as code paths take a mutex. As the IRQ may be shared, we can't use the default handler and must disable the MMU interrupts locally. Cc: Tomeu Vizoso Cc: Boris Brezillon Cc: Robin Murphy Cc: Steven Price Cc: Alyssa Rosenzweig Signed-off-by: Rob Herring Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index eba6ce785ef0..7d44328b280f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -300,12 +300,20 @@ static const char *access_type_name(struct panfrost_device *pfdev, static irqreturn_t panfrost_mmu_irq_handler(int irq, void *data) { struct panfrost_device *pfdev = data; - u32 status = mmu_read(pfdev, MMU_INT_STAT); - int i; - if (!status) + if (!mmu_read(pfdev, MMU_INT_STAT)) return IRQ_NONE; + mmu_write(pfdev, MMU_INT_MASK, 0); + return IRQ_WAKE_THREAD; +} + +static irqreturn_t panfrost_mmu_irq_handler_thread(int irq, void *data) +{ + struct panfrost_device *pfdev = data; + u32 status = mmu_read(pfdev, MMU_INT_RAWSTAT); + int i; + dev_err(pfdev->dev, "mmu irq status=%x\n", status); for (i = 0; status; i++) { @@ -350,6 +358,7 @@ static irqreturn_t panfrost_mmu_irq_handler(int irq, void *data) status &= ~mask; } + mmu_write(pfdev, MMU_INT_MASK, ~0); return IRQ_HANDLED; }; @@ -368,8 +377,9 @@ int panfrost_mmu_init(struct panfrost_device *pfdev) if (irq <= 0) return -ENODEV; - err = devm_request_irq(pfdev->dev, irq, panfrost_mmu_irq_handler, - IRQF_SHARED, "mmu", pfdev); + err = devm_request_threaded_irq(pfdev->dev, irq, panfrost_mmu_irq_handler, + panfrost_mmu_irq_handler_thread, + IRQF_SHARED, "mmu", pfdev); if (err) { dev_err(pfdev->dev, "failed to request mmu irq"); From patchwork Fri Aug 2 19:51:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170451 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223216ile; Fri, 2 Aug 2019 12:52:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDItDE9bsYOvDiXY3RGpC7PJmwsQVpk4bUPh46s7C2qVMmniO0vgzqnPaoGgEG91apzAlU X-Received: by 2002:a17:902:b68f:: with SMTP id c15mr134137117pls.104.1564775530221; Fri, 02 Aug 2019 12:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775530; cv=none; d=google.com; s=arc-20160816; b=tti+GtmrA19yN0+pj+LdMahm0krKH0qsVYYeY27AxHwUdF2K/N/u9H9+a0VZkPIM1O Z3XtI7uabnzxJlkQbGfLYo5PyddK3X0gGcAMN2QBYV+41iZK3Fu+ViMAFcSop43WFIfh d8xGfcv/dOwEIpvkiXB4Wr6rq1IKWromFTu+H78o9AcfH/9N523QhdlK6zpM9JcPuEAL HuXeD4wHpH6L8Y4iE9515kHb2o+DhYMyifnfFq/EB1f0rgrn6L2rGVVa74ttmmqCZQei MR2VzpjysuCyRZnn53P9aqMmxIegt8jWBH6V1jFfzKAR+60/LIX+jEFCSfnRIq38X8Mc zgSA== 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=bnGyRK+DdkRlevkIykUvYkgywIDPll1vR9te5Sthqg0=; b=C8oa2SOoBTOVVWzpWI+TG1cI6VcTQdLydr7Ke+Idib3dGjTA617Nm8lyPkfGJBCoMx LxCDiIqZvu8JkLadw5JFnyQ5fwClUnSK5vrbd428TTxyZW0eg6oO/Ci5EX17seVGSY58 477C2MLzE1BC0h82crmP9/wYkHI8R/yna3cpAmtH6/YnJazZRl1j25bSFaNM+/22kgCM hm6iUNrgClYRBKrJHLMi6ulnP9SimzrxRdWdbE5SSYGfMnnPYbn34d1m4Dyyt3ZASFuj ZPZXLKOptIzAqesGI+l7i8fOZbK/EmENfrVOzcNopNFwhSPhL0VIfMQREg75TZTc7Zs9 J9Ww== 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=NONE sp=NONE dis=NONE) header.from=kernel.org 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 v33si23398915pgk.152.2019.08.02.12.52.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:10 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE2BB6EDD5; Fri, 2 Aug 2019 19:52:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80E746EDD5 for ; Fri, 2 Aug 2019 19:52:02 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id j6so34879714ioa.5 for ; Fri, 02 Aug 2019 12:52:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pwIhp2y8f0D+4kEqwpU/HoJmB8e622d9feuXt2Phmd8=; b=A5vpVuk6mkDwvr/NfzVtKztZ38YS9reGZJNoUrc+kh6AhE4QT3R62zYwH3lzdAGP6v 5YIrj0sI9+UXzv1EtzObUjiAbMgjMq+QxKxISqptpE2vnw5NMRC+K/dUasIJLDHZQAsJ 28nW4tKfnENNO6W0TOee5hoAsupMw8JgOcHKRyxbSkqn9ld5Hot4eYifU1D9AjqT6bIV bAIU/3lWpezsQL39rIDXT1B9gA0cITWRf6pdRMgNvJ5abMd0VvgBbjagdqSt+TCAibxs CircdeE4JFReypjEwIGgH6ME4+IMd8ZyMDSkSbDtTCRzU6irKGOCMFBzHYNkYBXK6tg6 m2cg== X-Gm-Message-State: APjAAAVM72/mSE+l7/j+8PEV+zGFAalVaJF0XsfXghgHrPn+aV66RskT 6xEDVUx7vNYgiCoClXwkpigzGkI= X-Received: by 2002:a5d:8747:: with SMTP id k7mr6621802iol.20.1564775521339; Fri, 02 Aug 2019 12:52:01 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.52.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:52:00 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 7/8] drm/panfrost: Add support for GPU heap allocations Date: Fri, 2 Aug 2019 13:51:49 -0600 Message-Id: <20190802195150.23207-8-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The midgard/bifrost GPUs need to allocate GPU heap memory which is allocated on GPU page faults and not pinned in memory. The vendor driver calls this functionality GROW_ON_GPF. This implementation assumes that BOs allocated with the PANFROST_BO_NOEXEC flag are never mmapped or exported. Both of those may actually work, but I'm unsure if there's some interaction there. It would cause the whole object to be pinned in memory which would defeat the point of this. On faults, we map in 2MB at a time in order to utilize huge pages (if enabled). Currently, once we've mapped pages in, they are only unmapped if the BO is freed. Once we add shrinker support, we can unmap pages with the shrinker. Cc: Tomeu Vizoso Cc: Boris Brezillon Cc: Robin Murphy Cc: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/TODO | 2 - drivers/gpu/drm/panfrost/panfrost_drv.c | 11 +- drivers/gpu/drm/panfrost/panfrost_gem.c | 36 ++++++- drivers/gpu/drm/panfrost/panfrost_gem.h | 8 ++ drivers/gpu/drm/panfrost/panfrost_mmu.c | 129 ++++++++++++++++++++++-- include/uapi/drm/panfrost_drm.h | 1 + 6 files changed, 172 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/panfrost/TODO b/drivers/gpu/drm/panfrost/TODO index c2e44add37d8..64129bf73933 100644 --- a/drivers/gpu/drm/panfrost/TODO +++ b/drivers/gpu/drm/panfrost/TODO @@ -14,8 +14,6 @@ The hard part is handling when more address spaces are needed than what the h/w provides. -- Support pinning pages on demand (GPU page faults). - - Support userspace controlled GPU virtual addresses. Needed for Vulkan. (Tomeu) - Support for madvise and a shrinker. diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 7ebd82d8d570..a7126b5f8e5d 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -50,7 +50,12 @@ static int panfrost_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_panfrost_create_bo *args = data; if (!args->size || args->pad || - (args->flags & ~PANFROST_BO_NOEXEC)) + (args->flags & ~(PANFROST_BO_NOEXEC | PANFROST_BO_HEAP))) + return -EINVAL; + + /* Heaps should never be executable */ + if ((args->flags & PANFROST_BO_HEAP) && + !(args->flags & PANFROST_BO_NOEXEC)) return -EINVAL; bo = panfrost_gem_create_with_handle(file, dev, args->size, args->flags, @@ -265,6 +270,10 @@ static int panfrost_ioctl_mmap_bo(struct drm_device *dev, void *data, return -ENOENT; } + /* Don't allow mmapping of heap objects as pages are not pinned. */ + if (to_panfrost_bo(gem_obj)->is_heap) + return -EINVAL; + ret = drm_gem_create_mmap_offset(gem_obj); if (ret == 0) args->offset = drm_vma_node_offset_addr(&gem_obj->vma_node); diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c index 63731f6c5223..f3d5f61714ae 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -27,13 +27,35 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj) drm_mm_remove_node(&bo->node); spin_unlock(&pfdev->mm_lock); + if (bo->sgts) { + int i; + int n_sgt = bo->base.base.size / SZ_2M; + + for (i = 0; i < n_sgt; i++) { + if (bo->sgts[i].sgl) { + dma_unmap_sg(pfdev->dev, bo->sgts[i].sgl, + bo->sgts[i].nents, DMA_BIDIRECTIONAL); + sg_free_table(&bo->sgts[i]); + } + } + kfree(bo->sgts); + } + drm_gem_shmem_free_object(obj); } +static int panfrost_gem_pin(struct drm_gem_object *obj) +{ + if (to_panfrost_bo(obj)->is_heap) + return -EINVAL; + + return drm_gem_shmem_pin(obj); +} + static const struct drm_gem_object_funcs panfrost_gem_funcs = { .free = panfrost_gem_free_object, .print_info = drm_gem_shmem_print_info, - .pin = drm_gem_shmem_pin, + .pin = panfrost_gem_pin, .unpin = drm_gem_shmem_unpin, .get_sg_table = drm_gem_shmem_get_sg_table, .vmap = drm_gem_shmem_vmap, @@ -87,7 +109,10 @@ static int panfrost_gem_map(struct panfrost_device *pfdev, struct panfrost_gem_o if (ret) return ret; - return panfrost_mmu_map(bo); + if (!bo->is_heap) + ret = panfrost_mmu_map(bo); + + return ret; } struct panfrost_gem_object * @@ -101,7 +126,11 @@ panfrost_gem_create_with_handle(struct drm_file *file_priv, struct drm_gem_shmem_object *shmem; struct panfrost_gem_object *bo; - size = roundup(size, PAGE_SIZE); + /* Round up heap allocations to 2MB to keep fault handling simple */ + if (flags & PANFROST_BO_HEAP) + size = roundup(size, SZ_2M); + else + size = roundup(size, PAGE_SIZE); shmem = drm_gem_shmem_create_with_handle(file_priv, dev, size, handle); if (IS_ERR(shmem)) @@ -109,6 +138,7 @@ panfrost_gem_create_with_handle(struct drm_file *file_priv, bo = to_panfrost_bo(&shmem->base); bo->noexec = !!(flags & PANFROST_BO_NOEXEC); + bo->is_heap = !!(flags & PANFROST_BO_HEAP); ret = panfrost_gem_map(pfdev, bo); if (ret) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h index 132f02399b7b..b628c9b67784 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.h +++ b/drivers/gpu/drm/panfrost/panfrost_gem.h @@ -9,10 +9,12 @@ struct panfrost_gem_object { struct drm_gem_shmem_object base; + struct sg_table *sgts; struct drm_mm_node node; bool is_mapped :1; bool noexec :1; + bool is_heap :1; }; static inline @@ -21,6 +23,12 @@ struct panfrost_gem_object *to_panfrost_bo(struct drm_gem_object *obj) return container_of(to_drm_gem_shmem_obj(obj), struct panfrost_gem_object, base); } +static inline +struct panfrost_gem_object *drm_mm_node_to_panfrost_bo(struct drm_mm_node *node) +{ + return container_of(node, struct panfrost_gem_object, node); +} + struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t size); struct panfrost_gem_object * diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 7d44328b280f..aa83bf46360b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -2,6 +2,7 @@ /* Copyright 2019 Linaro, Ltd, Rob Herring */ #include #include +#include #include #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include #include "panfrost_device.h" @@ -235,12 +237,12 @@ void panfrost_mmu_unmap(struct panfrost_gem_object *bo) size_t unmapped_page; size_t pgsize = get_pgsize(iova, len - unmapped_len); - unmapped_page = ops->unmap(ops, iova, pgsize); - if (!unmapped_page) - break; - - iova += unmapped_page; - unmapped_len += unmapped_page; + if (ops->iova_to_phys(ops, iova)) { + unmapped_page = ops->unmap(ops, iova, pgsize); + WARN_ON(unmapped_page != pgsize); + } + iova += pgsize; + unmapped_len += pgsize; } mmu_hw_do_operation(pfdev, 0, bo->node.start << PAGE_SHIFT, @@ -276,6 +278,105 @@ static const struct iommu_gather_ops mmu_tlb_ops = { .tlb_sync = mmu_tlb_sync_context, }; +static struct drm_mm_node *addr_to_drm_mm_node(struct panfrost_device *pfdev, int as, u64 addr) +{ + struct drm_mm_node *node; + u64 offset = addr >> PAGE_SHIFT; + + drm_mm_for_each_node(node, &pfdev->mm) { + if (offset >= node->start && offset < (node->start + node->size)) + return node; + } + return NULL; +} + +#define NUM_FAULT_PAGES (SZ_2M / PAGE_SIZE) + +int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, u64 addr) +{ + int ret, i; + struct drm_mm_node *node; + struct panfrost_gem_object *bo; + struct address_space *mapping; + pgoff_t page_offset; + struct sg_table *sgt; + struct page **pages; + + node = addr_to_drm_mm_node(pfdev, as, addr); + if (!node) + return -ENOENT; + + bo = drm_mm_node_to_panfrost_bo(node); + if (!bo->is_heap) { + dev_WARN(pfdev->dev, "matching BO is not heap type (GPU VA = %llx)", + node->start << PAGE_SHIFT); + return -EINVAL; + } + /* Assume 2MB alignment and size multiple */ + addr &= ~((u64)SZ_2M - 1); + page_offset = addr >> PAGE_SHIFT; + page_offset -= node->start; + + mutex_lock(&bo->base.pages_lock); + + if (!bo->base.pages) { + bo->sgts = kvmalloc_array(bo->base.base.size / SZ_2M, + sizeof(struct sg_table), GFP_KERNEL | __GFP_ZERO); + if (!bo->sgts) + return -ENOMEM; + + pages = kvmalloc_array(bo->base.base.size >> PAGE_SHIFT, + sizeof(struct page *), GFP_KERNEL | __GFP_ZERO); + if (!pages) { + kfree(bo->sgts); + bo->sgts = NULL; + return -ENOMEM; + } + bo->base.pages = pages; + bo->base.pages_use_count = 1; + } else + pages = bo->base.pages; + + mapping = bo->base.base.filp->f_mapping; + mapping_set_unevictable(mapping); + + for (i = page_offset; i < page_offset + NUM_FAULT_PAGES; i++) { + pages[i] = shmem_read_mapping_page(mapping, i); + if (IS_ERR(pages[i])) { + mutex_unlock(&bo->base.pages_lock); + ret = PTR_ERR(pages[i]); + goto err_pages; + } + } + + mutex_unlock(&bo->base.pages_lock); + + sgt = &bo->sgts[page_offset / (SZ_2M / PAGE_SIZE)]; + ret = sg_alloc_table_from_pages(sgt, pages + page_offset, + NUM_FAULT_PAGES, 0, SZ_2M, GFP_KERNEL); + if (ret) + goto err_pages; + + if (!dma_map_sg(pfdev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL)) { + ret = -EINVAL; + goto err_map; + } + + mmu_map_sg(pfdev, addr, IOMMU_WRITE | IOMMU_READ | IOMMU_NOEXEC, sgt); + + bo->is_mapped = true; + + dev_dbg(pfdev->dev, "mapped page fault @ %llx", addr); + + return 0; + +err_map: + sg_free_table(sgt); +err_pages: + drm_gem_shmem_put_pages(&bo->base); + return ret; +} + static const char *access_type_name(struct panfrost_device *pfdev, u32 fault_status) { @@ -312,9 +413,7 @@ static irqreturn_t panfrost_mmu_irq_handler_thread(int irq, void *data) { struct panfrost_device *pfdev = data; u32 status = mmu_read(pfdev, MMU_INT_RAWSTAT); - int i; - - dev_err(pfdev->dev, "mmu irq status=%x\n", status); + int i, ret; for (i = 0; status; i++) { u32 mask = BIT(i) | BIT(i + 16); @@ -336,6 +435,18 @@ static irqreturn_t panfrost_mmu_irq_handler_thread(int irq, void *data) access_type = (fault_status >> 8) & 0x3; source_id = (fault_status >> 16); + /* Page fault only */ + if ((status & mask) == BIT(i)) { + WARN_ON(exception_type < 0xC1 || exception_type > 0xC4); + + ret = panfrost_mmu_map_fault_addr(pfdev, i, addr); + if (!ret) { + mmu_write(pfdev, MMU_INT_CLEAR, BIT(i)); + status &= ~mask; + continue; + } + } + /* terminal fault, print info about the fault */ dev_err(pfdev->dev, "Unhandled Page fault in AS%d at VA 0x%016llX\n" diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h index 17fb5d200f7a..9150dd75aad8 100644 --- a/include/uapi/drm/panfrost_drm.h +++ b/include/uapi/drm/panfrost_drm.h @@ -83,6 +83,7 @@ struct drm_panfrost_wait_bo { }; #define PANFROST_BO_NOEXEC 1 +#define PANFROST_BO_HEAP 2 /** * struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs. From patchwork Fri Aug 2 19:51:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170452 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223248ile; Fri, 2 Aug 2019 12:52:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEfPR/cM0PU5K9IExH2sHgASCRxCBQ7qDJAtl3bGgUdiMZ4N1YWNCpfIVWl4Vy9NDyGNgq X-Received: by 2002:a17:902:2aa9:: with SMTP id j38mr126683894plb.206.1564775531735; Fri, 02 Aug 2019 12:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775531; cv=none; d=google.com; s=arc-20160816; b=tnXflKHODQgjxcSc3YQxFRHEy+KgF7IJ+MSFGryFY5qnAIUOJkPcdQK98zfWKD0c3S 1snovKh8q/8aQ3m0DIy5y1txd+xeTx6VN9hCgRQTwOdUxcUjeW4P7UOlLAO/6K78bhl5 J0zlfMT7LuhpPy3TAq39vCtxQUCtHfzdLE+SVcpF2YFf2176v7wZfN4yGq8j1Kr8dyp3 7f2YlfKbsRqU9TEaT4b8A9tKaKvGxcgq4wVCYGlIPjvlcLsZ1DI0m01iz1iFLbxBNXq7 ICCh0Jlb63ejA50MKODJBg+DPWSNtkAqUrSd6YwK0wCUEJ45En9y6hDn4Ts4opq6zIV4 t7Kg== 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=7HLW8bLPX6epf1rkFzhzx/ybAo1dldziG1nGpgDsAO4=; b=jbLvPVLnP/xrL1kfTP3D8S/KhvS4//cv7yimVUHr6v/GzcFz2n9i0JKwOtb+UEMjF0 3DqB6mMWtihKk1NHkQLhgATFjSGsf2Ye2Y8RxKuOyNscW4c3OCDLyxCiSfkpX4+lcwtx ZfAoSqny8ITDGN5Z5EAyMReF6GBz2AhKmSOodHHyqjlS1bHmVRMgfxKizxvm4Rkmh6a6 XPOqAOgPrtxOmO6WljDyGLfTMcST2BWrjmM/Qtdh6Q1GWkRNCmi89MbiTVSARMTZON7o +N3oKe3x3kBVqdiCyEZwdSg7pcitjTXUoA0LS7om2GdyOkCcI2vQiDByhTBYNRx0cbcC cmIw== 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id i3si34901957plb.205.2019.08.02.12.52.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:11 -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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 730C26EE97; Fri, 2 Aug 2019 19:52:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id D65906EDD3 for ; Fri, 2 Aug 2019 19:52:03 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id s7so154531306iob.11 for ; Fri, 02 Aug 2019 12:52:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=53jqDknmz3cAFGkT4uctiKFipCfEAS9AmkKGScMrxFc=; b=WJB6onx6f+6LKXJl467Gq7qIF7z2c6OYLjQfAGCZ3EqshSj1IKeby4ZgAbMCxWxthG ojEUu/ZB29ipo4Wh2RH7RO9uqnYWmPxnxpZC28QhReusEP77tAfZo71SYr0sKYkf6aYt 87Xveq9ULbtwINFD81XTtZva+vcc6uS65KXdfwAAfjbUT4ZGoSFkTMmJ73fIF4ec19CA m/CwVBA5xRclQZTA385JF8NKr1dwg7HbQUy5Ol6+0ze3mDiXuuosWvoJhB9Li3YtgjEz FQmx6h0ePlC/ke4kBFVG9fFNXpriq9rCPvW6YejfdaHnbi1dVpaHHULQVV2qXjgeFj3Z B7tA== X-Gm-Message-State: APjAAAWvO/rJyDKUTKtFrpLlD/7JvTDFzx+TRCtI+x+kp8YCz/FcfSOd w1ut9wxREMJbZdW/pFzPhsowJ6A= X-Received: by 2002:a02:3f0a:: with SMTP id d10mr67375634jaa.23.1564775522554; Fri, 02 Aug 2019 12:52:02 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.52.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:52:02 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 8/8] drm/panfrost: Bump driver version to 1.1 Date: Fri, 2 Aug 2019 13:51:50 -0600 Message-Id: <20190802195150.23207-9-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 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: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Increment the driver version to expose the new BO allocation flags. Cc: Tomeu Vizoso Cc: Boris Brezillon Cc: Robin Murphy Cc: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring --- drivers/gpu/drm/panfrost/panfrost_drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index a7126b5f8e5d..ecdbe2c9fd67 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -357,6 +357,11 @@ static const struct drm_ioctl_desc panfrost_drm_driver_ioctls[] = { DEFINE_DRM_GEM_SHMEM_FOPS(panfrost_drm_driver_fops); +/* + * Panfrost driver version: + * - 1.0 - initial interface + * - 1.1 - adds HEAP and NOEXEC flags for CREATE_BO + */ static struct drm_driver panfrost_drm_driver = { .driver_features = DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ, .open = panfrost_open, @@ -368,7 +373,7 @@ static struct drm_driver panfrost_drm_driver = { .desc = "panfrost DRM", .date = "20180908", .major = 1, - .minor = 0, + .minor = 1, .gem_create_object = panfrost_gem_create_object, .prime_handle_to_fd = drm_gem_prime_handle_to_fd,