How to write to a PCIe config space during kernel boot up

Ozgur Karatas ozgurk at
Wed Apr 13 05:09:36 EDT 2022

On Wed, Apr 13, 2022 at 11:34 AM Greg KH <greg at> wrote:

> On Wed, Apr 13, 2022 at 07:01:01AM +0000, Khalid F. Sabzwari wrote:
> >  Thanks Ozgur for quick reply.The link you shared below seems to work
> with MDIO interface.The PHY used on my board is Intel's i211 PHY which is
> controlled by PCIe interface.I found this link:
> >
> > I never wrote a kernel code before, and am trying to just hack for an
> experiment to write to config space of this PHY. so I will give it a try to
> see if i can read/write to i211's config space, during early kernel boot
> time, using pci_(read|write)_config_(byte|word|dword)

as Greg-KH said below, you dont need to do anything about kernel or PCI
So I have question, this card already driven and initialized by Linux
Can you run this card inserting into slot as PCIE?

if it probably has a driver that uses phy.h I think and in  this case, will
get a PHY id and use it to shift it after initing to PCIE address (for
example PCIE0).
You just need to process module file before inital process and you dont
need to work with an additional processing or PCIE structure on kernel side.

if you want to see an example please check these out:


These examples will show you PCIE addressing shift and PHY communication of
a Qualcom PCIE etherner card.
Sorry for my bad English and wrong information.



> Do so in the driver that binds to the device, before it initializes it.
> Not in the kernel core, otherwise in the kernel core you do not have
> access to the needed pci structures.
> thanks,
> greg k-h
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Kernelnewbies mailing list