Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1242123

Re: [PATCH v8 3/6] pci:host: Add Altera PCIe host controller driver

From Russell King - ARM Linux <linux@arm.linux.org.uk>
Newsgroups linux.kernel
Subject Re: [PATCH v8 3/6] pci:host: Add Altera PCIe host controller driver
Date 2015-10-08 11:50 +0200
Message-ID <qhfZL-88e-3@gated-at.bofh.it> (permalink)
References <qhfZL-88e-5@gated-at.bofh.it> <qhfZL-88e-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Oct 08, 2015 at 05:43:11PM +0800, Ley Foon Tan wrote:
> +static int altera_pcie_cfg_write(struct pci_bus *bus, unsigned int devfn,
> +				 int where, int size, u32 value)
> +{
> +	struct altera_pcie *pcie = bus->sysdata;
> +	u32 data32;
> +	u32 shift = 8 * (where & 3);
> +	int ret;
> +
> +	if (!altera_pcie_valid_config(pcie, bus, PCI_SLOT(devfn)))
> +		return PCIBIOS_DEVICE_NOT_FOUND;
> +
> +	/* write partial */
> +	if (size != sizeof(u32)) {
> +		ret = tlp_cfg_dword_read(pcie, bus->number, devfn,
> +					 where & ~DWORD_MASK, &data32);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	switch (size) {
> +	case 1:
> +		data32 = (data32 & ~(0xff << shift)) |
> +				((value & 0xff) << shift);
> +		break;
> +	case 2:
> +		data32 = (data32 & ~(0xffff << shift)) |
> +				((value & 0xffff) << shift);
> +		break;
> +	default:
> +		data32 = value;

Can you generate proper 1, 2 and 4 byte configuration accesses?  That
is much preferred over the above read-modify-write, as there are
registers in PCI and PCIe that are read/write-1-to-clear.  The above
has the effect of inadvertently clearing those RW1C bits.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v8 3/6] pci:host: Add Altera PCIe host controller driver Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-10-08 11:50 +0200
  Re: [PATCH v8 3/6] pci:host: Add Altera PCIe host controller driver Ley Foon Tan <lftan@altera.com> - 2015-10-08 12:10 +0200
    Re: [PATCH v8 3/6] pci:host: Add Altera PCIe host controller driver Bjorn Helgaas <helgaas@kernel.org> - 2015-10-10 01:20 +0200
      Re: [PATCH v8 3/6] pci:host: Add Altera PCIe host controller driver Arnd Bergmann <arnd@arndb.de> - 2015-10-12 14:10 +0200
        Re: [PATCH v8 3/6] pci:host: Add Altera PCIe host controller driver Ley Foon Tan <lftan@altera.com> - 2015-10-13 09:50 +0200

csiph-web