On Fri, 30 Jan 2026 17:33:50 +0530 Arpit Kumar <[email protected]> wrote:
> On 27/01/26 03:23PM, Jonathan Cameron wrote: > >On Tue, 16 Sep 2025 13:37:34 +0530 > >Arpit Kumar <[email protected]> wrote: > > > >> This patch series refactor existing support for Identify Switch Device > >> and Get Physical Port State by utilizing physical ports (USP & DSP) > >> information stored during enumeration. > > > >Hi Arpit. > > > >So I came back to this series to try and tweak it into being in a state > >for upstreaming. I made some fairly heavy changes (to push the > >data down to the individual ports where to me it more logically sits) > >but it became apparent to me during this that there is a fundamental > >problem. This stuff isn't static because it needs to reflect port > >retraining and hotplug events etc. If we want to store cached > >data we are going to have to deal with updating it from a significant > >number of different places. The perst one you have covered in patch 2 > >is an example but there are others. > > > >Now we definitely can do the generation in a neater way, but I've > >come to the conclusion that caching it really doesn't make sense. > > > >Maybe we can do that for the USP, but definitely not DSPs. > > > >Given I did a bunch of refactoring I might as well share it even though > >I'm currently thinking it might not be worth doing: > > > >From 40a8a36f22a6eb053c965231a698c8054d417049 Mon Sep 17 00:00:00 2001 > >From: Arpit Kumar <[email protected]> > >Date: Tue, 16 Sep 2025 13:37:35 +0530 > >Subject: [PATCH] hw/cxl: Refactored Identify Switch Device & Get Physical > >Port > > State > > > >Store the physical port info for the USP on reset but refresh > >it on demand for the DSPs as they are hotplug capable. > > > >Enables common data to be used for both of: > >* Identify Switch Device (Opcode 5100h) > >* Get Physical Port State (Opcode 5101h) physical switch FM-API command set. > > > >Signed-off-by: Arpit Kumar <[email protected]> > >Co-developed: Jonathan Cameron <[email protected]> > >Signed-off-by: Jonathan Cameron <[email protected]> > > > >--- > >Added a Co-dev as I have modified this a lot from Arpit's v4. > >v5: > >- Create a new header to avoid importing all of cxl_device.h into > >the upstream port emulation. > >- Move the call that caches state to the cxl_upstream_port reset > > to ensure downstream ports are in place before it is called. > > Also will make it available from whatever CCI. If we ever support > > multiple VCS switches this will need to move an appropriate structure > > representing whole switch information. With only one USP that is > > a reasonable place to put full switch info. > >- Downstream ports have more dynamic state (as devices can be > > hotplugged below them). As such, only fill in the data at time > > of request. > > Hi Jonathan, > Thanks for the update! The changes look good to me. I do concede that > it requires more dynamic approach. This would help in future command > support like multiple VCS, MLD etc. I intially refrained from making changes > to individual ports but it does logically fits there and would > optimize the command support. My current thinking is this major refactor is justified. There isn't a strong reason not to do what the original code does and built it directly in the command handler. I'm preparing some cleanup of that though, such as using the defines you added so it is more obvious what values are set. The Physical Port Controls stuff can then drop in on top of that. Once all that is in place we can reconsider if a refactor like the one in the code below is worth doing. We might also need a few more updates to keep track of things like flit mode control patches. Anyhow, I'll throw something together in the next day or two to share. Jonathan
