Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp474540ybj; Wed, 6 May 2020 23:45:20 -0700 (PDT) X-Google-Smtp-Source: APiQypKYRAC1xSfVeZvzuGtpCyv3BIdi/RMk6NuaFgsEci3dSL+bnlXlDTDnxXRIDd8iQJVcH1OC X-Received: by 2002:a17:906:a39a:: with SMTP id k26mr10122187ejz.172.1588833920216; Wed, 06 May 2020 23:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588833920; cv=none; d=google.com; s=arc-20160816; b=E95c/vrdF1nen40AHM5ioSkdgMnxIHjJ0IAeW5PEIuLViI6vPXAvOnehqf7NYg8Ath FhiEqhtWGMHtEuE18CCkfQVO5IBBG7kKXuLlO2iMCsY9zogWi4c+kzacVtsHUNMcVIUx ZB41QgUEhvRXw5WlJeHJgnV0SKFAw0fLUH5bZDPPDyDG8mZnbUSTB544lE2JqdDzpLeo hbOFikiaBijPF8MHt9/w2i/byUPhV5EwiNXAIm1R8wnQJ8czeAUhXz8hiYC6tc+W9hB/ Gqd0Q4pVgNy5YEG8IpN/oc/1re3SK6MQQG743OIW/EWE1djAvgpHTXlqSmrEwzU1eCxF bemQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to:dkim-signature; bh=u9x5CxPuUX9KvELHPIEAEoDfCQa03ODaNOa1+2QT5/Y=; b=bJJEezLogqScoVdlTzOVlfJmmcX0IIypk9h80K8Que0Znq+H2s7G9es6eete5OcBkw 778BiOQdaHbO+HmvgNVv4YFanPdlBXPsjG0jjnv33VywJI+PqKVHmtcay0be/FDN7VZs kVxvfoTc0DbpKRrxFSxEKxnswnMWepiOFtcWHcNVbT/L7Il+S/MfavwtNbXOkbPfnJ1L fEhMDfPwI4HAHSJZnGK/xtckNTOvpJ2acI0PtuXvmGaEM/VFk71k4sojgINctzsio8tH LI6Uv9rSPU8iSyCJ8gzasWZEO1W0tJcMKJHym1kTiiOR1WC87HYBJSHnBQsZ0rKc50Qe kHWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Jg/8Weta"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si2391917edv.395.2020.05.06.23.44.56; Wed, 06 May 2020 23:45:20 -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=@gmail.com header.s=20161025 header.b="Jg/8Weta"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725905AbgEGGmz (ORCPT + 99 others); Thu, 7 May 2020 02:42:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725802AbgEGGmz (ORCPT ); Thu, 7 May 2020 02:42:55 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B965AC061A10 for ; Wed, 6 May 2020 23:42:54 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id r26so5392415wmh.0 for ; Wed, 06 May 2020 23:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=u9x5CxPuUX9KvELHPIEAEoDfCQa03ODaNOa1+2QT5/Y=; b=Jg/8Weta4UEn+UaAsuYfsWcL1WXFxhUUbzx32Wng0weqzZVChYoliVf2Dsbab7b/C0 W6KUk8QGFnu5KOXA/Be5pqeb7TjNTrzbp6vX/dt8j20PeV2aIBV+6olcpYubdxE/Db3J C/sFMOhCAxNPRpHjouJt1eY/ipGii6NtklkePn5KEbCIwb9ff7585NWCyJJSGeBk2aQb cf+XAJVC0YwTWYp0ZoJSqb8nfiGM0W0uc/5Dky7UCBR4mjQwBJHtHpCIyTEJRVDmmn8k 9U0XpRh7SQ4Bhe/acqZtzzlsMDv+Ny90GzU5uCgog0nlhLPEZqbQBYSHZBMmK3CFea1C bhbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=u9x5CxPuUX9KvELHPIEAEoDfCQa03ODaNOa1+2QT5/Y=; b=hF3TYerhIfJOCLLw3/O1LeVvAGstes8MRDxu6y+wdryfPz5+NbleDS7QZAkqcST3I2 L4yh6Y9N1SdJQzUKOGwWbWyhDVeQA1rZpEseKIizF2oU2OE7ZjutOowrCUQOaWBtxK6o A3k2kzRdkq6gg/zVH5512YJv7OlAS5p8SHJcaAjiEHDjxbh9wzveGyxHCPmCRVwD0myz Tzq8xbVYUp0U0NV12fzYnvsYSrZW20h2DY8xQ77T4hB3uHguGhXw4ajUxGAlqquXTPuR TtQYbcSdSwc84Aj3lMsmoN4vyFJxHZNjP5Um+oUo1wXyva7PhxyI3H66MTzCi/clIM+T /HNw== X-Gm-Message-State: AGi0PuZJ0lZLiYhJN6u+LaLPxf6Nzaf2NHM45IQV+nrigQq6iFTsAyj+ RqqphchGSEQMZ1L5qDbZexE= X-Received: by 2002:a7b:ce0b:: with SMTP id m11mr8755266wmc.67.1588833773329; Wed, 06 May 2020 23:42:53 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id w6sm6674286wrt.39.2020.05.06.23.42.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 May 2020 23:42:52 -0700 (PDT) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH] drm/amdgpu: allocate large structures dynamically To: Joe Perches , Arnd Bergmann , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter , Hawking Zhang , John Clements Cc: Guchun Chen , Tao Zhou , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Dennis Li References: <20200505140208.284473-1-arnd@arndb.de> <006e29037a9314fb286a5d6d84905bce99cef6c7.camel@perches.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <845a2e12-538c-fb6d-db80-78e8adf1413f@gmail.com> Date: Thu, 7 May 2020 08:42:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <006e29037a9314fb286a5d6d84905bce99cef6c7.camel@perches.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 06.05.20 um 21:01 schrieb Joe Perches: > On Tue, 2020-05-05 at 16:01 +0200, Arnd Bergmann wrote: >> After the structure was padded to 1024 bytes, it is no longer >> suitable for being a local variable, as the function surpasses >> the warning limit for 32-bit architectures: >> >> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:587:5: error: stack frame size of 1072 bytes in function 'amdgpu_ras_feature_enable' [-Werror,-Wframe-larger-than=] >> int amdgpu_ras_feature_enable(struct amdgpu_device *adev, >> ^ >> >> Use kzalloc() instead to get it from the heap. > [] >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > [] >> @@ -588,19 +588,23 @@ int amdgpu_ras_feature_enable(struct amdgpu_device *adev, >> struct ras_common_if *head, bool enable) >> { >> struct amdgpu_ras *con = amdgpu_ras_get_context(adev); >> - union ta_ras_cmd_input info; >> + union ta_ras_cmd_input *info; >> int ret; >> >> if (!con) >> return -EINVAL; >> >> + info = kzalloc(sizeof(union ta_ras_cmd_input), GFP_KERNEL); > Spaces were used for indentation here not a tab. > It might be useful to run your proposed patches through checkpatch > > Is this an actual bug fix as the previous use didn't > zero unused info members? > >> + if (!info) >> + return -ENOMEM; >> + >> if (!enable) { >> - info.disable_features = (struct ta_ras_disable_features_input) { >> + info->disable_features = (struct ta_ras_disable_features_input) { >> .block_id = amdgpu_ras_block_to_ta(head->block), >> .error_type = amdgpu_ras_error_to_ta(head->type), >> }; >> } else { >> - info.enable_features = (struct ta_ras_enable_features_input) { >> + info->enable_features = (struct ta_ras_enable_features_input) { >> .block_id = amdgpu_ras_block_to_ta(head->block), >> .error_type = amdgpu_ras_error_to_ta(head->type), >> }; >> @@ -609,26 +613,33 @@ int amdgpu_ras_feature_enable(struct amdgpu_device *adev, >> /* Do not enable if it is not allowed. */ >> WARN_ON(enable && !amdgpu_ras_is_feature_allowed(adev, head)); >> /* Are we alerady in that state we are going to set? */ >> - if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head))) >> - return 0; >> + if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head))) { > And trivia: > > The !! uses with bool seem unnecessary and it's probably better > to make amdgpu_ras_is_feature_enabled to return bool. > > Maybe something like: > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > index 538895cfd862..05c4eaf0ddfa 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > @@ -526,16 +526,16 @@ void amdgpu_ras_parse_status_code(struct amdgpu_device* adev, > } > > /* feature ctl begin */ > -static int amdgpu_ras_is_feature_allowed(struct amdgpu_device *adev, > - struct ras_common_if *head) > +static bool amdgpu_ras_is_feature_allowed(struct amdgpu_device *adev, > + struct ras_common_if *head) > { > struct amdgpu_ras *con = amdgpu_ras_get_context(adev); > > return con->hw_supported & BIT(head->block); > } > > -static int amdgpu_ras_is_feature_enabled(struct amdgpu_device *adev, > - struct ras_common_if *head) > +static bool amdgpu_ras_is_feature_enabled(struct amdgpu_device *adev, > + struct ras_common_if *head) > { > struct amdgpu_ras *con = amdgpu_ras_get_context(adev); > > @@ -560,7 +560,7 @@ static int __amdgpu_ras_feature_enable(struct amdgpu_device *adev, > */ > if (!amdgpu_ras_is_feature_allowed(adev, head)) > return 0; > - if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head))) > + if (!(enable ^ amdgpu_ras_is_feature_enabled(adev, head))) And while we are at improving coding style I think that writing this as "if (enabled == amdgpu_ras_is_feature_enabled(adev, head))" would be much more readable. Christian. > return 0; > > if (enable) { > @@ -609,7 +609,7 @@ int amdgpu_ras_feature_enable(struct amdgpu_device *adev, > /* Do not enable if it is not allowed. */ > WARN_ON(enable && !amdgpu_ras_is_feature_allowed(adev, head)); > /* Are we alerady in that state we are going to set? */ > - if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head))) > + if (!(enable ^ amdgpu_ras_is_feature_enabled(adev, head))) > return 0; > > if (!amdgpu_ras_intr_triggered()) { > > > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx