From patchwork Sun Feb 14 09:16:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 8301591 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C82269F6E7 for ; Sun, 14 Feb 2016 09:17:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB58A203AC for ; Sun, 14 Feb 2016 09:17:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C7B65203ED for ; Sun, 14 Feb 2016 09:17:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED0306E41C; Sun, 14 Feb 2016 01:17:48 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id B22096E41E for ; Sun, 14 Feb 2016 01:17:47 -0800 (PST) Received: by mail-wm0-f65.google.com with SMTP id a4so5482802wme.3 for ; Sun, 14 Feb 2016 01:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k1wULxAM1GiUX1oHs4zKadDvsxtlbl1HJ4lyBJ4ictE=; b=aoY9ByGKxwBCZUkV9shBhds//FNRSwa3z1j3HIJ0Wm9h/CuSe5RmjStalHrMY76bHN ebaRlbNVS0wWchjh5CO0gZasWmSb699u3Zhi6P0AZbutNU9SJPtzNTcyZNWAe1zMiJyY OKeCX/AlUrhYlXskqnCTB1Lur2kxnYsIvJgwdmk3Dvk4efOTKKK81+jvmzFPt0wftAjt IWemuLv0hg2gFILYroXZ1h7tbucIwRONLbydLvrlXWD52gokwUIWXaVefCSLHXTlA5SX 7s/OcOoDzCyxe1Ln0KgGFhvh3zFAzfK5iPT9DtzkiTlFwpRklP43ukGB/ixo7G4lS1YD NNNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k1wULxAM1GiUX1oHs4zKadDvsxtlbl1HJ4lyBJ4ictE=; b=ZBD/Wa9GDgqIgZjh4kew3BoN2HMSvF3+WL1W0gYzNzua5ggpN6ltcElOAwY86F68lZ cNSZS+u/RfsI2erO+R1NfGbl/XZ4TIfO+DYnBwYIVulj+KListHe8u+zl2g8MbvJwSNe AMjHzTY29kQY8c/fheU49ScXPekUvugNLzvoG/MkYooJVX+Xz0NeA8ZPijK6gFIWA/qV rGHolZrA9Mz4Vb0hey+Xv5g5D7vWj4npWXxDS2D08A713PhMUFSmgWxtwRS3Z/zFTKDQ mTZtwYAOHUfu1QQ12BCupglX7GEt44ezySo5Sf/FzfW935CAKUuwmPVqS9I+xlCq+lBz 5bcQ== X-Gm-Message-State: AG10YOT1PALOcUc23MTIYby/kTXfMnOdv2liz0GhUpTk7uXTDEhrsZ+vpplDpAhMmYbnQQ== X-Received: by 10.28.96.85 with SMTP id u82mr6364920wmb.81.1455441421520; Sun, 14 Feb 2016 01:17:01 -0800 (PST) Received: from odedg-tlv.redhat.com ([77.125.92.242]) by smtp.gmail.com with ESMTPSA id r10sm19821938wjz.24.2016.02.14.01.16.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Feb 2016 01:17:00 -0800 (PST) From: Oded Gabbay To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/radeon: Return -EPROBE_DEFER when amdkfd not loaded Date: Sun, 14 Feb 2016 11:16:54 +0200 Message-Id: <1455441415-16901-3-git-send-email-oded.gabbay@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455441415-16901-1-git-send-email-oded.gabbay@gmail.com> References: <1455441415-16901-1-git-send-email-oded.gabbay@gmail.com> Cc: daniel.vetter@ffwll.ch X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP radeon must load only after amdkfd's loading has been completed. If that is not enforced, then radeon's call into amdkfd's functions will cause a kernel BUG. When radeon and amdkfd are built as kernel modules, that rule is enforced by the kernel's modules loading mechanism. When radeon and amdkfd are built inside the kernel image, that rule is enforced by ordering in the drm Makefile (amdkfd before radeon). Instead of using drm Makefile ordering, we can now use deferred loading as amdkfd now returns -EPROBE_DEFER in kgd2kfd_init() when it is not yet loaded. This patch defers radeon loading by propagating -EPROBE_DEFER to the kernel's drivers loading infrastructure. That will put radeon into the pending drivers list (see description in dd.c). Once amdkfd is loaded, a call to kgd2kfd_init() will return successfully and radeon will be able to load. Signed-off-by: Oded Gabbay --- drivers/gpu/drm/radeon/radeon_drv.c | 10 ++++++++-- drivers/gpu/drm/radeon/radeon_kfd.c | 25 ++++++++++++------------- drivers/gpu/drm/radeon/radeon_kfd.h | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index e266ffc..4147350 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -319,6 +319,14 @@ static int radeon_pci_probe(struct pci_dev *pdev, { int ret; + /* + * Initialize amdkfd before starting radeon. If it was not loaded yet, + * defer radeon probing + */ + ret = radeon_kfd_init(); + if (ret == -EPROBE_DEFER) + return ret; + /* Get rid of things like offb */ ret = radeon_kick_out_firmware_fb(pdev); if (ret) @@ -570,8 +578,6 @@ static int __init radeon_init(void) return -EINVAL; } - radeon_kfd_init(); - /* let modprobe override vga console setting */ return drm_pci_init(driver, pdriver); } diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c b/drivers/gpu/drm/radeon/radeon_kfd.c index 83c2704..87a9ebb 100644 --- a/drivers/gpu/drm/radeon/radeon_kfd.c +++ b/drivers/gpu/drm/radeon/radeon_kfd.c @@ -132,35 +132,34 @@ static const struct kfd2kgd_calls kfd2kgd = { static const struct kgd2kfd_calls *kgd2kfd; -bool radeon_kfd_init(void) +int radeon_kfd_init(void) { + int ret; + #if defined(CONFIG_HSA_AMD_MODULE) - bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**); + int (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**); kgd2kfd_init_p = symbol_request(kgd2kfd_init); if (kgd2kfd_init_p == NULL) - return false; + return -ENOENT; - if (kgd2kfd_init_p(KFD_INTERFACE_VERSION, &kgd2kfd)) { + ret = kgd2kfd_init_p(KFD_INTERFACE_VERSION, &kgd2kfd); + if (ret) { symbol_put(kgd2kfd_init); kgd2kfd = NULL; - - return false; } - return true; #elif defined(CONFIG_HSA_AMD) - if (kgd2kfd_init(KFD_INTERFACE_VERSION, &kgd2kfd)) { + ret = kgd2kfd_init(KFD_INTERFACE_VERSION, &kgd2kfd); + if (ret) kgd2kfd = NULL; - return false; - } - - return true; #else - return false; + ret = -ENOENT; #endif + + return ret; } void radeon_kfd_fini(void) diff --git a/drivers/gpu/drm/radeon/radeon_kfd.h b/drivers/gpu/drm/radeon/radeon_kfd.h index 1103f90..9df1fea 100644 --- a/drivers/gpu/drm/radeon/radeon_kfd.h +++ b/drivers/gpu/drm/radeon/radeon_kfd.h @@ -33,7 +33,7 @@ struct radeon_device; -bool radeon_kfd_init(void); +int radeon_kfd_init(void); void radeon_kfd_fini(void); void radeon_kfd_suspend(struct radeon_device *rdev);