public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	petrm@nvidia.com, pabeni@redhat.com, edumazet@google.com,
	mlxsw@nvidia.com
Subject: Re: [patch net-next 02/11] mlxsw: core_linecards: Introduce per line card auxiliary device
Date: Thu, 16 Jun 2022 10:11:56 +0300	[thread overview]
Message-ID: <YqrXvLY0GGCFLs4U@shredder> (raw)
In-Reply-To: <YqoYy/RLWaDd/6uh@nanopsycho>

On Wed, Jun 15, 2022 at 07:37:15PM +0200, Jiri Pirko wrote:
> Wed, Jun 15, 2022 at 04:52:13PM CEST, idosch@nvidia.com wrote:
> >> +int mlxsw_linecard_bdev_add(struct mlxsw_linecard *linecard)
> >> +{
> >> +	struct mlxsw_linecard_bdev *linecard_bdev;
> >> +	int err;
> >> +	int id;
> >> +
> >> +	id = mlxsw_linecard_bdev_id_alloc();
> >> +	if (id < 0)
> >> +		return id;
> >> +
> >> +	linecard_bdev = kzalloc(sizeof(*linecard_bdev), GFP_KERNEL);
> >> +	if (!linecard_bdev) {
> >> +		mlxsw_linecard_bdev_id_free(id);
> >> +		return -ENOMEM;
> >> +	}
> >> +	linecard_bdev->adev.id = id;
> >> +	linecard_bdev->adev.name = MLXSW_LINECARD_DEV_ID_NAME;
> >> +	linecard_bdev->adev.dev.release = mlxsw_linecard_bdev_release;
> >> +	linecard_bdev->adev.dev.parent = linecard->linecards->bus_info->dev;
> >> +	linecard_bdev->linecard = linecard;
> >> +
> >> +	err = auxiliary_device_init(&linecard_bdev->adev);
> >> +	if (err) {
> >> +		mlxsw_linecard_bdev_id_free(id);
> >> +		kfree(linecard_bdev);
> >> +		return err;
> >> +	}
> >> +
> >> +	err = auxiliary_device_add(&linecard_bdev->adev);
> >> +	if (err) {
> >> +		auxiliary_device_uninit(&linecard_bdev->adev);
> >> +		return err;
> >> +	}
> >> +
> >> +	linecard->bdev = linecard_bdev;
> >> +	return 0;
> >> +}
> >
> >[...]
> >
> >> +static int mlxsw_linecard_bdev_probe(struct auxiliary_device *adev,
> >> +				     const struct auxiliary_device_id *id)
> >> +{
> >> +	struct mlxsw_linecard_bdev *linecard_bdev =
> >> +			container_of(adev, struct mlxsw_linecard_bdev, adev);
> >> +	struct mlxsw_linecard_dev *linecard_dev;
> >> +	struct devlink *devlink;
> >> +
> >> +	devlink = devlink_alloc(&mlxsw_linecard_dev_devlink_ops,
> >> +				sizeof(*linecard_dev), &adev->dev);
> >> +	if (!devlink)
> >> +		return -ENOMEM;
> >> +	linecard_dev = devlink_priv(devlink);
> >> +	linecard_dev->linecard = linecard_bdev->linecard;
> >> +	linecard_bdev->linecard_dev = linecard_dev;
> >> +
> >> +	devlink_register(devlink);
> >> +	return 0;
> >> +}
> >
> >[...]
> >
> >> @@ -252,6 +253,14 @@ mlxsw_linecard_provision_set(struct mlxsw_linecard *linecard, u8 card_type,
> >>  	linecard->provisioned = true;
> >>  	linecard->hw_revision = hw_revision;
> >>  	linecard->ini_version = ini_version;
> >> +
> >> +	err = mlxsw_linecard_bdev_add(linecard);
> >
> >If a line card is already provisioned and we are reloading the primary
> >devlink instance, isn't this going to deadlock on the global (not
> >per-instance) devlink mutex? It is held throughout the reload operation
> >and also taken in devlink_register()
> >
> >My understanding of the auxiliary bus model is that after adding a
> >device to the bus via auxiliary_device_add(), the probe() function of
> >the auxiliary driver will be called. In our case, this function acquires
> >the global devlink mutex in devlink_register().
> 
> No, the line card auxdev is supposed to be removed during
> linecard_fini(). This, I forgot to add, will do in v2.

