All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/3] cxl: Region bandwidth calculation for targets with shared upstream link
@ 2024-07-10 22:23 Dave Jiang
  2024-07-10 22:24 ` [PATCH v7 1/3] cxl: Preserve the CDAT access_coordinate for an endpoint Dave Jiang
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Dave Jiang @ 2024-07-10 22:23 UTC (permalink / raw)
  To: linux-cxl
  Cc: dan.j.williams, ira.weiny, vishal.l.verma, alison.schofield,
	Jonathan.Cameron, dave

v7:
- Add documentation explaining how the bandwidth is calculated. (Dan)
- Fix 2hb2rp2ep case. (Jonathan)
  - Split out the RP and HB level work.
- Rename functions and add kdoc comments to clarify the code. (Dan)
- Move activation point to immediately after cxl_region_setup_targets(). (Dan)
- Added information on testing and results in commit log. (Dan)
- See specific patches for more details.

This series provides recalculation of the CXL region bandwidth when the targets have
shared upstream link by walking the toplogy from bottom up and clamp the bandwdith
as the code traverses up the tree. An example topology:

 An example topology from Jonathan:

                 CFMWS 0
                   |
          _________|_________
         |                   |
     ACPI0017-0            ACPI0017-1
   GP0/HB0/ACPI0016-0   GP1/HB1/ACPI0016-1
     |          |        |           |
    RP0        RP1      RP2         RP3
     |          |        |           |
   SW 0       SW 1     SW 2        SW 3
   |   |      |   |    |   |       |   |
  EP0 EP1    EP2 EP3  EP4  EP5    EP6 EP7

 Computation for the example topology:

 Min (GP0 to CPU BW,
      Min(SW 0 Upstream Link to RP0 BW,
          Min(SW0SSLBIS for SW0DSP0 (EP0), EP0 DSLBIS, EP0 Upstream Link) +
          Min(SW0SSLBIS for SW0DSP1 (EP1), EP1 DSLBIS, EP1 Upstream link)) +
      Min(SW 1 Upstream Link to RP1 BW,
          Min(SW1SSLBIS for SW1DSP0 (EP2), EP2 DSLBIS, EP2 Upstream Link) +
          Min(SW1SSLBIS for SW1DSP1 (EP3), EP3 DSLBIS, EP3 Upstream link))) +
 Min (GP1 to CPU BW,
      Min(SW 2 Upstream Link to RP2 BW,
          Min(SW2SSLBIS for SW2DSP0 (EP4), EP4 DSLBIS, EP4 Upstream Link) +
          Min(SW2SSLBIS for SW2DSP1 (EP5), EP5 DSLBIS, EP5 Upstream link)) +
      Min(SW 3 Upstream Link to RP3 BW,
          Min(SW3SSLBIS for SW3DSP0 (EP6), EP6 DSLBIS, EP6 Upstream Link) +
          Min(SW3SSLBIS for SW3DSP1 (EP7), EP7 DSLBIS, EP7 Upstream link))))

---

Dave Jiang (3):
      cxl: Preserve the CDAT access_coordinate for an endpoint
      cxl: Calculate region bandwidth of targets with shared upstream link
      cxl: Add documentation to explain the shared link bandwidth calculation

 Documentation/driver-api/cxl/access-coordinates.rst |  90 +++++++
 Documentation/driver-api/cxl/index.rst              |   1 +
 MAINTAINERS                                         |   1 +
 drivers/cxl/core/cdat.c                             | 509 +++++++++++++++++++++++++++++++++++++++-
 drivers/cxl/core/core.h                             |   4 +-
 drivers/cxl/core/pci.c                              |  23 ++
 drivers/cxl/core/port.c                             |  20 ++
 drivers/cxl/core/region.c                           |   2 +
 drivers/cxl/cxl.h                                   |   1 +
 drivers/cxl/cxlmem.h                                |   4 +-
 10 files changed, 640 insertions(+), 15 deletions(-)


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [PATCH v7 2/3] cxl: Calculate region bandwidth of targets with shared upstream link
@ 2024-07-11 12:04 kernel test robot
  0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2024-07-11 12:04 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240710222716.797267-3-dave.jiang@intel.com>
References: <20240710222716.797267-3-dave.jiang@intel.com>
TO: Dave Jiang <dave.jiang@intel.com>

Hi Dave,

kernel test robot noticed the following build warnings:

[auto build test WARNING on v6.10-rc6]
[cannot apply to cxl/next linus/master cxl/pending v6.10-rc7 next-20240711]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dave-Jiang/cxl-Preserve-the-CDAT-access_coordinate-for-an-endpoint/20240711-092210
base:   v6.10-rc6
patch link:    https://lore.kernel.org/r/20240710222716.797267-3-dave.jiang%40intel.com
patch subject: [PATCH v7 2/3] cxl: Calculate region bandwidth of targets with shared upstream link
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: i386-randconfig-141-20240711 (https://download.01.org/0day-ci/archive/20240711/202407111927.7Q2PF9i0-lkp@intel.com/config)
compiler: gcc-10 (Ubuntu 10.5.0-1ubuntu1) 10.5.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202407111927.7Q2PF9i0-lkp@intel.com/

smatch warnings:
drivers/cxl/core/cdat.c:785 cxl_switch_gather_bandwidth() error: uninitialized symbol 'is_root'.

vim +/is_root +785 drivers/cxl/core/cdat.c

dfbcea34995e70 Dave Jiang 2024-07-10  732  
dfbcea34995e70 Dave Jiang 2024-07-10  733  /*
dfbcea34995e70 Dave Jiang 2024-07-10  734   * cxl_switch_gather_bandwidth - collect all the bandwidth at switch level in an xarray
dfbcea34995e70 Dave Jiang 2024-07-10  735   * @cxlr: The region being operated on
dfbcea34995e70 Dave Jiang 2024-07-10  736   * @input_xa: xarray indexed by upstream device of a switch with data of 'struct
dfbcea34995e70 Dave Jiang 2024-07-10  737   *	      cxl_perf_ctx'
dfbcea34995e70 Dave Jiang 2024-07-10  738   * @gp_is_root: (output) bool of whether the grandparent is cxl root.
dfbcea34995e70 Dave Jiang 2024-07-10  739   *
dfbcea34995e70 Dave Jiang 2024-07-10  740   * Return: a xarray of resulting cxl_perf_ctx per parent switch or root port
dfbcea34995e70 Dave Jiang 2024-07-10  741   *         or ERR_PTR(-errno)
dfbcea34995e70 Dave Jiang 2024-07-10  742   *
dfbcea34995e70 Dave Jiang 2024-07-10  743   * Iterate through the xarray. Take the minimum of the downstream calculated
dfbcea34995e70 Dave Jiang 2024-07-10  744   * bandwidth, the upstream link bandwidth, and the SSLBIS of the upstream
dfbcea34995e70 Dave Jiang 2024-07-10  745   * switch if exists. Sum the resulting bandwidth under the switch upstream
dfbcea34995e70 Dave Jiang 2024-07-10  746   * device or a RP device. The function can be iterated over multiple switches
dfbcea34995e70 Dave Jiang 2024-07-10  747   * if the switches are present.
dfbcea34995e70 Dave Jiang 2024-07-10  748   */
dfbcea34995e70 Dave Jiang 2024-07-10  749  static struct xarray *cxl_switch_gather_bandwidth(struct cxl_region *cxlr,
dfbcea34995e70 Dave Jiang 2024-07-10  750  						  struct xarray *input_xa,
dfbcea34995e70 Dave Jiang 2024-07-10  751  						  bool *gp_is_root)
dfbcea34995e70 Dave Jiang 2024-07-10  752  {
dfbcea34995e70 Dave Jiang 2024-07-10  753  	struct xarray *res_xa __free(free_perf_xa) =
dfbcea34995e70 Dave Jiang 2024-07-10  754  		kzalloc(sizeof(*res_xa), GFP_KERNEL);
dfbcea34995e70 Dave Jiang 2024-07-10  755  	struct access_coordinate coords[ACCESS_COORDINATE_MAX];
dfbcea34995e70 Dave Jiang 2024-07-10  756  	struct cxl_perf_ctx *ctx, *us_ctx;
dfbcea34995e70 Dave Jiang 2024-07-10  757  	unsigned long index, us_index;
dfbcea34995e70 Dave Jiang 2024-07-10  758  	int dev_count = 0;
dfbcea34995e70 Dave Jiang 2024-07-10  759  	int gp_count = 0;
dfbcea34995e70 Dave Jiang 2024-07-10  760  	void *ptr;
dfbcea34995e70 Dave Jiang 2024-07-10  761  	int rc;
dfbcea34995e70 Dave Jiang 2024-07-10  762  
dfbcea34995e70 Dave Jiang 2024-07-10  763  	if (!res_xa)
dfbcea34995e70 Dave Jiang 2024-07-10  764  		return ERR_PTR(-ENOMEM);
dfbcea34995e70 Dave Jiang 2024-07-10  765  	xa_init(res_xa);
dfbcea34995e70 Dave Jiang 2024-07-10  766  
dfbcea34995e70 Dave Jiang 2024-07-10  767  	xa_for_each(input_xa, index, ctx) {
dfbcea34995e70 Dave Jiang 2024-07-10  768  		struct device *dev = (struct device *)index;
dfbcea34995e70 Dave Jiang 2024-07-10  769  		struct cxl_port *port = ctx->port;
dfbcea34995e70 Dave Jiang 2024-07-10  770  		struct cxl_port *parent_port = to_cxl_port(port->dev.parent);
dfbcea34995e70 Dave Jiang 2024-07-10  771  		struct cxl_port *gp_port = to_cxl_port(parent_port->dev.parent);
dfbcea34995e70 Dave Jiang 2024-07-10  772  		struct cxl_dport *dport = port->parent_dport;
dfbcea34995e70 Dave Jiang 2024-07-10  773  		bool is_root;
dfbcea34995e70 Dave Jiang 2024-07-10  774  
dfbcea34995e70 Dave Jiang 2024-07-10  775  		dev_count++;
dfbcea34995e70 Dave Jiang 2024-07-10  776  		if (is_cxl_root(gp_port)) {
dfbcea34995e70 Dave Jiang 2024-07-10  777  			is_root = true;
dfbcea34995e70 Dave Jiang 2024-07-10  778  			gp_count++;
dfbcea34995e70 Dave Jiang 2024-07-10  779  		}
dfbcea34995e70 Dave Jiang 2024-07-10  780  
dfbcea34995e70 Dave Jiang 2024-07-10  781  		/*
dfbcea34995e70 Dave Jiang 2024-07-10  782  		 * If the grandparent is cxl root, then index is the root port,
dfbcea34995e70 Dave Jiang 2024-07-10  783  		 * otherwise it's the parent switch upstream device.
dfbcea34995e70 Dave Jiang 2024-07-10  784  		 */
dfbcea34995e70 Dave Jiang 2024-07-10 @785  		if (is_root)
dfbcea34995e70 Dave Jiang 2024-07-10  786  			us_index = (unsigned long)port->parent_dport->dport_dev;
dfbcea34995e70 Dave Jiang 2024-07-10  787  		else
dfbcea34995e70 Dave Jiang 2024-07-10  788  			us_index = (unsigned long)parent_port->uport_dev;
dfbcea34995e70 Dave Jiang 2024-07-10  789  
dfbcea34995e70 Dave Jiang 2024-07-10  790  		us_ctx = xa_load(res_xa, us_index);
dfbcea34995e70 Dave Jiang 2024-07-10  791  		if (!us_ctx) {
dfbcea34995e70 Dave Jiang 2024-07-10  792  			struct cxl_perf_ctx *n __free(kfree) =
dfbcea34995e70 Dave Jiang 2024-07-10  793  				kzalloc(sizeof(*n), GFP_KERNEL);
dfbcea34995e70 Dave Jiang 2024-07-10  794  
dfbcea34995e70 Dave Jiang 2024-07-10  795  			if (!n)
dfbcea34995e70 Dave Jiang 2024-07-10  796  				return ERR_PTR(-ENOMEM);
dfbcea34995e70 Dave Jiang 2024-07-10  797  
dfbcea34995e70 Dave Jiang 2024-07-10  798  			ptr = xa_store(res_xa, us_index, n, GFP_KERNEL);
dfbcea34995e70 Dave Jiang 2024-07-10  799  			if (xa_is_err(ptr))
dfbcea34995e70 Dave Jiang 2024-07-10  800  				return ERR_PTR(xa_err(ptr));
dfbcea34995e70 Dave Jiang 2024-07-10  801  			us_ctx = no_free_ptr(n);
dfbcea34995e70 Dave Jiang 2024-07-10  802  			us_ctx->port = parent_port;
dfbcea34995e70 Dave Jiang 2024-07-10  803  		}
dfbcea34995e70 Dave Jiang 2024-07-10  804  
dfbcea34995e70 Dave Jiang 2024-07-10  805  		/*
dfbcea34995e70 Dave Jiang 2024-07-10  806  		 * If the device isn't an upstream PCIe port, there's something
dfbcea34995e70 Dave Jiang 2024-07-10  807  		 * wrong with the topology.
dfbcea34995e70 Dave Jiang 2024-07-10  808  		 */
dfbcea34995e70 Dave Jiang 2024-07-10  809  		if (!dev_is_pci(dev))
dfbcea34995e70 Dave Jiang 2024-07-10  810  			return ERR_PTR(-EINVAL);
dfbcea34995e70 Dave Jiang 2024-07-10  811  
dfbcea34995e70 Dave Jiang 2024-07-10  812  		/* Retrieve the upstream link bandwidth */
dfbcea34995e70 Dave Jiang 2024-07-10  813  		rc = cxl_pci_get_bandwidth(to_pci_dev(dev), coords);
dfbcea34995e70 Dave Jiang 2024-07-10  814  		if (rc)
dfbcea34995e70 Dave Jiang 2024-07-10  815  			return ERR_PTR(-ENXIO);
dfbcea34995e70 Dave Jiang 2024-07-10  816  
dfbcea34995e70 Dave Jiang 2024-07-10  817  		/*
dfbcea34995e70 Dave Jiang 2024-07-10  818  		 * Take the min of downstream bandwidth and the upstream link
dfbcea34995e70 Dave Jiang 2024-07-10  819  		 * bandwidth.
dfbcea34995e70 Dave Jiang 2024-07-10  820  		 */
dfbcea34995e70 Dave Jiang 2024-07-10  821  		cxl_coordinates_combine(coords, coords, ctx->coord);
dfbcea34995e70 Dave Jiang 2024-07-10  822  
dfbcea34995e70 Dave Jiang 2024-07-10  823  		/*
dfbcea34995e70 Dave Jiang 2024-07-10  824  		 * Take the min of the calculated bandwdith and the upstream
dfbcea34995e70 Dave Jiang 2024-07-10  825  		 * switch SSLBIS bandwidth if there's a parent switch
dfbcea34995e70 Dave Jiang 2024-07-10  826  		 */
dfbcea34995e70 Dave Jiang 2024-07-10  827  		if (!is_root)
dfbcea34995e70 Dave Jiang 2024-07-10  828  			cxl_coordinates_combine(coords, coords, dport->coord);
dfbcea34995e70 Dave Jiang 2024-07-10  829  
dfbcea34995e70 Dave Jiang 2024-07-10  830  		/*
dfbcea34995e70 Dave Jiang 2024-07-10  831  		 * Aggregate the calculated bandwidth common to an upstream
dfbcea34995e70 Dave Jiang 2024-07-10  832  		 * switch.
dfbcea34995e70 Dave Jiang 2024-07-10  833  		 */
dfbcea34995e70 Dave Jiang 2024-07-10  834  		cxl_bandwidth_add(us_ctx->coord, us_ctx->coord, coords);
dfbcea34995e70 Dave Jiang 2024-07-10  835  	}
dfbcea34995e70 Dave Jiang 2024-07-10  836  
dfbcea34995e70 Dave Jiang 2024-07-10  837  	/* Asymmetric topology detected. */
dfbcea34995e70 Dave Jiang 2024-07-10  838  	if (gp_count) {
dfbcea34995e70 Dave Jiang 2024-07-10  839  		if (gp_count != dev_count) {
dfbcea34995e70 Dave Jiang 2024-07-10  840  			dev_dbg(&cxlr->dev,
dfbcea34995e70 Dave Jiang 2024-07-10  841  				"Asymmetric hierachy detected, bandwidth not updated\n");
dfbcea34995e70 Dave Jiang 2024-07-10  842  			return ERR_PTR(-EOPNOTSUPP);
dfbcea34995e70 Dave Jiang 2024-07-10  843  		}
dfbcea34995e70 Dave Jiang 2024-07-10  844  		*gp_is_root = true;
dfbcea34995e70 Dave Jiang 2024-07-10  845  	}
dfbcea34995e70 Dave Jiang 2024-07-10  846  
dfbcea34995e70 Dave Jiang 2024-07-10  847  	return no_free_ptr(res_xa);
dfbcea34995e70 Dave Jiang 2024-07-10  848  }
dfbcea34995e70 Dave Jiang 2024-07-10  849  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-08-28 16:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10 22:23 [PATCH v7 0/3] cxl: Region bandwidth calculation for targets with shared upstream link Dave Jiang
2024-07-10 22:24 ` [PATCH v7 1/3] cxl: Preserve the CDAT access_coordinate for an endpoint Dave Jiang
2024-07-10 22:24 ` [PATCH v7 2/3] cxl: Calculate region bandwidth of targets with shared upstream link Dave Jiang
2024-07-11  1:39   ` Alison Schofield
2024-07-11 16:00     ` Dave Jiang
2024-07-11  7:15   ` kernel test robot
2024-07-11 13:45   ` Dan Carpenter
2024-07-10 22:24 ` [PATCH v7 3/3] cxl: Add documentation to explain the shared link bandwidth calculation Dave Jiang
2024-08-27 16:06   ` Jonathan Cameron
2024-08-27 22:38     ` Dave Jiang
2024-08-28  9:00       ` Jonathan Cameron
2024-08-28 15:35         ` Dave Jiang
2024-08-28 16:12           ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2024-07-11 12:04 [PATCH v7 2/3] cxl: Calculate region bandwidth of targets with shared upstream link kernel test robot

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.