Re: [PATCH v16 6/8] i3c: hub: Add support for the I3C interface in the I3C hub
From: Krzysztof Kozlowski
Date: Thu Aug 27 2026 - 06:10:42 EST
On 26/08/2026 12:38, Lakshay Piplani wrote:
> +/**
> + * i3c_hub_init() - Initialize hub context
> + * @hub: Hub instance
> + * @ops: Vendor callbacks
> + * @hub_dev: I3C hub device
> + */
> +void i3c_hub_init(struct i3c_hub *hub,
> + const struct i3c_hub_ops *ops,
> + struct i3c_device *hub_dev)
> +{
> + struct i3c_master_controller *parent;
> + unsigned int depth;
> +
> + hub->ops = ops;
> + hub->hub_dev = hub_dev;
> + mutex_init(&hub->lock);
> +
> + if (!IS_ENABLED(CONFIG_LOCKDEP))
So without lockdep you do not initialize? Honestly, kerneldoc is useless
here and explains nothing. Kerneldoc is pretty clear - you initialize
hub context thus why hub context should be uninitialized without lockdep?
> + return;
> +
> + if (WARN_ON_ONCE(!hub_dev || !hub_dev->desc))
> + return;
How is this possible? Why panicking the machine?
> +
> + parent = i3c_dev_get_master(hub_dev->desc);
> + if (WARN_ON_ONCE(!parent))
> + return;
Why panicking here (WARN on panic)?
> +
> + /*
> + * The routing mutex has the same hub nesting depth as the virtual
> + * controllers this hub exposes, so the parent controller is one level
> + * shallower. Keying it once here, rather than per port, avoids
> + * reclassifying the single shared routing mutex from a later port that
> + * may already have used it.
> + */
> + depth = i3c_hub_controller_depth(parent) + 1;
> + if (WARN_ONCE(depth > I3C_HUB_MAX_LOCK_DEPTH,
> + "i3c-hub: routing lock depth %u exceeds lockdep support\n",
> + depth))
> + depth = I3C_HUB_MAX_LOCK_DEPTH;
> +
> + lockdep_set_class(&hub->lock, &i3c_hub_routing_lock_keys[depth - 1]);
> +}
> +EXPORT_SYMBOL_GPL(i3c_hub_init);
> +
> +const struct i3c_master_controller_ops *i3c_hub_master_ops(void)
> +{
> + return &i3c_hub_master_ops_data;
> +}
> +EXPORT_SYMBOL_GPL(i3c_hub_master_ops);
Do you really need a wrapper call over single variable? Can the i3c hub
core code be NOT present when your I3C hub driver is buillin?
Best regards,
Krzysztof