From: David Laight <David.Laight@ACULAB.COM>
To: 'Philipp Hortmann' <philipp.g.hortmann@gmail.com>
Cc: Forest Bond <forest@alittletooquiet.net>,
"linux-staging@lists.linux.dev" <linux-staging@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
'Greg Kroah-Hartman' <gregkh@linuxfoundation.org>
Subject: RE: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32
Date: Wed, 27 Apr 2022 21:59:17 +0000 [thread overview]
Message-ID: <0b6873bcd7c54d71b1f0b84a61561261@AcuMS.aculab.com> (raw)
In-Reply-To: <748780b1-12ba-34d0-1ce3-36b74b1b90b7@gmail.com>
From: Philipp Hortmann
> Sent: 27 April 2022 20:10
>
> On 4/27/22 10:01, David Laight wrote:
> > Actually I suspect that 'iobase' should be an __iomem structure
> > pointer, pqwCurrTSF a point of the same type and MAC_REG_xxxx
> > structure members.
> >
> > Then the code should be using readl() not ioread32().
> > I very much doubt that 'iobase' is in PCI IO space.
>
> Hi David,
>
> here some infos and questions:
>
> $ sudo lspci -s 01:05.0 -vvv
> 01:05.0 Network controller: VIA Technologies, Inc. VT6655 WiFi Adapter, 802.11a/b/g
> Subsystem: VIA Technologies, Inc. VT6655 WiFi Adapter, 802.11a/b/g
...
> Region 0: Memory at f7c00000 (32-bit, non-prefetchable) [size=256]
> Region 1: I/O ports at e000 [size=256]
...
> ---- In file device_main.c line 1699
> priv->memaddr = pci_resource_start(pcid, 0);
> priv->ioaddr = pci_resource_start(pcid, 1);
> priv->port_offset = ioremap(priv->memaddr & PCI_BASE_ADDRESS_MEM_MASK, 256);
WTF is that mask?
The driver code I've got just uses pci_iomap(pci_dev, bar_number, length);
It then uses pci_iounmap(pci_dev, vaddr) to free it.
> dev_info(&pcid->dev, "vt6655_probe priv->memaddr: %x priv->ioaddr: %x",
> priv->memaddr, priv->ioaddr);
>
> ----- Output:
> [ +0.000018] vt6655 0000:01:05.0: vt6655_probe priv->memaddr: f7c00000
> priv->ioaddr: e000
>
>
> So port_offset is derived from memaddr.
>
>
> ----- In file card.c line 742
> bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
> {
> void __iomem *iobase = priv->port_offset;
> ...
> VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
>
> Please tell me if you need further infos to see if it is PCI IO space.
> I think it is memory-mapped.
BAR 0 is memory, BAR 1 I/O, both almost certainly refer to the
same physical device registers.
Basically PCI(e) I/O space is (mostly) deprecated.
It (sort of) exists so that PCI hardware could replace very old
(eg ISA) hardware without requiring driver changes.
> So is ioread32 wrong, right or can it be used?
(Assuming x86)
ioread32() has to contain a test to see whether the address
is an 'io address' or a 'memory address'.
For the former an 'inw' instruction is executed for the latter
a normal memory access instruction.
OTOH readl() is just a memory access (with compiler barriers)
and is inlined into the driver object.
So if you used priv->ioaddr you'd have to use ioread32().
Since you are using the memory space addresses from BAR 0
you can use ioread32() but it is more efficient to use readl().
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2022-04-27 21:59 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 [this message]
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
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=0b6873bcd7c54d71b1f0b84a61561261@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=forest@alittletooquiet.net \
--cc=gregkh@linuxfoundation.org \
--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).