From patchwork Tue Oct 9 17:14:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10634173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 303F415E2 for ; Wed, 10 Oct 2018 08:24:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F43129405 for ; Wed, 10 Oct 2018 08:24:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5000E29862; Wed, 10 Oct 2018 08:24:50 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable 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 0E64829405 for ; Wed, 10 Oct 2018 08:24:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5537989CBC; Wed, 10 Oct 2018 08:24:49 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 00B1089F5F; Tue, 9 Oct 2018 17:14:26 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id y16so2672289wrw.3; Tue, 09 Oct 2018 10:14:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ixmq0eTdX6XQdK50jLnhNrpgIWjhAAnM3DDCvlSc1f0=; b=r+BQhU9nQQgnIZpDik3U3qKxCqfHquGlgIH8xJcpr6kCGW2KRJ35HfEk+CNbAXoV8e fZVL+t9X9QXwu75zSTi2GEHveWtoSSKU0LFeDs80fKLrmcZ4jAZz4yuAKa95xzotAGmv C3yw7mVIsHGg64TcS3NH0athmrTO38/aH/BRi99XiMVrPOhxi5et9X+y/Gu5FweXlzGy 1UxxxOXUnHcWuCrB6PEGJQRnXnuxkraVkEhCKPBZloY+mfg4OCi+UeHlvmRBWnAzAXT3 yxws+sZZLk4/QmW8neQ6keNe7FVP7kkwH81hMNlCghdaSgRoxDkGOZw236jdNQKlD8h2 iv8w== X-Gm-Message-State: ABuFfogpZav3rLe/m8nn6w3HY527dadSSqII+PsgOQ2E6TD94y/QqK3Q hsVcUdX4sB2+qPlfjGRv2TE= X-Google-Smtp-Source: ACcGV62t6G5rgbTtWcsN9KvMI9e1kauB2U2o+0sIhHRW//wXRAiGSF9vrYzOAQ73unsh5H4alVbArw== X-Received: by 2002:a5d:680b:: with SMTP id w11-v6mr19087047wru.186.1539105265109; Tue, 09 Oct 2018 10:14:25 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id f1-v6sm13467468wme.23.2018.10.09.10.14.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 10:14:24 -0700 (PDT) From: Nathan Chancellor To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi Date: Tue, 9 Oct 2018 10:14:01 -0700 Message-Id: <20181009171401.14980-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 10 Oct 2018 08:24:48 +0000 Subject: [Intel-gfx] [PATCH] drm/i915: Convert _print_param to a macro X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, Nick Desaulniers , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Lukas Bulwahn , Nathan Chancellor Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP When building the kernel with Clang with defconfig and CONFIG_64BIT disabled, vmlinux fails to link because of the BUILD_BUG in _print_param. ld: drivers/gpu/drm/i915/i915_params.o: in function `i915_params_dump': i915_params.c:(.text+0x56): undefined reference to `__compiletime_assert_191' This function is semantically invalid unless the code is first inlined then constant folded, which doesn't work for Clang because semantic analysis happens before optimization/inlining. Converting this function to a macro avoids this problem and allows Clang to properly remove the BUILD_BUG during optimization. The output of 'objdump -D' is identically before and after this change for GCC regardless of if CONFIG_64BIT is set and allows Clang to link the kernel successfully with or without CONFIG_64BIT set. Link: https://github.com/ClangBuiltLinux/linux/issues/191 Suggested-by: Nick Desaulniers Signed-off-by: Nathan Chancellor --- drivers/gpu/drm/i915/i915_params.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 295e981e4a39..a0f20b9b6f2d 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -174,22 +174,19 @@ i915_param_named(enable_dpcd_backlight, bool, 0600, i915_param_named(enable_gvt, bool, 0400, "Enable support for Intel GVT-g graphics virtualization host support(default:false)"); -static __always_inline void _print_param(struct drm_printer *p, - const char *name, - const char *type, - const void *x) -{ - if (!__builtin_strcmp(type, "bool")) - drm_printf(p, "i915.%s=%s\n", name, yesno(*(const bool *)x)); - else if (!__builtin_strcmp(type, "int")) - drm_printf(p, "i915.%s=%d\n", name, *(const int *)x); - else if (!__builtin_strcmp(type, "unsigned int")) - drm_printf(p, "i915.%s=%u\n", name, *(const unsigned int *)x); - else if (!__builtin_strcmp(type, "char *")) - drm_printf(p, "i915.%s=%s\n", name, *(const char **)x); - else - BUILD_BUG(); -} +#define _print_param(p, name, type, x) \ +do { \ + if (!__builtin_strcmp(type, "bool")) \ + drm_printf(p, "i915.%s=%s\n", name, yesno(*(const bool *)x)); \ + else if (!__builtin_strcmp(type, "int")) \ + drm_printf(p, "i915.%s=%d\n", name, *(const int *)x); \ + else if (!__builtin_strcmp(type, "unsigned int")) \ + drm_printf(p, "i915.%s=%u\n", name, *(const unsigned int *)x); \ + else if (!__builtin_strcmp(type, "char *")) \ + drm_printf(p, "i915.%s=%s\n", name, *(const char **)x); \ + else \ + BUILD_BUG(); \ +} while (0) /** * i915_params_dump - dump i915 modparams