Decouple SnadyBridge quirk form VTd timeout
PATCH v2 1/1 Decouple SnadyBridge quirk form VTd timeout
Currently the quirk code for SandyBridge uses the VTd timeout value when writing to an IGD register. This is the wrong timeout to use and, at 1000 msec, is much too large. Change this behavior by adding a new boot paramter, snb_igd_timeout, that can specify the timeout to be used when accessing the IGD registers in the quirk code.
For compatibility purposes, specifying the current boolean parameter, snb_igd_quirk, will enable the quirk code with a timeout of 1000 msec. Specifying the new parameter, snb_igd_timeout, with no value will enable the quirk code with the theoretical maximum timeout of 670 msec. Specifying a value for this parameter sets the timeout to that number of msec.
xen/drivers/passthrough/vtd/quirks.c +30 -1
@@ -50,6 +50,9 @@#define IS_ILK (id) (id == 0x00408086 || id == 0x00448086 || id== 0x00628086 || id == 0x006A8086)#define IS_CPT (id) (id == 0x01008086 || id == 0x01048086) +#define SNB_IGD_TIMEOUT MILLISECS(670) +static u32 snb_igd_timeout =MILLISECS (1000 ); +static u32 __read_mostly ioh_id;static u32 __initdata igd_id;bool_t __read_mostly rwbf_quirk;
@@ -158,6 +161,20 @@* Workaround is to prevent graphics get into RC6 * state when doing VT-d IOTLB operations, do the VT-d * IOTLB operation, and then re-enable RC6 state. +* +* This code, enabled by the Xen command line parameter +* snb_igd_quirk, due to legacy issues, uses th VTd timeout +* of 1000 msec. This timeout is too large so a second +* integer parameter, snb_igd_timeout, can be used to fine +* tune the IGD register access timeout. +* +* Specifying snb_igd_timeout with no value enables this +* quirk and sets the timeout to the theoretical maximum +* of 670 msec. Setting this parameter with a value enables +* this quirk and sets the timeout to that value. +* +* If neither snb_igd_quirk nor snb_igd_timeout are specified +* then the quirk code is not enabled. */ static void snb_vtd_ops_preamble (struct iommu * iommu) {
@@ -177,7 +194,7 @@ start_time =NOW ();while ( (*(volatile u32 *)(igd_reg_va +0x22AC ) &0xF ) !=0 ) { -if (NOW () > start_time +DMAR_OPERATION_TIMEOUT ) +if (NOW () > start_time + snb_igd_timeout ) { dprintk(XENLOG_INFO VTDPREFIX, "snb_vtd_ops_preamble: failed to disable idle handshake\n");
@@ -237,6 +254,18 @@ } } +static void __init parse_snb_timeout (const char *s) +{ + +if (*s =='\0' ) + snb_igd_timeout =SNB_IGD_TIMEOUT ; +else + snb_igd_timeout =MILLISECS (simple_strtoul (s, &s,0 )); + snb_igd_quirk =1 ; +return ; +} +custom_param ("snb_igd_timeout" , parse_snb_timeout); +/* 5500/5520/X58 Chipset Interrupt remapping errata, for stepping B-3. * Fixed in stepping C-2. */ static void __init tylersburg_intremap_quirk (void )
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 05:11, <[email protected]> wrote:
xen/drivers/passthrough/vtd/quirks.c +1
-0@@ -237,6 +254,18 @@ } } +static void __init parse_snb_timeout (const char *s)
xen/drivers/passthrough/vtd/quirks.c line 267
Quoted 10 lines
xen/drivers/passthrough/vtd/quirks.c +10
-0+{ + +if (*s =='\0' ) + snb_igd_timeout =SNB_IGD_TIMEOUT ; +else + snb_igd_timeout =MILLISECS (simple_strtoul (s, &s,0 )); + snb_igd_quirk =1 ; +return ; +} +custom_param ("snb_igd_timeout" , parse_snb_timeout);
Rather than adding a new command line option, can't you simply re-use (by extending) the existing (boolean) one? And similarly replace the current variable (using a value of zero to indicate no quirk) rather than adding another one?
Also note that the if() statement above needs spaces inserted to match our coding style.
Jan
Hmm, good ideas. How about I change the `snb_igd_quirk' parameter to be:
snb_igd_quirk => current behavior, enable quirk with 1 sec timeout
snb_igd_quirk=default => enable quirk with theoretical max timeout of 670 msec
snb_igd_quirk=n => enable quirk with timeout of `n' msec
--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Ph: 303/443-3786
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, November 17, 2014 5:07 AM
To: Dugger, Donald D
Cc: Kay, Allen M; Dong, Eddie; Auld, Will; [email protected]
Subject: Re: [PATCH V2] Decouple SnadyBridge quirk form VTd timeout
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 05:11, <[email protected]> wrote:
xen/drivers/passthrough/vtd/quirks.c +0
-0@@ -237,6 +254,18 @@ } }
xen/drivers/passthrough/vtd/quirks.c line 266
Quoted 10 lines
xen/drivers/passthrough/vtd/quirks.c +10
-0+static void __init parse_snb_timeout (const char *s) { + +if (*s =='\0' ) + snb_igd_timeout =SNB_IGD_TIMEOUT ; +else + snb_igd_timeout =MILLISECS (simple_strtoul (s, &s,0 )); + snb_igd_quirk =1 ; +return ; +} +custom_param ("snb_igd_timeout" , parse_snb_timeout);
Rather than adding a new command line option, can't you simply re-use (by extending) the existing (boolean) one? And similarly replace the current variable (using a value of zero to indicate no quirk) rather than adding another one?
Also note that the if() statement above needs spaces inserted to match our coding style.
Jan
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 14:32, <[email protected]> wrote:
Hmm, good ideas. How about I change the `snb_igd_quirk' parameter to be:
snb_igd_quirk=> current behavior, enable quirk with 1 sec timeout
snb_igd_quirk=default => enable quirk with theoretical max timeout of 670 msec
snb_igd_quirk=n => enable quirk with timeout of `n' msec
Please retain the current boolean behavior (i.e. =yes, =no, etc should all continue to be permitted). And the =yes case then would become what you propose above as =default. Plus I see no reason for the lack of a specified value to mean 1s - if 670ms is the theoretical may, there's no need to support the 1s one by means other than the use specifying that value on the command line.
Jan
I'm a big believer in backward compatibility, especially in not doing things that change current defined behavior. The current `snb_igd_quirk' flag enables the quirk code with a 1sec timeout. Even though that value is excessive silently changing the meaning of the parameter just seems wrong.
--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Ph: 303/443-3786
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, November 17, 2014 6:38 AM
To: Dugger, Donald D
Cc: Kay, Allen M; Dong, Eddie; Auld, Will; [email protected]
Subject: RE: [PATCH V2] Decouple SnadyBridge quirk form VTd timeout
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 14:32, <[email protected]> wrote:
Hmm, good ideas. How about I change the `snb_igd_quirk' parameter to be:
snb_igd_quirk=> current behavior, enable quirk with 1 sec timeout
snb_igd_quirk=default => enable quirk with theoretical max timeout of 670 msec
snb_igd_quirk=n => enable quirk with timeout of `n' msec
Please retain the current boolean behavior (i.e. =yes, =no, etc should all continue to be permitted). And the =yes case then would become what you propose above as =default. Plus I see no reason for the lack of a specified value to mean 1s - if 670ms is the theoretical may, there's no need to support the 1s one by means other than the use specifying that value on the command line.
Jan
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 15:27, <[email protected]> wrote:
I'm a big believer in backward compatibility, especially in not doing things that change current defined behavior. The current `snb_igd_quirk' flag enables the quirk code with a 1sec timeout. Even though that value is excessive silently changing the meaning of the parameter just seems wrong.
But it's the purpose of the patch to change this.
Jan
My primary goal is to decouple the IGD quirk code from the VTd timeout value, the two are unrelated and shouldn't be using the same define. In the process we can clean up the IGD code so that, if a user wants, the user can specify a more appropriate timeout value for the quirk code. There's no need to change the current behavior of the flag, just give the user more options.
--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Ph: 303/443-3786
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, November 17, 2014 7:41 AM
To: Dugger, Donald D
Cc: Kay, Allen M; Dong, Eddie; Auld, Will; [email protected]
Subject: RE: [PATCH V2] Decouple SnadyBridge quirk form VTd timeout
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 15:27, <[email protected]> wrote:
I'm a big believer in backward compatibility, especially in not doing
things that change current defined behavior. The current
`snb_igd_quirk' flag enables the quirk code with a 1sec timeout. Even
though that value is excessive silently changing the meaning of the parameter just seems wrong.
But it's the purpose of the patch to change this.
Jan
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 15:51, <[email protected]> wrote:
My primary goal is to decouple the IGD quirk code from the VTd timeout value, the two are unrelated and shouldn't be using the same define. In the process we can clean up the IGD code so that, if a user wants, the user can specify a more appropriate timeout value for the quirk code. There's no need to change the current behavior of the flag, just give the user more options.
It the VT-d maintainers agree with that, I certainly won't stand in the way.
Jan
Well, Allen (the original VTd maintainer and the author of the IGD quirk code) agrees that the original IGD quirk timeout code just used the VTd timeout as a convenience. He's the one who identified 670 msec as the theoretical max latency for IGD access but, due to certification issues, suggests we keep the current 1 sec max as a default.
--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Ph: 303/443-3786
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, November 17, 2014 7:58 AM
To: Dugger, Donald D
Cc: Kay, Allen M; Dong, Eddie; Auld, Will; [email protected]
Subject: RE: [PATCH V2] Decouple SnadyBridge quirk form VTd timeout
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 17.11.14 at 15:51, <[email protected]> wrote:
My primary goal is to decouple the IGD quirk code from the VTd timeout
value, the two are unrelated and shouldn't be using the same define.
In the process we can clean up the IGD code so that, if a user wants,
the user can specify a more appropriate timeout value for the quirk
code. There's no need to change the current behavior of the flag, just give the user more options.
It the VT-d maintainers agree with that, I certainly won't stand in the way.
Jan