Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: f.fainelli@gmail.com, robh+dt@kernel.org, ardb@kernel.org,
	hch@infradead.org, narmstrong@baylibre.com, dwmw2@infradead.org,
	linux@armlinux.org.uk, catalin.marinas@arm.com, arnd@arndb.de,
	will@kernel.org
Subject: Re: [RFC 02/13] driver core: Introduce MMIO configuration
Date: Tue, 2 Mar 2021 11:29:10 +0000
Message-ID: <644fd416-ab64-f1cc-ffb0-ea5649e3b600@arm.com> (raw)
In-Reply-To: <20210226140305.26356-3-nsaenzjulienne@suse.de>

On 2021-02-26 14:02, Nicolas Saenz Julienne wrote:
> Some devices might inadvertently sit on buses that don't support 64bit
> MMIO access, and need a mechanism to query these limitations without
> prejudice to other buses in the system (i.e. defaulting to 32bit access
> system wide isn't an option).
> 
> Introduce a new bus callback, 'mmio_configure(),' which will take care
> of populating the relevant device properties based on the bus'
> limitations.

Devil's advocate: there already exist workarounds for 8-bit and/or 
16-bit accesses not working in various places, does it make sense for a 
64-bit workaround to be so wildly different and disjoint?

> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>   arch/Kconfig               | 8 ++++++++
>   drivers/base/dd.c          | 6 ++++++
>   include/linux/device.h     | 3 +++
>   include/linux/device/bus.h | 3 +++
>   4 files changed, 20 insertions(+)
> 
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 2bb30673d8e6..ba7f246b6b9d 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -1191,6 +1191,14 @@ config ARCH_SPLIT_ARG64
>   config ARCH_HAS_ELFCORE_COMPAT
>   	bool
>   
> +config ARCH_HAS_64BIT_MMIO_BROKEN
> +	bool
> +	depends on 64BIT

As mentioned previously, 32-bit systems may not need the overrides for 
kernel I/O accessors, but they could still need the same workarounds for 
the memory-mapping implications (if this is to be a proper generic 
mechanism).

> +	default n

Tip: it is always redundant to state that.

Robin.

> +	help
> +	   Arch might contain busses unable to perform 64bit mmio accessses on
> +	   an otherwise 64bit system.
> +
>   source "kernel/gcov/Kconfig"
>   
>   source "scripts/gcc-plugins/Kconfig"
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 9179825ff646..8086ce8f17a6 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -538,6 +538,12 @@ static int really_probe(struct device *dev, struct device_driver *drv)
>   			goto probe_failed;
>   	}
>   
> +	if (dev->bus->mmio_configure) {
> +		ret = dev->bus->mmio_configure(dev);
> +		if (ret)
> +			goto probe_failed;
> +	}
> +
>   	if (driver_sysfs_add(dev)) {
>   		pr_err("%s: driver_sysfs_add(%s) failed\n",
>   		       __func__, dev_name(dev));
> diff --git a/include/linux/device.h b/include/linux/device.h
> index ba660731bd25..bd94aa0cbd72 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -553,6 +553,9 @@ struct device {
>   #ifdef CONFIG_DMA_OPS_BYPASS
>   	bool			dma_ops_bypass : 1;
>   #endif
> +#if defined(CONFIG_ARCH_HAS_64BIT_MMIO_BROKEN)
> +	bool			mmio_64bit_broken:1;
> +#endif
>   };
>   
>   /**
> diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
> index 1ea5e1d1545b..680dfc3b4744 100644
> --- a/include/linux/device/bus.h
> +++ b/include/linux/device/bus.h
> @@ -59,6 +59,8 @@ struct fwnode_handle;
>    *		bus supports.
>    * @dma_configure:	Called to setup DMA configuration on a device on
>    *			this bus.
> + * @mmio_configure:	Called to setup MMIO configuration on a device on
> + *			this bus.
>    * @pm:		Power management operations of this bus, callback the specific
>    *		device driver's pm-ops.
>    * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
> @@ -103,6 +105,7 @@ struct bus_type {
>   	int (*num_vf)(struct device *dev);
>   
>   	int (*dma_configure)(struct device *dev);
> +	int (*mmio_configure)(struct device *dev);
>   
>   	const struct dev_pm_ops *pm;
>   
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply index

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26 14:02 [RFC 00/13] Generic way of dealing with broken 64-bit buses Nicolas Saenz Julienne
2021-02-26 14:02 ` [RFC 01/13] dt-bindings: Introduce 64bit-mmio-broken Nicolas Saenz Julienne
2021-02-26 14:02 ` [RFC 02/13] driver core: Introduce MMIO configuration Nicolas Saenz Julienne
2021-03-02 11:29   ` Robin Murphy [this message]
2021-03-02 14:09     ` Nicolas Saenz Julienne
2021-02-26 14:02 ` [RFC 03/13] of: device: Introduce of_mmio_configure() Nicolas Saenz Julienne
2021-02-26 14:02 ` [RFC 04/13] driver core: plafrom: Introduce platform_mmio_configure() Nicolas Saenz Julienne
2021-02-26 14:02 ` [RFC 05/13] pci: Introduce pci_mmio_configure() Nicolas Saenz Julienne
2021-02-26 14:02 ` [RFC 06/13] device core: Introduce dev_64bit_mmio_supported() Nicolas Saenz Julienne
2021-02-26 14:02 ` [RFC 07/13] arm64: Mark ARCH_MVEBU as needing broken 64bit MMIO support Nicolas Saenz Julienne
2021-02-26 14:03 ` [RFC 08/13] arm64: dts: marvell: armada-ap80x: Mark config-space bus as 64bit-mmio-broken Nicolas Saenz Julienne
2021-02-26 14:03 ` [RFC 09/13] iommu/arm-smmu: Make use of dev_64bit_mmio_supported() Nicolas Saenz Julienne
2021-03-02  9:32   ` Arnd Bergmann
2021-03-02 12:42     ` Nicolas Saenz Julienne
2021-03-02 11:07   ` Robin Murphy
2021-03-02 13:38     ` Nicolas Saenz Julienne
2021-03-03  8:44     ` Arnd Bergmann
2021-02-26 14:03 ` [RFC 10/13] iommu/arm-smmu-impl: Get rid of Marvell's implementation details Nicolas Saenz Julienne
2021-03-02 11:40   ` Robin Murphy
2021-03-02 14:06     ` Nicolas Saenz Julienne
2021-02-26 14:03 ` [RFC 11/13] arm64: Mark ARCH_BCM2835 as needing broken 64bit MMIO support Nicolas Saenz Julienne
2021-02-26 14:03 ` [RFC 12/13] ARM: dts: bcm2711: Mark PCIe bus as 64bit-mmio-broken Nicolas Saenz Julienne
2021-02-26 14:03 ` [RFC 13/13] scsi: megaraid: Make use of dev_64bit_mmio_supported() Nicolas Saenz Julienne
2021-02-26 14:30   ` Arnd Bergmann
2021-02-26 18:06     ` Arnd Bergmann

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=644fd416-ab64-f1cc-ffb0-ea5649e3b600@arm.com \
    --to=robin.murphy@arm.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=f.fainelli@gmail.com \
    --cc=hch@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=narmstrong@baylibre.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=robh+dt@kernel.org \
    --cc=will@kernel.org \
    /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

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git