Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3331133rwo; Fri, 4 Aug 2023 03:16:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZcrAD13dZy/XId7G0SFBmJhsJsqR7PZVkMetPvHaans7u23NoNHtOwOxYLTMyw79Mq8Pu X-Received: by 2002:a17:90b:38c9:b0:261:1141:b716 with SMTP id nn9-20020a17090b38c900b002611141b716mr1213540pjb.33.1691144165787; Fri, 04 Aug 2023 03:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691144165; cv=none; d=google.com; s=arc-20160816; b=ubRz2QV7qCW6UI5j4CAeuBPfSiEmGmX/SlWy0Nlwh2D+phtRtQ1kRMpn5OqHixcuNl HLKDw4336S2OxIu4v8jweQiElQyf8RsoWo6i96fLraEick7bgeWVLS1fD0fsX7LeXTsu TmhrSR468irtCGk8rLSAhMKvjDBsYdm+Hsh9uaySD2ViX/vjU/vhbs+UvB+2PLpwCf3Z r8VJd8nUTbcRfvVcoQh/+diuovQRnrDePfG2em5KtWjw7v9W7p+bYEQSA6a/XS76zLD6 dralXVb19fHliFLHecNnu3qWMm8a238N6Qe5ABXUkaktshYyLimg9L/yyzVBFtpOiuGv KOsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E6pJFE+LbN3t9KX562ET/U8O9x6jKkVFfcHxU4OoKLU=; fh=GdWGeGpgCZxFdk5L95QTCXMU26XJG8MVLG1BM6S+0oI=; b=bqc64Y0z9sNvt+aE2qWTAaLPL5m8Pah8cI56iPod57DvnETwR/OPpVx0Qr8N/MD85/ 5VBOCMxDsb5YezUXhVubz+9uDmkVNH1LCRiZptX9CsLPbQPmp3k/UcE3sCA5awwPLLnc n5OKDIIXayBg9bTmizkG0w2IwaaRx0FbmCkPCH/ngbXQiJz6kjEJ7E0uEsfciFnANi/c IiFl7X/LnJrC+Eo2DEsXCg733JFvb8Ps8Vx9APlL4bY1vJq0Mbv6wNEC81zNaRlcVOKZ +YqJ8RVahGc3kT04ahYElulHTy0PQjc3pBY+gshQZxHnC6lu4gzsd4HzodX8Javy13eI vVeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GaIVrBlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a17090a70ce00b0026825823da0si1650903pjm.59.2023.08.04.03.15.53; Fri, 04 Aug 2023 03:16:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GaIVrBlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbjHDJds (ORCPT + 99 others); Fri, 4 Aug 2023 05:33:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjHDJdo (ORCPT ); Fri, 4 Aug 2023 05:33:44 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F15D49C7 for ; Fri, 4 Aug 2023 02:33:41 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-686f8614ce5so1770334b3a.3 for ; Fri, 04 Aug 2023 02:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1691141621; x=1691746421; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=E6pJFE+LbN3t9KX562ET/U8O9x6jKkVFfcHxU4OoKLU=; b=GaIVrBlWNau1bDYf593GlJiU6Af7nAeBxxB4u4JryuWCHG8sEeuZrKeXi0Jkc5ydvg f5XIIJXgZ6tFqSs1y6JJluCYxHah8cYi2iM/peqn9wrByAlUjT+T5EwQdGIKOSObiBdh vXZrFjRXul+2bYCK0XU0x719gMWrepNiI/ld1MZjlcvoWzgIWyqD4vQWEGTYvdAlr4vl yOuYWt4cBHch29OVlaSlUWs+NHFRivXWHfPcmPSAIcRaXJrYop/kZMlqspmCLYJAq1TM RzOhjzIV+E8WdLg0Scjri0wwQ7hnaraeQULqXHImH4YHHGDqMS4OttacG9d3If/bcmxc an/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691141621; x=1691746421; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=E6pJFE+LbN3t9KX562ET/U8O9x6jKkVFfcHxU4OoKLU=; b=h0FjTDzFzPOZdGYbPWpcQVtqEb8FdVWcanfCOgNKxxQ1lqgW/hh5hplmi4fC+r896G rWWP17BYnnxd6Eo7pqUkc9Qwg4SOxMK+nB6gQ8rgPVaQ+qh+3gVpA+I5BHuRwigetRbE lPNGtUzRVF0GzHtR/cGJ3X05ZDA2rnVow/jNgeaGCHzKyCLBCjZxU5s3MCxh7DveZ5eK kmEqjTJtzQMyRTqm/cYomDmV4rtaZ5W2nkAOAcPTgGsYSfClvzN6uvdPgBedZviKNLeU iSa38I6mEGsqAqm3n2Gw+tbmxXXrdFJkbUJcYUprY31wz/4LimQS1DOayiNBtRYuebWs /XjA== X-Gm-Message-State: AOJu0YwIN2cxZFhg9Zbou0sJpcbCMvukkzE71zbaaBswOlQChiEUytu7 p11xYJrM3OJIW10qyRGJO3kFmg== X-Received: by 2002:a05:6a00:21d5:b0:687:7d09:c0f with SMTP id t21-20020a056a0021d500b006877d090c0fmr1517925pfj.12.1691141620733; Fri, 04 Aug 2023 02:33:40 -0700 (PDT) Received: from sunil-laptop ([106.51.190.143]) by smtp.gmail.com with ESMTPSA id v13-20020a62a50d000000b00686ee7ba3easm1180143pfm.216.2023.08.04.02.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 02:33:40 -0700 (PDT) Date: Fri, 4 Aug 2023 15:03:29 +0530 From: Sunil V L To: Andy Shevchenko Cc: linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" , Len Brown , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , Daniel Lezcano , Thomas Gleixner , Anup Patel , Marc Zyngier , Bjorn Helgaas , Robert Moore , Haibo Xu , Andrew Jones , Conor Dooley , Atish Kumar Patra Subject: Re: [RFC PATCH v1 08/21] RISC-V: ACPI: RHCT: Add function to get CBO block sizes Message-ID: References: <20230803175916.3174453-1-sunilvl@ventanamicro.com> <20230803175916.3174453-9-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 Fri, Aug 04, 2023 at 09:00:45AM +0300, Andy Shevchenko wrote: > On Thu, Aug 03, 2023 at 11:29:03PM +0530, Sunil V L wrote: > > CBO related block size in ACPI is provided by RHCT. Add > > support to read the CMO node in RHCT to get this information. > > ... > > > + if (!table) { > > Why not positive conditional? > Sure. > > + rhct = (struct acpi_table_rhct *)acpi_get_rhct(); > > + if (!rhct) > > + return -ENOENT; > > + } else { > > + rhct = (struct acpi_table_rhct *)table; > > + } > > ... > > > + end = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->header.length); > > > + > > Blank line here is not needed. > Okay. > > + for (node = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->node_offset); > > + node < end; > > + node = ACPI_ADD_PTR(struct acpi_rhct_node_header, node, node->length)) { > > > + for (int i = 0; i < hart_info->num_offsets; i++) { > > + ref_node = ACPI_ADD_PTR(struct acpi_rhct_node_header, > > + rhct, hart_info_node_offset[i]); > > + if (ref_node->type == ACPI_RHCT_NODE_TYPE_CMO) { > > + cmo_node = ACPI_ADD_PTR(struct acpi_rhct_cmo_node, > > + ref_node, size_hdr); > > + if (cbom_size) > > + *cbom_size = 1 << cmo_node->cbom_size; > > + > > + if (cboz_size) > > + *cboz_size = 1 << cmo_node->cboz_size; > > + > > + if (cbop_size) > > + *cbop_size = 1 << cmo_node->cbop_size; > > BIT() in all three cases? > Sure. > But how you guarantee it will not overflow? I mean who prevents cboX_size to be > bigger than 30 (note also that 31 in your case is Undefined Behaviour in > accordance with the C standard). > Good catch!. Let me add a check that the value is not more than 30. Thanks! Sunil