From: "Cheatham, Benjamin" <benjamin.cheatham@amd.com>
To: Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [RFC PATCH 12/18] cxl/cache: Add CXL Cache ID Route Table mapping
Date: Thu, 18 Sep 2025 15:15:35 -0500 [thread overview]
Message-ID: <91bd9d26-d824-4bc9-ae42-ef1ca73a044d@amd.com> (raw)
In-Reply-To: <e9c93671-5e4c-4ca2-a521-608fe6544a21@intel.com>
[snip]
>> +
>> +static int find_cache_id(struct cxl_cachedev *cxlcd)
>
> get_cache_id()? since you are returning the id.
>
Sure!
>> +{
>> + struct cxl_cache_state *cstate = &cxlcd->cxlds->cstate;
>> + u32 cap, count, entry, portn;
>> + struct cxl_dport *dport;
>> + struct cxl_port *port;
>> + int id;
>> +
>> + if (cstate->cache_id != CXL_CACHE_ID_NO_ID)
>> + return cstate->cache_id;
>> +
>> + dport = cxlcd->endpoint->parent_dport;
>> + if (!dport)
>> + return -ENODEV;
>> + port = dport->port;
>> +
>> + cap = readl(port->regs.cidrt + CXL_CACHE_IDRT_CAP_OFFSET);
>> + count = FIELD_GET(CXL_CACHE_IDRT_CAP_CNT_MASK, cap);
>> +
>> + for (id = 0; id < count; id++) {
>> + entry = readl(port->regs.cidrt +
>> + CXL_CACHE_IDRT_TARGETN_OFFSET(id));
>> + portn = FIELD_GET(CXL_CACHE_IDRT_TARGETN_PORT_MASK, entry);
>> + if (portn != dport->port_id &&
>> + !(entry & CXL_CACHE_IDRT_TARGETN_VALID))
>> + continue;
>> +
>> + cstate->cache_id = id;
>> + return 0;
>> + }
>> +
>> + id = ida_alloc(&cache_id_ida, GFP_KERNEL);
>> + if (id < 0)
>> + return id;
>> +
>> + cstate->cache_id = id;
>> + return devm_add_action_or_reset(&cxlcd->dev, free_cache_id, cstate);
>> +}
>> +
>> +static int devm_cxl_cachedev_allocate_cache_id(struct cxl_cachedev *cxlcd)
>> +{
>> + struct cxl_port *endpoint = cxlcd->endpoint, *port;
>> + struct cxl_dport *dport;
>> + int rc;
>> +
>> + for (dport = endpoint->parent_dport, port = parent_port_of(endpoint);
>> + dport && port && !is_cxl_root(port);
>> + dport = port->parent_dport, port = parent_port_of(port)) {
>> + guard(device)(&port->dev);
>> + rc = map_cache_idrt_cap(port);
>
> Would it make sense to map this once at enumeration instead of every allocation?
>
Yes. I ended up changing cache id assignment/programming to be part of the endpoint port probe
for cache devices. It makes more sense to do this there (imo) since it's technically a port capability
and not device dependent.
next prev parent reply other threads:[~2025-09-18 20:15 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 21:29 [RFC PATCH 00/18] Initial CXL.cache device support Ben Cheatham
2025-08-12 21:29 ` [RFC PATCH 01/18] cxl/mem: Change cxl_memdev_ops to cxl_dev_ops Ben Cheatham
2025-08-12 21:29 ` [RFC PATCH 02/18] cxl: Move struct cxl_dev_state definition Ben Cheatham
2025-08-19 11:33 ` Jonathan Cameron
2025-08-22 18:00 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 03/18] cxl/core: Add CXL.cache device struct Ben Cheatham
2025-08-19 11:48 ` Jonathan Cameron
2025-08-22 18:00 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 04/18] cxl: Replace cxl_mem_find_port() with cxl_dev_find_port() Ben Cheatham
2025-08-12 21:29 ` [RFC PATCH 05/18] cxl: Change cxl_ep_load() to use struct device * parameter Ben Cheatham
2025-08-12 21:29 ` [RFC PATCH 06/18] cxl/port, mem: Make adding an endpoint device type agnostic Ben Cheatham
2025-08-19 11:53 ` Jonathan Cameron
2025-08-22 18:00 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 07/18] cxl/port: Split endpoint port probe on device type Ben Cheatham
2025-08-19 11:57 ` Jonathan Cameron
2025-08-22 18:01 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 08/18] cxl/port: Update switch_port_probe() for CXL cache devices Ben Cheatham
2025-08-19 12:03 ` Jonathan Cameron
2025-08-22 18:01 ` Cheatham, Benjamin
2025-09-09 16:20 ` Dave Jiang
2025-09-09 16:33 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 09/18] cxl/core: Add function for getting CXL cache info Ben Cheatham
2025-09-09 20:58 ` Dave Jiang
2025-09-10 15:55 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 10/18] cxl/cache: Add cxl_cache driver Ben Cheatham
2025-08-19 12:11 ` Jonathan Cameron
2025-08-22 18:01 ` Cheatham, Benjamin
2025-09-09 21:29 ` Dave Jiang
2025-09-10 15:52 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 11/18] cxl/core: Add CXL snoop filter setup and checking Ben Cheatham
2025-08-19 14:18 ` Jonathan Cameron
2025-08-22 18:01 ` Cheatham, Benjamin
2025-09-10 20:36 ` Dave Jiang
2025-09-18 20:15 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 12/18] cxl/cache: Add CXL Cache ID Route Table mapping Ben Cheatham
2025-08-19 15:09 ` Jonathan Cameron
2025-08-22 18:01 ` Cheatham, Benjamin
2025-09-10 21:22 ` Dave Jiang
2025-09-18 20:15 ` Cheatham, Benjamin [this message]
2025-08-12 21:29 ` [RFC PATCH 13/18] cxl/cache: Implement Cache ID Route Table programming Ben Cheatham
2025-08-19 15:07 ` Jonathan Cameron
2025-08-22 18:01 ` Cheatham, Benjamin
2025-09-10 21:37 ` Dave Jiang
2025-09-18 20:15 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 14/18] cxl/cache: Add Cache ID Decoder capability mapping Ben Cheatham
2025-08-19 14:12 ` Alireza Sanaee
2025-08-22 18:01 ` Cheatham, Benjamin
2025-09-10 21:56 ` Dave Jiang
2025-08-12 21:29 ` [RFC PATCH 15/18] cxl/cache: Implement Cache ID Decoder programming Ben Cheatham
2025-08-19 13:44 ` Alireza Sanaee
2025-08-20 8:55 ` Alireza Sanaee
2025-08-19 15:26 ` Jonathan Cameron
2025-08-22 18:01 ` Cheatham, Benjamin
2025-09-10 22:29 ` Dave Jiang
2025-09-18 20:16 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 16/18] cxl/cache: Add cache device counting for CXL ports Ben Cheatham
2025-08-19 15:30 ` Jonathan Cameron
2025-08-22 18:02 ` Cheatham, Benjamin
2025-09-10 22:51 ` Dave Jiang
2025-09-18 20:16 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 17/18] cxl/core: Add cache device attributes Ben Cheatham
2025-08-19 15:38 ` Jonathan Cameron
2025-08-22 18:02 ` Cheatham, Benjamin
2025-08-12 21:29 ` [RFC PATCH 18/18] cxl/core: Add cache device cache management attributes Ben Cheatham
2025-08-19 15:53 ` Jonathan Cameron
2025-08-22 18:02 ` Cheatham, Benjamin
2025-09-10 23:02 ` Dave Jiang
2025-09-18 20:16 ` Cheatham, Benjamin
2025-09-18 21:45 ` Dave Jiang
2025-09-19 13:42 ` Cheatham, Benjamin
2025-08-13 11:25 ` [RFC PATCH 00/18] Initial CXL.cache device support Alejandro Lucero Palau
2025-08-19 15:57 ` Jonathan Cameron
2025-08-19 16:05 ` Jonathan Cameron
2025-08-26 10:42 ` Alejandro Lucero Palau
2025-08-22 18:02 ` Cheatham, Benjamin
2025-08-26 10:44 ` Alejandro Lucero Palau
2025-09-10 23:12 ` Dave Jiang
2025-09-18 20:16 ` Cheatham, Benjamin
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=91bd9d26-d824-4bc9-ae42-ef1ca73a044d@amd.com \
--to=benjamin.cheatham@amd.com \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.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.