Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4618731pxj; Wed, 12 May 2021 09:21:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys9OraPd2K8CRPPYNtjPkxZwHjQwVUoaJPYh/ExvxQeIXPCBoW3IjiDIePSvVI+kLTrskM X-Received: by 2002:a17:907:969e:: with SMTP id hd30mr21538487ejc.501.1620836488956; Wed, 12 May 2021 09:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836488; cv=none; d=google.com; s=arc-20160816; b=lEJn29XijLep4eE9Wg5JAHs4ZxJnnWNHJ8WGo6Q9L5g9bsS0ywlJQKvDUPxj3lQzS+ KiIBmHw8JmYtwzyIrYvkfi/8S0fJZw5x263ONBtrNb5GD1clNB993ElVp/0EcTYUyPkB p1wVz9x+2w+TQYV1rtVC0ekBXbPog1U18ckNF6wHFtgF7Poo3OFhE7JxVQDvoSxbB6o2 NRoq5zEXK00tQNomyod5ELbdB+NB0QwkW/rjPrWh70VJuTnHTJ/sX0xSIA2iO+j/1afy MCkBG+cGRRt0g2w3KVhFwLJzboFZUiLhyoMPhAt8LSofQAsoAWV52PazQL7PXW2xKj5f qVVg== 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=w9gjnAb/by6Azv1qb3jlchi8YM8IPCgR/6dIiZSiasA=; b=0giN9sE3vsOu3tcsZXez0pdDDkLe2QuQU6njphr9tlUsIKpYrS5hH61W4ZBg0PNRED j/lmQUh5MVIxdZmb3EqYBXWlzUZqazIcLjFgsZ08x5q31SMvzWYiH6cuQFGLjiS7VREu 0fcvHhJoSMdlbvSGVllaDDLryn7QcJQrv3PvhdQKAWtwG6SUCt0wTAL1r1a0PMHz8pRQ Jz2wd1epSHh4qyS/pUaf93W1ojgmf29gKPQIXWmq/rbnKyAqyNLcNsakqQFjQSo0LAec 8bTgyK8j7I+ekKVTom+e/wWpU4mq0zV2XQm5ewlgKC9Q0jSWfbx8utiaIYLrRlCxTaTZ yjiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m1aZVyh1; 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 h6si325507ejp.651.2021.05.12.09.21.04; Wed, 12 May 2021 09:21:28 -0700 (PDT) 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=m1aZVyh1; 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 S237855AbhELQN2 (ORCPT + 99 others); Wed, 12 May 2021 12:13:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:48856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233445AbhELPbH (ORCPT ); Wed, 12 May 2021 11:31:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8AFD161C62; Wed, 12 May 2021 15:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832567; bh=SR3WXmghqDoHJxmq9YLtFUgAT/4xx5GNK+FL4MSe3UA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m1aZVyh1G2WGRtPnlx62hZ4zoCNYu4BRvRvOC5hIx6eyUwHfGrtvFtOTlPglUWavE /xRD39kST7Fb42LOKbV/9priBoV48l+mH5ERqI0sOEvgG9SK+/rlMVLzAP1F1GLTRT GDIl/UcS72kw/wFQUTayYpBOv2cfcpwMJSxI23a0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Felix Kuehling , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.10 299/530] drm/amdkfd: fix build error with AMD_IOMMU_V2=m Date: Wed, 12 May 2021 16:46:49 +0200 Message-Id: <20210512144829.628425330@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Felix Kuehling [ Upstream commit 1e87068570a2cc4db5f95a881686add71729e769 ] Using 'imply AMD_IOMMU_V2' does not guarantee that the driver can link against the exported functions. If the GPU driver is built-in but the IOMMU driver is a loadable module, the kfd_iommu.c file is indeed built but does not work: x86_64-linux-ld: drivers/gpu/drm/amd/amdkfd/kfd_iommu.o: in function `kfd_iommu_bind_process_to_device': kfd_iommu.c:(.text+0x516): undefined reference to `amd_iommu_bind_pasid' x86_64-linux-ld: drivers/gpu/drm/amd/amdkfd/kfd_iommu.o: in function `kfd_iommu_unbind_process': kfd_iommu.c:(.text+0x691): undefined reference to `amd_iommu_unbind_pasid' x86_64-linux-ld: drivers/gpu/drm/amd/amdkfd/kfd_iommu.o: in function `kfd_iommu_suspend': kfd_iommu.c:(.text+0x966): undefined reference to `amd_iommu_set_invalidate_ctx_cb' x86_64-linux-ld: kfd_iommu.c:(.text+0x97f): undefined reference to `amd_iommu_set_invalid_ppr_cb' x86_64-linux-ld: kfd_iommu.c:(.text+0x9a4): undefined reference to `amd_iommu_free_device' x86_64-linux-ld: drivers/gpu/drm/amd/amdkfd/kfd_iommu.o: in function `kfd_iommu_resume': kfd_iommu.c:(.text+0xa9a): undefined reference to `amd_iommu_init_device' x86_64-linux-ld: kfd_iommu.c:(.text+0xadc): undefined reference to `amd_iommu_set_invalidate_ctx_cb' x86_64-linux-ld: kfd_iommu.c:(.text+0xaff): undefined reference to `amd_iommu_set_invalid_ppr_cb' x86_64-linux-ld: kfd_iommu.c:(.text+0xc72): undefined reference to `amd_iommu_bind_pasid' x86_64-linux-ld: kfd_iommu.c:(.text+0xe08): undefined reference to `amd_iommu_set_invalidate_ctx_cb' x86_64-linux-ld: kfd_iommu.c:(.text+0xe26): undefined reference to `amd_iommu_set_invalid_ppr_cb' x86_64-linux-ld: kfd_iommu.c:(.text+0xe42): undefined reference to `amd_iommu_free_device' Use IS_REACHABLE to only build IOMMU-V2 support if the amd_iommu symbols are reachable by the amdkfd driver. Output a warning if they are not, because that may not be what the user was expecting. Fixes: 64d1c3a43a6f ("drm/amdkfd: Centralize IOMMUv2 code and make it conditional") Reported-by: Arnd Bergmann Signed-off-by: Felix Kuehling Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 6 ++++++ drivers/gpu/drm/amd/amdkfd/kfd_iommu.h | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c index 66bbca61e3ef..9318936aa805 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c @@ -20,6 +20,10 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include + +#if IS_REACHABLE(CONFIG_AMD_IOMMU_V2) + #include #include #include @@ -355,3 +359,5 @@ int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev) return 0; } + +#endif diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_iommu.h b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.h index dd23d9fdf6a8..afd420b01a0c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_iommu.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.h @@ -23,7 +23,9 @@ #ifndef __KFD_IOMMU_H__ #define __KFD_IOMMU_H__ -#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) +#include + +#if IS_REACHABLE(CONFIG_AMD_IOMMU_V2) #define KFD_SUPPORT_IOMMU_V2 @@ -46,6 +48,9 @@ static inline int kfd_iommu_check_device(struct kfd_dev *kfd) } static inline int kfd_iommu_device_init(struct kfd_dev *kfd) { +#if IS_MODULE(CONFIG_AMD_IOMMU_V2) + WARN_ONCE(1, "iommu_v2 module is not usable by built-in KFD"); +#endif return 0; } @@ -73,6 +78,6 @@ static inline int kfd_iommu_add_perf_counters(struct kfd_topology_device *kdev) return 0; } -#endif /* defined(CONFIG_AMD_IOMMU_V2) */ +#endif /* IS_REACHABLE(CONFIG_AMD_IOMMU_V2) */ #endif /* __KFD_IOMMU_H__ */ -- 2.30.2