Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4161978iog; Tue, 21 Jun 2022 13:25:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tW9HZHMsIJlayH6WrMgk0LIKmHJlD5n4jXKSUgqxb5FHZKaRdxyYNJaIoUwrT66+CXo8vu X-Received: by 2002:a17:907:2d28:b0:722:e1d9:529 with SMTP id gs40-20020a1709072d2800b00722e1d90529mr5532876ejc.464.1655843154923; Tue, 21 Jun 2022 13:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655843154; cv=none; d=google.com; s=arc-20160816; b=NdlCRprPpdKp/328PkC7N+U3neUjl8iDorC5pi4JYakGpHRejAs5/UqMtUhqv7r+1y VLYYyakOuIGd95hEiZ1kLSHrR3LQKlS+dRgVvzudXfqrVcMoBsd8KjjJG+IFV4mha8Ec ekKSSjAm3pvSOAAAWZd+U6DGh/6MBH6UXFbqbYScZB0YCtMHyny1gRSy7pdhvqZoijfy QXdgQ3dAszUdEMcrzI4YJL4cx85yaRjq9eu+tS16NliyBTGBhx0XFfQb6qDjK0b+eu7b WuzK2wOtj72ZbDeNoWqLIY8DPHEew9ldcGubT5z8hyKz/ZoAadiFhyH8ONwcE06YKBUG ePvA== 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=ITV+N+0zKejsc3U/xp1Kz9EkmLM2/I64DUATFR3S+dY=; b=b7hV+UydPuqnVWsPwvYzdrcwgJTByC9CwkXoC6qQ+zc/5pdFq7NZ13mXamDYjOSxdv Xa8b7UEpCON3DqDqp56JDyVYfoHmXYxMwVPGHJYCaYfYiA5gQmqvkVUeew5gJ2gIKYUR xmFDqpwLgKH5lhpKC6Trf1+QD8FliSK5M615AhsDENVDBG6+NGqt/tBuWMiMqGGVQ/o+ 0789PBh4u2xs21qv3H5BkswslDt7OdbhtvgPYqRhwCAV1JtMM16RQbmQQ5E9f2NcLYSE M5unt0yK0sVIyUX74Quu6kKr6DM5p0O3p26xez6ZV1NhgvPsiEMDk9qp4D/E3yuctsQ7 AksA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i3Z+NXjl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a170906795100b00718bdf7794esi2200687ejo.487.2022.06.21.13.25.29; Tue, 21 Jun 2022 13:25:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i3Z+NXjl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354229AbiFUUBp (ORCPT + 99 others); Tue, 21 Jun 2022 16:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353669AbiFUUB1 (ORCPT ); Tue, 21 Jun 2022 16:01:27 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 867652D1E5 for ; Tue, 21 Jun 2022 13:01:20 -0700 (PDT) Received: from hermes-devbox.fritz.box (82-71-8-225.dsl.in-addr.zen.co.uk [82.71.8.225]) (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: bbeckett) by madras.collabora.co.uk (Postfix) with ESMTPSA id 9FFC4660188E; Tue, 21 Jun 2022 21:01:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655841677; bh=xMYv7v3aHxlEQIE2QtkE00E2gW9W0dS8yiKhilZWusw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i3Z+NXjl66eav0Ee/FimPffiTtZrKh7gRzLbltR+tYrKQ+iO/PhAThssq+rjUnQ7R 8x6SCb3XrwCD4YU25z799eE2DDLhN48/VkqRN3XUn6dD4qntjYG0UaLPFdFKSQAxYn LggEmd06PalHuAZud/341IYUCXuume05znANTWaLuFGe3OHRMZwqQV03sebJIko8lt ElyM8gPuSl7d6UrFPuLOa4rZjW6MAj5Vev9LGW3/+FZ74YKTh7E91sNYrauBttPIxI rtdOcqLDtkvy7p+77IFBlGtoH7O64EGXCDdwmmPc/S9hIERChrbB3F9mm4MVM++Fux fwWPnuf7ekkFQ== From: Robert Beckett To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: kernel@collabora.com, Robert Beckett , Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , linux-kernel@vger.kernel.org Subject: [PATCH v8 08/10] drm/i915: allow memory region creators to alloc and free the region Date: Tue, 21 Jun 2022 20:00:56 +0000 Message-Id: <20220621200058.3536182-9-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621200058.3536182-1-bob.beckett@collabora.com> References: <20220621200058.3536182-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org add callbacks for alloc and free. this allows region creators to allocate any extra storage they may require. Signed-off-by: Robert Beckett --- drivers/gpu/drm/i915/intel_memory_region.c | 16 +++++++++++++--- drivers/gpu/drm/i915/intel_memory_region.h | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_memory_region.c b/drivers/gpu/drm/i915/intel_memory_region.c index e38d2db1c3e3..3da07a712f90 100644 --- a/drivers/gpu/drm/i915/intel_memory_region.c +++ b/drivers/gpu/drm/i915/intel_memory_region.c @@ -231,7 +231,10 @@ intel_memory_region_create(struct drm_i915_private *i915, struct intel_memory_region *mem; int err; - mem = kzalloc(sizeof(*mem), GFP_KERNEL); + if (ops->alloc) + mem = ops->alloc(); + else + mem = kzalloc(sizeof(*mem), GFP_KERNEL); if (!mem) return ERR_PTR(-ENOMEM); @@ -265,7 +268,10 @@ intel_memory_region_create(struct drm_i915_private *i915, if (mem->ops->release) mem->ops->release(mem); err_free: - kfree(mem); + if (mem->ops->free) + mem->ops->free(mem); + else + kfree(mem); return ERR_PTR(err); } @@ -288,7 +294,11 @@ void intel_memory_region_destroy(struct intel_memory_region *mem) GEM_WARN_ON(!list_empty_careful(&mem->objects.list)); mutex_destroy(&mem->objects.lock); - if (!ret) + if (ret) + return; + if (mem->ops->free) + mem->ops->free(mem); + else kfree(mem); } diff --git a/drivers/gpu/drm/i915/intel_memory_region.h b/drivers/gpu/drm/i915/intel_memory_region.h index 3d8378c1b447..048955b5429f 100644 --- a/drivers/gpu/drm/i915/intel_memory_region.h +++ b/drivers/gpu/drm/i915/intel_memory_region.h @@ -61,6 +61,8 @@ struct intel_memory_region_ops { resource_size_t size, resource_size_t page_size, unsigned int flags); + struct intel_memory_region *(*alloc)(void); + void (*free)(struct intel_memory_region *mem); }; struct intel_memory_region { -- 2.25.1