From patchwork Sun Jul 10 23:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12912707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD082C43334 for ; Sun, 10 Jul 2022 23:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=USxQ550IPyaJOVLQYdsBLYyuamGYqZcm403YHOebTNU=; b=A7mt1qR10Cj0+j Cd9wZMUyS02p+fYiRQV7x4lpkQGZ+AfF0yXwpV8nu8gJOjlhyIaXRFtgMRBV7wMGUgNq8SCCMHGxL EYWGMUb+KdvsSvHhW5QW0LCtlymP4JNQcw8DNDVGZaNIwYx+1qebmKUu3QbbLBQw4wzVdEQ0dzJ2w WUQf1CS3ech0f7TvUtJH4n+HzVTxjn3xjjBgYuluBNCzAOVn1zsOf4Pzja+xLm4QCzwro+apJqPI/ Rf/T8vrS9LXXlKX5Tx7XSPbPfnDmhvYSV9CrSY4ZQIMquFuZV/wWpgeINmtvHTNs97WlXZLc9ttkW 0kfAsVMW41TOcdDyQ4fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAg0R-00E8M8-8A; Sun, 10 Jul 2022 23:06:27 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAg0A-00E87a-S4 for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 23:06:12 +0000 Received: by mail-wr1-x434.google.com with SMTP id q9so4915963wrd.8 for ; Sun, 10 Jul 2022 16:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R103erxeCCHS3ZUMewsB5C1yy+zcGyX5sa9sukmtQlA=; b=fLuyUwyFBhuSKQzea4YKfooN5u8vLxajhzZfJiUNNmT6fjM23kiTCm6Z5yIImksVh5 lKbtLFd24T7ayF/oB0abItkwp0lNCG0ghAJzPh4G3postibpTtFBBvM4Fntt1BEaOWvP zEyhX4ho27fL4YtKz90nx849VrALn9l90CFJEKmyU41u4qcCLTP9evbyTEfAuyaBC3gN oKvStT4nSnB10aKgpJ29VmiNuHp8pccko5rT27B8qfz9szXra3l/v4EVewqKj/SdJbRR JtuV3zuxQesh8+7sU7ZHpouewD8sn/EUwkU8oDubw4Og8ir0KQ+5xlNDJ61h99y991xI 72cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R103erxeCCHS3ZUMewsB5C1yy+zcGyX5sa9sukmtQlA=; b=3+QAdLhyRHn4+FzJQoc7KY9ZVZ5aCS3K8VfM4tdO/i29u/Jz1cllLrSi8RJZOMfy8z KEslQjXoHbmL+ORfhXIQeVaXTE4vLTwOj2IIaX9GgQNuxZG43IAS/7OTnS5nSGtuOXq7 /wTpc4YfLWAcemd9biJErVO/iF15dqcZ8tNycfoKmuYHNvh11jz6gG905DKY3fUWYBAq YAWc8T4oWqSkyYsnD5sWz+gzp5ZBVbWLmekWwdU+/KrlEGIisfEhpTvoIVwvF+xA8yQK jcUSqmQEGK4IV/5LiMZkxdazZXjKclT1Q87kwc9cfbyGjYQ4AS+F4AOX+alS/bwk3bFI QQPw== X-Gm-Message-State: AJIora+Na22PBxZVTpJ3R71ALqjNQETEcEibH0aEKRIYYamEBn0Q/GiO MCtQtMbnb7rNWtpcUG5lhByD7w== X-Google-Smtp-Source: AGRyM1vww+/EwQUG5ItTSVzcGPkgSaNRCtATWrYEb+Z/Gu6CFwsngTsI375t0lfeO503K1T635bVCg== X-Received: by 2002:a5d:4402:0:b0:21d:8093:138c with SMTP id z2-20020a5d4402000000b0021d8093138cmr13985720wrq.535.1657494368329; Sun, 10 Jul 2022 16:06:08 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id m4-20020a5d6244000000b0021d6e917442sm5383041wrv.72.2022.07.10.16.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jul 2022 16:06:07 -0700 (PDT) From: Sam Protsenko To: Marek Szyprowski , Krzysztof Kozlowski Cc: Joerg Roedel , Will Deacon , Robin Murphy , Janghyuck Kim , Cho KyongHo , Daniel Mentz , David Virag , Sumit Semwal , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] iommu/exynos: Set correct dma mask for SysMMU v5+ Date: Mon, 11 Jul 2022 02:05:59 +0300 Message-Id: <20220710230603.13526-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220710230603.13526-1-semen.protsenko@linaro.org> References: <20220710230603.13526-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_160610_927502_FA899929 X-CRM114-Status: GOOD ( 14.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SysMMU v5+ supports 36 bit physical address space. Set corresponding DMA mask to avoid falling back to SWTLBIO usage in dma_map_single() because of failed dma_capable() check. The original code for this fix was suggested by Marek. Signed-off-by: Sam Protsenko Co-developed-by: Marek Szyprowski Signed-off-by: Marek Szyprowski Acked-by: Krzysztof Kozlowski --- Changes in v2: - Handled failed dma_set_mask() call - Replaced "Originally-by" tag by "Co-developed-by" + SoB tags drivers/iommu/exynos-iommu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index c85db9dab851..494f7d7aa9c5 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -646,6 +646,14 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) } } + if (MMU_MAJ_VER(data->version) >= 5) { + ret = dma_set_mask(dev, DMA_BIT_MASK(36)); + if (ret) { + dev_err(dev, "Unable to set DMA mask: %d\n", ret); + goto err_dma_set_mask; + } + } + /* * use the first registered sysmmu device for performing * dma mapping operations on iommu page tables (cpu cache flush) @@ -657,6 +665,8 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) return 0; +err_dma_set_mask: + iommu_device_unregister(&data->iommu); err_iommu_register: iommu_device_sysfs_remove(&data->iommu); return ret;