From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Cc: Forest Bond <forest@alittletooquiet.net>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32
Date: Fri, 29 Apr 2022 17:25:26 +0200 [thread overview]
Message-ID: <YmwDZi3mmWRHzKAT@kroah.com> (raw)
In-Reply-To: <b3d6b773-4ca1-a72e-933b-455c5d2b91c9@gmail.com>
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?
> The pqwCurrTSF is a microsecond counter running in the WLAN Router:
> At a later Measurement I got the following values:
> 269 seconds later: 0x3 6d89 fd91 -> 269.30 seconds
> 15 minutes later: 0x3 6d89 fd91 -> 15.54 minutes
> 8:38 hours later: 0xa 9787 ad91 -> 8.62 hours
>
> So both methods work on a AMD64 processor.
>
> > Adding 1 to a u64 pointer increments it by a full u64. So I guess the
> > cast to u32 * moves it only by a u32? Hopefully? That's messy.
>
> That is the reason why I wanted to change this.
>
> > Why not keep the current mess and do:
> > pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
> > ((u32 *)pqwCurTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);
> > Or does that not compile?
>
> drivers/staging/vt6655/card.c:760:13: warning: assignment to ‘u64 *’ {aka
> ‘long long unsigned int *’} from ‘unsigned int’ makes pointer from integer
> without a cast [-Wint-conversion]
> 760 | pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
> | ^
> drivers/staging/vt6655/card.c:761:26: error: lvalue required as left operand
> of assignment
> 761 | ((u32 *)pqwCurrTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);
> | ^
>
> This compiles:
> *(u32 *)pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
> *((u32 *)pqwCurrTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);
Heh, I just guessed :)
> Log:
> vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 178f41d90
> vt6655 0000:01:05.0: CARDbGetCurrentTSF with ioread: 178f41d90
>
> Ick, how about:
> > u32 *temp = (u32 *)pqwCurTSF;
> >
> > temp = ioread32(iobase + MAC_REG_TSFCNTR);
> > temp++;
> > temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);
>
> This is working:
> u32 *temp = (u32 *)pqwCurrTSF;
>
> *temp = ioread32(iobase + MAC_REG_TSFCNTR);
> temp++;
> *temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);
Nice!
thanks for testing,
greg k-h
next prev parent reply other threads:[~2022-04-29 15:25 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 [this message]
2022-04-29 15:32 ` Philipp Hortmann
2022-04-29 15:45 ` Greg Kroah-Hartman
2022-04-29 21:04 ` Philipp Hortmann
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=YmwDZi3mmWRHzKAT@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=forest@alittletooquiet.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=philipp.g.hortmann@gmail.com \
/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).