All of lore.kernel.org
 help / color / mirror / Atom feed
From: Drew Fustini <fustini@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Adrien Ricciardi" <aricciardi@baylibre.com>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Atish Patra" <atish.patra@linux.dev>,
	"Babu Moger" <babu.moger@amd.com>,
	"Ben Horgan" <ben.horgan@arm.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Chen Pei" <cp0613@linux.alibaba.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Dave Martin" <Dave.Martin@arm.com>,
	"Fenghua Yu" <fenghuay@nvidia.com>,
	"Gong Shuai" <gong.shuai@sanechips.com.cn>,
	"Gong Shuai" <gsh517@gmail.com>,
	guo.wenjia23@zte.com.cn, "James Morse" <james.morse@arm.com>,
	"Kornel Dulęba" <mindal@semihalf.com>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	liu.qingtao2@zte.com.cn,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Peter Newman" <peternewman@google.com>,
	"Radim Krčmář" <radim.krcmar@oss.qualcomm.com>,
	"Reinette Chatre" <reinette.chatre@intel.com>,
	"Rob Herring" <robh@kernel.org>,
	"Samuel Holland" <samuel.holland@sifive.com>,
	"Sunil V L" <sunilvl@oss.qualcomm.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"yunhui cui" <cuiyunhui@bytedance.com>,
	"Zhanpeng Zhang" <zhangzhanpeng.jasper@bytedance.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Shaopeng Tan" <tan.shaopeng@jp.fujitsu.com>,
	"Zeng Heng" <zengheng@picoheart.com>,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	x86@kernel.org, devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH v12 1/5] riscv_cbqri: Add capacity controller core
Date: Thu, 19 Nov 2026 16:21:53 -0800	[thread overview]
Message-ID: <av-SoU-qFbVqz6dn@thelio> (raw)
In-Reply-To: <20261119000846.776930b3@jic23-hlaptop>

On Thu, Nov 19, 2026 at 12:08:46AM +0000, Jonathan Cameron wrote:
> On Sat, 14 Nov 2026 14:06:21 -0800
> Drew Fustini <fustini@kernel.org> wrote:
> 
> > Add the core for RISC-V CBQRI capacity controllers: the register
> > layout, the capability probe, and the allocation operations that
> > program a capacity block mask for an RCID and read it back.
> > 
> > A discovery layer maps the register block and describes the controller
> > in a cbqri_controller_info descriptor. riscv_cbqri_register_cc() probes
> > the controller from that descriptor and adds it to the controller list,
> > which stays private to the core. The core owns the controller state
> > after registration, so nothing in it depends on how the controller was
> > discovered. The caller keeps the register mapping alive.
> > 
> > Tested-by: Zeng Heng <zengheng@picoheart.com>
> > Reviewed-by: Zeng Heng <zengheng@picoheart.com>
> > Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > Signed-off-by: Drew Fustini <fustini@kernel.org>
> 
> A couple more drive by comments.

Thanks for your attention!

> > diff --git a/drivers/resctrl/cbqri_devices.c b/drivers/resctrl/cbqri_devices.c
> > new file mode 100644
> > index 000000000000..5522872f5cc1
> > --- /dev/null
> > +++ b/drivers/resctrl/cbqri_devices.c
> 
> 
> > +
> > +/* Read the configured CBM for closid on the AT half via READ_LIMIT. */
> > +int cbqri_read_cache_config(struct cbqri_controller *ctrl, u32 closid,
> > +			    u32 at, u32 *cbm_out)
> > +{
> > +	int err;
> > +
> > +	guard(mutex)(&ctrl->lock);
> > +
> > +	err = cbqri_cc_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, closid, at, 0);
> > +	if (err == 0) {
> > +		/*
> > +		 * resctrl exposes the CBM as a u32 and cbqri_probe_cc() rejects
> > +		 * ncblks > 32, so the mask fits the low 32-bit word of the
> > +		 * cc_block_mask register.
> > +		 */
> > +		*cbm_out = readl(ctrl->base + CBQRI_CC_BLOCK_MASK_OFF);
> > +	}
> > +
> > +	return err;
> Unless this gets more complex in later patches I'd do
> 	if (err)
> 		return err;
> 
> 	/*
> 	 * resctrl exposes the CBM as a u32 and cbqri_probe_cc() rejects
> 	 * ncblks > 32, so the mask fits the low 32-bit word of the
> 	 * cc_block_mask register.
> 	 */
> 	*cbm_out = readl(ctrl->base + CBQRI_CC_BLOCK_MASK_OFF);
> 
> 	return 0;
> 
> Just to keep error handling out of line and that
> comment block less indented.

