lkml.org 
[lkml]   [2019]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 08/24] EDAC: Introduce mci_for_each_dimm() iterator
Date
On 14.08.19 17:18:24, Borislav Petkov wrote:
> On Mon, Jun 24, 2019 at 03:09:11PM +0000, Robert Richter wrote:
> > Make code more readable by introducing a mci_for_each_dimm() iterator.
> > Now, we just get a pointer to a struct dimm_info. Direct array access
> > using an index is no longer needed to iterate.
> >
> > Signed-off-by: Robert Richter <rrichter@marvell.com>
> > ---
> > drivers/edac/edac_mc.c | 18 ++++++++++--------
> > drivers/edac/edac_mc_sysfs.c | 34 +++++++++++++++-------------------
> > drivers/edac/ghes_edac.c | 8 ++++----
> > drivers/edac/i5100_edac.c | 11 +++++------
> > include/linux/edac.h | 7 +++++++
> > 5 files changed, 41 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
> > index c44bc83e8502..27277ca46ab3 100644
> > --- a/drivers/edac/edac_mc.c
> > +++ b/drivers/edac/edac_mc.c
> > @@ -145,15 +145,18 @@ static void edac_mc_dump_channel(struct rank_info *chan)
> > edac_dbg(4, " channel->dimm = %p\n", chan->dimm);
> > }
> >
> > -static void edac_mc_dump_dimm(struct dimm_info *dimm, int number)
> > +static void edac_mc_dump_dimm(struct dimm_info *dimm)
> > {
> > char location[80];
> >
> > + if (!dimm->nr_pages)
> > + return;
> > +
>
> What's that for?

This is moved from the iterator loop below to here. It limits the dump
to only populated dimm slots.

>
> > edac_dimm_info_location(dimm, location, sizeof(location));
> >
> > edac_dbg(4, "%s%i: %smapped as virtual row %d, chan %d\n",
> > dimm->mci->csbased ? "rank" : "dimm",
> > - number, location, dimm->csrow, dimm->cschannel);
> > + dimm->idx, location, dimm->csrow, dimm->cschannel);
> > edac_dbg(4, " dimm = %p\n", dimm);
> > edac_dbg(4, " dimm->label = '%s'\n", dimm->label);
> > edac_dbg(4, " dimm->nr_pages = 0x%x\n", dimm->nr_pages);

> > diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
> > index 39ba7f2414ae..7ec42b26a716 100644
> > --- a/drivers/edac/i5100_edac.c
> > +++ b/drivers/edac/i5100_edac.c
> > @@ -846,14 +846,13 @@ static void i5100_init_interleaving(struct pci_dev *pdev,
> >
> > static void i5100_init_csrows(struct mem_ctl_info *mci)
> > {
> > - int i;
> > struct i5100_priv *priv = mci->pvt_info;
> > + struct dimm_info *dimm;
> >
> > - for (i = 0; i < mci->tot_dimms; i++) {
> > - struct dimm_info *dimm;
> > - const unsigned long npages = i5100_npages(mci, i);
> > - const unsigned chan = i5100_csrow_to_chan(mci, i);
> > - const unsigned rank = i5100_csrow_to_rank(mci, i);
> > + mci_for_each_dimm(mci, dimm) {
> > + const unsigned long npages = i5100_npages(mci, dimm->idx);
> > + const unsigned chan = i5100_csrow_to_chan(mci, dimm->idx);
> > + const unsigned rank = i5100_csrow_to_rank(mci, dimm->idx);
> >
> > if (!npages)
> > continue;
>
> This cannot be right: the code here under this does now:
>
> dimm = edac_get_dimm(mci, chan, rank, 0);
>
> but dimm is already set. It used to get the DIMM using chan and rank but
> now you're iterating over the already initialized pointers. So I think
> you don't need the edac_get_dimm() anymore.

Right, it should calculate to the same pointer we already have and can
be removed. Good catch.

>
> Also fix those up too, while at it pls:
>
> WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
> #235: FILE: drivers/edac/i5100_edac.c:854:
> + const unsigned chan = i5100_csrow_to_chan(mci, dimm->idx);
>
> WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
> #236: FILE: drivers/edac/i5100_edac.c:855:
> + const unsigned rank = i5100_csrow_to_rank(mci, dimm->idx);

I am going to fix this is a separate patch, though I will exclude
rework of struct i5100_priv.

I have reworked the patch according to all your other comments.

Thanks for review.

-Robert

\
 
 \ /
  Last update: 2019-08-28 10:19    [W:0.171 / U:40.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site