From patchwork Fri Feb 26 14:02:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 12106701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06190C433E0 for ; Fri, 26 Feb 2021 14:05:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5D8F64EF0 for ; Fri, 26 Feb 2021 14:05:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5D8F64EF0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4tJ7iNAQAL7jCQ0IIBQUTufu24I91y3FNP0XwpNDCQc=; b=bJdb79hMghA7W6kngngFdaZfT mOP75xwEdCQP8l3OMrjfw5b2U7qZqykxNZra2Z7gzbS2qm6yvPy7dg2wnW6qh/eAB/ra3L9jPu0+G CLo1+rxulwQ9RXWR5OfBWbe/QnXYj36kvjsTo8Y9HbKSFtgY3hzCojGby6VHrpBwzCnry2/rejf9h vZHzSyoQPjOFozs0XrLJUAzt5OXtE76BfoziuyacDXTP10twlqGFeaMehpE/yPRy9ijndXnRMUkR1 bSYrX9YnrYIZmaMqkGxg6R3hACrwuVpPjiPdZsqln+pSOFfjOGc1wAvTEdK4MaVP3XUN3czDovZHN 7md4SyLhQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFdic-0003zD-59; Fri, 26 Feb 2021 14:03:46 +0000 Received: from mx2.suse.de ([195.135.220.15]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFdiD-0003n9-Ev for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2021 14:03:25 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1C466B03D; Fri, 26 Feb 2021 14:03:17 +0000 (UTC) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 02/13] driver core: Introduce MMIO configuration Date: Fri, 26 Feb 2021 15:02:54 +0100 Message-Id: <20210226140305.26356-3-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210226140305.26356-1-nsaenzjulienne@suse.de> References: <20210226140305.26356-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210226_090321_830110_45218428 X-CRM114-Status: GOOD ( 17.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, arnd@arndb.de, narmstrong@baylibre.com, dwmw2@infradead.org, linux@armlinux.org.uk, hch@infradead.org, will@kernel.org, robh+dt@kernel.org, catalin.marinas@arm.com, robin.murphy@arm.com, ardb@kernel.org, Nicolas Saenz Julienne Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. 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 + default n + 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;