Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp951214pxb; Wed, 3 Mar 2021 22:16:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKO9jJX3TphHkYHJFYTEKd6JqgfIzBU35QdvGl6rDFL+rb0GallGKJZGyzpVPpVp4+CqaR X-Received: by 2002:a17:907:76b3:: with SMTP id jw19mr2487899ejc.202.1614838563517; Wed, 03 Mar 2021 22:16:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614838563; cv=none; d=google.com; s=arc-20160816; b=hs4hln8X+6a5OyBU7uo+VXKh6uUTPG+MqXGnLNb1csYwaYFDDfwcwOwAGY7Pr8SXou QUY8AEywhOVwvBdblutexjr3f8TKEZj5JzSDcWmF84dytdi2luSFgZDImAo4keiPSRF1 u7HdHJs5HURuSWw43gc2GWyUJSCyOrqey39vTsDyKeeJsDh5lYX4gPy/BBODOjQA947V 3L/jmej7MGqnCEtmtJ5OePWh4u1UMH86vkWAmnm3D9ZCUVsZ7+ofvmcym34/cgdqtPf+ RwuxWZL9t3OU3vOO/d4o5tEjg/GHq7sRMWwUwRPcMy+O4kA4rgDQJM6O+kqPnV8VV0nb 4ZXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=GgbAyYe8Haw7NT2zRqZanIWmYlkGE1dV47alhKG06DU=; b=nMSHyFCC5eAjdVI0yIL4UQdb5pb8HLMo0bSA/TOS1FvKVzF7VuAts7jzDy/2cIylj2 6WBrs1jxVIvhlE+m4QCpd39OamqQzGKAGmZuVErcLs5Vm19QujIy2YHMjWe0nc4wdeki Y27dpC3hOyPqajI9FJNpX1QltCdIjhd+VtiEZXo5Jk5gbhYVmtANL3yFTU6Mr4eXYv2u kRR9C4W1jGX7ADWgRLtR5vCffbqOZlldzO+Y43+RCped1qgJKKICg8gW4KtRXJgT3/Tr 6cEJ4iue2MaPvxxSzYJTCGH5gFVRlGjYwQFnF0ktcmw72rNM1LIswKKFQJPYMPjee+FS hD8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss21si17164608ejb.338.2021.03.03.22.15.41; Wed, 03 Mar 2021 22:16:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442273AbhCBLqg (ORCPT + 99 others); Tue, 2 Mar 2021 06:46:36 -0500 Received: from foss.arm.com ([217.140.110.172]:49816 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344596AbhCBLaE (ORCPT ); Tue, 2 Mar 2021 06:30:04 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 663B01042; Tue, 2 Mar 2021 03:29:18 -0800 (PST) Received: from [10.57.48.219] (unknown [10.57.48.219]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 08EA73F73C; Tue, 2 Mar 2021 03:29:15 -0800 (PST) Subject: Re: [RFC 02/13] driver core: Introduce MMIO configuration To: Nicolas Saenz Julienne , 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 References: <20210226140305.26356-1-nsaenzjulienne@suse.de> <20210226140305.26356-3-nsaenzjulienne@suse.de> From: Robin Murphy Message-ID: <644fd416-ab64-f1cc-ffb0-ea5649e3b600@arm.com> Date: Tue, 2 Mar 2021 11:29:10 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210226140305.26356-3-nsaenzjulienne@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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; > >