From: Vadym Kochan <vadym.kochan@plvision.eu>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@mellanox.com>,
Ido Schimmel <idosch@mellanox.com>, Andrew Lunn <andrew@lunn.ch>,
Oleksandr Mazur <oleksandr.mazur@plvision.eu>,
Serhiy Boiko <serhiy.boiko@plvision.eu>,
Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
Taras Chornyi <taras.chornyi@plvision.eu>,
Andrii Savka <andrii.savka@plvision.eu>,
netdev <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Mickey Rachamim <mickeyr@marvell.com>
Subject: Re: [net-next v3 2/6] net: marvell: prestera: Add PCI interface support
Date: Mon, 27 Jul 2020 12:34:21 +0300 [thread overview]
Message-ID: <20200727093421.GA21360@plvision.eu> (raw)
In-Reply-To: <CAHp75Vea6eWUqvXAKtu5Qv3Q0Oo=mxD+zf+zogZdcYOFtRe17g@mail.gmail.com>
Hi Andy,
On Mon, Jul 27, 2020 at 11:04:56AM +0300, Andy Shevchenko wrote:
> On Mon, Jul 27, 2020 at 1:55 AM Vadym Kochan <vadym.kochan@plvision.eu> wrote:
> > On Sun, Jul 26, 2020 at 01:32:19PM +0300, Andy Shevchenko wrote:
> > > On Sat, Jul 25, 2020 at 6:10 PM Vadym Kochan <vadym.kochan@plvision.eu> wrote:
>
> ...
>
> For the non-commented I assume you are agree with. Correct?
>
Yes
> ...
>
> > > > +config PRESTERA_PCI
> > > > + tristate "PCI interface driver for Marvell Prestera Switch ASICs family"
> > > > + depends on PCI && HAS_IOMEM && PRESTERA
> > >
> > > > + default m
> > >
> > > Even if I have CONFIG_PRESTERA=y, why as a user I must have this as a module?
> > > If it's a crucial feature, shouldn't it be rather
> > > default CONFIG_PRESTERA
> > > ?
> >
> > The firmware image should be located on rootfs, and in case the rootfs
> > should be mounted later the pci driver can't pick this up when
> > statically compiled so I left it as 'm' by default.
>
> We have for a long time to catch firmware blobs from initrd (initramfs).
> default m is very unusual.
>
For example drivers/net/ethernet/mellanox/mlxsw/pci.c also uses 'm' as
default, but may be in that case the reason is that there are several
bus implementations - i2c, pci.
> ...
>
> > > > +#define PRESTERA_FW_PATH \
> > > > + "mrvl/prestera/mvsw_prestera_fw-v" \
> > > > + __stringify(PRESTERA_SUPP_FW_MAJ_VER) \
> > > > + "." __stringify(PRESTERA_SUPP_FW_MIN_VER) ".img"
> > >
> > > Wouldn't it be better to see this in the C code?
> >
> > I have no strong opinion on this, but looks like macro is enough for
> > this statically defined versioning.
>
> The problem is that you have to bounce your editor to C code then to
> macro then to another macro...
> (in case you are looking for the code responsible for that)
> In many drivers I saw either it's one static line (without those
> __stringify(), etc) or done in C code dynamically near to
> request_firmware() call.
>
> Maybe you may replace __stringify by explicit characters / strings and
> comment how the name was constructed?
>
> #define FW_NAME "patch/to/it/fileX.Y.img"
>
I used snprintf, and now it looks simpler.
> ...
>
> > > > +static void prestera_pci_copy_to(u8 __iomem *dst, u8 *src, size_t len)
> > > > +{
> > > > + u32 __iomem *dst32 = (u32 __iomem *)dst;
> > > > + u32 *src32 = (u32 *)src;
> > > > + int i;
> > > > +
> > > > + for (i = 0; i < (len / 4); dst32++, src32++, i++)
> > > > + writel_relaxed(*src32, dst32);
> > > > +}
> > > > +
> > > > +static void prestera_pci_copy_from(u8 *dst, u8 __iomem *src, size_t len)
> > > > +{
> > > > + u32 __iomem *src32 = (u32 __iomem *)src;
> > > > + u32 *dst32 = (u32 *)dst;
> > > > + int i;
> > > > +
> > > > + for (i = 0; i < (len / 4); dst32++, src32++, i++)
> > > > + *dst32 = readl_relaxed(src32);
> > > > +}
> > >
> > > NIH of memcpy_fromio() / memcpy_toio() ?
> > >
> > I am not sure if there will be no issue with < 4 bytes transactions over
> > PCI bus. I need to check it.
>
> I didn't get it. You always do 4 byte chunks, so, supply aligned
> length to memcpy and you will have the same.
>
> ...
Yes, I converted code to use these helpers.
>
> > > > +static int prestera_fw_rev_check(struct prestera_fw *fw)
> > > > +{
> > > > + struct prestera_fw_rev *rev = &fw->dev.fw_rev;
> > > > + u16 maj_supp = PRESTERA_SUPP_FW_MAJ_VER;
> > > > + u16 min_supp = PRESTERA_SUPP_FW_MIN_VER;
> > > > +
> > >
> > > > + if (rev->maj == maj_supp && rev->min >= min_supp)
> > > > + return 0;
> > >
> > > Why not traditional pattern
> > >
> > > if (err) {
> > > ...
> > > }
> >
> > At least for me it looks simpler when to check which version is
> > correct.
>
> OK.
>
> > > ...
> > > return 0;
> > >
> > > ?
> > >
> > > > + dev_err(fw->dev.dev, "Driver supports FW version only '%u.%u.x'",
> > > > + PRESTERA_SUPP_FW_MAJ_VER, PRESTERA_SUPP_FW_MIN_VER);
> > > > +
> > > > + return -EINVAL;
> > > > +}
>
> ...
>
> > Thanks Andy for the comments, especially for pcim_ helpers.
>
> You are welcome!
>
> --
> With Best Regards,
> Andy Shevchenko
Thanks!
next prev parent reply other threads:[~2020-07-27 9:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-25 15:06 [net-next v3 0/6] net: marvell: prestera: Add Switchdev driver for Prestera family ASIC device 98DX326x (AC3x) Vadym Kochan
2020-07-25 15:06 ` [net-next v3 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices Vadym Kochan
2020-07-26 8:35 ` Jiri Pirko
2020-07-25 15:06 ` [net-next v3 2/6] net: marvell: prestera: Add PCI interface support Vadym Kochan
2020-07-26 9:51 ` Jiri Pirko
2020-07-26 10:32 ` Andy Shevchenko
2020-07-26 22:55 ` Vadym Kochan
2020-07-27 8:04 ` Andy Shevchenko
2020-07-27 9:34 ` Vadym Kochan [this message]
2020-07-27 11:05 ` Andy Shevchenko
2020-07-25 15:06 ` [net-next v3 3/6] net: marvell: prestera: Add basic devlink support Vadym Kochan
2020-07-26 9:20 ` Jiri Pirko
2020-07-25 15:06 ` [net-next v3 4/6] net: marvell: prestera: Add ethtool interface support Vadym Kochan
2020-07-26 9:46 ` Jiri Pirko
2020-07-25 15:06 ` [net-next v3 5/6] net: marvell: prestera: Add Switchdev driver implementation Vadym Kochan
2020-07-26 8:34 ` Jiri Pirko
2020-07-25 15:06 ` [net-next v3 6/6] dt-bindings: marvell,prestera: Add description for device-tree bindings Vadym Kochan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200727093421.GA21360@plvision.eu \
--to=vadym.kochan@plvision.eu \
--cc=andrew@lunn.ch \
--cc=andrii.savka@plvision.eu \
--cc=andy.shevchenko@gmail.com \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mickeyr@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=oleksandr.mazur@plvision.eu \
--cc=serhiy.boiko@plvision.eu \
--cc=serhiy.pshyk@plvision.eu \
--cc=taras.chornyi@plvision.eu \
--cc=volodymyr.mytnyk@plvision.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).