Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1165562pxb; Wed, 6 Apr 2022 10:15:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/zL7AizI67qLTr9NxfDZ7j/HHFWoy1SxHjMphSBFMgXxE7g3MeylrJT1Q0UV7sutWSspn X-Received: by 2002:a17:903:2352:b0:155:d4e8:12c6 with SMTP id c18-20020a170903235200b00155d4e812c6mr10027011plh.27.1649265334195; Wed, 06 Apr 2022 10:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649265334; cv=none; d=google.com; s=arc-20160816; b=Aog+OFWcsFrUJXt9fmGF5Vyob2qzlsSn6FTfUMo6kGKUEK9JDaViRiLJtSgnnM5orD mmc/Ncw0CGEpUFQOA5l2P2mmw9qS8K4K2PthJc2bK5EvgtuDm4GZJHhBCHX20dICaA36 u+D4HnEfO2F5ACy/UFy+tA4fw51WqOYlirgvR4a0DUgY3HiAtm5DJMlTA1zeTV0IG7f6 hxYtLaCEZjCyGwnJktPcME0OZ2ir1Jpd/M4pfBJg+nseTvTrPA8VM42ASWgqDsF87WPY cmtYcIl1mVM1iy9F4JtcFp2DN7kDg+ErIPMRUDdJoOXfjP6O1WENuebUQ8kJlYzhJjgn 70jw== 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 :message-id:date:references:organization:in-reply-to:subject:cc:to :from:dkim-signature; bh=I0fb3N4FQFl4xJrOA7an9kNIazVTdyrDB/BNcieQG/w=; b=lPp+5tfHLBCS+zBW9D50hvo2dZHKl67Aw1dkvIK+m72PCYYPFAWtgEwOEu/mT4AiiV rtNkXkdCCADViajpeGGbBdWwKluoyH4MdYcDc2qL40rZ0ebaq39cmPHNiTCaC0i5O46J r7pgBevNv5n5SKk2T0K/b+c0LtfxLFkb3/wueCbMMaDbZ7KtCH2kwoMXNShUs0UA4yEl 9ddkyxofRVyy9N/dZZfySWtIPeOfSP/B0C6c8q4nUD8IqMQ5ubzTPjaABZQmsUd5rzkz ajPAxm1+DnypsgUFbwo6cUYWuV+RIw7/0EW4c6J2KAY+Kzcv3G3lMaM4dkvf/B0fGPM3 2AvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T2kyJ+lc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id cp22-20020a17090afb9600b001ca87dc22fasi4939219pjb.176.2022.04.06.10.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 10:15:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T2kyJ+lc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 456A52689BB; Wed, 6 Apr 2022 10:09:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238571AbiDFRLi (ORCPT + 99 others); Wed, 6 Apr 2022 13:11:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238599AbiDFRK5 (ORCPT ); Wed, 6 Apr 2022 13:10:57 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B6B17E37A for ; Wed, 6 Apr 2022 07:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649255560; x=1680791560; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=D2k6neIoq0HuAMjXdsRZhn8IXAOS7zwhgg73BXGOJrA=; b=T2kyJ+lcCfFwJRcwFB3pwl//gpVY7V9ZO4Y9bkJrRSXsLHq4t8SwycJm Mlt4CM3zHUCJ19obuRtAU7PyJxjD25NpvQZQUqEEaHnNemAj2TQheJPj3 Vwlvdg2RjmlbPaneaPvq9CFD6PE6knP/7wrIjwJR87F9F+LEKkyv67ks2 Xt/gyb15sJ+5poi7MkiAY52C5lWwP+QsgWCkOyxq49SWQx5xiHgAw09mO siTb1WNReBJpOzLw+7bk5h7ecqHD2+JvMig+/RGVjoNbCwoAMWNAYSFcB M4/5ssvlfvmk5rAMxDlYFp1lz16lSPz1XrAL9jzd7i4rxYSYvcpRdlza6 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="261058191" X-IronPort-AV: E=Sophos;i="5.90,240,1643702400"; d="scan'208";a="261058191" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 07:26:52 -0700 X-IronPort-AV: E=Sophos;i="5.90,240,1643702400"; d="scan'208";a="722540100" Received: from mgrabins-mobl.ger.corp.intel.com (HELO localhost) ([10.249.141.83]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 07:26:47 -0700 From: Jani Nikula To: Christian =?utf-8?Q?K=C3=B6nig?= , Grigory Vasilyev , Rodrigo Siqueira , Melissa Wen Cc: Alex Deucher , "Pan, Xinhui" , David Airlie , Daniel Vetter , Jiawei Gu , Lucas De Marchi , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/amdgpu: Senseless code and unnecessary memset In-Reply-To: <614a4844-fa5d-8b8e-0628-894394f31608@amd.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20220405173632.2663-1-h0tc0d3@gmail.com> <614a4844-fa5d-8b8e-0628-894394f31608@amd.com> Date: Wed, 06 Apr 2022 17:26:44 +0300 Message-ID: <874k3670ez.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 05 Apr 2022, Christian K=C3=B6nig wrote: > Am 05.04.22 um 19:36 schrieb Grigory Vasilyev: >> Using memset on local arrays before exiting the function is pointless. >> Compilator will remove this code. Also for local arrays is preferable to >> use {0} instead of memset. Mistakes are often made when working with >> memset. > > Well actually memset is preferred when working with structures which are= =20 > given to the hardware parser because {0} won't initialize paddings. Not that I'd know anything that's going on here... but it sure seems strange to me to be passing unpacked structures where the padding might matter to a "hardware parser". *shrug* BR, Jani. > > So please don't use {0} in any of the atom bios code. > > Regards, > Christian. > >> >> Signed-off-by: Grigory Vasilyev >> --- >> drivers/gpu/drm/amd/amdgpu/atom.c | 8 +------- >> 1 file changed, 1 insertion(+), 7 deletions(-) >> >> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amd= gpu/atom.c >> index be9d61bcb8ae..537e48fbbe6b 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/atom.c >> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c >> @@ -1538,11 +1538,9 @@ struct atom_context *amdgpu_atom_parse(struct car= d_info *card, void *bios) >> int amdgpu_atom_asic_init(struct atom_context *ctx) >> { >> int hwi =3D CU16(ctx->data_table + ATOM_DATA_FWI_PTR); >> - uint32_t ps[16]; >> + uint32_t ps[16] =3D {0}; >> int ret; >>=20=20=20 >> - memset(ps, 0, 64); >> - >> ps[0] =3D cpu_to_le32(CU32(hwi + ATOM_FWI_DEFSCLK_PTR)); >> ps[1] =3D cpu_to_le32(CU32(hwi + ATOM_FWI_DEFMCLK_PTR)); >> if (!ps[0] || !ps[1]) >> @@ -1551,10 +1549,6 @@ int amdgpu_atom_asic_init(struct atom_context *ct= x) >> if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT)) >> return 1; >> ret =3D amdgpu_atom_execute_table(ctx, ATOM_CMD_INIT, ps); >> - if (ret) >> - return ret; >> - >> - memset(ps, 0, 64); >>=20=20=20 >> return ret; >> } > --=20 Jani Nikula, Intel Open Source Graphics Center