Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3563304pxb; Mon, 24 Jan 2022 12:17:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKVlYKiXsf52j8cLBYG/VpaUB5eE8rfLiNpSgjBZ0o5i9xaM7Xm2YZUut7WsnzzQJOiGLa X-Received: by 2002:aa7:91d1:0:b0:4c0:27ac:4d6b with SMTP id z17-20020aa791d1000000b004c027ac4d6bmr14975336pfa.85.1643055473143; Mon, 24 Jan 2022 12:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055473; cv=none; d=google.com; s=arc-20160816; b=Qc6fNqOZDLqqQ2fQVjN2AharpHA8pjZ4suZAsk3wmZoJ/ddiH7leiohfGD11bY832Z vqHPGyerwt+/QKHm3numL+9C7QJssLG7glGiX5Gd3TLP0r9RM7ED1qfEXYZDwuJ5U+pc IQY6FlmCI8gmqwjX6cnbpjNxy3t6N1027/qgduBjV2FtnO46goqUirq2b8DFQOtZNa+U yggcILg+6xPuDJEepRT1rPHcug1ctKAH7TV3udva5Tz1pEDHtHmU+LR9ZR9km8diR+St zd6Olqq2DEImw8HRbxVh/yGwedpG7K5cEDPujLtSu11oJ81lkxAs60DKXxitP1d6MvOP VJ0Q== 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=Truj00xK110OJpgVec9Hl2u626fdmf6e7y2kFIOIR2U=; b=e0igFkjaJ/L5q8E5yfDwWyp5ZMDIHLi2vJZt7rQU/89OO0XbBYKxTGTeHBP/9YdL62 6Hl60iRARE/fiYTFvHztLppmYXimhniWm9peFvPal5Z2CwoIEd38xPJoonWf5TEBnRAG pOoFnC41Ot+3tNbyZQauAdJOYOUSot2FqqqFty7BV4+P+slTZ2giubMirH3+Dl9dCDrY PHisWJuZu86kQSjmKtz+AY9d3iWc8FbNM2WxTHkHgFQBr0FMHTD3swpNpL2C5PAOe8NM Ll60LAe4+7CPPZLFYVqkYDVHP3DbxsC1CmfIi5/J+xiCfcvoiD85Hikg7F/Gu2XGWpNO MUOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TfMi8kDw; 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 u1si14048918pge.729.2022.01.24.12.17.40; Mon, 24 Jan 2022 12:17:53 -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=TfMi8kDw; 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 S1349116AbiAXTUP (ORCPT + 99 others); Mon, 24 Jan 2022 14:20:15 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:37860 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344749AbiAXTMB (ORCPT ); Mon, 24 Jan 2022 14:12:01 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 5DBE260B86; Mon, 24 Jan 2022 19:12:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20256C340E5; Mon, 24 Jan 2022 19:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051520; bh=tKj4Kkf+G5JYmjrwLFve0RgOclpjWKePgs1gs4EF3Sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TfMi8kDwQ9nO1aP8dPAPofOEZLrHpCt9F1QL0d/r3GkURQo5kFnTqS+kaX3a46VDw AuAJUvGqKAlk3jdknvYoX2esB7FbMwQlLOIVhAIfwJ5tVOdPz+fcZwAC6od1RnBcyr ZbNmtLfj0DKXNxrJ3ADnW5xpuEiTCSKaB+gaSInc= 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.14 181/186] drm/ttm/nouveau: dont call tt destroy callback on alloc failure. Date: Mon, 24 Jan 2022 19:44:16 +0100 Message-Id: <20220124183942.928229926@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 @@ -106,12 +106,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 @@ -199,7 +199,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; } @@ -232,7 +231,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; }