From patchwork Fri Feb 26 14:02:52 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: 12106693 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=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 B8573C433DB for ; Fri, 26 Feb 2021 14:05:22 +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 526B664EF6 for ; Fri, 26 Feb 2021 14:05:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 526B664EF6 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: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:In-Reply-To:References:List-Owner; bh=PzE0lMIfPX4HnRrElbwAd5wq/cQmyVOQ1QM66L82Q9E=; b=ArOzLJ79Nr+e3fSKiGPcVGUEDs oJc1YGhtwNCNyI3ywR3lTxVr1ltzfvs0Zo/YAW5qrh8s1k/Byt5KuqLoXJPM2vazJHpyoqBQHaROh OnNTN8WNAaSrmQFqowkQNhxcIHki6Ht9Nj23hdm8wHu0pHbPDDI86kg2+dVGjfjsnnjq89NJFnz9D rXko6AhnF429y/7AfpS+bTGRPULUInH/SGMMYfrbDGBPU/a66T7/1uKRbq+fbg1lkG6Bjtx533v1u 3WPYip2a8VpWZnd5PYuXgIfj+whNTB0B1PwQgUe6WQ4f4G1MRqTPiEMOB8XE/7ARDVYhp4aQyhynH YKXqpCyA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFdif-0003zu-Qp; Fri, 26 Feb 2021 14:03:49 +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-0003n5-Dc for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2021 14:03:26 +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 D6620AF63; Fri, 26 Feb 2021 14:03:15 +0000 (UTC) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 00/13] Generic way of dealing with broken 64-bit buses Date: Fri, 26 Feb 2021 15:02:52 +0100 Message-Id: <20210226140305.26356-1-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210226_090321_855714_74752D86 X-CRM114-Status: GOOD ( 14.42 ) 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 BCM2711, Raspberry Pi 4's arm64 system on chip, contains a PCIe bus that can't handle 64-bit accesses to its MMIO address space. The issue has already been discussed here[1], and it turns out BCM2711 isn't the only broken device in the wild. In most cases, the solution to this issue is to convert writeq/readq() to into their lo_hi/hi_lo variants and the eventual introduction of some amount of locking. But that's not good enough for every device. For example, on some arm's SMMU configurations atomic 64-bit accesses are mandatory. This series tries to introduce a mechanism for drivers to be able to ascertain whether or not they are allowed to perform 64-bit accesses. The big question is the amount of granularity needed to deal with this (think here of distro images): - Build-time: if a broken platform included in the image, disallow any 64-bit access. Drivers that need 64-bit accesses could simply bypass the check and hope for the best. Imposes a performance penalty on otherwise well behaving platforms, and features that depend on 64bit access might be disabled unnecessarily. It's simple to implement, yet not very generic/future proof. - Run-time: allow/disallow 64-bit accesses based on boot time checks (i.e. check which platform the kernel is running on). Gets rid of all the negative aspects imposed to well-behaving platforms. Well-behaving buses can't coexist with broken ones while using all features. - Per-device: each device has its MMIO access properties and can take decisions based on its local bus. That said, I'm not aware of a system that absolutely needs this ATM. This series implements the third option mainly as a proof of concept. It's my personal preference on how to deal with this. That said, my main aim ATM is to settle on a general approach. Regards, Nicolas [1] https://lore.kernel.org/linux-arm-kernel/c188698ca0de3ed6c56a0cf7880e1578aa753077.camel@suse.de/ --- Nicolas Saenz Julienne (13): dt-bindings: Introduce 64bit-mmio-broken driver core: Introduce MMIO configuration of: device: Introduce of_mmio_configure() driver core: plafrom: Introduce platform_mmio_configure() pci: Introduce pci_mmio_configure() device core: Introduce dev_64bit_mmio_supported() arm64: Mark ARCH_MVEBU as needing broken 64bit MMIO support arm64: dts: marvell: armada-ap80x: Mark config-space bus as 64bit-mmio-broken iommu/arm-smmu: Make use of dev_64bit_mmio_supported() iommu/arm-smmu-impl: Get rid of Marvell's implementation details arm64: Mark ARCH_BCM2835 as needing broken 64bit MMIO support ARM: dts: bcm2711: Mark PCIe bus as 64bit-mmio-broken scsi: megaraid: Make use of dev_64bit_mmio_supported() .../devicetree/bindings/common-properties.txt | 15 +++++++++++ arch/Kconfig | 8 ++++++ arch/arm/boot/dts/bcm2711.dtsi | 1 + arch/arm64/Kconfig.platforms | 2 ++ arch/arm64/boot/dts/marvell/armada-ap80x.dtsi | 1 + drivers/base/dd.c | 6 +++++ drivers/base/platform.c | 9 +++++++ drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 21 --------------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 9 +++++++ drivers/iommu/arm/arm-smmu/arm-smmu.h | 9 +++++-- drivers/of/device.c | 19 ++++++++++++++ drivers/pci/pci-driver.c | 26 +++++++++++++++++++ drivers/scsi/megaraid/megaraid_sas_fusion.c | 23 ++++++++-------- include/linux/device.h | 20 ++++++++++++++ include/linux/device/bus.h | 3 +++ include/linux/of_device.h | 8 ++++++ 16 files changed, 145 insertions(+), 35 deletions(-)