netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: stefanc@marvell.com
Cc: netdev@vger.kernel.org, thomas.petazzoni@bootlin.com,
	davem@davemloft.net, nadavh@marvell.com, ymarkman@marvell.com,
	linux-kernel@vger.kernel.org, kuba@kernel.org, mw@semihalf.com,
	andrew@lunn.ch, atenart@kernel.org
Subject: Re: [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map
Date: Sun, 24 Jan 2021 12:28:10 +0000	[thread overview]
Message-ID: <20210124122809.GV1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <1611488647-12478-4-git-send-email-stefanc@marvell.com>

On Sun, Jan 24, 2021 at 01:43:52PM +0200, stefanc@marvell.com wrote:
> +static int mvpp2_get_sram(struct platform_device *pdev,
> +			  struct mvpp2 *priv)
> +{
> +	struct device_node *dn = pdev->dev.of_node;
> +	static bool defer_once;
> +	struct resource *res;
> +
> +	if (has_acpi_companion(&pdev->dev)) {
> +		res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
> +		if (!res) {
> +			dev_warn(&pdev->dev, "ACPI is too old, Flow control not supported\n");
> +			return 0;
> +		}
> +		priv->cm3_base = devm_ioremap_resource(&pdev->dev, res);
> +		if (IS_ERR(priv->cm3_base))
> +			return PTR_ERR(priv->cm3_base);
> +	} else {
> +		priv->sram_pool = of_gen_pool_get(dn, "cm3-mem", 0);
> +		if (!priv->sram_pool) {
> +			if (!defer_once) {
> +				defer_once = true;
> +				/* Try defer once */
> +				return -EPROBE_DEFER;
> +			}
> +			dev_warn(&pdev->dev, "DT is too old, Flow control not supported\n");
> +			return -ENOMEM;
> +		}

Above, priv->sram_pool will only be non-NULL if the pool has been
initialised.

> +err_cm3:
> +	if (!has_acpi_companion(&pdev->dev) && priv->cm3_base)
> +		gen_pool_free(priv->sram_pool, (unsigned long)priv->cm3_base,
> +			      MSS_SRAM_SIZE);

So wouldn't:
	if (priv->sram_pool && priv->cm3_base)

be more appropriate here?

> +	if (!has_acpi_companion(&pdev->dev) && priv->cm3_base) {
> +		gen_pool_free(priv->sram_pool, (unsigned long)priv->cm3_base,
> +			      MSS_SRAM_SIZE);
> +		gen_pool_destroy(priv->sram_pool);
> +	}

Same here.

Why is it correct to call gen_pool_destroy() in the remove path but not
the error path? I think you want to drop this - the pool is created and
destroyed by the SRAM driver, users of it should not be destroying it.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2021-01-24 12:28 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 11:43 [PATCH v2 RFC net-next 00/18] net: mvpp2: Add TX Flow Control support stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 01/18] doc: marvell: add cm3-mem device tree bindings description stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 02/18] dts: marvell: add CM3 SRAM memory to cp115 ethernet device tree stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map stefanc
2021-01-24 12:28   ` Russell King - ARM Linux admin [this message]
2021-01-24 12:44   ` Russell King - ARM Linux admin
2021-01-24 18:51     ` Andrew Lunn
2021-01-24 18:46   ` Andrew Lunn
2021-01-25  7:16     ` [EXT] " Stefan Chulski
2021-01-24 11:43 ` [PATCH v2 RFC net-next 04/18] net: mvpp2: add PPv23 version definition stefanc
2021-01-24 13:18   ` Russell King - ARM Linux admin
2021-01-24 13:55     ` [EXT] " Stefan Chulski
2021-01-24 19:03       ` Andrew Lunn
2021-01-25  7:12         ` Stefan Chulski
2021-01-24 11:43 ` [PATCH v2 RFC net-next 05/18] net: mvpp2: always compare hw-version vs MVPP21 stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 06/18] net: mvpp2: increase BM pool size to 2048 buffers stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 07/18] net: mvpp2: increase RXQ size to 1024 descriptors stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 08/18] net: mvpp2: add FCA periodic timer configurations stefanc
2021-01-24 12:14   ` Russell King - ARM Linux admin
2021-01-24 14:43     ` [EXT] " Stefan Chulski
2021-01-24 19:11       ` Andrew Lunn
2021-01-25  7:15         ` Stefan Chulski
2021-01-24 11:43 ` [PATCH v2 RFC net-next 09/18] net: mvpp2: add FCA RXQ non occupied descriptor threshold stefanc
2021-01-24 13:01   ` Russell King - ARM Linux admin
2021-01-24 13:24     ` [EXT] " Stefan Chulski
2021-01-24 11:43 ` [PATCH v2 RFC net-next 10/18] net: mvpp2: add spinlock for FW FCA configuration path stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 11/18] net: mvpp2: enable global flow control stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 12/18] net: mvpp2: add RXQ flow control configurations stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 13/18] net: mvpp2: add ethtool flow control configuration support stefanc
2021-01-24 12:35   ` Russell King - ARM Linux admin
2021-01-24 12:39     ` [EXT] " Stefan Chulski
2021-01-24 11:44 ` [PATCH v2 RFC net-next 14/18] net: mvpp2: add BM protection underrun feature support stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 15/18] net: mvpp2: add PPv23 RX FIFO flow control stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 16/18] net: mvpp2: set 802.3x GoP Flow Control mode stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 17/18] net: mvpp2: limit minimum ring size to 1024 descriptors stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 18/18] net: mvpp2: add TX FC firmware check stefanc

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=20210124122809.GV1551@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=atenart@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mw@semihalf.com \
    --cc=nadavh@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=stefanc@marvell.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=ymarkman@marvell.com \
    /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).