Re: [PATCH 07/12] net: ll_temac: Support indirect_mutex share within TEMAC IP

From: Andrew Lunn
Date: Fri Apr 26 2019 - 10:15:17 EST


On Fri, Apr 26, 2019 at 09:32:26AM +0200, Esben Haabendal wrote:
> @@ -1092,7 +1092,15 @@ static int temac_probe(struct platform_device *pdev)
> lp->dev = &pdev->dev;
> lp->options = XTE_OPTION_DEFAULTS;
> spin_lock_init(&lp->rx_lock);
> - mutex_init(&lp->indirect_mutex);
> +
> + /* Setup mutex for synchronization of indirect register access */
> + if (pdata && pdata->indirect_mutex) {
> + lp->indirect_mutex = pdata->indirect_mutex;
> + } else {
> + lp->indirect_mutex = devm_kmalloc(
> + &pdev->dev, sizeof(*lp->indirect_mutex), GFP_KERNEL);
> + mutex_init(lp->indirect_mutex);
> + }

Hi Esben

I would make the mutex mandatory, not optional. I think there will be
less hard to debug errors that way. You want the developer to actually
think about this mutex, should it be shared, or individual. Forcing
them to provide it means they are more likely to read the
documentation, and more likely to over share it than under share
it. That is maybe not so good for performance, but safer.

Andrew