It doesn't get more complex so I will change it.

[..]
> > +	/* The resctrl glue keys its domains on cache_id, one controller each. */
> > +	list_for_each_entry(other, &cbqri_controllers, list) {
> > +		if (other->cache.cache_level == info->cache_level &&
> > +		    other->cache.cache_id == info->cache_id) {
> > +			pr_warn("CC at %pa duplicates the L%u cache id %u controller at %pa, skipping\n",
> > +				&ctrl->addr, info->cache_level, info->cache_id,
> > +				&other->addr);
> > +			return -EEXIST;
> > +		}
> > +	}
> > +
> > +	list_add_tail(&ctrl->list, &cbqri_controllers);
> > +	retain_and_null_ptr(ctrl);
> 
> Common trick for this is something like:
> 
> 	list_add_tail(&no_free_ptr(ctrl)->list, &cbqri_controllers);
> 
> because it couples ownership passing with stopping the autofree
> magic.  I'd personally only use retain_and_null_ptr() in cases where I need
> to check for success of the ownership being handed off.

Thanks, I will use no_free_ptr.

[..]
> > +/**
> > + * struct cbqri_controller_info - registration descriptor
> > + * @addr:        MMIO base address of the controller's register interface
> > + * @size:        size of the MMIO region
> > + * @type:        controller type (capacity)
> > + * @rcid_count:  number of supported RCIDs
> > + * @cache_id:    cache id used as the resctrl domain id
> > + * @cache_level: cache level (2 or 3) the controller backs
> > + * @base:        mapped register block, which the caller keeps mapped for
> > + *               the life of the system
> Out of order documentation is unusual.  Why?

No reason, I'll fix it.

Thanks,
Drew

WARNING: multiple messages have this Message-ID (diff)
From: Drew Fustini <fustini@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Adrien Ricciardi" <aricciardi@baylibre.com>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Atish Patra" <atish.patra@linux.dev>,
	"Babu Moger" <babu.moger@amd.com>,
	"Ben Horgan" <ben.horgan@arm.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Chen Pei" <cp0613@linux.alibaba.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Dave Martin" <Dave.Martin@arm.com>,
	"Fenghua Yu" <fenghuay@nvidia.com>,
	"Gong Shuai" <gong.shuai@sanechips.com.cn>,
	"Gong Shuai" <gsh517@gmail.com>,
	guo.wenjia23@zte.com.cn, "James Morse" <james.morse@arm.com>,
	"Kornel Dulęba" <mindal@semihalf.com>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	liu.qingtao2@zte.com.cn,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Peter Newman" <peternewman@google.com>,
	"Radim Krčmář" <radim.krcmar@oss.qualcomm.com>,
	"Reinette Chatre" <reinette.chatre@intel.com>,
	"Rob Herring" <robh@kernel.org>,
	"Samuel Holland" <samuel.holland@sifive.com>,
	"Sunil V L" <sunilvl@oss.qualcomm.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"yunhui cui" <cuiyunhui@bytedance.com>,
	"Zhanpeng Zhang" <zhangzhanpeng.jasper@bytedance.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Shaopeng Tan" <tan.shaopeng@jp.fujitsu.com>,
	"Zeng Heng" <zengheng@picoheart.com>,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	x86@kernel.org, devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH v12 1/5] riscv_cbqri: Add capacity controller core
Date: Thu, 19 Nov 2026 16:21:53 -0800	[thread overview]
Message-ID: <av-SoU-qFbVqz6dn@thelio> (raw)
In-Reply-To: <20261119000846.776930b3@jic23-hlaptop>

On Thu, Nov 19, 2026 at 12:08:46AM +0000, Jonathan Cameron wrote:
> On Sat, 14 Nov 2026 14:06:21 -0800
> Drew Fustini <fustini@kernel.org> wrote:
> 
> > Add the core for RISC-V CBQRI capacity controllers: the register
> > layout, the capability probe, and the allocation operations that
> > program a capacity block mask for an RCID and read it back.
> > 
> > A discovery layer maps the register block and describes the controller
> > in a cbqri_controller_info descriptor. riscv_cbqri_register_cc() probes
> > the controller from that descriptor and adds it to the controller list,
> > which stays private to the core. The core owns the controller state
> > after registration, so nothing in it depends on how the controller was
> > discovered. The caller keeps the register mapping alive.
> > 
> > Tested-by: Zeng Heng <zengheng@picoheart.com>
> > Reviewed-by: Zeng Heng <zengheng@picoheart.com>
> > Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > Signed-off-by: Drew Fustini <fustini@kernel.org>
> 
> A couple more drive by comments.

Thanks for your attention!

> > diff --git a/drivers/resctrl/cbqri_devices.c b/drivers/resctrl/cbqri_devices.c
> > new file mode 100644
> > index 000000000000..5522872f5cc1
> > --- /dev/null
> > +++ b/drivers/resctrl/cbqri_devices.c
> 
> 
> > +
> > +/* Read the configured CBM for closid on the AT half via READ_LIMIT. */
> > +int cbqri_read_cache_config(struct cbqri_controller *ctrl, u32 closid,
> > +			    u32 at, u32 *cbm_out)
> > +{
> > +	int err;
> > +
> > +	guard(mutex)(&ctrl->lock);
> > +
> > +	err = cbqri_cc_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, closid, at, 0);
> > +	if (err == 0) {
> > +		/*
> > +		 * resctrl exposes the CBM as a u32 and cbqri_probe_cc() rejects
> > +		 * ncblks > 32, so the mask fits the low 32-bit word of the
> > +		 * cc_block_mask register.
> > +		 */
> > +		*cbm_out = readl(ctrl->base + CBQRI_CC_BLOCK_MASK_OFF);
> > +	}
> > +
> > +	return err;
> Unless this gets more complex in later patches I'd do
> 	if (err)
> 		return err;
> 
> 	/*
> 	 * resctrl exposes the CBM as a u32 and cbqri_probe_cc() rejects
> 	 * ncblks > 32, so the mask fits the low 32-bit word of the
> 	 * cc_block_mask register.
> 	 */
> 	*cbm_out = readl(ctrl->base + CBQRI_CC_BLOCK_MASK_OFF);
> 
> 	return 0;
> 
> Just to keep error handling out of line and that
> comment block less indented.

