All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers
@ 2022-02-10 19:22 Sergey Shtylyov
  2022-02-10 19:22 ` [PATCH 1/3] ata: pata_hpt366: disable fast interrupts in prereset() method Sergey Shtylyov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2022-02-10 19:22 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide

Here are 3 patches against the 'for-next' branch of Damien Le Moal's
'libata.git' repo. Disable the so called fast interrupts in the prereset()
methods of the HighPoint HPT36x/37x/3x2N drivers -- that will allow to
de-duplicate the PIO/DMA mode setting in the HPT37x driver...

Sergey Shtylyov (3):
  ata: pata_hpt366: disable fast interrupts in prereset() method
  ata: pata_hpt37x: disable fast interrupts in prereset() method
  ata: pata_hpt3x2n: disable fast interrupts in prereset() method

 drivers/ata/pata_hpt366.c  | 13 ++++++-----
 drivers/ata/pata_hpt37x.c  | 48 +++++++++++++++++---------------------
 drivers/ata/pata_hpt3x2n.c | 23 ++++++++----------
 3 files changed, 39 insertions(+), 45 deletions(-)

-- 
2.26.3


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

* [PATCH 1/3] ata: pata_hpt366: disable fast interrupts in prereset() method
  2022-02-10 19:22 [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Sergey Shtylyov
@ 2022-02-10 19:22 ` Sergey Shtylyov
  2022-02-10 19:22 ` [PATCH 2/3] ata: pata_hpt37x: " Sergey Shtylyov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2022-02-10 19:22 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide

The PIO/DMA mode setting function is hardly a good place for disabling
the fast interrupts on a channel -- let's move that code to the driver's
prereset() method instead.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/ata/pata_hpt366.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 96caa79dc8d7..c99e8f0708b3 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -23,7 +23,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"pata_hpt366"
-#define DRV_VERSION	"0.6.12"
+#define DRV_VERSION	"0.6.13"
 
 struct hpt_clock {
 	u8	xfer_mode;
@@ -300,10 +300,15 @@ static int hpt366_prereset(struct ata_link *link, unsigned long deadline)
 	static const struct pci_bits hpt366_enable_bits = {
 		0x50, 1, 0x30, 0x30
 	};
+	u8 mcr2;
 
 	if (!pci_test_config_bits(pdev, &hpt366_enable_bits))
 		return -ENOENT;
 
+	pci_read_config_byte(pdev, 0x51, &mcr2);
+	if (mcr2 & 0x80)
+		pci_write_config_byte(pdev, 0x51, mcr2 & ~0x80);
+
 	return ata_sff_prereset(link, deadline);
 }
 
@@ -334,17 +339,13 @@ static struct ata_port_operations hpt366_port_ops = {
 
 static void hpt36x_init_chipset(struct pci_dev *dev)
 {
-	u8 drive_fast, mcr1;
+	u8 mcr1;
 
 	pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
 	pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78);
 	pci_write_config_byte(dev, PCI_MIN_GNT, 0x08);
 	pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
 
-	pci_read_config_byte(dev, 0x51, &drive_fast);
-	if (drive_fast & 0x80)
-		pci_write_config_byte(dev, 0x51, drive_fast & ~0x80);
-
 	/*
 	 * Now we'll have to force both channels enabled if at least one
 	 * of them has been enabled by BIOS...
-- 
2.26.3


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

* [PATCH 2/3] ata: pata_hpt37x: disable fast interrupts in prereset() method
  2022-02-10 19:22 [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Sergey Shtylyov
  2022-02-10 19:22 ` [PATCH 1/3] ata: pata_hpt366: disable fast interrupts in prereset() method Sergey Shtylyov
@ 2022-02-10 19:22 ` Sergey Shtylyov
  2022-02-10 19:22 ` [PATCH 3/3] ata: pata_hpt3x2n: " Sergey Shtylyov
  2022-02-16  7:19 ` [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Damien Le Moal
  3 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2022-02-10 19:22 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide

The PIO/DMA mode setting functions are hardly a good place for disabling
the fast interrupts on a channel -- let's move that code to the driver's
prereset() method instead.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/ata/pata_hpt37x.c | 48 ++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 7abc7e04f656..cb0fcee02de3 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -23,7 +23,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"pata_hpt37x"
-#define DRV_VERSION	"0.6.23"
+#define DRV_VERSION	"0.6.24"
 
 struct hpt_clock {
 	u8	xfer_speed;
@@ -394,6 +394,7 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline)
 		{ 0x50, 1, 0x04, 0x04 },
 		{ 0x54, 1, 0x04, 0x04 }
 	};
+	u8 mcr2;
 
 	if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
 		return -ENOENT;
@@ -402,6 +403,20 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline)
 	pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
 	udelay(100);
 
+	/*
+	 * Disable the "fast interrupt" prediction.  Don't hold off
+	 * on interrupts. (== 0x01 despite what the docs say)
+	 */
+	pci_read_config_byte(pdev, 0x51 + 4 * ap->port_no, &mcr2);
+	/* Is it HPT370/A? */
+	if (pdev->device == PCI_DEVICE_ID_TTI_HPT366 && pdev->revision < 5) {
+		mcr2 &= ~0x02;
+		mcr2 |= 0x01;
+	} else {
+		mcr2 &= ~0x07;
+	}
+	pci_write_config_byte(pdev, 0x51 + 4 * ap->port_no, mcr2);
+
 	return ata_sff_prereset(link, deadline);
 }
 
@@ -409,18 +424,8 @@ static void hpt370_set_mode(struct ata_port *ap, struct ata_device *adev,
 			    u8 mode)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-	u32 addr1, addr2;
+	int addr = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
 	u32 reg, timing, mask;
-	u8 fast;
-
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
-	addr2 = 0x51 + 4 * ap->port_no;
-
-	/* Fast interrupt prediction disable, hold off interrupt disable */
-	pci_read_config_byte(pdev, addr2, &fast);
-	fast &= ~0x02;
-	fast |= 0x01;
-	pci_write_config_byte(pdev, addr2, fast);
 
 	/* Determine timing mask and find matching mode entry */
 	if (mode < XFER_MW_DMA_0)
@@ -432,9 +437,9 @@ static void hpt370_set_mode(struct ata_port *ap, struct ata_device *adev,
 
 	timing = hpt37x_find_mode(ap, mode);
 
-	pci_read_config_dword(pdev, addr1, &reg);
+	pci_read_config_dword(pdev, addr, &reg);
 	reg = (reg & ~mask) | (timing & mask);
-	pci_write_config_dword(pdev, addr1, reg);
+	pci_write_config_dword(pdev, addr, reg);
 }
 /**
  *	hpt370_set_piomode		-	PIO setup
@@ -503,17 +508,8 @@ static void hpt372_set_mode(struct ata_port *ap, struct ata_device *adev,
 			    u8 mode)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-	u32 addr1, addr2;
+	int addr = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
 	u32 reg, timing, mask;
-	u8 fast;
-
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
-	addr2 = 0x51 + 4 * ap->port_no;
-
-	/* Fast interrupt prediction disable, hold off interrupt disable */
-	pci_read_config_byte(pdev, addr2, &fast);
-	fast &= ~0x07;
-	pci_write_config_byte(pdev, addr2, fast);
 
 	/* Determine timing mask and find matching mode entry */
 	if (mode < XFER_MW_DMA_0)
@@ -525,9 +521,9 @@ static void hpt372_set_mode(struct ata_port *ap, struct ata_device *adev,
 
 	timing = hpt37x_find_mode(ap, mode);
 
-	pci_read_config_dword(pdev, addr1, &reg);
+	pci_read_config_dword(pdev, addr, &reg);
 	reg = (reg & ~mask) | (timing & mask);
-	pci_write_config_dword(pdev, addr1, reg);
+	pci_write_config_dword(pdev, addr, reg);
 }
 
 /**
-- 
2.26.3


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

* [PATCH 3/3] ata: pata_hpt3x2n: disable fast interrupts in prereset() method
  2022-02-10 19:22 [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Sergey Shtylyov
  2022-02-10 19:22 ` [PATCH 1/3] ata: pata_hpt366: disable fast interrupts in prereset() method Sergey Shtylyov
  2022-02-10 19:22 ` [PATCH 2/3] ata: pata_hpt37x: " Sergey Shtylyov
@ 2022-02-10 19:22 ` Sergey Shtylyov
  2022-02-16  7:19 ` [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Damien Le Moal
  3 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2022-02-10 19:22 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide

The PIO/DMA mode setting function is hardly a good place for disabling
the fast interrupts on a channel -- let's move that code to the driver's
prereset() method instead.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/ata/pata_hpt3x2n.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index b36090808890..1f6afd8ee29b 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -24,7 +24,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME	"pata_hpt3x2n"
-#define DRV_VERSION	"0.3.17"
+#define DRV_VERSION	"0.3.18"
 
 enum {
 	PCI66		=	(1 << 1),
@@ -166,6 +166,7 @@ static int hpt3x2n_pre_reset(struct ata_link *link, unsigned long deadline)
 		{ 0x50, 1, 0x04, 0x04 },
 		{ 0x54, 1, 0x04, 0x04 }
 	};
+	u8 mcr2;
 
 	if (!pci_test_config_bits(pdev, &hpt3x2n_enable_bits[ap->port_no]))
 		return -ENOENT;
@@ -174,6 +175,11 @@ static int hpt3x2n_pre_reset(struct ata_link *link, unsigned long deadline)
 	pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
 	udelay(100);
 
+	/* Fast interrupt prediction disable, hold off interrupt disable */
+	pci_read_config_byte(pdev, 0x51 + 4 * ap->port_no, &mcr2);
+	mcr2 &= ~0x07;
+	pci_write_config_byte(pdev, 0x51 + 4 * ap->port_no, mcr2);
+
 	return ata_sff_prereset(link, deadline);
 }
 
@@ -181,17 +187,8 @@ static void hpt3x2n_set_mode(struct ata_port *ap, struct ata_device *adev,
 			     u8 mode)
 {
 	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-	u32 addr1, addr2;
+	int addr = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
 	u32 reg, timing, mask;
-	u8 fast;
-
-	addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
-	addr2 = 0x51 + 4 * ap->port_no;
-
-	/* Fast interrupt prediction disable, hold off interrupt disable */
-	pci_read_config_byte(pdev, addr2, &fast);
-	fast &= ~0x07;
-	pci_write_config_byte(pdev, addr2, fast);
 
 	/* Determine timing mask and find matching mode entry */
 	if (mode < XFER_MW_DMA_0)
@@ -203,9 +200,9 @@ static void hpt3x2n_set_mode(struct ata_port *ap, struct ata_device *adev,
 
 	timing = hpt3x2n_find_mode(ap, mode);
 
-	pci_read_config_dword(pdev, addr1, &reg);
+	pci_read_config_dword(pdev, addr, &reg);
 	reg = (reg & ~mask) | (timing & mask);
-	pci_write_config_dword(pdev, addr1, reg);
+	pci_write_config_dword(pdev, addr, reg);
 }
 
 /**
-- 
2.26.3


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

* Re: [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers
  2022-02-10 19:22 [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Sergey Shtylyov
                   ` (2 preceding siblings ...)
  2022-02-10 19:22 ` [PATCH 3/3] ata: pata_hpt3x2n: " Sergey Shtylyov
@ 2022-02-16  7:19 ` Damien Le Moal
  3 siblings, 0 replies; 5+ messages in thread
