From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sunil V L <sunilvl@ventanamicro.com>
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 <corbet@lwn.net>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Daniel Scally <djrscally@gmail.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Anup Patel <anup@brainfault.org>, Marc Zyngier <maz@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Robert Moore <robert.moore@intel.com>,
Haibo Xu <haibo1.xu@intel.com>,
Andrew Jones <ajones@ventanamicro.com>,
Conor Dooley <conor.dooley@microchip.com>,
Atish Kumar Patra <atishp@rivosinc.com>
Subject: Re: [RFC PATCH v1 08/21] RISC-V: ACPI: RHCT: Add function to get CBO block sizes
Date: Fri, 4 Aug 2023 09:00:45 +0300 [thread overview]
Message-ID: <ZMyUDZE0SxoOC696@smile.fi.intel.com> (raw)
In-Reply-To: <20230803175916.3174453-9-sunilvl@ventanamicro.com>
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?
> + 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.
> + 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?
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).
> + return 0;
> + }
> + }
> + }
--
With Best Regards,
Andy Shevchenko
WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sunil V L <sunilvl@ventanamicro.com>
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 <corbet@lwn.net>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Daniel Scally <djrscally@gmail.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Anup Patel <anup@brainfault.org>, Marc Zyngier <maz@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Robert Moore <robert.moore@intel.com>,
Haibo Xu <haibo1.xu@intel.com>,
Andrew Jones <ajones@ventanamicro.com>,
Conor Dooley <conor.dooley@microchip.com>,
Atish Kumar Patra <atishp@rivosinc.com>
Subject: Re: [RFC PATCH v1 08/21] RISC-V: ACPI: RHCT: Add function to get CBO block sizes
Date: Fri, 4 Aug 2023 09:00:45 +0300 [thread overview]
Message-ID: <ZMyUDZE0SxoOC696@smile.fi.intel.com> (raw)
In-Reply-To: <20230803175916.3174453-9-sunilvl@ventanamicro.com>
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?
> + 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.
> + 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?
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).
> + return 0;
> + }
> + }
> + }
--
With Best Regards,
Andy Shevchenko
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sunil V L <sunilvl@ventanamicro.com>
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 <corbet@lwn.net>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Daniel Scally <djrscally@gmail.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Anup Patel <anup@brainfault.org>, Marc Zyngier <maz@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Robert Moore <robert.moore@intel.com>,
Haibo Xu <haibo1.xu@intel.com>,
Andrew Jones <ajones@ventanamicro.com>,
Conor Dooley <conor.dooley@microchip.com>,
Atish Kumar Patra <atishp@rivosinc.com>
Subject: Re: [RFC PATCH v1 08/21] RISC-V: ACPI: RHCT: Add function to get CBO block sizes
Date: Fri, 4 Aug 2023 09:00:45 +0300 [thread overview]
Message-ID: <ZMyUDZE0SxoOC696@smile.fi.intel.com> (raw)
In-Reply-To: <20230803175916.3174453-9-sunilvl@ventanamicro.com>
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?
> + 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.
> + 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?
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).
> + return 0;
> + }
> + }
> + }
--
With Best Regards,
Andy Shevchenko
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-08-04 6:02 UTC|newest]
Thread overview: 150+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 17:58 [RFC PATCH v1 00/21] RISC-V: ACPI: Add external interrupt controller support Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` [RFC PATCH v1 01/21] ACPICA: MADT: Add RISC-V external interrupt controllers Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` [RFC PATCH v1 02/21] ACPICA: RHCT: Add flags, CMO and MMU nodes Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` [RFC PATCH v1 03/21] RISC-V: ACPI: Fix acpi_os_ioremap to return iomem address Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-07 8:20 ` Andrew Jones
2023-08-07 8:20 ` Andrew Jones
2023-08-07 8:20 ` Andrew Jones
2023-08-03 17:58 ` [RFC PATCH v1 04/21] RISC-V: ACPI: Enhance acpi_os_ioremap with MMIO remapping Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-03 17:58 ` Sunil V L
2023-08-04 5:47 ` Andy Shevchenko
2023-08-04 5:47 ` Andy Shevchenko
2023-08-04 5:47 ` Andy Shevchenko
2023-08-04 8:19 ` Sunil V L
2023-08-04 8:19 ` Sunil V L
2023-08-04 8:19 ` Sunil V L
2023-08-07 8:41 ` Andrew Jones
2023-08-07 8:41 ` Andrew Jones
2023-08-07 8:41 ` Andrew Jones
2023-08-03 17:59 ` [RFC PATCH v1 05/21] arm64: PCI: Migrate ACPI related functions to pci-acpi.c Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-04 5:53 ` Andy Shevchenko
2023-08-04 5:53 ` Andy Shevchenko
2023-08-04 5:53 ` Andy Shevchenko
2023-08-04 8:23 ` Sunil V L
2023-08-04 8:23 ` Sunil V L
2023-08-04 8:23 ` Sunil V L
2023-08-07 22:41 ` Bjorn Helgaas
2023-08-07 22:41 ` Bjorn Helgaas
2023-08-07 22:41 ` Bjorn Helgaas
2023-08-08 4:52 ` Sunil V L
2023-08-08 4:52 ` Sunil V L
2023-08-08 4:52 ` Sunil V L
2023-08-08 13:11 ` Andy Shevchenko
2023-08-08 13:11 ` Andy Shevchenko
2023-08-08 13:11 ` Andy Shevchenko
2023-08-08 13:11 ` Andy Shevchenko
2023-08-08 13:11 ` Andy Shevchenko
2023-08-08 13:11 ` Andy Shevchenko
2023-08-03 17:59 ` [RFC PATCH v1 06/21] RISC-V: ACPI: Implement PCI related functionality Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 07/21] RISC-V: Kconfig: Select ECAM and MCFG Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 08/21] RISC-V: ACPI: RHCT: Add function to get CBO block sizes Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-04 6:00 ` Andy Shevchenko [this message]
2023-08-04 6:00 ` Andy Shevchenko
2023-08-04 6:00 ` Andy Shevchenko
2023-08-04 9:33 ` Sunil V L
2023-08-04 9:33 ` Sunil V L
2023-08-04 9:33 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 09/21] RISC-V: cacheflush: Initialize CBO variables on ACPI systems Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-04 5:56 ` Andy Shevchenko
2023-08-04 5:56 ` Andy Shevchenko
2023-08-04 5:56 ` Andy Shevchenko
2023-08-04 9:20 ` Sunil V L
2023-08-04 9:20 ` Sunil V L
2023-08-04 9:20 ` Sunil V L
2023-08-04 14:59 ` Andy Shevchenko
2023-08-04 14:59 ` Andy Shevchenko
2023-08-04 14:59 ` Andy Shevchenko
2023-08-04 15:19 ` Conor Dooley
2023-08-04 15:19 ` Conor Dooley
2023-08-04 16:52 ` Andy Shevchenko
2023-08-04 16:52 ` Andy Shevchenko
2023-08-04 16:56 ` Andy Shevchenko
2023-08-04 16:56 ` Andy Shevchenko
2023-08-03 17:59 ` [RFC PATCH v1 10/21] clocksource/timer-riscv: ACPI: Add timer_cannot_wakeup_cpu Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 11/21] swnode: Add support to create early during boot Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-04 6:09 ` Andy Shevchenko
2023-08-04 6:09 ` Andy Shevchenko
2023-08-04 6:09 ` Andy Shevchenko
2023-08-04 8:11 ` Sunil V L
2023-08-04 8:11 ` Sunil V L
2023-08-04 8:11 ` Sunil V L
2023-08-08 13:17 ` Marc Zyngier
2023-08-08 13:17 ` Marc Zyngier
2023-08-08 13:17 ` Marc Zyngier
2023-08-09 5:44 ` Sunil V L
2023-08-09 5:44 ` Sunil V L
2023-08-09 5:44 ` Sunil V L
2023-08-08 13:06 ` Marc Zyngier
2023-08-08 13:06 ` Marc Zyngier
2023-08-08 13:06 ` Marc Zyngier
2023-08-03 17:59 ` [RFC PATCH v1 12/21] irqchip/riscv-intc: Use swnode framework to create fwnode Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-08 8:31 ` Conor Dooley
2023-08-08 8:31 ` Conor Dooley
2023-08-08 8:31 ` Conor Dooley
2023-08-09 5:49 ` Sunil V L
2023-08-09 5:49 ` Sunil V L
2023-08-09 5:49 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 13/21] irqchip/riscv-imsic-early: Add ACPI support Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 14/21] ACPI: bus: Add acpi_riscv_init function Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 15/21] ACPI: RISC-V: Create IMSIC platform device Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 16/21] ACPI: Add APLIC IRQ model for RISC-V Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 17/21] ACPI: RISC-V: Create APLIC platform device Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 18/21] irqchip/irq-riscv-aplic-msi: Add ACPI support Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 19/21] ACPI: bus: Add PLIC IRQ model Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 20/21] RISC-V: ACPI: Create PLIC platform device Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-08 8:41 ` Conor Dooley
2023-08-08 8:41 ` Conor Dooley
2023-08-08 8:41 ` Conor Dooley
2023-08-08 10:57 ` Anup Patel
2023-08-08 10:57 ` Anup Patel
2023-08-08 10:57 ` Anup Patel
2023-08-08 11:30 ` Conor Dooley
2023-08-08 11:30 ` Conor Dooley
2023-08-08 11:30 ` Conor Dooley
2023-08-09 5:47 ` Sunil V L
2023-08-09 5:47 ` Sunil V L
2023-08-09 5:47 ` Sunil V L
2023-08-03 17:59 ` [RFC PATCH v1 21/21] irqchip/sifive-plic: Add GSI conversion support Sunil V L
2023-08-03 17:59 ` Sunil V L
2023-08-03 17:59 ` Sunil V L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZMyUDZE0SxoOC696@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=ajones@ventanamicro.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atishp@rivosinc.com \
--cc=bhelgaas@google.com \
--cc=catalin.marinas@arm.com \
--cc=conor.dooley@microchip.com \
--cc=corbet@lwn.net \
--cc=daniel.lezcano@linaro.org \
--cc=djrscally@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=haibo1.xu@intel.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=maz@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rafael@kernel.org \
--cc=robert.moore@intel.com \
--cc=sakari.ailus@linux.intel.com \
--cc=sunilvl@ventanamicro.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.