It doesn't get more complex so I will change it.

[..]
> > +	/* The resctrl glue keys its domains on cache_id, one controller each. */
> > +	list_for_each_entry(other, &cbqri_controllers, list) {
> > +		if (other->cache.cache_level == info->cache_level &&
> > +		    other->cache.cache_id == info->cache_id) {
> > +			pr_warn("CC at %pa duplicates the L%u cache id %u controller at %pa, skipping\n",
> > +				&ctrl->addr, info->cache_level, info->cache_id,
> > +				&other->addr);
> > +			return -EEXIST;
> > +		}
> > +	}
> > +
> > +	list_add_tail(&ctrl->list, &cbqri_controllers);
> > +	retain_and_null_ptr(ctrl);
> 
> Common trick for this is something like:
> 
> 	list_add_tail(&no_free_ptr(ctrl)->list, &cbqri_controllers);
> 
> because it couples ownership passing with stopping the autofree
> magic.  I'd personally only use retain_and_null_ptr() in cases where I need
> to check for success of the ownership being handed off.

Thanks, I will use no_free_ptr.

[..]
> > +/**
> > + * struct cbqri_controller_info - registration descriptor
> > + * @addr:        MMIO base address of the controller's register interface
> > + * @size:        size of the MMIO region
> > + * @type:        controller type (capacity)
> > + * @rcid_count:  number of supported RCIDs
> > + * @cache_id:    cache id used as the resctrl domain id
> > + * @cache_level: cache level (2 or 3) the controller backs
> > + * @base:        mapped register block, which the caller keeps mapped for
> > + *               the life of the system
> Out of order documentation is unusual.  Why?

No reason, I'll fix it.

Thanks,
Drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2026-11-20  0:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 22:06 [PATCH v12 0/5] riscv: Add initial CBQRI resctrl support Drew Fustini
2026-11-14 22:06 ` Drew Fustini
2026-11-14 22:06 ` [PATCH v12 1/5] riscv_cbqri: Add capacity controller core Drew Fustini
2026-11-14 22:06   ` Drew Fustini
2026-11-19  0:08   ` Jonathan Cameron
2026-11-19  0:08     ` Jonathan Cameron
2026-11-19 11:00     ` [External] " yunhui cui
2026-11-19 11:00       ` yunhui cui
2026-11-20  0:39       ` Drew Fustini
2026-11-20  0:39         ` Drew Fustini
2026-11-20  9:30         ` yunhui cui
2026-11-20  9:30           ` yunhui cui
2026-11-20  0:21     ` Drew Fustini [this message]
2026-11-20  0:21       ` Drew Fustini
2026-11-14 22:06 ` [PATCH v12 2/5] riscv_cbqri: resctrl: Add cache allocation via capacity block mask Drew Fustini
2026-11-14 22:06   ` Drew Fustini
2026-11-14 22:06 ` [PATCH v12 3/5] riscv_cbqri: Make RESCTRL_FS available on RISC-V Drew Fustini
2026-11-14 22:06   ` Drew Fustini
2026-11-14 22:06 ` [PATCH v12 4/5] dt-bindings: riscv: Add binding for CBQRI controllers Drew Fustini
2026-11-14 22:06   ` Drew Fustini
2026-11-14 22:06 ` [PATCH v12 5/5] riscv_cbqri: Add CBQRI capacity allocation platform driver Drew Fustini
2026-11-14 22:06   ` Drew Fustini
2026-11-19  0:00   ` Jonathan Cameron
2026-11-19  0:00     ` Jonathan Cameron
2026-11-20  0:30     ` Drew Fustini
2026-11-20  0:30       ` Drew Fustini

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=av-SoU-qFbVqz6dn@thelio \
    --to=fustini@kernel.org \
    --cc=Dave.Martin@arm.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=aricciardi@baylibre.com \
    --cc=atish.patra@linux.dev \
    --cc=babu.moger@amd.com \
    --cc=ben.horgan@arm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=cp0613@linux.alibaba.com \
    --cc=cuiyunhui@bytedance.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=fenghuay@nvidia.com \
    --cc=gong.shuai@sanechips.com.cn \
    --cc=gsh517@gmail.com \
    --cc=guo.wenjia23@zte.com.cn \
    --cc=james.morse@arm.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=liu.qingtao2@zte.com.cn \
    --cc=liwei1518@gmail.com \
    --cc=mindal@semihalf.com \
    --cc=palmer@dabbelt.com \
    --cc=peternewman@google.com \
    --cc=pjw@kernel.org \
    --cc=radim.krcmar@oss.qualcomm.com \
    --cc=reinette.chatre@intel.com \
    --cc=robh@kernel.org \
    --cc=samuel.holland@sifive.com \
    --cc=sunilvl@oss.qualcomm.com \
    --cc=tan.shaopeng@jp.fujitsu.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=zengheng@picoheart.com \
    --cc=zhangzhanpeng.jasper@bytedance.com \
    --cc=zhiwei_liu@linux.alibaba.com \
    /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.