From: Damien Le Moal @ 2022-02-16  7:19 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-ide

On 2/11/22 04:22, Sergey Shtylyov wrote:
> Here are 3 patches against the 'for-next' branch of Damien Le Moal's
> 'libata.git' repo. Disable the so called fast interrupts in the prereset()
> methods of the HighPoint HPT36x/37x/3x2N drivers -- that will allow to
> de-duplicate the PIO/DMA mode setting in the HPT37x driver...
> 
> Sergey Shtylyov (3):
>   ata: pata_hpt366: disable fast interrupts in prereset() method
>   ata: pata_hpt37x: disable fast interrupts in prereset() method
>   ata: pata_hpt3x2n: disable fast interrupts in prereset() method
> 
>  drivers/ata/pata_hpt366.c  | 13 ++++++-----
>  drivers/ata/pata_hpt37x.c  | 48 +++++++++++++++++---------------------
>  drivers/ata/pata_hpt3x2n.c | 23 ++++++++----------
>  3 files changed, 39 insertions(+), 45 deletions(-)

Applied to for-5.18. Thanks !


-- 
Damien Le Moal
Western Digital Research

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

end of thread, other threads:[~2022-02-16  7:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 19:22 [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Sergey Shtylyov
2022-02-10 19:22 ` [PATCH 1/3] ata: pata_hpt366: disable fast interrupts in prereset() method Sergey Shtylyov
2022-02-10 19:22 ` [PATCH 2/3] ata: pata_hpt37x: " Sergey Shtylyov
2022-02-10 19:22 ` [PATCH 3/3] ata: pata_hpt3x2n: " Sergey Shtylyov
2022-02-16  7:19 ` [PATCH 0/3] Disable the fast interrupts in the prereset() methods of HighPoint HPT36x/37x drivers Damien Le Moal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.