From patchwork Fri Apr 13 21:24:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10340771 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 BA60C600D0 for ; Fri, 13 Apr 2018 21:24:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71A1B28A1D for ; Fri, 13 Apr 2018 21:24:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63E3728A20; Fri, 13 Apr 2018 21:24:27 +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, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 D601F28A1D for ; Fri, 13 Apr 2018 21:24:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A893E6EBA0; Fri, 13 Apr 2018 21:24:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot0-f196.google.com (mail-ot0-f196.google.com [74.125.82.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id 528CB6EB9C for ; Fri, 13 Apr 2018 21:24:22 +0000 (UTC) Received: by mail-ot0-f196.google.com with SMTP id o9-v6so11397640otj.5 for ; Fri, 13 Apr 2018 14:24:22 -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=t+NMc3wTSPqTRlc4wymVw8yLH7odihMta2WDEKBjms8=; b=HH7QISRPKX3oZLfjtn0NLAwhvWi1joPy4Bv8u4Fy4oGhZitC3SvQtWUI3p9bfb7BKi dyp3w7S5iwXwJSLq5ptXVBycKtslbzNMgI6d1IzfQBEp5fDSt3ZlIvF4xvr1xfTB5ykB BPhMqv2INoLZpMRbj7YU/vEdc4+1OG0z0fuRnOWkaNYlPXia2qss/wuWdO1DwlHqJUpC 1Mu1Fdu1VrI5GCQ7OR8aEgumc7t2585em7N7Ncbau7OpNb9ac0iIJ2dipxeQGTI4QhFe wBnLiqZv7IYw/ql7ZNPGbkkD8XFeuElb3C86HXTjC/ADup5dP9QReFagmLOs8Rg/BDAj Awrw== X-Gm-Message-State: ALQs6tCG/ixJ1OIU0UQ9Dndp1+0fdUW3KfF/rt5s2uazzz6IkYS0oulS xdFDcSgx2NXeHcSqaW+XwVA6fA== X-Google-Smtp-Source: AIpwx4+16bK14OIr/z++GUONcsfXlwLRck2HZJRhzOHltHn8SS3ot8Fov66Kat4nwV10Lkg7h4f2Ag== X-Received: by 2002:a9d:38b2:: with SMTP id p47-v6mr4473818otc.171.1523654661558; Fri, 13 Apr 2018 14:24:21 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc::ce63]) by smtp.gmail.com with ESMTPSA id k91-v6sm4198372otc.7.2018.04.13.14.24.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Apr 2018 14:24:20 -0700 (PDT) From: Laura Abbott To: Oded Gabbay , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , Felix Kuehling Subject: [PATCHv3] drm/amdkfd: Remove vla Date: Fri, 13 Apr 2018 14:24:12 -0700 Message-Id: <20180413212412.18205-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 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: , Cc: Kees Cook , kernel-hardening@lists.openwall.com, David Airlie , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Switch to a constant value that covers all hardware. [1] https://lkml.org/lkml/2018/3/7/621 Reviewed-by: Felix Kuehling Acked-by: Christian König Signed-off-by: Laura Abbott --- v3: Introduced a #define for the max value, switched to pr_err_once to avoid log flood, switched to sizeof(array) per private suggestion. --- drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 8 +++++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c index 035c351f47c5..db6d9336b80d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c @@ -139,10 +139,12 @@ static void interrupt_wq(struct work_struct *work) { struct kfd_dev *dev = container_of(work, struct kfd_dev, interrupt_work); + uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE]; - uint32_t ih_ring_entry[DIV_ROUND_UP( - dev->device_info->ih_ring_entry_size, - sizeof(uint32_t))]; + if (dev->device_info->ih_ring_entry_size > sizeof(ih_ring_entry)) { + dev_err_once(kfd_chardev(), "Ring entry too small\n"); + return; + } while (dequeue_ih_ring_entry(dev, ih_ring_entry)) dev->device_info->event_interrupt_class->interrupt_wq(dev, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 96a9cc0f02c9..a90db05dfe61 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -39,6 +39,8 @@ #include "amd_shared.h" +#define KFD_MAX_RING_ENTRY_SIZE 8 + #define KFD_SYSFS_FILE_MODE 0444 #define KFD_MMAP_DOORBELL_MASK 0x8000000000000ull