LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCHv4 0/2] parport: parport_pc: Fix false-positives at checking for Intel bug
@ 2014-07-18  7:12 matwey
  2014-07-18  7:12 ` [PATCHv4 1/2] parport: parport_pc: Introduce intel_bug_present function matwey
  2014-07-18  7:12 ` [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives matwey
  0 siblings, 2 replies; 7+ messages in thread
From: matwey @ 2014-07-18  7:12 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, linux-parport, hsommer, gnomes, matwey.kornilov,
	Matwey V. Kornilov

From: "Matwey V. Kornilov" <matwey@sai.msu.ru>

Hi,

The following patch series is to deal with the issue on false-positives
of Intel EPP bug check [1].

More than a decade ago, the check was introduced in order to prevent EPP
operation on the some Intel LPT chipsets. The main issue to defence from
was CPU hang at EPP operation on broken chipsets. It is mentioned that
affected chipsets are Intel 82091. However, it is not known whether
there are others.

The check was implemented in strange manner. Now, there is no explanations
why. The check itself now leads to the false-positives, disabling EPP on
many PC-s (Dell OptiPlex series for instance). The latter is an issue.

As it was suggested by One Thousand Gnomes we implement the additional check of CPU model.
If CPU is Intel 80486 or Pentium, then it is considered as potentially affected by the initial problem, so the initial check is applied.

The patches organized as following:

1. Introduce-intel_bug_present-function.

The transparent refactoring of the check is performed.
Make the check be immutable regarding to ECR register.

2. Implement CPU model check to cut off false-positives

Based on CPU model, disable the check. The check is enabled only for Intel 80486 or Pentium.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630593

Suggested-by: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> 
Tested-by: Heiko Andreas Sommer <hsommer@eso.org>
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>

---
Changes from v3:
 - Do not introduce the additional option, rely on CPU model instead.

Changes from v2:
 - The module option has more clear description

Changes from v1:
 - Patch 1 fetched from right branch and now compiled


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv4 1/2] parport: parport_pc: Introduce intel_bug_present function.
  2014-07-18  7:12 [PATCHv4 0/2] parport: parport_pc: Fix false-positives at checking for Intel bug matwey
@ 2014-07-18  7:12 ` matwey
  2014-07-18  7:12 ` [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives matwey
  1 sibling, 0 replies; 7+ messages in thread
From: matwey @ 2014-07-18  7:12 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, linux-parport, hsommer, gnomes, matwey.kornilov,
	Matwey V. Kornilov

From: "Matwey V. Kornilov" <matwey@sai.msu.ru>

Put the code to check present of the Intel bug from parport_EPP_supported
into new intel_bug_present function. The later also return ECR register
to the state it has before function call.

Suggested-by: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Tested-by: Heiko Andreas Sommer <hsommer@eso.org>
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
---
 drivers/parport/parport_pc.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 76ee775..a6eaafb 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1702,6 +1702,30 @@ static int parport_ECP_supported(struct parport *pb)
 }
 #endif
 
