Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3557220pxb; Mon, 24 Jan 2022 12:09:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEJbpTBwBXt5P/jAk+PFhPbe/1LKSdjYuzrFriZlzfFOSRyaP+kxMoGDw9FWZOHRk7ms0G X-Received: by 2002:a17:90a:6401:: with SMTP id g1mr3468272pjj.218.1643054979626; Mon, 24 Jan 2022 12:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054979; cv=none; d=google.com; s=arc-20160816; b=huuGSoGRGG3J18s6wK4VmBh89yY+E5x9aiBCR74Y00+j1eNuXO1Iiq5kgtzlxdAoJy HuAbgwxa0Utzr49Q4lkMlp0iDuwXduTG0A3Ev83e5gvFFbgP1Pn2WmyKLLU0dKr4tys3 W0anbI7FwzhTjvmc8c6Ept8L5KyBlS9L7ZssOwZZK+/4j43Zk7rQDGQSQ5HJMhRrIQfg 1hV1U4E1I/MR8jbn3SMO9N043j6LqEp7B1AvT8nWeS4hpWbXQFUSZPC73RaV51dm5AiB JLUpOQTVAMYOMzzFN/9gUM8niDNGg5wgcfFObdZcWHN4kqlFs2W9gWuWlbYTtCLmNVkm q1VQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GTb3PTcqTbCU1j5hqSTI57pp7Gr4WS4s1iLdsGg53Uk=; b=HjRxS+IhMSs7KXncwFvQT2R6Jo1EFCWejmBmUtpk0tdga5bmWj23T7WErtSt8Pzeq+ C3X7TE6eLrvvCdW8SPRuGzQjeOAYaK2To8KJYahGjndIDRv8NQmVnoA4tNywTv0b1RwZ xPDZlR4uaEUDpNpzpE4sJIpu0+WyZ29YHAEddyw4znxxElO88swHxnrrJLwUPn9RpPyk fjS7vsAYYJdT1GVgrte4lbXkD7GZJoBeqy5Pj6beb50WWXeRunMQ49VnFiYImJv5u/SQ P2vk04XyNP0PuZNXD9QE1HzF1leeSmsx6XYz23mu4OQYlX+rDeifGobklZps4OSF+OTW z2QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DWpuKXSf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si3225071pli.286.2022.01.24.12.09.26; Mon, 24 Jan 2022 12:09:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DWpuKXSf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344490AbiAXTIa (ORCPT + 99 others); Mon, 24 Jan 2022 14:08:30 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:59026 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236937AbiAXTCJ (ORCPT ); Mon, 24 Jan 2022 14:02:09 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E0912B81215; Mon, 24 Jan 2022 19:02:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0089BC340E5; Mon, 24 Jan 2022 19:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050923; bh=peYOOlMTmm+OyUGHt8OuEe9VzQ3EpRYmy3uRyqu9rOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DWpuKXSfr/zvOv7+w+e6zyTRDQPMEVsfzK+RfHLOHiiTHnVxwZlkhd4FjTldcGO5C 6qxpYXJ+sjJSmln4IP6SSTvDYRTuXRRrPgDZ/QakDvBYxGyR2rjcyrRCk+HGpc6iwe UkvF6duSfqcrPoVtkj8wrnEsMBW1N/cCwsL9Zb90= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Dave Airlie , Ben Hutchings Subject: [PATCH 4.9 148/157] drm/ttm/nouveau: dont call tt destroy callback on alloc failure. Date: Mon, 24 Jan 2022 19:43:58 +0100 Message-Id: <20220124183937.461801402@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Dave Airlie commit 5de5b6ecf97a021f29403aa272cb4e03318ef586 upstream. This is confusing, and from my reading of all the drivers only nouveau got this right. Just make the API act under driver control of it's own allocation failing, and don't call destroy, if the page table fails to create there is nothing to cleanup here. (I'm willing to believe I've missed something here, so please review deeply). Reviewed-by: Christian König Signed-off-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/20200728041736.20689-1-airlied@gmail.com [bwh: Backported to 4.14: - Drop change in ttm_sg_tt_init() - Adjust context] Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/nouveau/nouveau_sgdma.c | 9 +++------ drivers/gpu/drm/ttm/ttm_tt.c | 2 -- 2 files changed, 3 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c @@ -105,12 +105,9 @@ nouveau_sgdma_create_ttm(struct ttm_bo_d else nvbe->ttm.ttm.func = &nv50_sgdma_backend; - if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) - /* - * A failing ttm_dma_tt_init() will call ttm_tt_destroy() - * and thus our nouveau_sgdma_destroy() hook, so we don't need - * to free nvbe here. - */ + if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) { + kfree(nvbe); return NULL; + } return &nvbe->ttm.ttm; } --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -195,7 +195,6 @@ int ttm_tt_init(struct ttm_tt *ttm, stru ttm_tt_alloc_page_directory(ttm); if (!ttm->pages) { - ttm_tt_destroy(ttm); pr_err("Failed allocating page table\n"); return -ENOMEM; } @@ -228,7 +227,6 @@ int ttm_dma_tt_init(struct ttm_dma_tt *t INIT_LIST_HEAD(&ttm_dma->pages_list); ttm_dma_tt_alloc_page_directory(ttm_dma); if (!ttm->pages) { - ttm_tt_destroy(ttm); pr_err("Failed allocating page table\n"); return -ENOMEM; }