diff mbox series

[2/8] thunderbolt: Move NVM upgrade support flag to struct icm

Message ID 20190705095800.43534-3-mika.westerberg@linux.intel.com (mailing list archive)
State RFC, archived
Headers show
Series thunderbolt: Intel Ice Lake support | expand

Commit Message

Mika Westerberg July 5, 2019, 9:57 a.m. UTC
This is depends on the controller and on the platform/CPU we are
running. Move it to struct icm so we can set it per controller.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/icm.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Yehezkel Bernat July 5, 2019, 10:52 a.m. UTC | #1
On Fri, Jul 5, 2019 at 12:58 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> @@ -1913,12 +1915,7 @@ static int icm_start(struct tb *tb)
>         if (IS_ERR(tb->root_switch))
>                 return PTR_ERR(tb->root_switch);
>
> -       /*
> -        * NVM upgrade has not been tested on Apple systems and they
> -        * don't provide images publicly either. To be on the safe side
> -        * prevent root switch NVM upgrade on Macs for now.
> -        */
> -       tb->root_switch->no_nvm_upgrade = x86_apple_machine;
> +       tb->root_switch->no_nvm_upgrade = !icm->can_upgrade_nvm;
>         tb->root_switch->rpm = icm->rpm;
>
>         ret = tb_switch_add(tb->root_switch);
> @@ -2021,6 +2018,7 @@ struct tb *icm_probe(struct tb_nhi *nhi)
>         switch (nhi->pdev->device) {
>         case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI:
>         case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI:
> +               icm->can_upgrade_nvm = true;
>                 icm->is_supported = icm_fr_is_supported;
>                 icm->get_route = icm_fr_get_route;
>                 icm->save_devices = icm_fr_save_devices;
> @@ -2038,6 +2036,13 @@ struct tb *icm_probe(struct tb_nhi *nhi)
>         case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_NHI:
>         case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_NHI:
>                 icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
> +               /*
> +                * NVM upgrade has not been tested on Apple systems and
> +                * they don't provide images publicly either. To be on
> +                * the safe side prevent root switch NVM upgrade on Macs
> +                * for now.
> +                */
> +               icm->can_upgrade_nvm = !x86_apple_machine;
>                 icm->is_supported = icm_ar_is_supported;
>                 icm->cio_reset = icm_ar_cio_reset;
>                 icm->get_mode = icm_ar_get_mode;
> @@ -2054,6 +2059,7 @@ struct tb *icm_probe(struct tb_nhi *nhi)
>         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
>         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
>                 icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
> +               icm->can_upgrade_nvm = true;

Shouldn't this be also !x86_apple_machine just like AR?
(For FR, we don't use ICM on Apple machines, as much as I remember, so it's fine
to enable it there unconditionally for ICM code path.)

>                 icm->is_supported = icm_ar_is_supported;
>                 icm->cio_reset = icm_tr_cio_reset;
>                 icm->get_mode = icm_ar_get_mode;
> --
> 2.20.1
>
Mika Westerberg July 5, 2019, 10:58 a.m. UTC | #2
On Fri, Jul 05, 2019 at 01:52:49PM +0300, Yehezkel Bernat wrote:
> > @@ -2054,6 +2059,7 @@ struct tb *icm_probe(struct tb_nhi *nhi)
> >         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
> >         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
> >                 icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
> > +               icm->can_upgrade_nvm = true;
> 
> Shouldn't this be also !x86_apple_machine just like AR?
> (For FR, we don't use ICM on Apple machines, as much as I remember, so it's fine
> to enable it there unconditionally for ICM code path.)

Yes, good point. I'll fix it up.
Limonciello, Mario July 9, 2019, 3:11 p.m. UTC | #3
> -----Original Message-----
> From: Mika Westerberg <mika.westerberg@linux.intel.com>
> Sent: Friday, July 5, 2019 5:58 AM
> To: Yehezkel Bernat
> Cc: LKML; Andreas Noever; Michael Jamet; Rafael J . Wysocki; Len Brown; Lukas
> Wunner; Limonciello, Mario; Anthony Wong; linux-acpi@vger.kernel.org
> Subject: Re: [PATCH 2/8] thunderbolt: Move NVM upgrade support flag to struct
> icm
> 
> 
> [EXTERNAL EMAIL]
> 
> On Fri, Jul 05, 2019 at 01:52:49PM +0300, Yehezkel Bernat wrote:
> > > @@ -2054,6 +2059,7 @@ struct tb *icm_probe(struct tb_nhi *nhi)
> > >         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
> > >         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
> > >                 icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
> > > +               icm->can_upgrade_nvm = true;
> >
> > Shouldn't this be also !x86_apple_machine just like AR?
> > (For FR, we don't use ICM on Apple machines, as much as I remember, so it's fine
> > to enable it there unconditionally for ICM code path.)
> 
> Yes, good point. I'll fix it up.

Another thought - does the TR or AR ID's setting can_upgrade_nvm to !x86_apple_machine
show up in anything like a dock or is it only host controllers?  If it's in docks, then it might be worth
only blocking on apple if it's a host.
Mika Westerberg Aug. 5, 2019, 1:15 p.m. UTC | #4
On Tue, Jul 09, 2019 at 03:11:15PM +0000, Mario.Limonciello@dell.com wrote:
> > -----Original Message-----
> > From: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Sent: Friday, July 5, 2019 5:58 AM
> > To: Yehezkel Bernat
> > Cc: LKML; Andreas Noever; Michael Jamet; Rafael J . Wysocki; Len Brown; Lukas
> > Wunner; Limonciello, Mario; Anthony Wong; linux-acpi@vger.kernel.org
> > Subject: Re: [PATCH 2/8] thunderbolt: Move NVM upgrade support flag to struct
> > icm
> > 
> > 
> > [EXTERNAL EMAIL]
> > 
> > On Fri, Jul 05, 2019 at 01:52:49PM +0300, Yehezkel Bernat wrote:
> > > > @@ -2054,6 +2059,7 @@ struct tb *icm_probe(struct tb_nhi *nhi)
> > > >         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
> > > >         case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
> > > >                 icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
> > > > +               icm->can_upgrade_nvm = true;
> > >
> > > Shouldn't this be also !x86_apple_machine just like AR?
> > > (For FR, we don't use ICM on Apple machines, as much as I remember, so it's fine
> > > to enable it there unconditionally for ICM code path.)
> > 
> > Yes, good point. I'll fix it up.
> 
> Another thought - does the TR or AR ID's setting can_upgrade_nvm to !x86_apple_machine
> show up in anything like a dock or is it only host controllers?  If it's in docks, then it might be worth
> only blocking on apple if it's a host.

It affects only hosts so on Apple system you can't upgrade host NVM but
docks and other devices you can.
diff mbox series

Patch

diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
index fbdcef56a676..2a56d9478b34 100644
--- a/drivers/thunderbolt/icm.c
+++ b/drivers/thunderbolt/icm.c
@@ -55,6 +55,7 @@ 
  * @safe_mode: ICM is in safe mode
  * @max_boot_acl: Maximum number of preboot ACL entries (%0 if not supported)
  * @rpm: Does the controller support runtime PM (RTD3)
+ * @can_upgrade_nvm: Can the NVM firmware be upgrade on this controller
  * @is_supported: Checks if we can support ICM on this controller
  * @cio_reset: Trigger CIO reset
  * @get_mode: Read and return the ICM firmware mode (optional)
@@ -74,6 +75,7 @@  struct icm {
 	int vnd_cap;
 	bool safe_mode;
 	bool rpm;
+	bool can_upgrade_nvm;
 	bool (*is_supported)(struct tb *tb);
 	int (*cio_reset)(struct tb *tb);
 	int (*get_mode)(struct tb *tb);
@@ -1913,12 +1915,7 @@  static int icm_start(struct tb *tb)
 	if (IS_ERR(tb->root_switch))
 		return PTR_ERR(tb->root_switch);
 
-	/*
-	 * NVM upgrade has not been tested on Apple systems and they
-	 * don't provide images publicly either. To be on the safe side
-	 * prevent root switch NVM upgrade on Macs for now.
-	 */
-	tb->root_switch->no_nvm_upgrade = x86_apple_machine;
+	tb->root_switch->no_nvm_upgrade = !icm->can_upgrade_nvm;
 	tb->root_switch->rpm = icm->rpm;
 
 	ret = tb_switch_add(tb->root_switch);
@@ -2021,6 +2018,7 @@  struct tb *icm_probe(struct tb_nhi *nhi)
 	switch (nhi->pdev->device) {
 	case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI:
 	case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI:
+		icm->can_upgrade_nvm = true;
 		icm->is_supported = icm_fr_is_supported;
 		icm->get_route = icm_fr_get_route;
 		icm->save_devices = icm_fr_save_devices;
@@ -2038,6 +2036,13 @@  struct tb *icm_probe(struct tb_nhi *nhi)
 	case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_NHI:
 	case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_NHI:
 		icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
+		/*
+		 * NVM upgrade has not been tested on Apple systems and
+		 * they don't provide images publicly either. To be on
+		 * the safe side prevent root switch NVM upgrade on Macs
+		 * for now.
+		 */
+		icm->can_upgrade_nvm = !x86_apple_machine;
 		icm->is_supported = icm_ar_is_supported;
 		icm->cio_reset = icm_ar_cio_reset;
 		icm->get_mode = icm_ar_get_mode;
@@ -2054,6 +2059,7 @@  struct tb *icm_probe(struct tb_nhi *nhi)
 	case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
 	case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
 		icm->max_boot_acl = ICM_AR_PREBOOT_ACL_ENTRIES;
+		icm->can_upgrade_nvm = true;
 		icm->is_supported = icm_ar_is_supported;
 		icm->cio_reset = icm_tr_cio_reset;
 		icm->get_mode = icm_ar_get_mode;