On 12/18/2018 10:40 AM, Jason Gunthorpe wrote:
On Tue, Dec 18, 2018 at 10:22:36AM -0500, Doug Ledford wrote:
On Tue, 2018-12-18 at 13:30 +0000, Ruhl, Michael J wrote:
Hmm, taking a little close look at the debugfs.c module for HFI I am wondering if
there is some confusion WRT how the HFI driver uses debugfs.
The init function (hfi1_dbg_ibdev_init() occurs after hfi1_ib_register(), with a
comment of "create debugfs files after init and ib register". This uses the
hfi1_ibdev data structure as the "private data" for the debugfs information.
However, the root debufs system is based off of "DRIVER_NAME" (hfi1), and
the actual filenames within that directory is based off of hfi1_class_name (hfi1)
and the "port" value.
Well, it is 'unit' and unit comes from an internal global IDR and is
thus guaranteed globally unique.
For each HFI we will increment port, so for two instance of the driver, there will
always be a uniquely defined name.
From that perspective, as far as I can tell, the HFI driver is meeting the
"globally uniqueness" requirement.
You are correct. This satisfies the needs for device rename and can be
left just as it is.
The original problem stemmed from drivers using their ib device name
(such as mlx4_0), which presents a problem on rename in that when the
first mlx4 device is registered it would be mlx4_0, then udev renames
the device to <whatever> but the debugfs files are still in a directory
named mlx4_0, and then you register another mlx4 device, and because
there is no mlx4_0 any more, the new device gets the name mlx4_0 again,
and now the creation of the debugfs files for the second mlx4 device
fail because the name mlx4_0 is already in use. Your naming scheme
avoids that problem, and so it is fine just as it is and there is no
need to break any existing user space or switch to PCI address naming
schemes.
Yah, I agree, it still breaks userspace in the sense that the hfi_1
debugfs name doesn't correlate to any ibdev name, but it doesn't cause
any kernel level problem.
You should probably still use the PCI name for debugfs and add a
symlink to it from from the unit based name.
This may just be the way to go, we get the best of both worlds.
-Denny