+static int intel_bug_present(struct parport *pb)
+{
+	const struct parport_pc_private *priv = pb->private_data;
+	int bug_present = 0;
+
+	if (priv->ecr) {
+		/* store value of ECR */
+		unsigned char ecr = inb(ECONTROL(pb));
+		unsigned char i;
+		for (i = 0x00; i < 0x80; i += 0x20) {
+			ECR_WRITE(pb, i);
+			if (clear_epp_timeout(pb)) {
+				/* Phony EPP in ECP. */
+				bug_present = 1;
+				break;
+			}
+		}
+		/* return ECR into the inital state */
+		ECR_WRITE(pb, ecr);
+	}
+
+	return bug_present;
+}
+
 static int parport_ECPPS2_supported(struct parport *pb)
 {
 	const struct parport_pc_private *priv = pb->private_data;
@@ -1722,8 +1746,6 @@ static int parport_ECPPS2_supported(struct parport *pb)
 
 static int parport_EPP_supported(struct parport *pb)
 {
-	const struct parport_pc_private *priv = pb->private_data;
-
 	/*
 	 * Theory:
 	 *	Bit 0 of STR is the EPP timeout bit, this bit is 0
@@ -1742,16 +1764,8 @@ static int parport_EPP_supported(struct parport *pb)
 		return 0;  /* No way to clear timeout */
 
 	/* Check for Intel bug. */
-	if (priv->ecr) {
-		unsigned char i;
-		for (i = 0x00; i < 0x80; i += 0x20) {
-			ECR_WRITE(pb, i);
-			if (clear_epp_timeout(pb)) {
-				/* Phony EPP in ECP. */
-				return 0;
-			}
-		}
-	}
+	if (intel_bug_present(pb))
+		return 0;
 
 	pb->modes |= PARPORT_MODE_EPP;
 
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives
  2014-07-18  7:12 [PATCHv4 0/2] parport: parport_pc: Fix false-positives at checking for Intel bug matwey
  2014-07-18  7:12 ` [PATCHv4 1/2] parport: parport_pc: Introduce intel_bug_present function matwey
@ 2014-07-18  7:12 ` matwey
  2014-07-18  7:31   ` Ondrej Zary
  1 sibling, 1 reply; 7+ messages in thread
From: matwey @ 2014-07-18  7:12 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, linux-parport, hsommer, gnomes, matwey.kornilov,
	Matwey V. Kornilov

From: "Matwey V. Kornilov" <matwey@sai.msu.ru>

The code in intel_bug_present is known to produce much false-positives.
It is believed that the affected by the bug hardware are used with either Intel 80486 or Pentium.

Perform the check only when the kernel configured as CONFIG_X86_32,
then use cpuinfo_x86 of the first available CPU to check the model
and run initial check code.

Suggested-by: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Tested-by: Heiko Andreas Sommer <hsommer@eso.org>
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
---
 drivers/parport/parport_pc.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index a6eaafb..6b28f9f 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -65,6 +65,7 @@
 #include <linux/parport_pc.h>
 #include <linux/via.h>
 #include <asm/parport.h>
+#include <asm/processor.h>
 
 #define PARPORT_PC_MAX_PORTS PARPORT_MAX
 
@@ -1702,7 +1703,11 @@ static int parport_ECP_supported(struct parport *pb)
 }
 #endif
 
-static int intel_bug_present(struct parport *pb)
+/*  It is believed that CPU model correlates with buggy LPT chipset model.
+    Here we check that or CPU is elder than Pentium Pro: either 80486 or Pentium.
+    If it is then we perform The Check. */
+#ifdef CONFIG_X86_32
+static int intel_bug_present_check_epp(struct parport *pb)
 {
 	const struct parport_pc_private *priv = pb->private_data;
 	int bug_present = 0;
@@ -1725,6 +1730,20 @@ static int intel_bug_present(struct parport *pb)
 
 	return bug_present;
 }
+static int intel_bug_present(struct parport *pb)
+{
+	struct cpuinfo_x86 *c = &cpu_data(0);
+
+	if (c->x86_vendor == X86_VENDOR_INTEL && (c->x86 == 4 || c->x86 == 5))
+		return intel_bug_present_check_epp(pb);
+	return 0;
+}
+#else
+static int intel_bug_present(struct parport *pb)
+{
+	return 0;
+}
+#endif
 
 static int parport_ECPPS2_supported(struct parport *pb)
 {
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives
  2014-07-18  7:12 ` [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives matwey
@ 2014-07-18  7:31   ` Ondrej Zary
  2014-08-13  8:04     ` Matwey V. Kornilov
  0 siblings, 1 reply; 7+ messages in thread
From: Ondrej Zary @ 2014-07-18  7:31 UTC (permalink / raw)
  To: matwey
  Cc: gregkh, linux-kernel, linux-parport, hsommer, gnomes, matwey.kornilov

On Friday 18 July 2014, matwey@sai.msu.ru wrote:
> From: "Matwey V. Kornilov" <matwey@sai.msu.ru>
>
> The code in intel_bug_present is known to produce much false-positives.
> It is believed that the affected by the bug hardware are used with either
> Intel 80486 or Pentium.
>
> Perform the check only when the kernel configured as CONFIG_X86_32,
> then use cpuinfo_x86 of the first available CPU to check the model
> and run initial check code.
>
> Suggested-by: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
> Tested-by: Heiko Andreas Sommer <hsommer@eso.org>
> Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
> ---
>  drivers/parport/parport_pc.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
> index a6eaafb..6b28f9f 100644
> --- a/drivers/parport/parport_pc.c
> +++ b/drivers/parport/parport_pc.c
> @@ -65,6 +65,7 @@
>  #include <linux/parport_pc.h>
>  #include <linux/via.h>
>  #include <asm/parport.h>
> +#include <asm/processor.h>
>
>  #define PARPORT_PC_MAX_PORTS PARPORT_MAX
>
> @@ -1702,7 +1703,11 @@ static int parport_ECP_supported(struct parport *pb)
>  }
>  #endif
>
> -static int intel_bug_present(struct parport *pb)
> +/*  It is believed that CPU model correlates with buggy LPT chipset model.
> +    Here we check that or CPU is elder than Pentium Pro: either 80486 or
> Pentium. +    If it is then we perform The Check. */
> +#ifdef CONFIG_X86_32
> +static int intel_bug_present_check_epp(struct parport *pb)
>  {
>  	const struct parport_pc_private *priv = pb->private_data;
>  	int bug_present = 0;
> @@ -1725,6 +1730,20 @@ static int intel_bug_present(struct parport *pb)
>
>  	return bug_present;
>  }
> +static int intel_bug_present(struct parport *pb)
> +{
> +	struct cpuinfo_x86 *c = &cpu_data(0);
> +
> +	if (c->x86_vendor == X86_VENDOR_INTEL && (c->x86 == 4 || c->x86 == 5))
> +		return intel_bug_present_check_epp(pb);

You can have a non-Intel CPU in a 486 or Pentium board.

> +	return 0;
> +}
> +#else
> +static int intel_bug_present(struct parport *pb)
> +{
> +	return 0;
> +}
> +#endif
>
>  static int parport_ECPPS2_supported(struct parport *pb)
>  {



-- 
Ondrej Zary

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives
  2014-07-18  7:31   ` Ondrej Zary
@ 2014-08-13  8:04     ` Matwey V. Kornilov
  2015-01-21 16:51       ` [Linux-parport] " Leopold Palomo-Avellaneda
  0 siblings, 1 reply; 7+ messages in thread
From: Matwey V. Kornilov @ 2014-08-13  8:04 UTC (permalink / raw)
  To: Ondrej Zary
  Cc: Greg KH, linux-kernel, linux-parport, Heiko Andreas Sommer, gnomes

Hi,

What do you think, would it be better just to left the check for all
x86 32-bit hardware?.


2014-07-18 11:31 GMT+04:00 Ondrej Zary <linux@rainbow-software.org>:
> On Friday 18 July 2014, matwey@sai.msu.ru wrote:
>> From: "Matwey V. Kornilov" <matwey@sai.msu.ru>
>>
>> The code in intel_bug_present is known to produce much false-positives.
>> It is believed that the affected by the bug hardware are used with either
>> Intel 80486 or Pentium.
>>
>> Perform the check only when the kernel configured as CONFIG_X86_32,
>> then use cpuinfo_x86 of the first available CPU to check the model
>> and run initial check code.
>>
>> Suggested-by: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
>> Tested-by: Heiko Andreas Sommer <hsommer@eso.org>
>> Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
>> ---
>>  drivers/parport/parport_pc.c | 21 ++++++++++++++++++++-
>>  1 file changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
>> index a6eaafb..6b28f9f 100644
>> --- a/drivers/parport/parport_pc.c
>> +++ b/drivers/parport/parport_pc.c
>> @@ -65,6 +65,7 @@
>>  #include <linux/parport_pc.h>
>>  #include <linux/via.h>
>>  #include <asm/parport.h>
>> +#include <asm/processor.h>
>>
>>  #define PARPORT_PC_MAX_PORTS PARPORT_MAX
>>
>> @@ -1702,7 +1703,11 @@ static int parport_ECP_supported(struct parport *pb)
>>  }
>>  #endif
>>
>> -static int intel_bug_present(struct parport *pb)
>> +/*  It is believed that CPU model correlates with buggy LPT chipset model.
>> +    Here we check that or CPU is elder than Pentium Pro: either 80486 or
>> Pentium. +    If it is then we perform The Check. */
>> +#ifdef CONFIG_X86_32
>> +static int intel_bug_present_check_epp(struct parport *pb)
>>  {
>>       const struct parport_pc_private *priv = pb->private_data;
>>       int bug_present = 0;
>> @@ -1725,6 +1730,20 @@ static int intel_bug_present(struct parport *pb)
>>
>>       return bug_present;
>>  }
>> +static int intel_bug_present(struct parport *pb)
>> +{
>> +     struct cpuinfo_x86 *c = &cpu_data(0);
>> +
>> +     if (c->x86_vendor == X86_VENDOR_INTEL && (c->x86 == 4 || c->x86 == 5))
>> +             return intel_bug_present_check_epp(pb);
>
> You can have a non-Intel CPU in a 486 or Pentium board.
>
>> +     return 0;
>> +}
>> +#else
>> +static int intel_bug_present(struct parport *pb)
>> +{
>> +     return 0;
>> +}
>> +#endif
>>
>>  static int parport_ECPPS2_supported(struct parport *pb)
>>  {
>
>
>
> --
> Ondrej Zary



-- 
With best regards,
Matwey V. Kornilov.
Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Linux-parport] [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives
  2014-08-13  8:04     ` Matwey V. Kornilov
@ 2015-01-21 16:51       ` Leopold Palomo-Avellaneda
  2015-01-21 17:09         ` Matwey V. Kornilov
  0 siblings, 1 reply; 7+ messages in thread
From: Leopold Palomo-Avellaneda @ 2015-01-21 16:51 UTC (permalink / raw)
  To: linux-parport
  Cc: Matwey V. Kornilov, Ondrej Zary, Greg KH, Heiko Andreas Sommer,
	gnomes, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

El Dimecres, 13 d'agost de 2014, a les 12:04:55, Matwey V. Kornilov va 
escriure:
> Hi,
> 
> What do you think, would it be better just to left the check for all
> x86 32-bit hardware?.
> 

Finally,

finally this patch was applied? 

Best regards,

Leopold


-- 
--
Linux User 152692     GPG: 05F4A7A949A2D9AA
Catalonia
-------------------------------------
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Linux-parport] [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives
  2015-01-21 16:51       ` [Linux-parport] " Leopold Palomo-Avellaneda
@ 2015-01-21 17:09         ` Matwey V. Kornilov
  0 siblings, 0 replies; 7+ messages in thread
From: Matwey V. Kornilov @ 2015-01-21 17:09 UTC (permalink / raw)
  To: Leopold Palomo-Avellaneda
  Cc: linux-parport, Ondrej Zary, Greg KH, Heiko Andreas Sommer,
	gnomes, linux-kernel

2015-01-21 19:51 GMT+03:00 Leopold Palomo-Avellaneda <leo@alaxarxa.net>:
> finally this patch was applied?

This has been applied and it is available at 3.18+

-- 
With best regards,
Matwey V. Kornilov.
Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-21 17:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-18  7:12 [PATCHv4 0/2] parport: parport_pc: Fix false-positives at checking for Intel bug matwey
2014-07-18  7:12 ` [PATCHv4 1/2] parport: parport_pc: Introduce intel_bug_present function matwey
2014-07-18  7:12 ` [PATCHv4 2/2] parport: parport_pc: Implement CPU model check to cut off false-positives matwey
2014-07-18  7:31   ` Ondrej Zary
2014-08-13  8:04     ` Matwey V. Kornilov
2015-01-21 16:51       ` [Linux-parport] " Leopold Palomo-Avellaneda
2015-01-21 17:09         ` Matwey V. Kornilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).