From patchwork Fri Feb 23 12:25:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10237505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 96B2760209 for ; Fri, 23 Feb 2018 12:25:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82ECD29551 for ; Fri, 23 Feb 2018 12:25:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7794329553; Fri, 23 Feb 2018 12:25:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2824529551 for ; Fri, 23 Feb 2018 12:25:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB2A06F0D0; Fri, 23 Feb 2018 12:25:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id E487E6F0D0 for ; Fri, 23 Feb 2018 12:25:13 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id s5so13931235wra.0 for ; Fri, 23 Feb 2018 04:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=tjkTU24M5ZaO1EMfCPbaFWdlnbhgM/G3hOX5s/ae4uo=; b=mkFzea7T1m3+zDct3d2cOJsHuRXItXDXY6eJHG3+ER5uc4C4xbXCYAshfxercMeMpD XxEWn4dZnpuO8qH2FV+icynoDh3lFg7sFVQHrlBeIb7lXEVpwaFIkL9ZsgFhCpWHLQvg NqZlm8TvIPXqcL8Q0owR7LUYeHXaqcotZ5KVMq4B53zA8mfVqg6IpxjDp8+6+nZMsgk6 uTV4bqjKwXcVpAJ8SCUqGpZSqleBlm36wIRI3EYrO6oOtj1FdBYniwqKBS5e+Ik8s4HG zLL2lcrUsR6WW7bSSWUbFYnxuZTrQmPH6/WiYDb7xAVnH/XWn6mN8vYeB7J92i0nymQw aPdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tjkTU24M5ZaO1EMfCPbaFWdlnbhgM/G3hOX5s/ae4uo=; b=bFwOaRpnuWTIUqMtjVv53/PPoSUMGzWfp3jDtoJCbLSzgO2SLUU01pXpnItZdmSbvw B4tZWVoipJjgHKvlu+BNWgWZtRB9wKd0k0C7hdsj62n+K/5agsPPNBcq4zdoVX6ZUYCA rEYaORcN6DAWsq822KwrchI6/1aatg9Tp6W4aun3T8SfgYsxZFd64AHj1YyeUfuBnY20 eHF9AHe5h54suWbV5c8qCDW9DgBCWlYV2b43bBJkLqLsz+5TacNNfQpcvOz7DVJ6sZxj sDMEkkmm9KRKCRxX0KifNTr/Bujo84CbQEqbEdgstpjAh3acgKTVgw2LfnIdyQzsPVWO JaLw== X-Gm-Message-State: APf1xPC9I2yomVxp8muU80FMsf0NgBDM9cgz+Dnr83wx19Wnr60CZnyC hU2S3Wqap8gsRWdQSU7q7NF7rA== X-Google-Smtp-Source: AG47ELvtl/fV4Rp6rrAwkM5Ycm4N6D5eEBHou1my522D1EFhz4j4vfu4CxhFqPdmGngkk4VxvgMmRQ== X-Received: by 10.223.130.76 with SMTP id 70mr1442008wrb.95.1519388712272; Fri, 23 Feb 2018 04:25:12 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:dccd:6cc2:86be:cf2f]) by smtp.gmail.com with ESMTPSA id m71sm2761865wmd.6.2018.02.23.04.25.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 04:25:11 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/ttm: cleanup ttm_tt_create Date: Fri, 23 Feb 2018 13:25:09 +0100 Message-Id: <20180223122509.52465-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180223122509.52465-1-christian.koenig@amd.com> References: <20180223122509.52465-1-christian.koenig@amd.com> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Cleanup ttm_tt_create a bit. Signed-off-by: Christian König Reviewed-by: Michel Dänzer --- drivers/gpu/drm/ttm/ttm_tt.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 917942d03047..0ee3b8f11605 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -53,11 +53,9 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc) { struct ttm_bo_device *bdev = bo->bdev; - int ret = 0; uint32_t page_flags = 0; reservation_object_assert_held(bo->resv); - bo->ttm = NULL; if (bdev->need_dma32) page_flags |= TTM_PAGE_FLAG_DMA32; @@ -69,28 +67,27 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc) case ttm_bo_type_device: if (zero_alloc) page_flags |= TTM_PAGE_FLAG_ZERO_ALLOC; + break; case ttm_bo_type_kernel: - bo->ttm = bdev->driver->ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT, - page_flags); - if (unlikely(bo->ttm == NULL)) - ret = -ENOMEM; break; case ttm_bo_type_sg: - bo->ttm = bdev->driver->ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT, - page_flags | TTM_PAGE_FLAG_SG); - if (unlikely(bo->ttm == NULL)) { - ret = -ENOMEM; - break; - } - bo->ttm->sg = bo->sg; + page_flags |= TTM_PAGE_FLAG_SG; break; default: + bo->ttm = NULL; pr_err("Illegal buffer object type\n"); - ret = -EINVAL; - break; + return -EINVAL; } - return ret; + bo->ttm = bdev->driver->ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT, + page_flags); + if (unlikely(bo->ttm == NULL)) + return -ENOMEM; + + if (bo->type == ttm_bo_type_sg) + bo->ttm->sg = bo->sg; + + return 0; } /**