From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 870BEC43381 for ; Fri, 29 Mar 2019 21:16:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5513A2184C for ; Fri, 29 Mar 2019 21:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730334AbfC2VQd (ORCPT ); Fri, 29 Mar 2019 17:16:33 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:46724 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729771AbfC2VQd (ORCPT ); Fri, 29 Mar 2019 17:16:33 -0400 Received: by mail-oi1-f196.google.com with SMTP id x188so2769870oia.13; Fri, 29 Mar 2019 14:16:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JaV0olP+PRVr93TPoHK2LvE8ZTF6aplfAuvUXORDfRg=; b=t4QZRvJKN6YKQl7C156HzfSeD6MNXurvPT29eSVxvHylizKdhc/1q3nc7aIXrza5Me 2GqXYgxowlgS4B5qbUva2f2TqPc54dhkHsg5CEgKnI+oujvLvzkpWw4UE2YpYWV6/OWn hpr/66VV4AdhA+P4SzXUg5vuc+Ti/vtPA4et9A96Qu0bsbzOAMHaXSNm951f/fWTcT1/ CVxmU9ksnhk4VfyccEUWcdIjsBPXEwZZza+rx7UUc6JofiuOyDDGu2IgnvarU+tubgJz ka+AZixsbuHUXG9tTkycOpGbpcQl/4F8MHmwmSqG4det5n+CSW5mp/a/o6x7MSZobRGp /GDA== X-Gm-Message-State: APjAAAV5zFqwcOUlqyTZuQa+/XcEN9NkXWAyhLmWCyJmpvEG9dL3iQ+H 76dFg9agFl/hKfx5vneknKgZ1P8H0Y8= X-Google-Smtp-Source: APXvYqzjnFM+ymLtSbRZ5IAChptmJlP2bA56DiGle8aA0QWPGqXGnKsC6nJn1Xg+Xm6ttQIgF9pkgg== X-Received: by 2002:aca:ad8e:: with SMTP id w136mr4955377oie.109.1553894192646; Fri, 29 Mar 2019 14:16:32 -0700 (PDT) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com. [209.85.210.51]) by smtp.gmail.com with ESMTPSA id k3sm1163403oic.11.2019.03.29.14.16.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 14:16:31 -0700 (PDT) Received: by mail-ot1-f51.google.com with SMTP id 103so3302532otd.9; Fri, 29 Mar 2019 14:16:31 -0700 (PDT) X-Received: by 2002:a9d:30d1:: with SMTP id r17mr34948159otg.331.1553894191481; Fri, 29 Mar 2019 14:16:31 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-3-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-3-laurentiu.tudor@nxp.com> From: Li Yang Date: Fri, 29 Mar 2019 16:16:20 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 02/13] soc/fsl/bman: map FBPR area in the iommu To: Laurentiu Tudor Cc: Netdev , madalin.bucur@nxp.com, Roy Pledge , camelia.groza@nxp.com, David Miller , Linux IOMMU , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a one-to-one iommu mapping for bman private data memory (FBPR). > This is required for BMAN to work without faults behind an iommu. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index 7c3cc968053c..b209c79511bb 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -29,6 +29,7 @@ > */ > > #include "bman_priv.h" > +#include > > u16 bman_ip_rev; > EXPORT_SYMBOL(bman_ip_rev); > @@ -178,6 +179,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > int ret, err_irq; > struct device *dev = &pdev->dev; > struct device_node *node = dev->of_node; > + struct iommu_domain *domain; > struct resource *res; > u16 id, bm_pool_cnt; > u8 major, minor; > @@ -225,6 +227,15 @@ static int fsl_bman_probe(struct platform_device *pdev) > > dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz); > > + /* Create an 1-to-1 iommu mapping for FBPR area */ > + domain = iommu_get_domain_for_dev(dev); > + if (domain) { > + ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > + if (ret) > + dev_warn(dev, "failed to iommu_map() %d\n", ret); > + } Like Robin has pointed out, could you explain why the mapping in this patch and other similar patches cannot be dealt with the dma APIs automatically? If the current bqman driver doesn't use the dma APIs correctly, we need to fix that instead of doing the mapping explicitly. > + > bm_set_memory(fbpr_a, fbpr_sz); > > err_irq = platform_get_irq(pdev, 0); > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS 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 8FA0BC43381 for ; Fri, 29 Mar 2019 21:23:01 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 03B162184C for ; Fri, 29 Mar 2019 21:23:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03B162184C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44WF824cZyzDqYX for ; Sat, 30 Mar 2019 08:22:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=209.85.210.68; helo=mail-ot1-f68.google.com; envelope-from=pku.leo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44WF0m6KrlzDqXC for ; Sat, 30 Mar 2019 08:16:37 +1100 (AEDT) Received: by mail-ot1-f68.google.com with SMTP id u15so3303589otq.10 for ; Fri, 29 Mar 2019 14:16:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JaV0olP+PRVr93TPoHK2LvE8ZTF6aplfAuvUXORDfRg=; b=QgbvpvM6Z+11mbKdkEkKCmB+klZ3NzE7AL2gZzh+ixY8VauuweuFi9vRcfOFVxsuT5 nKMryomjxtw2pje+iUAhsyTGpm8Ukm4JQx7X6x31L978bGugWJxeZjqpDaDvYUmoPM9A EQ6h0OeARO0NYnwHZjeXzcBxlPx5lRMEWheaCW8AUAgqraihLmmzFRlchnO3+EoKgPQW Et8LzsW+RW4qY3skcN1cvK8bLtESoGL9eyB+rfwG6B2WeEDoX53pXUzFD6FbK6UtoMA1 zdULk8TCqqDYIdURGme+vlo8OXh8paUPEJUjH/KidlFvKE/N0s156stARV8FM0kY5m0F bhlw== X-Gm-Message-State: APjAAAUqLcpK8zX4TheRaL4534bcIXR3VE+otYEGBWhvlQYTjqn8u5of puJbfaK1ib/BnAquE1/79T39r8ABgLc= X-Google-Smtp-Source: APXvYqzTiCJEzyRTE3Ntt1O4C7O/Y2KpdDBmpCL5/q14H5glry7WkkX0pdkFn6DZNnDAfYDh5jm80Q== X-Received: by 2002:a9d:745a:: with SMTP id p26mr5431219otk.136.1553894192753; Fri, 29 Mar 2019 14:16:32 -0700 (PDT) Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com. [209.85.210.52]) by smtp.gmail.com with ESMTPSA id s73sm1228032oie.53.2019.03.29.14.16.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 14:16:31 -0700 (PDT) Received: by mail-ot1-f52.google.com with SMTP id t8so3320243otp.7 for ; Fri, 29 Mar 2019 14:16:31 -0700 (PDT) X-Received: by 2002:a9d:30d1:: with SMTP id r17mr34948159otg.331.1553894191481; Fri, 29 Mar 2019 14:16:31 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-3-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-3-laurentiu.tudor@nxp.com> From: Li Yang Date: Fri, 29 Mar 2019 16:16:20 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 02/13] soc/fsl/bman: map FBPR area in the iommu To: Laurentiu Tudor Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: madalin.bucur@nxp.com, Netdev , Roy Pledge , lkml , Linux IOMMU , camelia.groza@nxp.com, linuxppc-dev , David Miller , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a one-to-one iommu mapping for bman private data memory (FBPR). > This is required for BMAN to work without faults behind an iommu. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index 7c3cc968053c..b209c79511bb 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -29,6 +29,7 @@ > */ > > #include "bman_priv.h" > +#include > > u16 bman_ip_rev; > EXPORT_SYMBOL(bman_ip_rev); > @@ -178,6 +179,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > int ret, err_irq; > struct device *dev = &pdev->dev; > struct device_node *node = dev->of_node; > + struct iommu_domain *domain; > struct resource *res; > u16 id, bm_pool_cnt; > u8 major, minor; > @@ -225,6 +227,15 @@ static int fsl_bman_probe(struct platform_device *pdev) > > dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz); > > + /* Create an 1-to-1 iommu mapping for FBPR area */ > + domain = iommu_get_domain_for_dev(dev); > + if (domain) { > + ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > + if (ret) > + dev_warn(dev, "failed to iommu_map() %d\n", ret); > + } Like Robin has pointed out, could you explain why the mapping in this patch and other similar patches cannot be dealt with the dma APIs automatically? If the current bqman driver doesn't use the dma APIs correctly, we need to fix that instead of doing the mapping explicitly. > + > bm_set_memory(fbpr_a, fbpr_sz); > > err_irq = platform_get_irq(pdev, 0); > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Yang Subject: Re: [PATCH 02/13] soc/fsl/bman: map FBPR area in the iommu Date: Fri, 29 Mar 2019 16:16:20 -0500 Message-ID: References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-3-laurentiu.tudor@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20190329140014.8126-3-laurentiu.tudor@nxp.com> Sender: linux-kernel-owner@vger.kernel.org To: Laurentiu Tudor Cc: Netdev , madalin.bucur@nxp.com, Roy Pledge , camelia.groza@nxp.com, David Miller , Linux IOMMU , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , lkml List-Id: iommu@lists.linux-foundation.org On Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a one-to-one iommu mapping for bman private data memory (FBPR). > This is required for BMAN to work without faults behind an iommu. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index 7c3cc968053c..b209c79511bb 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -29,6 +29,7 @@ > */ > > #include "bman_priv.h" > +#include > > u16 bman_ip_rev; > EXPORT_SYMBOL(bman_ip_rev); > @@ -178,6 +179,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > int ret, err_irq; > struct device *dev = &pdev->dev; > struct device_node *node = dev->of_node; > + struct iommu_domain *domain; > struct resource *res; > u16 id, bm_pool_cnt; > u8 major, minor; > @@ -225,6 +227,15 @@ static int fsl_bman_probe(struct platform_device *pdev) > > dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz); > > + /* Create an 1-to-1 iommu mapping for FBPR area */ > + domain = iommu_get_domain_for_dev(dev); > + if (domain) { > + ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > + if (ret) > + dev_warn(dev, "failed to iommu_map() %d\n", ret); > + } Like Robin has pointed out, could you explain why the mapping in this patch and other similar patches cannot be dealt with the dma APIs automatically? If the current bqman driver doesn't use the dma APIs correctly, we need to fix that instead of doing the mapping explicitly. > + > bm_set_memory(fbpr_a, fbpr_sz); > > err_irq = platform_get_irq(pdev, 0); > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 4F473C43381 for ; Fri, 29 Mar 2019 21:16:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 13A642184C for ; Fri, 29 Mar 2019 21:16:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RxefFfWj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13A642184C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a7KvtRp6Joq4J3zWCg0fUwFpgKpmryTy6XULY8mIIRw=; b=RxefFfWjABbqB0 jYrPTHE+g20KelIMa+DY/isFMVjPnqgg/fpc2PQ8UwcSzR22Y7ILCvhUEW8lyhd/+12uugTIT3Gwb Xa5lHfH8i4TwBjFjy29ag6q3XFbmamGtQ2HJKQXl8GPTE1fZ9L16iaJ7FkNtXd+3j16TkLQFFSpFD SrAsUhms26nPLQOYnr5TwZKJYrNzai2zFMsjwEwcffZm5HC+80lrpqfCkZcIwZmUR7JjR/7AbNk52 fGjUyD1UTqCTtvWTnNHaeDUrZz6xclbc+mXifa0XTMX+y+MYTy6MJtDzY/yA8wSfZnIyFVWVIcVcn zgw4Mo5ksSEu46z4coXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9yrd-0004yn-IJ; Fri, 29 Mar 2019 21:16:37 +0000 Received: from mail-oi1-f196.google.com ([209.85.167.196]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9yra-0004yO-M2 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2019 21:16:36 +0000 Received: by mail-oi1-f196.google.com with SMTP id y84so2763791oia.12 for ; Fri, 29 Mar 2019 14:16:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JaV0olP+PRVr93TPoHK2LvE8ZTF6aplfAuvUXORDfRg=; b=UStbxVPoCSyhA/JLWeojhZ+ZG7gfCntENJKasakqWuYwb3gpI9cQAm6vcOAqjzx3lx 8SyXQ/LInyP1WmRo2loncAFY/RGZwixk0SS0el63QneWtYU3D8Khxbb8ut1OZkEb3suh 7RWeECM/k6362GNse+YbhOVWg/h0RUGq/tJ75VIY30H4cWLlm5J6m2Oap7V+Ihn45ovZ Dx1Z+fOoU+AZOJJF11PHA+/xWCXUy7Uq7UDLWthm7IF/3Z13s/jH/cepC7+0oxYCi0nd YkC4/wJ0LI2t2pz1bZUUC/MPjBEQyee0If+WecbmPMSSG99LUGbifbyxtH7qOsnbtm1P QkaQ== X-Gm-Message-State: APjAAAWysgkDby2HKNqbv2Mt4mcJcbjbJ50eKqsrkUHMiCfw2I68Xkx8 DyGyXM/2uRLW1TtoVtqGnQVN5rxfs8g= X-Google-Smtp-Source: APXvYqyL/IhJGjNOHONVo8YBGB+CfesUIhP5ibJZxpweT8GJelIFzFWwOgfiRmTx9krMOIzQNhLYWw== X-Received: by 2002:aca:5dd6:: with SMTP id r205mr4798072oib.167.1553894193111; Fri, 29 Mar 2019 14:16:33 -0700 (PDT) Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com. [209.85.210.43]) by smtp.gmail.com with ESMTPSA id p186sm1245926oif.34.2019.03.29.14.16.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 14:16:31 -0700 (PDT) Received: by mail-ot1-f43.google.com with SMTP id e5so3291038otk.12 for ; Fri, 29 Mar 2019 14:16:31 -0700 (PDT) X-Received: by 2002:a9d:30d1:: with SMTP id r17mr34948159otg.331.1553894191481; Fri, 29 Mar 2019 14:16:31 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-3-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-3-laurentiu.tudor@nxp.com> From: Li Yang Date: Fri, 29 Mar 2019 16:16:20 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 02/13] soc/fsl/bman: map FBPR area in the iommu To: Laurentiu Tudor X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_141634_720737_3D5BA4B8 X-CRM114-Status: GOOD ( 16.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: madalin.bucur@nxp.com, Netdev , Roy Pledge , lkml , Linux IOMMU , camelia.groza@nxp.com, linuxppc-dev , David Miller , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a one-to-one iommu mapping for bman private data memory (FBPR). > This is required for BMAN to work without faults behind an iommu. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_ccsr.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c > index 7c3cc968053c..b209c79511bb 100644 > --- a/drivers/soc/fsl/qbman/bman_ccsr.c > +++ b/drivers/soc/fsl/qbman/bman_ccsr.c > @@ -29,6 +29,7 @@ > */ > > #include "bman_priv.h" > +#include > > u16 bman_ip_rev; > EXPORT_SYMBOL(bman_ip_rev); > @@ -178,6 +179,7 @@ static int fsl_bman_probe(struct platform_device *pdev) > int ret, err_irq; > struct device *dev = &pdev->dev; > struct device_node *node = dev->of_node; > + struct iommu_domain *domain; > struct resource *res; > u16 id, bm_pool_cnt; > u8 major, minor; > @@ -225,6 +227,15 @@ static int fsl_bman_probe(struct platform_device *pdev) > > dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz); > > + /* Create an 1-to-1 iommu mapping for FBPR area */ > + domain = iommu_get_domain_for_dev(dev); > + if (domain) { > + ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz, > + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE); > + if (ret) > + dev_warn(dev, "failed to iommu_map() %d\n", ret); > + } Like Robin has pointed out, could you explain why the mapping in this patch and other similar patches cannot be dealt with the dma APIs automatically? If the current bqman driver doesn't use the dma APIs correctly, we need to fix that instead of doing the mapping explicitly. > + > bm_set_memory(fbpr_a, fbpr_sz); > > err_irq = platform_get_irq(pdev, 0); > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel