Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4338105rdb; Thu, 14 Sep 2023 21:31:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFf7cw7VJ/4JH1FiU6KvM7CWdBtlmBYKSvtAd6/A0AkSxundOOnX5OetsGWvHYhvQeYWaUz X-Received: by 2002:a54:458f:0:b0:3a4:2545:1cec with SMTP id z15-20020a54458f000000b003a425451cecmr684287oib.38.1694752298974; Thu, 14 Sep 2023 21:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694752298; cv=none; d=google.com; s=arc-20160816; b=FTcVsL/tQTCceAR9nRm9y8dT4qo4oA0Ipq+qjVgxbCPhGBRmrtu32jq3xXln1QZcEF 6Beg98UFzSF1McHrv5AVDXLJk528gyl45VCyGJQw6AHnj+eHSnWz0+hnM89VNnXdD/82 kVyXmsQTK+iOpfJ0cxly6KXt6TrKKOlfawUOZwhnF0PTmUsnOklmhQLCk+W5qIQWDm2r vBU28IpIkzF5KmKughWjmcIrHzt1YTUsHOtOICFxUECndVkTiYLLirkI4oUmSOeoV8ul nAosUUQkxETgEPz/KrAIUmBt8nhmqVEHUXKmTRomji3Vzz7lAxYNbaRri2Kg9Os9iREC 2hkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=91sRC8xUKBw0304GCh1nlixOLi8jNDRqan6E8v3BjXU=; fh=J6jIr4zQ7C+2dedjt84bZIf7pTpHxTiA88jNoeHaVQc=; b=bFLBLfwvnfWHivglmm8NQ04M2txxI7ArSZFDeR2pagfXOBu1/cXYKfv51CWRrJafhk dtVED+tSoitAtLUWJ4njtF1snGfwB99wz8kjRnPU1DEmrRA0W9BPeNvruOi3zLHV1wGf 5SYbwoR1zBz0qOpwBhgCTnjsf2kv+lskkyQ0gh3OJ+eEKfNJ1wnCs+7cKCF+RbFNuri2 arwWmupWRTLQMLgNBmJSUAz9G5MfGo3GCA/9MpvJWBOCGL0wiVTcbMk3j/W3PnMa2dky wIR1qiHJqwyTHq1UXHtRDntLOnUnZIZeiiCIk53jpANwAjr/veJxKvKkiVJew2Fus4fa X+UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZRFDvW8w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q21-20020a056a00085500b0068fe7db970csi2834398pfk.47.2023.09.14.21.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 21:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZRFDvW8w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9F45F8315D4C; Thu, 14 Sep 2023 15:40:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbjINWjz (ORCPT + 99 others); Thu, 14 Sep 2023 18:39:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbjINWjp (ORCPT ); Thu, 14 Sep 2023 18:39:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 333D11FCE; Thu, 14 Sep 2023 15:39:41 -0700 (PDT) Received: from localhost.localdomain (unknown [IPv6:2a02:8010:65b5:0:1ac0:4dff:feee:236a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: alarumbe) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0C4276607355; Thu, 14 Sep 2023 23:39:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694731178; bh=xCX3VeUn+fXJ2KHECRcv5IOFpPiIUTDrz2jnYGUGtK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZRFDvW8wEBs5KxplnBa0TQInGL1oDmZ67sSN2hI3f1YUSRG1jUGn0fBIJFi3nGzsO hTdtWm9Z3ASW9B2t9M5rb3yH/6uNG8r4swByqZDtc4Bd7SVUOyecUxnEOVkpzCSlYr CX+DT55+VpRhGWWlCUimwQf8SyhaT0NEWHaKSazoEaSV4qDMjIDVJjgmwgkh3V66oA fBzK0ZimfIJyKi9JXuy+V1M6naYzV+XA1tQJORaBrRfAxtrLPk8xa+Oxf2svk1eK/1 n737Eu58gpndg8GYqHh+L8N+oIPcrMb2Z8W+hKcR7glK8FqW4XIiPuIxDILkFNZ8qJ Rh0KhJFW0a01g== From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, marijn.suijten@somainline.org, robh@kernel.org, steven.price@arm.com Cc: adrian.larumbe@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, healych@amazon.com, kernel@collabora.com, Boris Brezillon Subject: [PATCH v5 5/6] drm/panfrost: Implement generic DRM object RSS reporting function Date: Thu, 14 Sep 2023 23:38:43 +0100 Message-ID: <20230914223928.2374933-6-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914223928.2374933-1-adrian.larumbe@collabora.com> References: <20230914223928.2374933-1-adrian.larumbe@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 15:40:02 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email BO's RSS is updated every time new pages are allocated on demand and mapped for the object at GPU page fault's IRQ handler, but only for heap buffers. The reason this is unnecessary for non-heap buffers is that they are mapped onto the GPU's VA space and backed by physical memory in their entirety at BO creation time. This calculation is unnecessary for imported PRIME objects, since heap buffers cannot be exported by our driver, and the actual BO RSS size is the one reported in its attached dmabuf structure. Signed-off-by: Adrián Larumbe Reviewed-by: Boris Brezillon --- drivers/gpu/drm/panfrost/panfrost_gem.c | 15 +++++++++++++++ drivers/gpu/drm/panfrost/panfrost_gem.h | 5 +++++ drivers/gpu/drm/panfrost/panfrost_mmu.c | 1 + 3 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c index 7d8f83d20539..4365434b48db 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -208,6 +208,20 @@ static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_object *obj return res; } +static size_t panfrost_gem_rss(struct drm_gem_object *obj) +{ + struct panfrost_gem_object *bo = to_panfrost_bo(obj); + + if (bo->is_heap) { + return bo->heap_rss_size; + } else if (bo->base.pages) { + WARN_ON(bo->heap_rss_size); + return bo->base.base.size; + } else { + return 0; + } +} + static const struct drm_gem_object_funcs panfrost_gem_funcs = { .free = panfrost_gem_free_object, .open = panfrost_gem_open, @@ -220,6 +234,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = { .vunmap = drm_gem_shmem_object_vunmap, .mmap = drm_gem_shmem_object_mmap, .status = panfrost_gem_status, + .rss = panfrost_gem_rss, .vm_ops = &drm_gem_shmem_vm_ops, }; diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h index ad2877eeeccd..13c0a8149c3a 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.h +++ b/drivers/gpu/drm/panfrost/panfrost_gem.h @@ -36,6 +36,11 @@ struct panfrost_gem_object { */ atomic_t gpu_usecount; + /* + * Object chunk size currently mapped onto physical memory + */ + size_t heap_rss_size; + bool noexec :1; bool is_heap :1; }; diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index d54d4e7b2195..7b1490cdaa48 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -522,6 +522,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, IOMMU_WRITE | IOMMU_READ | IOMMU_NOEXEC, sgt); bomapping->active = true; + bo->heap_rss_size += SZ_2; dev_dbg(pfdev->dev, "mapped page fault @ AS%d %llx", as, addr); -- 2.42.0