RE: [PATCH v2 2/3] soc: sifive: Add SiFive specific Cadence DDR controller driver

From: Yash Shah
Date: Tue Sep 08 2020 - 23:57:02 EST

> -----Original Message-----
> From: Palmer Dabbelt <palmer@xxxxxxxxxxx>
> Sent: 09 September 2020 08:42
> To: Christoph Hellwig <hch@xxxxxxxxxxxxx>; dkangude@xxxxxxxxxxx
> Cc: Yash Shah <yash.shah@xxxxxxxxxxxx>; robh+dt@xxxxxxxxxx; Paul
> Walmsley ( Sifive) <paul.walmsley@xxxxxxxxxx>; bp@xxxxxxxxx;
> mchehab@xxxxxxxxxx; tony.luck@xxxxxxxxx; devicetree@xxxxxxxxxxxxxxx;
> aou@xxxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Sachin Ghadi
> <sachin.ghadi@xxxxxxxxxxxx>; rrichter@xxxxxxxxxxx;
> james.morse@xxxxxxx; linux-riscv@xxxxxxxxxxxxxxxxxxx; linux-
> edac@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2 2/3] soc: sifive: Add SiFive specific Cadence DDR
> controller driver
> [External Email] Do not click links or attachments unless you recognize the
> sender and know the content is safe
> On Sun, 06 Sep 2020 23:11:26 PDT (-0700), Christoph Hellwig wrote:
> > On Mon, Sep 07, 2020 at 11:17:58AM +0530, Yash Shah wrote:
> >> Add a driver to manage the Cadence DDR controller present on SiFive
> >> SoCs At present the driver manages the EDAC feature of the DDR
> controller.
> >> Additional features may be added to the driver in future to control
> >> other aspects of the DDR controller.
> >
> > So if this is a generic(ish) Cadence IP block shouldn't it be named
> > Cadence and made generic? Or is the frontend somehow SiFive specific?
> For some reason I thought we had a SiFive-specific interface to this, but I may
> have gotten that confused with something else as it's been a while. Someone
> from SiFive would probably have a better idea, but it looks like the person I'd
> ask isn't thereany more so I'm all out of options ;)
> It looks like there was a very similar driver posted by Dhananjay Kangude
> from Cadence in April: . Some of the
> register definitions seem to be different, but the code I looked at is very
> similar so there's at least some bits that could be shared. I found a v4 of that
> patch set, but that was back in May: . It
> alludes to a v5, but I can't find one. I've added Dhananjay, maybe he knows
> what's up?

I consulted with Dhananjay before posting this patch. From what I understood, Cadence provide highly configurable and customised DDR IP blocks based on the SoC vendor's need. This impacts the register configuration and probably the offsets too.
I had also refer the v4 patch posted by Dhananjay mentioned above and found that the registers offsets are not matching with that of Cadence DDR IP in SiFive SoC. Therefore it seems this DDR IP block has SiFive specific configurations and hence this Sifive specific driver.

> I don't know enough about the block to know if the subtle difference in
> register names/offsets means. They look properly jumbled up (ie, not just an
> offset), so maybe there's just different versions or that's the SiFive-specific
> part I had bouncing around my head? Either way, it seems like one driver
> with some simple configuration could handle both of these -- either sticking
> the offsets in the DT (if they're going to be different everywhere) or by
> coming up with some version sort of thing (if there's a handful of these).
> I'm now also a bit worried about the provenace of this code. The two drivers
> are errily similar -- for example, the variable definitions in handle_ce()
> u64 err_c_addr = 0x0;
> u64 err_c_data = 0x0;
> u32 err_c_synd, err_c_id;
> u32 sig_val_l, sig_val_h;
> are exactly the same.

I apologized, I forgot to mention it in cover-letter. I have based my work on Dhananjay's v4 patch[0].

- Yash