From: Philipp Hortmann <philipp.g.hortmann@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Forest Bond <forest@alittletooquiet.net>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
David Laight <David.Laight@ACULAB.COM>
Subject: Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32
Date: Fri, 29 Apr 2022 23:04:54 +0200 [thread overview]
Message-ID: <6ecca4d7-8b1f-7476-da4b-b1d94995b0e8@gmail.com> (raw)
In-Reply-To: <YmwDZi3mmWRHzKAT@kroah.com>
On 4/29/22 17:25, Greg Kroah-Hartman wrote:
> On Fri, Apr 29, 2022 at 05:18:28PM +0200, Philipp Hortmann wrote:
>> On 4/27/22 07:55, Greg Kroah-Hartman wrote:
>>>> MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
>>>> for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
>>>> @@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
>>>> }
>>>> if (ww == W_MAX_TIMEOUT)
>>>> return false;
>>>> - VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
>>>> - VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
>>>> + low = ioread32(iobase + MAC_REG_TSFCNTR);
>>>> + high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
>>>> + *pqwCurrTSF = low + ((u64)high << 32);
>>> Are you_sure_ this is doing the same thing?
>>>
>> To compare I used the following code:
>> VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
>> VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
>> dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF: %llx",
>> *pqwCurrTSF);
>> low = ioread32(iobase + MAC_REG_TSFCNTR);
>> high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
>> dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF low/high: %llx", low +
>> ((u64)high << 32));
>>
>> Output:
>> vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 1155ba
>> vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 1155ba
>> vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd7c
>> vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd7c
>> vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd8a
>> vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd8a
>>
>> So no different results for numbers larger than 32 Bit.
> And for a big endian system? Do you get the same result?
>
Using ioread32be to simulate output of the big endian computer.
Code:
u32 *temp = (u32 *)pqwCurrTSF;
VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF:
0x%016llx", *pqwCurrTSF);
temp++;
*temp = ioread32be(iobase + MAC_REG_TSFCNTR);
temp--;
*temp = ioread32be(iobase + MAC_REG_TSFCNTR + 4);
dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF big-endian:
0x%016llx", *pqwCurrTSF);
*temp = ioread32(iobase + MAC_REG_TSFCNTR);
temp++;
*temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);
dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF little endian:
0x%016llx", *pqwCurrTSF);
Output:
[21250.521826] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF:
0x00 00 00 05 f8 55 1d 9b
[21250.521831] vt6655 0000:01:05.0: CARDbGetCurrentTSF big-endian:
0x9b 1d 55 f8 05 00 00 00
[21250.521835] vt6655 0000:01:05.0: CARDbGetCurrentTSF little endian:
0x00 00 00 05 f8 55 1d 9b
Code 2:
u32 high, low;
VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF:
0x%016llx", *pqwCurrTSF);
low = ioread32be(iobase + MAC_REG_TSFCNTR);
high = ioread32be(iobase + MAC_REG_TSFCNTR + 4);
dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF big-endian:
0x%016llx", high + ((u64)low << 32));
low = ioread32(iobase + MAC_REG_TSFCNTR);
high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF little endian:
0x%016llx", low + ((u64)high << 32));
Output 2:
[21996.659694] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF:
0x00 00 00 06 24 cd 8d 91
[21996.659698] vt6655 0000:01:05.0: CARDbGetCurrentTSF big-endian:
0x91 8d cd 24 06 00 00 00
[21996.659701] vt6655 0000:01:05.0: CARDbGetCurrentTSF little endian:
0x00 00 00 06 24 cd 8d 91
[22453.448296] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF:
0x00 00 00 06 40 07 dd a3
[22453.448300] vt6655 0000:01:05.0: CARDbGetCurrentTSF big-endian:
0xa3 dd 07 40 06 00 00 00
[22453.448304] vt6655 0000:01:05.0: CARDbGetCurrentTSF little endian:
0x00 00 00 06 40 07 dd a3
I am assuming that in case the big endian computer is used the ioread32
will be automatically converted to ioread32be. So I have only to care
about the u32 to be exchanged. That is easier with the second example.
Code:
low = ioread32(iobase + MAC_REG_TSFCNTR);
high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
#ifdef __BIG_ENDIAN
*pqwCurrTSF = high + ((u64)low << 32);
#else
*pqwCurrTSF = low + ((u64)high << 32);
#endif
Comments are welcome.
This is the article that helped me a lot:
https://en.wikipedia.org/wiki/Endianness#Bit_endianness
Especially the "Endian example" picture
Thanks,
Bye Philipp
prev parent reply other threads:[~2022-04-29 21:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 5:42 [PATCH v3 0/3] staging: vt6655: Replace macro VNSvInPortD with ioread32() Philipp Hortmann
2022-04-27 5:42 ` [PATCH v3 1/3] staging: vt6655: Replace MACvReadMIBCounter with VNSvInPortD Philipp Hortmann
2022-04-27 5:42 ` [PATCH v3 2/3] staging: vt6655: Replace MACvReadISR " Philipp Hortmann
2022-04-27 5:42 ` [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32 Philipp Hortmann
2022-04-27 5:55 ` Greg Kroah-Hartman
2022-04-27 8:01 ` David Laight
2022-04-27 8:48 ` 'Greg Kroah-Hartman'
2022-04-27 19:10 ` Philipp Hortmann
2022-04-27 21:59 ` David Laight
2022-04-29 15:18 ` Philipp Hortmann
2022-04-29 15:25 ` Greg Kroah-Hartman
2022-04-29 15:32 ` Philipp Hortmann
2022-04-29 15:45 ` Greg Kroah-Hartman
2022-04-29 21:04 ` Philipp Hortmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6ecca4d7-8b1f-7476-da4b-b1d94995b0e8@gmail.com \
--to=philipp.g.hortmann@gmail.com \
--cc=David.Laight@ACULAB.COM \
--cc=forest@alittletooquiet.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).