* [PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE
@ 2017-01-20 7:41 Yongji Xie
2017-01-20 7:41 ` [PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs Yongji Xie
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Yongji Xie @ 2017-01-20 7:41 UTC (permalink / raw)
To: bhelgaas
Cc: linux-pci, linuxppc-dev, alex.williamson, gwshan, aik, benh, mpe,
paulus, zhong
This series introduces a way for PCI resource allocator to force
MMIO BARs not to share PAGE_SIZE. This would make sense to VFIO
driver. Because current VFIO implementation disallows to mmap
sub-page(size < PAGE_SIZE) MMIO BARs which may share the same page
with other BARs for security reasons. Thus, we have to handle mmio
access to these BARs in QEMU emulation rather than in guest which
will cause some performance loss.
In our solution, we try to make use of the existing code path of
resource_alignment kernel parameter and add a macro to set default
alignment for it. Thus we can define this macro by default on some
archs which may easily hit the performance issue because of their
64K page.
In this series, patch 1,2 fixed bugs of using resource_alignment;
patch 3 adds a macro to set the default alignment of all MMIO BARs.
Changelog v8:
- Rebased against v4.10-rc4
- Rework the patch 2
- Change the commit log of patch 1
Changelog v7:
- Rebased against v4.9-rc2
- Drop two merged patches
- Rework the patch which fix a bug that resources's size is changed when
using resource_alignment
- Add a patch that fix a bug for IOV BARs when using resource_alignment
Changelog v6:
- Remove the option "noresize@" of resource_alignment
Changelog v5:
- Rebased against v4.8-rc6
- Drop the patch that forbidding disable memory decoding in
pci_reassigndev_resource_alignment()
Changelog v4:
- Rebased against v4.8-rc1
- Drop one irrelevant patch
- Drop the patch that adding wildcard to resource_alignment to enforce
the alignment of all MMIO BARs to be at least PAGE_SIZE
- Change the format of option "noresize" of resource_alignment
- Code style improvements
Changelog v3:
- Ignore enforced alignment to fixed BARs
- Fix issue that disabling memory decoding when reassigning the alignment
- Only enable default alignment on PowerNV platform
Changelog v2:
- Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment()
Yongji Xie (3):
PCI: Ignore requested alignment for IOV BARs
PCI: Make sure the driver could get correct BAR size from pci_resource_len()
PCI: Add a macro to set default alignment for all PCI devices
arch/powerpc/include/asm/pci.h | 4 ++++
drivers/pci/pci.c | 6 +++++-
include/linux/pci.h | 6 +++++-
3 files changed, 14 insertions(+), 2 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs
2017-01-20 7:41 [PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE Yongji Xie
@ 2017-01-20 7:41 ` Yongji Xie
2017-01-20 7:41 ` [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len() Yongji Xie
2017-01-20 7:41 ` [PATCH v8 3/3] PCI: Add a macro to set default alignment for all PCI devices Yongji Xie
2 siblings, 0 replies; 6+ messages in thread
From: Yongji Xie @ 2017-01-20 7:41 UTC (permalink / raw)
To: bhelgaas
Cc: linux-pci, linuxppc-dev, alex.williamson, gwshan, aik, benh, mpe,
paulus, zhong
We would call pci_reassigndev_resource_alignment() before
pci_init_capabilities(). So the requested alignment would
never work for IOV BARs.
Furthermore, it's meaningless to request additional alignment
for IOV BARs, the IOV BAR alignment is only determined by the
VF BAR size.
Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
drivers/pci/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a881c0d..220c31e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5084,7 +5084,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
command &= ~PCI_COMMAND_MEMORY;
pci_write_config_word(dev, PCI_COMMAND, command);
- for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
+ for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
r = &dev->resource[i];
if (!(r->flags & IORESOURCE_MEM))
continue;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()
2017-01-20 7:41 [PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE Yongji Xie
2017-01-20 7:41 ` [PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs Yongji Xie
@ 2017-01-20 7:41 ` Yongji Xie
2017-01-20 19:53 ` kbuild test robot
2017-01-20 20:41 ` kbuild test robot
2017-01-20 7:41 ` [PATCH v8 3/3] PCI: Add a macro to set default alignment for all PCI devices Yongji Xie
2 siblings, 2 replies; 6+ messages in thread
From: Yongji Xie @ 2017-01-20 7:41 UTC (permalink / raw)
To: bhelgaas
Cc: linux-pci, linuxppc-dev, alex.williamson, gwshan, aik, benh, mpe,
paulus, zhong
When using resource_alignment kernel parameter, the current implement
reassigns the alignment by expanding resources' size. So there exists two
kinds of *size* for one PCI BAR. One is the hardware size, the other is
the allocated size. Currently pci_resource_len() used by drivers return
the allocated size rather than the hardware size. This may potentially
break some drivers when they use the size to locate some registers whose
length is related to the hardware size. Some examples as below:
- misc\Hpilo.c:
off = pci_resource_len(pdev, bar) - 0x2000;
- net\ethernet\chelsio\cxgb4\cxgb4_uld.h:
(pci_resource_len((pdev), 2) - roundup_pow_of_two((vres)->ocq.size))
- infiniband\hw\nes\Nes_hw.c:
num_pds = pci_resource_len(nesdev->pcidev, BAR_1) >> PAGE_SHIFT;
This modifies pci_resource_len() to be aware of the increased size.
So it could return the hardware size instead. And if we need the allocated
size, resource_size()(or we can introuce a new helper function) can be used
to get it.
Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
---
drivers/pci/pci.c | 1 +
include/linux/pci.h | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 220c31e..04f2100 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5096,6 +5096,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
size = resource_size(r);
if (size < align) {
+ dev->res_addsize[i] = align - size;
size = align;
dev_info(&dev->dev,
"Rounding up size of resource #%d to %#llx.\n",
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e2d1a12..e4099fb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -334,6 +334,7 @@ struct pci_dev {
*/
unsigned int irq;
struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
+ resource_size_t res_addsize[PCI_ROM_RESOURCE + 1];
bool match_driver; /* Skip attaching driver */
/* These fields are used by common fixups */
@@ -1644,7 +1645,10 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
/* these helpers provide future and backwards compatibility
* for accessing popular PCI BAR info */
#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
-#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
+#define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \
+ (dev)->resource[(bar)].end : \
+ ((dev)->resource[(bar)].end - \
+ (dev)->res_addsize[(bar)]))
#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
#define pci_resource_len(dev,bar) \
((pci_resource_start((dev), (bar)) == 0 && \
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v8 3/3] PCI: Add a macro to set default alignment for all PCI devices
2017-01-20 7:41 [PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE Yongji Xie
2017-01-20 7:41 ` [PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs Yongji Xie
2017-01-20 7:41 ` [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len() Yongji Xie
@ 2017-01-20 7:41 ` Yongji Xie
2 siblings, 0 replies; 6+ messages in thread
From: Yongji Xie @ 2017-01-20 7:41 UTC (permalink / raw)
To: bhelgaas
Cc: linux-pci, linuxppc-dev, alex.williamson, gwshan, aik, benh, mpe,
paulus, zhong
When vfio passthroughs a PCI device of which MMIO BARs are
smaller than PAGE_SIZE, guest will not handle the mmio
accesses to the BARs which leads to mmio emulations in host.
This is because vfio will not allow to passthrough one BAR's
mmio page which may be shared with other BARs. Otherwise,
there will be a backdoor that guest can use to access BARs
of other guest.
This patch adds a macro to set default alignment for all
PCI devices. Then we could solve this issue on some platforms
which would easily hit this issue because of their 64K page
such as PowerNV platform by defining this macro as PAGE_SIZE.
Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/pci.h | 4 ++++
drivers/pci/pci.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index e9bd6cf..5e31bc2 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -28,6 +28,10 @@
#define PCIBIOS_MIN_IO 0x1000
#define PCIBIOS_MIN_MEM 0x10000000
+#ifdef CONFIG_PPC_POWERNV
+#define PCIBIOS_DEFAULT_ALIGNMENT PAGE_SIZE
+#endif
+
struct pci_dev;
/* Values for the `which' argument to sys_pciconfig_iobase syscall. */
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 04f2100..c2da41b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4965,6 +4965,9 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
resource_size_t align = 0;
char *p;
+#ifdef PCIBIOS_DEFAULT_ALIGNMENT
+ align = PCIBIOS_DEFAULT_ALIGNMENT;
+#endif
spin_lock(&resource_alignment_lock);
p = resource_alignment_param;
if (!*p)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()
2017-01-20 7:41 ` [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len() Yongji Xie
@ 2017-01-20 19:53 ` kbuild test robot
2017-01-20 20:41 ` kbuild test robot
1 sibling, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2017-01-20 19:53 UTC (permalink / raw)
To: Yongji Xie
Cc: kbuild-all, bhelgaas, zhong, aik, linux-pci, gwshan,
alex.williamson, paulus, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 2838 bytes --]
Hi Yongji,
[auto build test WARNING on pci/next]
[also build test WARNING on v4.10-rc4 next-20170120]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Yongji-Xie/PCI-Ignore-requested-alignment-for-IOV-BARs/20170121-031322
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: i386-defconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
In file included from drivers/ata/ata_piix.c:88:0:
drivers/ata/ata_piix.c: In function 'piix_init_sidpr':
>> include/linux/pci.h:1648:44: warning: comparison between 'enum <anonymous>' and 'enum <anonymous>' [-Wenum-compare]
#define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \
^
>> include/linux/pci.h:1655:4: note: in expansion of macro 'pci_resource_end'
pci_resource_end((dev), (bar)) == \
^~~~~~~~~~~~~~~~
>> drivers/ata/ata_piix.c:1471:6: note: in expansion of macro 'pci_resource_len'
pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN)
^~~~~~~~~~~~~~~~
>> include/linux/pci.h:1648:44: warning: comparison between 'enum <anonymous>' and 'enum <anonymous>' [-Wenum-compare]
#define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \
^
include/linux/pci.h:1658:4: note: in expansion of macro 'pci_resource_end'
(pci_resource_end((dev), (bar)) - \
^~~~~~~~~~~~~~~~
>> drivers/ata/ata_piix.c:1471:6: note: in expansion of macro 'pci_resource_len'
pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN)
^~~~~~~~~~~~~~~~
vim +1648 include/linux/pci.h
1642 #define pci_root_bus_fwnode(bus) NULL
1643 #endif
1644
1645 /* these helpers provide future and backwards compatibility
1646 * for accessing popular PCI BAR info */
1647 #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
> 1648 #define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \
1649 (dev)->resource[(bar)].end : \
1650 ((dev)->resource[(bar)].end - \
1651 (dev)->res_addsize[(bar)]))
1652 #define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
1653 #define pci_resource_len(dev,bar) \
1654 ((pci_resource_start((dev), (bar)) == 0 && \
> 1655 pci_resource_end((dev), (bar)) == \
1656 pci_resource_start((dev), (bar))) ? 0 : \
1657 \
1658 (pci_resource_end((dev), (bar)) - \
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25441 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()
2017-01-20 7:41 ` [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len() Yongji Xie
2017-01-20 19:53 ` kbuild test robot
@ 2017-01-20 20:41 ` kbuild test robot
1 sibling, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2017-01-20 20:41 UTC (permalink / raw)
To: Yongji Xie
Cc: kbuild-all, bhelgaas, zhong, aik, linux-pci, gwshan,
alex.williamson, paulus, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 22643 bytes --]
Hi Yongji,
[auto build test WARNING on pci/next]
[also build test WARNING on v4.10-rc4 next-20170120]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Yongji-Xie/PCI-Ignore-requested-alignment-for-IOV-BARs/20170121-031322
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: x86_64-kexec (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from drivers/ata/sata_sis.c:35:0:
drivers/ata/sata_sis.c: In function 'sis_init_one':
include/linux/pci.h:1648:44: warning: comparison between 'enum <anonymous>' and 'enum <anonymous>' [-Wenum-compare]
#define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \
^
include/linux/pci.h:1655:4: note: in expansion of macro 'pci_resource_end'
pci_resource_end((dev), (bar)) == \
^~~~~~~~~~~~~~~~
>> drivers/ata/sata_sis.c:223:8: note: in expansion of macro 'pci_resource_len'
(pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) {
^~~~~~~~~~~~~~~~
include/linux/pci.h:1648:44: warning: comparison between 'enum <anonymous>' and 'enum <anonymous>' [-Wenum-compare]
#define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \
^
include/linux/pci.h:1658:4: note: in expansion of macro 'pci_resource_end'
(pci_resource_end((dev), (bar)) - \
^~~~~~~~~~~~~~~~
>> drivers/ata/sata_sis.c:223:8: note: in expansion of macro 'pci_resource_len'
(pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) {
^~~~~~~~~~~~~~~~
vim +/pci_resource_len +223 drivers/ata/sata_sis.c
af36d7f0 drivers/scsi/sata_sis.c Jeff Garzik 2005-08-28 29 * Hardware documentation available under NDA.
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 30 *
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 31 */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 32
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 33 #include <linux/kernel.h>
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 34 #include <linux/module.h>
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 @35 #include <linux/pci.h>
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 36 #include <linux/blkdev.h>
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 37 #include <linux/delay.h>
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 38 #include <linux/interrupt.h>
a9524a76 drivers/scsi/sata_sis.c Jeff Garzik 2005-10-30 39 #include <linux/device.h>
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 40 #include <scsi/scsi_host.h>
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 41 #include <linux/libata.h>
4bb64fb9 drivers/ata/sata_sis.c Alan Cox 2007-02-16 42 #include "sis.h"
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 43
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 44 #define DRV_NAME "sata_sis"
2a3103ce drivers/ata/sata_sis.c Jeff Garzik 2007-08-31 45 #define DRV_VERSION "1.0"
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 46
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 47 enum {
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 48 sis_180 = 0,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 49 SIS_SCR_PCI_BAR = 5,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 50
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 51 /* PCI configuration registers */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 52 SIS_GENCTL = 0x54, /* IDE General Control register */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 53 SIS_SCR_BASE = 0xc0, /* sata0 phy SCR registers */
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 54 SIS180_SATA1_OFS = 0x10, /* offset from sata0->sata1 phy regs */
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 55 SIS182_SATA1_OFS = 0x20, /* offset from sata0->sata1 phy regs */
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 56 SIS_PMR = 0x90, /* port mapping register */
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 57 SIS_PMR_COMBINED = 0x30,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 58
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 59 /* random bits */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 60 SIS_FLAG_CFGSCR = (1 << 30), /* host flag: SCRs via PCI cfg */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 61
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 62 GENCTL_IOMAPPED_SCR = (1 << 26), /* if set, SCRs are in IO space */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 63 };
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 64
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 65 static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 66 static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 67 static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 68
3b7d697d drivers/scsi/sata_sis.c Jeff Garzik 2005-11-10 69 static const struct pci_device_id sis_pci_tbl[] = {
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 70 { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 71 { PCI_VDEVICE(SI, 0x0181), sis_180 }, /* SiS 964/180 */
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 72 { PCI_VDEVICE(SI, 0x0182), sis_180 }, /* SiS 965/965L */
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 73 { PCI_VDEVICE(SI, 0x0183), sis_180 }, /* SiS 965/965L */
a3cabb27 drivers/ata/sata_sis.c Uwe Koziolek 2007-06-14 74 { PCI_VDEVICE(SI, 0x1182), sis_180 }, /* SiS 966/680 */
a3cabb27 drivers/ata/sata_sis.c Uwe Koziolek 2007-06-14 75 { PCI_VDEVICE(SI, 0x1183), sis_180 }, /* SiS 966/966L/968/680 */
2d2744fc drivers/ata/sata_sis.c Jeff Garzik 2006-09-28 76
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 77 { } /* terminate list */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 78 };
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 79
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 80 static struct pci_driver sis_pci_driver = {
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 81 .name = DRV_NAME,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 82 .id_table = sis_pci_tbl,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 83 .probe = sis_init_one,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 84 .remove = ata_pci_remove_one,
58eb8cd5 drivers/ata/sata_sis.c Bartlomiej Zolnierkiewicz 2014-05-07 85 #ifdef CONFIG_PM_SLEEP
55c82a6c drivers/ata/sata_sis.c Alan 2014-01-01 86 .suspend = ata_pci_device_suspend,
55c82a6c drivers/ata/sata_sis.c Alan 2014-01-01 87 .resume = ata_pci_device_resume,
55c82a6c drivers/ata/sata_sis.c Alan 2014-01-01 88 #endif
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 89 };
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 90
193515d5 drivers/scsi/sata_sis.c Jeff Garzik 2005-11-07 91 static struct scsi_host_template sis_sht = {
68d1d07b drivers/ata/sata_sis.c Tejun Heo 2008-03-25 92 ATA_BMDMA_SHT(DRV_NAME),
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 93 };
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 94
029cfd6b drivers/ata/sata_sis.c Tejun Heo 2008-03-25 95 static struct ata_port_operations sis_ops = {
029cfd6b drivers/ata/sata_sis.c Tejun Heo 2008-03-25 96 .inherits = &ata_bmdma_port_ops,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 97 .scr_read = sis_scr_read,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 98 .scr_write = sis_scr_write,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 99 };
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 100
1626aeb8 drivers/ata/sata_sis.c Tejun Heo 2007-05-04 101 static const struct ata_port_info sis_port_info = {
9cbe056f drivers/ata/sata_sis.c Sergei Shtylyov 2011-02-04 102 .flags = ATA_FLAG_SATA,
14bdef98 drivers/ata/sata_sis.c Erik Inge Bolsø 2009-03-14 103 .pio_mask = ATA_PIO4,
14bdef98 drivers/ata/sata_sis.c Erik Inge Bolsø 2009-03-14 104 .mwdma_mask = ATA_MWDMA2,
bf6263a8 drivers/ata/sata_sis.c Jeff Garzik 2007-07-09 105 .udma_mask = ATA_UDMA6,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 106 .port_ops = &sis_ops,
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 107 };
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 108
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 109 MODULE_AUTHOR("Uwe Koziolek");
142924cf drivers/ata/sata_sis.c Chris Dunlop 2011-10-24 110 MODULE_DESCRIPTION("low-level driver for Silicon Integrated Systems SATA controller");
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 111 MODULE_LICENSE("GPL");
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 112 MODULE_DEVICE_TABLE(pci, sis_pci_tbl);
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 113 MODULE_VERSION(DRV_VERSION);
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 114
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 115 static unsigned int get_scr_cfg_addr(struct ata_link *link, unsigned int sc_reg)
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 116 {
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 117 struct ata_port *ap = link->ap;
9b14dec5 drivers/ata/sata_sis.c Alan Cox 2007-01-08 118 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 119 unsigned int addr = SIS_SCR_BASE + (4 * sc_reg);
9b14dec5 drivers/ata/sata_sis.c Alan Cox 2007-01-08 120 u8 pmr;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 121
9b14dec5 drivers/ata/sata_sis.c Alan Cox 2007-01-08 122 if (ap->port_no) {
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 123 switch (pdev->device) {
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 124 case 0x0180:
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 125 case 0x0181:
9b14dec5 drivers/ata/sata_sis.c Alan Cox 2007-01-08 126 pci_read_config_byte(pdev, SIS_PMR, &pmr);
9b14dec5 drivers/ata/sata_sis.c Alan Cox 2007-01-08 127 if ((pmr & SIS_PMR_COMBINED) == 0)
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 128 addr += SIS180_SATA1_OFS;
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 129 break;
8add7885 drivers/scsi/sata_sis.c Jeff Garzik 2005-09-08 130
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 131 case 0x0182:
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 132 case 0x0183:
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 133 case 0x1182:
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 134 addr += SIS182_SATA1_OFS;
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 135 break;
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 136 }
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 137 }
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 138 if (link->pmp)
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 139 addr += 0x10;
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 140
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 141 return addr;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 142 }
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 143
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 144 static u32 sis_scr_cfg_read(struct ata_link *link,
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 145 unsigned int sc_reg, u32 *val)
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 146 {
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 147 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 148 unsigned int cfg_addr = get_scr_cfg_addr(link, sc_reg);
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 149
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 150 if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
8e5443a0 drivers/ata/sata_sis.c Tejun Heo 2008-04-24 151 return -EINVAL;
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 152
aaa092a1 drivers/ata/sata_sis.c Tejun Heo 2007-10-18 153 pci_read_config_dword(pdev, cfg_addr, val);
aaa092a1 drivers/ata/sata_sis.c Tejun Heo 2007-10-18 154 return 0;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 155 }
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 156
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 157 static int sis_scr_cfg_write(struct ata_link *link,
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 158 unsigned int sc_reg, u32 val)
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 159 {
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 160 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 161 unsigned int cfg_addr = get_scr_cfg_addr(link, sc_reg);
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 162
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 163 pci_write_config_dword(pdev, cfg_addr, val);
8e5443a0 drivers/ata/sata_sis.c Tejun Heo 2008-04-24 164 return 0;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 165 }
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 166
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 167 static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 168 {
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 169 struct ata_port *ap = link->ap;
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 170 void __iomem *base = ap->ioaddr.scr_addr + link->pmp * 0x10;
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 171
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 172 if (sc_reg > SCR_CONTROL)
da3dbb17 drivers/ata/sata_sis.c Tejun Heo 2007-07-16 173 return -EINVAL;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 174
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 175 if (ap->flags & SIS_FLAG_CFGSCR)
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 176 return sis_scr_cfg_read(link, sc_reg, val);
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 177
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 178 *val = ioread32(base + sc_reg * 4);
da3dbb17 drivers/ata/sata_sis.c Tejun Heo 2007-07-16 179 return 0;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 180 }
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 181
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 182 static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 183 {
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 184 struct ata_port *ap = link->ap;
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 185 void __iomem *base = ap->ioaddr.scr_addr + link->pmp * 0x10;
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 186
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 187 if (sc_reg > SCR_CONTROL)
da3dbb17 drivers/ata/sata_sis.c Tejun Heo 2007-07-16 188 return -EINVAL;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 189
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 190 if (ap->flags & SIS_FLAG_CFGSCR)
82ef04fb drivers/ata/sata_sis.c Tejun Heo 2008-07-31 191 return sis_scr_cfg_write(link, sc_reg, val);
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 192
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 193 iowrite32(val, base + (sc_reg * 4));
da3dbb17 drivers/ata/sata_sis.c Tejun Heo 2007-07-16 194 return 0;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 195 }
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 196
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 197 static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 198 {
9a829ccf drivers/ata/sata_sis.c Tejun Heo 2007-04-17 199 struct ata_port_info pi = sis_port_info;
ddfc87a0 drivers/ata/sata_sis.c Uwe Koziolek 2007-05-25 200 const struct ata_port_info *ppi[] = { &pi, &pi };
9a829ccf drivers/ata/sata_sis.c Tejun Heo 2007-04-17 201 struct ata_host *host;
4adccf6f drivers/ata/sata_sis.c Uwe Koziolek 2006-11-08 202 u32 genctl, val;
f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 203 u8 pmr;
3f3e7313 drivers/ata/sata_sis.c Uwe Koziolek 2006-12-04 204 u8 port2_start = 0x20;
72fee382 drivers/ata/sata_sis.c Tejun Heo 2009-09-01 205 int i, rc;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 206
06296a1e drivers/ata/sata_sis.c Joe Perches 2011-04-15 207 ata_print_version_once(&pdev->dev, DRV_VERSION);
a9524a76 drivers/scsi/sata_sis.c Jeff Garzik 2005-10-30 208
24dc5f33 drivers/ata/sata_sis.c Tejun Heo 2007-01-20 209 rc = pcim_enable_device(pdev);
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 210 if (rc)
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 211 return rc;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 212
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 213 /* check and see if the SCRs are in IO space or PCI cfg space */
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 214 pci_read_config_dword(pdev, SIS_GENCTL, &genctl);
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 215 if ((genctl & GENCTL_IOMAPPED_SCR) == 0)
cf0e812f drivers/ata/sata_sis.c Tejun Heo 2006-10-27 216 pi.flags |= SIS_FLAG_CFGSCR;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 217
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 218 /* if hardware thinks SCRs are in IO space, but there are
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 219 * no IO resources assigned, change to PCI cfg space.
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 220 */
cf0e812f drivers/ata/sata_sis.c Tejun Heo 2006-10-27 221 if ((!(pi.flags & SIS_FLAG_CFGSCR)) &&
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 222 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) ||
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 @223 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) {
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 224 genctl &= ~GENCTL_IOMAPPED_SCR;
^1da177e drivers/scsi/sata_sis.c Linus Torvalds 2005-04-16 225 pci_write_config_dword(pdev, SIS_GENCTL, genctl);
cf0e812f drivers/ata/sata_sis.c Tejun Heo 2006-10-27 226 pi.flags |= SIS_FLAG_CFGSCR;
:::::: The code at line 223 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24445 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-20 20:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-20 7:41 [PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE Yongji Xie
2017-01-20 7:41 ` [PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs Yongji Xie
2017-01-20 7:41 ` [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len() Yongji Xie
2017-01-20 19:53 ` kbuild test robot
2017-01-20 20:41 ` kbuild test robot
2017-01-20 7:41 ` [PATCH v8 3/3] PCI: Add a macro to set default alignment for all PCI devices Yongji Xie
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.