mlxsw_linecard_fini() is called as part of reload with the global
devlink mutex held. The removal of the auxdev should prompt the
unregistration of its devlink instance which also takes this mutex. If
this doesn't deadlock, then I'm probably missing something.

Can you test reload with lockdep when line cards are already
provisioned/active?

> 
> 
> >
> >> +	if (err) {
> >> +		linecard->provisioned = false;
> >> +		mlxsw_linecard_provision_fail(linecard);
> >> +		return err;
> >> +	}
> >> +
> >>  	devlink_linecard_provision_set(linecard->devlink_linecard, type);
> >>  	return 0;
> >>  }

  reply	other threads:[~2022-06-16  7:12 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 12:33 [patch net-next 00/11] mlxsw: Implement dev info and dev flash for line cards Jiri Pirko
2022-06-14 12:33 ` [patch net-next 01/11] devlink: introduce nested devlink entity for line card Jiri Pirko
2022-06-15 14:05   ` Ido Schimmel
2022-06-15 17:37     ` Jiri Pirko
2022-06-15 23:37   ` Jakub Kicinski
2022-06-14 12:33 ` [patch net-next 02/11] mlxsw: core_linecards: Introduce per line card auxiliary device Jiri Pirko
2022-06-15 14:52   ` Ido Schimmel
2022-06-15 17:37     ` Jiri Pirko
2022-06-16  7:11       ` Ido Schimmel [this message]
2022-06-16 16:39         ` Jiri Pirko
2022-06-16 17:41           ` Ido Schimmel
2022-06-27  8:34             ` Jiri Pirko
2022-06-14 12:33 ` [patch net-next 03/11] mlxsw: core_linecard_dev: Set nested devlink relationship for a line card Jiri Pirko
2022-06-14 12:33 ` [patch net-next 04/11] mlxsw: core_linecards: Expose HW revision and INI version Jiri Pirko
2022-06-14 12:33 ` [patch net-next 05/11] mlxsw: reg: Extend MDDQ by device_info Jiri Pirko
2022-06-14 12:33 ` [patch net-next 06/11] mlxsw: core_linecards: Probe provisioned line cards for devices and expose FW version Jiri Pirko
2022-06-14 12:33 ` [patch net-next 07/11] mlxsw: reg: Add Management DownStream Device Tunneling Register Jiri Pirko
2022-06-14 12:33 ` [patch net-next 08/11] mlxsw: core_linecards: Expose device PSID over device info Jiri Pirko
2022-06-14 12:33 ` [patch net-next 09/11] mlxsw: core_linecards: Implement line card device flashing Jiri Pirko
2022-06-14 12:33 ` [patch net-next 10/11] selftests: mlxsw: Check line card info on provisioned line card Jiri Pirko
2022-06-14 12:33 ` [patch net-next 11/11] selftests: mlxsw: Check line card info on activated " Jiri Pirko
2022-06-15  9:13 ` [patch net-next 00/11] mlxsw: Implement dev info and dev flash for line cards Ido Schimmel
2022-06-15 17:40   ` Jiri Pirko
2022-06-16  7:03     ` Ido Schimmel
2022-06-16 13:11       ` Jiri Pirko
2022-06-16 14:47         ` Ido Schimmel
2022-06-16 16:37           ` Jiri Pirko
2022-06-18  6:12     ` Shannon Nelson
2022-06-27  8:43       ` Jiri Pirko
2022-06-27 18:38         ` Shannon Nelson
2022-06-27 18:52           ` Jakub Kicinski
2022-06-28  7:06             ` Jiri Pirko

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=YqrXvLY0GGCFLs4U@shredder \
    --to=idosch@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.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