# \[PATCH\] ata: hpt366: fix incorrect mask when checking at cmd\_high\_time

- Subsystems: LIBATA SUBSYSTEM (Serial and Parallel ATA drivers), THE REST
- Maintainers: Damien Le Moal, Niklas Cassel, Linus Torvalds
- List: linux-ide
- 5 messages, 4 authors
- Page: https://ratatoskr.run/linux-ide/2016/07/4792802/t

## \[PATCH\] ata: hpt366: fix incorrect mask when checking at cmd\_high\_time

- From: Colin King \<hidden\>
- Date: 2016-07-12 11:17:06 
- Message: https://ratatoskr.run/linux-ide/2016/07/4792802.md

```text
From: Colin Ian King <redacted>

According to the HPT366 data sheet, PCI config space dword 0x40-0x43
bits 11:8 specify the primary drive cmd_high_time, however,
currently just 3 bits of the 4 are being used because the mask
is 0x700 and not 0x0f00.  Fix the mask, allowing for the 40MHz clock
to be detected.

Signed-off-by: Colin Ian King <redacted>
---
 drivers/ata/pata_hpt366.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index e5fb752..a219a50 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -368,7 +368,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 
 	/* PCI clocking determines the ATA timing values to use */
 	/* info_hpt366 is safe against re-entry so we can scribble on it */
-	switch ((reg1 & 0x700) >> 8) {
+	switch ((reg1 & 0xf00) >> 8) {
 	case 9:
 		hpriv = &hpt366_40;
 		break;
-- 
2.8.1

```

## Re: \[PATCH\] ata: hpt366: fix incorrect mask when checking at cmd\_high\_time

- From: Bartlomiej Zolnierkiewicz \<hidden\>
- Date: 2016-07-12 11:28:34 
- Message: https://ratatoskr.run/linux-ide/2016/07/4792809.md

```text

Hi,

On Tuesday, July 12, 2016 12:16:19 PM Colin King wrote:
> From: Colin Ian King <redacted>
> 
> According to the HPT366 data sheet, PCI config space dword 0x40-0x43
> bits 11:8 specify the primary drive cmd_high_time, however,
> currently just 3 bits of the 4 are being used because the mask
> is 0x700 and not 0x0f00.  Fix the mask, allowing for the 40MHz clock
> to be detected.
> 
> Signed-off-by: Colin Ian King <redacted>

Acked-by: Bartlomiej Zolnierkiewicz <redacted>

Thanks for the patch, could you also fix also the old driver
(drivers/ide/hpt366.c)?

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> ---
>  drivers/ata/pata_hpt366.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
> index e5fb752..a219a50 100644
> --- a/drivers/ata/pata_hpt366.c
> +++ b/drivers/ata/pata_hpt366.c
> @@ -368,7 +368,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
>  
>  	/* PCI clocking determines the ATA timing values to use */
>  	/* info_hpt366 is safe against re-entry so we can scribble on it */
> -	switch ((reg1 & 0x700) >> 8) {
> +	switch ((reg1 & 0xf00) >> 8) {
>  	case 9:
>  		hpriv = &hpt366_40;
>  		break;

```

## Re: \[PATCH\] ata: hpt366: fix incorrect mask when checking at cmd\_high\_time

- From: Colin Ian King \<hidden\>
- Date: 2016-07-12 11:33:53 
- Message: https://ratatoskr.run/linux-ide/2016/07/4792812.md

```text
On 12/07/16 12:27, Bartlomiej Zolnierkiewicz wrote:
> 
> Hi,
> 
> On Tuesday, July 12, 2016 12:16:19 PM Colin King wrote:
>> From: Colin Ian King <redacted>
>>
>> According to the HPT366 data sheet, PCI config space dword 0x40-0x43
>> bits 11:8 specify the primary drive cmd_high_time, however,
>> currently just 3 bits of the 4 are being used because the mask
>> is 0x700 and not 0x0f00.  Fix the mask, allowing for the 40MHz clock
>> to be detected.
>>
>> Signed-off-by: Colin Ian King <redacted>
> 
> Acked-by: Bartlomiej Zolnierkiewicz <redacted>
> 
> Thanks for the patch, could you also fix also the old driver
> (drivers/ide/hpt366.c)?

Yep, patch already sent.

https://lkml.org/lkml/2016/7/12/199

> 
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> 
>> ---
>>  drivers/ata/pata_hpt366.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
>> index e5fb752..a219a50 100644
>> --- a/drivers/ata/pata_hpt366.c
>> +++ b/drivers/ata/pata_hpt366.c
>> @@ -368,7 +368,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
>>  
>>  	/* PCI clocking determines the ATA timing values to use */
>>  	/* info_hpt366 is safe against re-entry so we can scribble on it */
>> -	switch ((reg1 & 0x700) >> 8) {
>> +	switch ((reg1 & 0xf00) >> 8) {
>>  	case 9:
>>  		hpriv = &hpt366_40;
>>  		break;
> 
```

## Re: \[PATCH\] ata: hpt366: fix incorrect mask when checking at cmd\_high\_time

- From: Tejun Heo \<tj@kernel.org\>
- Date: 2016-07-12 15:03:37 
- Message: https://ratatoskr.run/linux-ide/2016/07/4793014.md

```text
On Tue, Jul 12, 2016 at 12:16:19PM +0100, Colin King wrote:
> From: Colin Ian King <redacted>
> 
> According to the HPT366 data sheet, PCI config space dword 0x40-0x43
> bits 11:8 specify the primary drive cmd_high_time, however,
> currently just 3 bits of the 4 are being used because the mask
> is 0x700 and not 0x0f00.  Fix the mask, allowing for the 40MHz clock
> to be detected.
> 
> Signed-off-by: Colin Ian King <redacted>

Applied to libata/for-4.8.

Thanks.

-- 
tejun
```

## Re: \[PATCH\] ata: hpt366: fix incorrect mask when checking at cmd\_high\_time

- From: One Thousand Gnomes \<hidden\>
- Date: 2016-07-18 20:15:02 
- Message: https://ratatoskr.run/linux-ide/2016/07/4797379.md

```text
On Tue, 12 Jul 2016 12:16:19 +0100
Colin King [ref] wrote:

> From: Colin Ian King <redacted>
> 
> According to the HPT366 data sheet, PCI config space dword 0x40-0x43
> bits 11:8 specify the primary drive cmd_high_time, however,
> currently just 3 bits of the 4 are being used because the mask
> is 0x700 and not 0x0f00.  Fix the mask, allowing for the 40MHz clock
> to be detected.

Is this tested on real hardware ? I learned long ago never to blindly
trust IDE data sheets. It looks right but if anyone actually has a 40MHz
PCI bus box with an HPT366 it would be good to test.

Alan
```
