Re: [PATCH 3/3] PCI: mediatek-gen3: Move reset/assert callbacks in .power_up()

lorenzo
2024-11-08T17:26:39Z

[-- Attachment #1: Type: text/plain, Size: 2400 bytes --]

On Nov 08, Bjorn Helgaas wrote:
> On Fri, Nov 08, 2024 at 06:04:13PM +0100, lorenzo@kernel.org wrote:
> > > On Fri, Nov 08, 2024 at 09:39:41AM +0100, lorenzo@kernel.org wrote:
> > > > > On Thu, 2024-11-07 at 17:08 +0100, Lorenzo Bianconi wrote:
> > > > > > > On Thu, Nov 07, 2024 at 02:50:55PM +0100, Lorenzo Bianconi wrote:
> > > > > > > > In order to make the code more readable, move phy and mac
> > > > > > > > reset lines assert/de-assert configuration in .power_up
> > > > > > > > callback (mtk_pcie_en7581_power_up/mtk_pcie_power_up).
> > >
> > > > > > > > + /*
> > > > > > > > + * The controller may have been left out of reset by the
> > > > > > > > bootloader
> > > > > > > > + * so make sure that we get a clean start by asserting resets
> > > > > > > > here.
> > > > > > > > + */
> > > > > > > > + reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
> > > > > > > > + pcie->phy_resets);
> > > > > > > > + reset_control_assert(pcie->mac_reset);
> > > > > > > > + usleep_range(10, 20);
> > > > > > >
> > > > > > > Unrelated to this patch, but since you're moving it, do you
> > > > > > > know what this delay is for? Can we add a #define and a spec
> > > > > > > citation for it?
> > > > > >
> > > > > > I am not sure about it, this was already there. @Jianjun Wang:
> > > > > > any input on it?
> > > > >
> > > > > This delay is used to ensure the reset is effective. A delay of
> > > > > 10us should be sufficient in this scenario.
> > > >
> > > > ack, so we can introduce a marco like:
> > > >
> > > > #define PCIE_RESET_TIME_US 10
> > > > ...
> > > >
> > > > usleep_range(PCIE_RESET_TIME_US, 2 * PCIE_RESET_TIME_US);
> > >
> > > Unless this corresponds to a value specified by the PCIe base spec
> > > or CEM spec, this macro should be internal to
> > > pcie-mediatek-gen3.c.
> >
> > My plan is to add it in pcie-mediatek-gen3.c. Do you think
> > PCIE_RESET_TIME_US is too generic?
>
> It's generic, but so are most of the other #defines in
> pcie-mediatek-gen3.c, so I'd follow suit.
>
> Connect it to language in the MediaTek spec if possible, i.e., if the
> spec names this parameter, try to use the same name.

unfortunately I do not have any mediatek spec documentation available.

@Jianjun Wang: is PCIE_RESET_TIME_US fine for you or according to the available
documentation?

Regards,
Lorenzo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]