lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YqbQ1fLUKR/iwbTD@ravnborg.org>
Date:   Mon, 13 Jun 2022 07:53:25 +0200
From:   Sam Ravnborg <sam@...nborg.org>
To:     Laurent Pinchart <laurent.pinchart@...asonboard.com>
Cc:     Venkateshwar Rao Gannavarapu 
        <venkateshwar.rao.gannavarapu@...inx.com>, airlied@...ux.ie,
        vgannava@...inx.com, dri-devel@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org
Subject: Re: [LINUX PATCH 2/2] drm: xlnx: dsi: driver for Xilinx DSI Tx
 subsystem

Hi Laurent,

> [snip]
> 
> > > +static inline void xlnx_dsi_writel(void __iomem *base, int offset, u32 val)
> > > +{
> > > +	writel(val, base + offset);
> > > +}
> > > +
> > > +static inline u32 xlnx_dsi_readl(void __iomem *base, int offset)
> > > +{
> > > +	return readl(base + offset);
> > > +}
> > 
> > When I see implementations like this I wonder if a regmap would be
> > beneficial?
> 
> regmap often seems overkill to me when the driver only needs plain
> 32-bit mmio read/write, given the overhead it adds at runtime. Is it
> just me ?

There are several points that speaks for using regmap:
- The interface is well known
- It has nice helpers - like update_bits
- No need for own wrappers, that sometimes are made in creative ways
  (not the case here)
- There is a possibility to add some run-time checks so one can catch
  attempt to write outside the register window, write to read-only
  registers etc.


On top of this - it is simple to configure:

static const struct regmap_config regmap_config = {
        .reg_bits = 32,
        .val_bits = 32,
        .reg_stride = 4,
};


>From the probe function:

	priv->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
	if (IS_ERR(priv->regs))
		return dev_err_probe(dev, PTR_ERR(priv->regs), "Failed to get memory resource\n");

	regmap_cfg = regmap_config;
	regmap_cfg.max_register = res->end - res->start;
	priv->regmap = devm_regmap_init_mmio(dev, priv->regs, &regmap_cfg);
	if (IS_ERR(priv->regmap))
		return dev_err_probe(dev, PTR_ERR(priv->regmap), "Failed to init regmap\n");


The one point that brought me over was the well known interface.
But using wrappers works too.

	Sam

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