From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andreas Noever <andreas.noever@gmail.com>,
Michael Jamet <michael.jamet@intel.com>,
Yehezkel Bernat <yehezkel.bernat@intel.com>,
Amir Levy <amir.jer.levy@intel.com>,
Andy Lutomirski <luto@kernel.org>,
Mario.Limonciello@dell.com, Jared.Dominguez@dell.com,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/24] thunderbolt: Convert switch to a device
Date: Wed, 24 May 2017 14:43:22 +0300 [thread overview]
Message-ID: <20170524114322.GB8541@lahna.fi.intel.com> (raw)
In-Reply-To: <20170524110908.GA22769@wunner.de>
On Wed, May 24, 2017 at 01:09:08PM +0200, Lukas Wunner wrote:
> On Thu, May 18, 2017 at 05:38:57PM +0300, Mika Westerberg wrote:
> > Thunderbolt domain consists of switches that are connected to each
> > other, forming a bus. This will convert each switch into a real Linux
> > device structure and adds them to the domain. The advantage here is
> > that we get all the goodies from the driver core, like reference
> > counting and sysfs hierarchy for free.
>
> I'm wondering, would it make sense to also model each port of a switch
> as a device?
>
> With your patches, the hierarchy looks something like this:
> nhi_pci_dev/domain0/switch0/switch1/switch2
>
> If each port is modeled as a device, we'd get something like this:
> nhi_pci_dev/domain0/switch0/port1/switch1/port3/switch2
>
> I think with the controllers that shipped, there can be up to two
> child switches below a switch. If ports are not modeled as devices,
> you can't tell which port a switch is connected to.
Yes you can - it is part of the route string that we use here as bus
address. Each "hop" there is the port number through the switch is
accessed. For example I have here 4 devices connected:
$ ls -1 /sys/bus/thunderbolt/devices/
0-0
0-1
0-1040301
0-301
0-40301
domain0
> Also, if ports are modeled as devices we'd be able to store attributes
> such as port type in sysfs. Of course we could also store those in
> each switch directory as "port0", "port1", ... files.
Is there any reason adding these? It will not help the user to identify
the connected device and I don't see how that information could be
useful.
That kind of information could go to debugfs, though.
> I don't know if this makes sense, but a discussion about the pros
> and cons is probably warranted. IIUC once the patches go in, the
> layout is set in stone because it's a user-space API.
Yes, that's right. Also that is one of the reasons why this series tries
to keep the attribute amout minimum and their contents simple.
> > +What: /sys/bus/thunderbolt/devices/.../device
> > +Date: Sep 2017
> > +KernelVersion: 4.13
> > +Contact: thunderbolt-software@lists.01.org
> > +Description: This attribute contains id of this device extracted from
> > + the device DROM.
>
> Hm, why did you choose to expose the DROM vendor + device ID instead of
> the one in switch config space?
That is the actual vendor/device who made the thing and can be used to
identify the actual device as well.
> The vendor on my MacBookPro9,1 is just 0x0001 and the device is 0x000a.
> Is this valid? Does Intel assign the vendor IDs, i.e. 0x0001 = Apple?
Apple vendor ID in Thunderbolt realm is 0x0001. Yes, Intel assigns
those.
> > + if (sw->config.vendor_id != PCI_VENDOR_ID_INTEL)
> > + tb_sw_warn(sw, "unknown switch vendor id %#x\n",
> > + sw->config.vendor_id);
> > +
> > + if (sw->config.device_id != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE &&
> > + sw->config.device_id != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C &&
> > + sw->config.device_id != PCI_DEVICE_ID_INTEL_PORT_RIDGE &&
> > + sw->config.device_id != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE &&
> > + sw->config.device_id != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE)
> > + tb_sw_warn(sw, "unsupported switch device id %#x\n",
> > + sw->config.device_id);
>
> I'm wondering if this makes sense anymore, as said we should try to avoid
> having to amend device lists in multiple places in the driver for each
> newly introduced controller.
I agree. In the next version I'm moving this to be part of the code
where we identify the generation. So at least it will be removed from
this place.
> > +static void tb_switch_set_uuid(struct tb_switch *sw)
> > +{
> > + u32 uuid[4];
> > + int cap;
> > +
> > + if (sw->uuid)
> > + return;
>
> When can this be nonzero?
On Macs with older controller than AR (no ICM running).
> > +
> > + /*
> > + * By default the UUID will be based on UID where upper two
> > + * dwords are filled with ones.
> > + */
> > + uuid[0] = sw->uid & 0xffffffff;
> > + uuid[1] = (sw->uid >> 32) & 0xffffffff;
> > + uuid[2] = 0xffffffff;
> > + uuid[3] = 0xffffffff;
> > +
> > + /*
> > + * The newer controllers include fused UUID as part of link
> > + * controller specific registers
> > + */
> > + cap = tb_switch_find_vsec_cap(sw, TB_VSEC_CAP_LINK_CONTROLLER);
> > + if (cap > 0)
> > + tb_sw_read(sw, uuid, TB_CFG_SWITCH, cap + 3, 4);
> > +
> > + sw->uuid = kmemdup(uuid, sizeof(uuid), GFP_KERNEL);
>
> Hm, so on newer controller the uuid is calculated and the result is
> subsequently overwritten? Meh... :-/
ICM gives the UUID as part of the device connected message. This here to
make the UUID working also on systems withouth ICM (older Macs). The
special case comes from the older devices where there is no fused UUID
so we generate one based on UID instead following what ICM does.
This allows us to show "unique_id" attribute the same way on all
systems.
> On Macs, the UUID is conveyed in an EFI device property.
Yes, but only for the host and UUID is actually coming from the fuses
(hardware), not from EFI property.
> How about putting the VSEC code path first, then fall back to calculating
> the default UUID? Apart from being prettier, this would allow me to
> easily add the Mac-specific code path.
I can change the ordering but you don't need to add Mac specific path
there - this code has been tested on Macs already and it should work
exactly the same there.
I have here Mac Mini (Light Ridge), Macbook (Cactus Ridge) and newer
Macbook with Alpine Ridge and I've tried to make sure it works the same.
Below is taken from the same devices connected to a Cactus Ridge based
Mac.
0-0/authorized:1
0-0/device:0xa
0-0/device_name:Macintosh
0-0/uevent:DEVTYPE=thunderbolt_device
0-0/unique_id:00000000-0000-0008-83b3-30099bc1194a
0-0/vendor:0x1
0-0/vendor_name:Apple, Inc.
0-1/authorized:1
0-1/device:0x5
0-1/device_name:34UC97
0-1/uevent:DEVTYPE=thunderbolt_device
0-1/unique_id:00000000-0000-0018-0022-c32682b35855
0-1/vendor:0x1e
0-1/vendor_name:LG Electronics
0-1030301/authorized:1
0-1030301/device:0x301
0-1030301/device_name:AKiTiO Thunder3 Duo Pro
0-1030301/nvm_authenticate:0x0
0-1030301/nvm_version:16.0
0-1030301/uevent:DEVTYPE=thunderbolt_device
0-1030301/unique_id:d3010000-0000-9518-a29c-9bc5cca35116
0-1030301/vendor:0x41
0-1030301/vendor_name:inXtron
0-301/authorized:1
0-301/device:0x3
0-301/device_name:eSata Hub
0-301/uevent:DEVTYPE=thunderbolt_device
0-301/unique_id:102f9d1e-0000-0300-ffff-ffffffffffff
0-301/vendor:0x3
0-301/vendor_name:LaCie
0-30301/authorized:1
0-30301/device:0x305
0-30301/device_name:AKiTiO Thunder3 PCIe Box
0-30301/nvm_authenticate:0x0
0-30301/nvm_version:19.0
0-30301/uevent:DEVTYPE=thunderbolt_device
0-30301/unique_id:dc010000-0000-8508-a22d-32ca6421cb16
0-30301/vendor:0x41
0-30301/vendor_name:inXtron
domain0/security:none
domain0/uevent:DEVTYPE=thunderbolt_domain
> BTW, why is there a uid for each switch and a UUID on top?
I think the UUID came with Redwood Ridge or so so before that there was
only UID.
> IIUC, if the switch is the root switch, then the UUID is used to
> uniquely identify the domain starting at that switch, is that correct?
Yes, that's correct.
> Actually just using the 64-bit uid would still suffice for that use case.
> That is something I've never really comprehended.
Well they decided to go with full UUID and I can't blame them ;-)
next prev parent reply other threads:[~2017-05-24 11:43 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 14:38 [PATCH 00/24] Thunderbolt security levels and NVM firmware upgrade Mika Westerberg
2017-05-18 14:38 ` [PATCH 01/24] thunderbolt: Use const buffer pointer in write operations Mika Westerberg
2017-05-25 13:19 ` Greg Kroah-Hartman
2017-05-18 14:38 ` [PATCH 02/24] thunderbolt: Do not try to read UID if DROM offset is read as 0 Mika Westerberg
2017-05-21 13:46 ` Andreas Noever
2017-05-22 8:40 ` Mika Westerberg
2017-05-22 18:41 ` Andreas Noever
2017-05-22 20:38 ` Mika Westerberg
2017-05-22 20:57 ` Andreas Noever
2017-05-18 14:38 ` [PATCH 03/24] thunderbolt: Do not warn about newer DROM versions Mika Westerberg
2017-05-18 14:38 ` [PATCH 04/24] thunderbolt: Add MSI-X support Mika Westerberg
2017-05-21 17:51 ` Andreas Noever
2017-05-22 8:52 ` Mika Westerberg
2017-05-22 10:35 ` Bernat, Yehezkel
2017-05-22 11:01 ` Mika Westerberg
2017-05-18 14:38 ` [PATCH 05/24] thunderbolt: Rework capability handling Mika Westerberg
2017-05-18 16:38 ` Andy Shevchenko
2017-05-19 8:12 ` Mika Westerberg
2017-05-19 13:18 ` Andy Shevchenko
2017-05-21 19:09 ` Andreas Noever
2017-05-22 9:45 ` Mika Westerberg
2017-05-22 9:58 ` Levy, Amir (Jer)
2017-05-25 6:13 ` Lukas Wunner
2017-05-18 14:38 ` [PATCH 06/24] thunderbolt: Introduce thunderbolt bus and connection manager Mika Westerberg
2017-05-18 16:43 ` Andy Shevchenko
2017-05-19 8:15 ` Mika Westerberg
2017-05-19 13:16 ` Andy Shevchenko
2017-05-24 10:28 ` Lukas Wunner
2017-05-24 10:39 ` Mika Westerberg
2017-05-25 13:23 ` Greg Kroah-Hartman
2017-05-25 14:42 ` Mika Westerberg
2017-05-18 14:38 ` [PATCH 07/24] thunderbolt: Convert switch to a device Mika Westerberg
2017-05-18 16:49 ` Andy Shevchenko
2017-05-19 8:20 ` Mika Westerberg
2017-05-24 11:09 ` Lukas Wunner
2017-05-24 11:43 ` Mika Westerberg [this message]
2017-05-24 13:53 ` Lukas Wunner
2017-05-25 6:57 ` Mika Westerberg
2017-05-18 14:38 ` [PATCH 08/24] thunderbolt: Fail switch adding operation if reading DROM fails Mika Westerberg
2017-05-18 14:38 ` [PATCH 09/24] thunderbolt: Do not fail if DROM data CRC32 is invalid Mika Westerberg
2017-05-18 14:39 ` [PATCH 10/24] thunderbolt: Read vendor and device name from DROM Mika Westerberg
2017-05-18 19:19 ` Andy Shevchenko
2017-05-19 8:22 ` Mika Westerberg
2017-05-19 10:07 ` Lukas Wunner
2017-05-19 10:28 ` Mika Westerberg
2017-05-21 5:31 ` Lukas Wunner
2017-05-21 7:48 ` Mika Westerberg
2017-05-21 9:33 ` Lukas Wunner
2017-05-18 14:39 ` [PATCH 11/24] thunderbolt: Move control channel messages to tb_msgs.h Mika Westerberg
2017-05-18 14:39 ` [PATCH 12/24] thunderbolt: Expose get_route() to other files Mika Westerberg
2017-05-18 14:39 ` [PATCH 13/24] thunderbolt: Expose make_header() " Mika Westerberg
2017-05-18 14:39 ` [PATCH 14/24] thunderbolt: Let the connection manager handle all notifications Mika Westerberg
2017-05-24 14:00 ` Lukas Wunner
2017-05-25 7:02 ` Mika Westerberg
2017-05-18 14:39 ` [PATCH 15/24] thunderbolt: Rework control channel to be more reliable Mika Westerberg
2017-05-25 13:25 ` Greg Kroah-Hartman
2017-05-25 14:35 ` Mika Westerberg
2017-05-18 14:39 ` [PATCH 16/24] thunderbolt: Add Thunderbolt 3 PCI IDs Mika Westerberg
2017-05-18 14:39 ` [PATCH 17/24] thunderbolt: Add support for NHI mailbox Mika Westerberg
2017-05-18 14:39 ` [PATCH 18/24] thunderbolt: Store Thunderbolt generation in the switch structure Mika Westerberg
2017-05-21 4:47 ` Lukas Wunner
2017-05-21 5:29 ` Levy, Amir (Jer)
2017-05-21 5:35 ` Lukas Wunner
2017-05-21 7:40 ` Mika Westerberg
2017-05-21 8:00 ` Mika Westerberg
2017-05-21 8:07 ` Levy, Amir (Jer)
2017-05-21 9:55 ` Bernat, Yehezkel
2017-05-21 10:47 ` Mika Westerberg
2017-05-21 11:18 ` Bernat, Yehezkel
2017-05-21 11:47 ` Mika Westerberg
2017-05-21 10:44 ` Mika Westerberg
2017-05-18 14:39 ` [PATCH 19/24] thunderbolt: Add support for DMA configuration based mailbox Mika Westerberg
2017-05-18 14:39 ` [PATCH 20/24] thunderbolt: Do not touch the hardware if the NHI is gone on resume Mika Westerberg
2017-05-24 14:43 ` Lukas Wunner
2017-05-25 7:10 ` Mika Westerberg
2017-05-18 14:39 ` [PATCH 21/24] thunderbolt: Add support for Internal Connection Manager (ICM) Mika Westerberg
2017-05-18 14:39 ` [PATCH 22/24] thunderbolt: Add support for host and device NVM firmware upgrade Mika Westerberg
2017-05-18 19:35 ` Andy Shevchenko
2017-05-19 8:26 ` Mika Westerberg
2017-05-25 13:28 ` Greg Kroah-Hartman
2017-05-25 14:39 ` Mika Westerberg
2017-05-25 14:57 ` Greg Kroah-Hartman
2017-05-18 14:39 ` [PATCH 23/24] thunderbolt: Add documentation how Thunderbolt bus can be used Mika Westerberg
2017-05-18 14:39 ` [PATCH 24/24] MAINTAINERS: Add maintainers for Thunderbolt driver Mika Westerberg
2017-05-19 16:35 ` [PATCH 00/24] Thunderbolt security levels and NVM firmware upgrade Mario.Limonciello
2017-05-19 17:19 ` Mika Westerberg
2017-05-19 17:54 ` Mario.Limonciello
2017-05-20 8:24 ` Mika Westerberg
2017-05-22 11:37 ` Mika Westerberg
2017-05-22 20:07 ` Mario.Limonciello
2017-05-22 20:10 ` Bernat, Yehezkel
2017-05-22 23:54 ` Mario.Limonciello
2017-05-22 20:48 ` Mika Westerberg
2017-05-23 17:30 ` Mario.Limonciello
2017-05-24 11:11 ` Mika Westerberg
2017-05-24 19:06 ` Mario.Limonciello
2017-05-24 19:32 ` Jamet, Michael
2017-05-25 7:20 ` mika.westerberg
2017-05-25 8:04 ` mika.westerberg
2017-05-25 12:03 ` mika.westerberg
2017-08-11 15:13 ` mika.westerberg
2017-05-25 7:19 ` Mika Westerberg
2017-05-19 18:00 ` Mika Westerberg
2017-05-20 9:15 ` Levy, Amir (Jer)
2017-05-21 8:08 ` mika.westerberg
2017-05-23 13:25 ` Andy Shevchenko
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=20170524114322.GB8541@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=Jared.Dominguez@dell.com \
--cc=Mario.Limonciello@dell.com \
--cc=amir.jer.levy@intel.com \
--cc=andreas.noever@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=luto@kernel.org \
--cc=michael.jamet@intel.com \
--cc=yehezkel.bernat@intel.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
all inboxes | Powered by JetHome®