Message ID | 1477468040-21034-10-git-send-email-peterx@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Oct 26, 2016 at 03:47:12PM +0800, Peter Xu wrote: > We have writel() for 4 bytes but still missing 2/1 bytes accessors. > > Signed-off-by: Peter Xu <peterx@redhat.com> > --- > lib/pci-host-generic.c | 12 ++++++++++++ > lib/x86/asm/pci.h | 14 ++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c > index be3f9e7..c04e4f5 100644 > --- a/lib/pci-host-generic.c > +++ b/lib/pci-host-generic.c > @@ -291,6 +291,18 @@ u32 pci_config_readl(pcidevaddr_t dev, u8 off) > return readl(conf + off); > } > > +void pci_config_writeb(pcidevaddr_t dev, u8 off, u8 val) > +{ > + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > + writeb(val, conf + off); > +} > + > +void pci_config_writew(pcidevaddr_t dev, u8 off, u16 val) > +{ > + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > + writew(val, conf + off); > +} > + > void pci_config_writel(pcidevaddr_t dev, u8 off, u32 val) > { > void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h > index 7384b91..abfe5d1 100644 > --- a/lib/x86/asm/pci.h > +++ b/lib/x86/asm/pci.h > @@ -29,6 +29,20 @@ static inline uint32_t pci_config_readl(pcidevaddr_t dev, uint8_t reg) > return inl(0xCFC); > } > > +static inline void pci_config_writeb(pcidevaddr_t dev, uint8_t reg, > + uint8_t val) > +{ > + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); > + outb(val, 0xCFC); > +} > + > +static inline void pci_config_writew(pcidevaddr_t dev, uint8_t reg, > + uint32_t val) ^^ should be 16 > +{ > + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); > + outw(val, 0xCFC); > +} > + > static inline void pci_config_writel(pcidevaddr_t dev, uint8_t reg, uint32_t val) > { > outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); > -- > 2.7.4 > Otherwise Reviewed-by: Andrew Jones <drjones@redhat.com> -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Oct 26, 2016 at 03:47:12PM +0800, Peter Xu wrote: > We have writel() for 4 bytes but still missing 2/1 bytes accessors. > > Signed-off-by: Peter Xu <peterx@redhat.com> > --- > lib/pci-host-generic.c | 12 ++++++++++++ > lib/x86/asm/pci.h | 14 ++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c > index be3f9e7..c04e4f5 100644 > --- a/lib/pci-host-generic.c > +++ b/lib/pci-host-generic.c > @@ -291,6 +291,18 @@ u32 pci_config_readl(pcidevaddr_t dev, u8 off) > return readl(conf + off); > } > > +void pci_config_writeb(pcidevaddr_t dev, u8 off, u8 val) > +{ > + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > + writeb(val, conf + off); > +} > + > +void pci_config_writew(pcidevaddr_t dev, u8 off, u16 val) > +{ > + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > + writew(val, conf + off); > +} > + The two above need to be declared in lib/asm-generic/pci-host-bridge.h > void pci_config_writel(pcidevaddr_t dev, u8 off, u32 val) > { > void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h > index 7384b91..abfe5d1 100644 > --- a/lib/x86/asm/pci.h > +++ b/lib/x86/asm/pci.h > @@ -29,6 +29,20 @@ static inline uint32_t pci_config_readl(pcidevaddr_t dev, uint8_t reg) > return inl(0xCFC); > } > > +static inline void pci_config_writeb(pcidevaddr_t dev, uint8_t reg, > + uint8_t val) > +{ > + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); > + outb(val, 0xCFC); > +} > + > +static inline void pci_config_writew(pcidevaddr_t dev, uint8_t reg, > + uint32_t val) > +{ > + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); > + outw(val, 0xCFC); > +} > + > static inline void pci_config_writel(pcidevaddr_t dev, uint8_t reg, uint32_t val) > { > outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); > -- > 2.7.4 > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, Nov 05, 2016 at 06:06:49PM +0100, Alexander Gordeev wrote: > On Wed, Oct 26, 2016 at 03:47:12PM +0800, Peter Xu wrote: > > We have writel() for 4 bytes but still missing 2/1 bytes accessors. > > > > Signed-off-by: Peter Xu <peterx@redhat.com> > > --- > > lib/pci-host-generic.c | 12 ++++++++++++ > > lib/x86/asm/pci.h | 14 ++++++++++++++ > > 2 files changed, 26 insertions(+) > > > > diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c > > index be3f9e7..c04e4f5 100644 > > --- a/lib/pci-host-generic.c > > +++ b/lib/pci-host-generic.c > > @@ -291,6 +291,18 @@ u32 pci_config_readl(pcidevaddr_t dev, u8 off) > > return readl(conf + off); > > } > > > > +void pci_config_writeb(pcidevaddr_t dev, u8 off, u8 val) > > +{ > > + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > > + writeb(val, conf + off); > > +} > > + > > +void pci_config_writew(pcidevaddr_t dev, u8 off, u16 val) > > +{ > > + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); > > + writew(val, conf + off); > > +} > > + > > The two above need to be declared in lib/asm-generic/pci-host-bridge.h Will add them. Thanks, -- peterx -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c index be3f9e7..c04e4f5 100644 --- a/lib/pci-host-generic.c +++ b/lib/pci-host-generic.c @@ -291,6 +291,18 @@ u32 pci_config_readl(pcidevaddr_t dev, u8 off) return readl(conf + off); } +void pci_config_writeb(pcidevaddr_t dev, u8 off, u8 val) +{ + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); + writeb(val, conf + off); +} + +void pci_config_writew(pcidevaddr_t dev, u8 off, u16 val) +{ + void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); + writew(val, conf + off); +} + void pci_config_writel(pcidevaddr_t dev, u8 off, u32 val) { void __iomem *conf = pci_get_dev_conf(pci_host_bridge, dev); diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h index 7384b91..abfe5d1 100644 --- a/lib/x86/asm/pci.h +++ b/lib/x86/asm/pci.h @@ -29,6 +29,20 @@ static inline uint32_t pci_config_readl(pcidevaddr_t dev, uint8_t reg) return inl(0xCFC); } +static inline void pci_config_writeb(pcidevaddr_t dev, uint8_t reg, + uint8_t val) +{ + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); + outb(val, 0xCFC); +} + +static inline void pci_config_writew(pcidevaddr_t dev, uint8_t reg, + uint32_t val) +{ + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8); + outw(val, 0xCFC); +} + static inline void pci_config_writel(pcidevaddr_t dev, uint8_t reg, uint32_t val) { outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8);
We have writel() for 4 bytes but still missing 2/1 bytes accessors. Signed-off-by: Peter Xu <peterx@redhat.com> --- lib/pci-host-generic.c | 12 ++++++++++++ lib/x86/asm/pci.h | 14 ++++++++++++++ 2 files changed, 26 insertions(+)