Message ID | 20230310-dma_iommu-v9-1-65bb8edd2beb@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6782265vqo; Mon, 15 May 2023 02:26:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RLaH0LDdQ07SISiJ4yJGP5x9djHgUDMgkEj4TJq5dRsJq336giL2OqyPpc3T3udmVbszc X-Received: by 2002:a05:6a20:6a2a:b0:f6:d4d:2d with SMTP id p42-20020a056a206a2a00b000f60d4d002dmr38179369pzk.31.1684142780095; Mon, 15 May 2023 02:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684142780; cv=none; d=google.com; s=arc-20160816; b=Wn0+AHztjGo2H6xdHI47xrWG2swaw/bRbOfjyiFj+TPblvd2qetCStCWk6i/nmc6UL IhvDHA/ZqPHOheONA9ovvRPEuocVFbVNeEUmFtaS1zSJO1OOH8bejtjROzyJj3bhSuU/ FFW/IxInkOwbHcXvWB92oRONhYsTSyj/4kg5Wz+KQLasXtqiJnVGSTTEgDYS812xqgiA 36J+v9byPXV/8XqFTLH1uVREbUsNNblq7+vYZeQvmfDzTtxTPGNXPXR/4nSb4uNfgTzA w//McohSjdlxQOR2G0ABzyzw2LI8vHGdjs0T7KX0uTsAFXzUwWLU5EYMWCFM8xR4LvVG BG9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=XZRYw/E+2b1j4bf5jYTm9vXk/07k2GIkOzbRS1UjgtA=; b=iFU2xRTIQA7OCymoIX+d7pG+YNaXhbzeFfPq+V2WhjetSccN4NKHbBj2uIuFyfCsiW rhCn6f2pyU/5Q4BRCIBZ8l5eJZ4EZKW59WkQc6iOxxpbpjCtvmSW0WMYm199vSXaitDC eeRVni3WTSfJw/TF89EsnqgqOmeX2wfT72qJxyQRir2+eK8uUiGMLHGBsOJ4e8cE14Ei AKvYdVklLrnY37UKK0l4jR1W4tMC6noKKcSNkLpfAXm2vrGmt1yVHFmBoHsgDcjba+04 gRPGQYqxNEQprPqfbX1egy423dB8TfVmaA56Spa/CxChusetMlVHORy6mm1tVvnYzsll SaDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Kpxh7+R0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a63e444000000b00513f070aaa1si15652377pgk.892.2023.05.15.02.26.07; Mon, 15 May 2023 02:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Kpxh7+R0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238461AbjEOJXC (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Mon, 15 May 2023 05:23:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237188AbjEOJWD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 15 May 2023 05:22:03 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D5901FE7; Mon, 15 May 2023 02:17:29 -0700 (PDT) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34F8xxw7018853; Mon, 15 May 2023 09:16:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : date : subject : mime-version : content-type : content-transfer-encoding : message-id : references : in-reply-to : to : cc; s=pp1; bh=XZRYw/E+2b1j4bf5jYTm9vXk/07k2GIkOzbRS1UjgtA=; b=Kpxh7+R0SgBWRyPiR3pp43jF6E5hBwZivqH29tFryUMUh6Z9+hD0kncddL1qLQXMueuI DIK+IhEqpNtklQp0lYRX8YYP7a9ZbgsJC4I2ocrV41MEB+7eGAo6SrxE8WRBFPJCpmku HnhgEvXGdV7Eea+6wGFVrGtLydHmdlSxSG2SbVEAFyAwmPuvGMOInz7nTIXwrcpM27XO S51aNd6mJ/5mHSbYx06OOJ/TFZYZN9lQ+ywzEddL1t6KWGsIYHqJ6kibGD3ptGQl3Doi dOSXwWm1Srt0VTv7BEjqnsxmNpObmDltbwoYPvn6y7uYhJKPVbFaYXeeCSxSHavvE0mf uw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qkhma8qtf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 May 2023 09:16:45 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 34F9Ehv8014120; Mon, 15 May 2023 09:16:32 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qkhma8qdt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 May 2023 09:16:32 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 34F98HBT007926; Mon, 15 May 2023 09:16:18 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3qj2650tgj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 May 2023 09:16:18 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 34F9GFGL42861076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 May 2023 09:16:15 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED1CF20043; Mon, 15 May 2023 09:16:14 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 185932004B; Mon, 15 May 2023 09:16:14 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 15 May 2023 09:16:14 +0000 (GMT) From: Niklas Schnelle <schnelle@linux.ibm.com> Date: Mon, 15 May 2023 11:15:51 +0200 Subject: [PATCH v9 1/6] s390/ism: Set DMA coherent mask MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230310-dma_iommu-v9-1-65bb8edd2beb@linux.ibm.com> References: <20230310-dma_iommu-v9-0-65bb8edd2beb@linux.ibm.com> In-Reply-To: <20230310-dma_iommu-v9-0-65bb8edd2beb@linux.ibm.com> To: Joerg Roedel <joro@8bytes.org>, Matthew Rosato <mjrosato@linux.ibm.com>, Will Deacon <will@kernel.org>, Wenjia Zhang <wenjia@linux.ibm.com>, Robin Murphy <robin.murphy@arm.com>, Jason Gunthorpe <jgg@ziepe.ca> Cc: Gerd Bayer <gbayer@linux.ibm.com>, Julian Ruess <julianr@linux.ibm.com>, Pierre Morel <pmorel@linux.ibm.com>, Alexandra Winter <wintera@linux.ibm.com>, Heiko Carstens <hca@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Alexander Gordeev <agordeev@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Sven Schnelle <svens@linux.ibm.com>, Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>, Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>, Alyssa Rosenzweig <alyssa@rosenzweig.io>, David Woodhouse <dwmw2@infradead.org>, Lu Baolu <baolu.lu@linux.intel.com>, Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Yong Wu <yong.wu@mediatek.com>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Gerald Schaefer <gerald.schaefer@linux.ibm.com>, Orson Zhai <orsonzhai@gmail.com>, Baolin Wang <baolin.wang@linux.alibaba.com>, Chunyan Zhang <zhang.lyra@gmail.com>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Thierry Reding <thierry.reding@gmail.com>, Krishna Reddy <vdumpa@nvidia.com>, Jonathan Hunter <jonathanh@nvidia.com>, Niklas Schnelle <schnelle@linux.ibm.com>, Jonathan Corbet <corbet@lwn.net>, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-doc@vger.kernel.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1331; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=iv5rTctIVBJRkTP8lY/YEQZWLj3JMw1iilc8H5Z4idA=; b=owGbwMvMwCH2Wz534YHOJ2GMp9WSGFISf0Qc5vv66xyHtOs/U5cwS9lPaSlRHmsnxXzS7Fh2f Z3N8WkPOkpZGMQ4GGTFFFkWdTn7rSuYYronqL8DZg4rE8gQBi5OAZhIcynDP5N3dkHV/LqhFcuU /jn47Vg/48kasQdStkeeBUh0l61fvISR4U2sXDZLRU0R37Lz3jf2t76WXXQrcIHat5BdDE1tMgF /mAE= X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pJoXblQutXXgbi5m_OUSFyoV1170AFtf X-Proofpoint-ORIG-GUID: Hk-7C_dDrmWdrumF0NtHFZD0h53OyVPV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-15_06,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305150078 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765951699765544836?= X-GMAIL-MSGID: =?utf-8?q?1765951699765544836?= |
Series |
iommu/dma: s390 DMA API conversion and optimized IOTLB flushing
|
|
Commit Message
Niklas Schnelle
May 15, 2023, 9:15 a.m. UTC
A future change will convert the DMA API implementation from the architecture specific arch/s390/pci/pci_dma.c to using the common code drivers/iommu/dma-iommu.c which the utilizes the same IOMMU hardware through the s390-iommu driver. Unlike the s390 specific DMA API this requires devices to correctly call set the coherent mask to be allowed to use IOVAs >2^32 in dma_alloc_coherent(). This was however not done for ISM devices. ISM requires such addresses since currently the DMA aperture for PCI devices starts at 2^32 and all calls to dma_alloc_coherent() would thus fail. Reviewed-by: Alexandra Winter <wintera@linux.ibm.com> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> --- drivers/s390/net/ism_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 5/15/23 11:15, Niklas Schnelle wrote: > A future change will convert the DMA API implementation from the > architecture specific arch/s390/pci/pci_dma.c to using the common code > drivers/iommu/dma-iommu.c which the utilizes the same IOMMU hardware > through the s390-iommu driver. Unlike the s390 specific DMA API this > requires devices to correctly call set the coherent mask to be allowed s/call// > to use IOVAs >2^32 in dma_alloc_coherent(). This was however not done > for ISM devices. ISM requires such addresses since currently the DMA > aperture for PCI devices starts at 2^32 and all calls to > dma_alloc_coherent() would thus fail. > > Reviewed-by: Alexandra Winter <wintera@linux.ibm.com> > Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> > Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> > --- > drivers/s390/net/ism_drv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/s390/net/ism_drv.c b/drivers/s390/net/ism_drv.c > index 8acb9eba691b..1399b5dc646c 100644 > --- a/drivers/s390/net/ism_drv.c > +++ b/drivers/s390/net/ism_drv.c > @@ -660,7 +660,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id) > if (ret) > goto err_disable; > > - ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); > + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); > if (ret) > goto err_resource; > > Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
On Mon, 15 May 2023 11:15:51 +0200 Niklas Schnelle <schnelle@linux.ibm.com> wrote: > A future change will convert the DMA API implementation from the > architecture specific arch/s390/pci/pci_dma.c to using the common code > drivers/iommu/dma-iommu.c which the utilizes the same IOMMU hardware > through the s390-iommu driver. Unlike the s390 specific DMA API this > requires devices to correctly call set the coherent mask to be allowed > to use IOVAs >2^32 in dma_alloc_coherent(). This was however not done > for ISM devices. ISM requires such addresses since currently the DMA > aperture for PCI devices starts at 2^32 and all calls to > dma_alloc_coherent() would thus fail. > > Reviewed-by: Alexandra Winter <wintera@linux.ibm.com> > Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> > Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> > --- > drivers/s390/net/ism_drv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/s390/net/ism_drv.c b/drivers/s390/net/ism_drv.c > index 8acb9eba691b..1399b5dc646c 100644 > --- a/drivers/s390/net/ism_drv.c > +++ b/drivers/s390/net/ism_drv.c > @@ -660,7 +660,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id) > if (ret) > goto err_disable; > > - ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); > + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); Ah. I love this change. I have already wondered a few times if the coherent DMA mask for this device may actually be different from dma_mask. Now I know. ;-) Thanks! Petr T
diff --git a/drivers/s390/net/ism_drv.c b/drivers/s390/net/ism_drv.c index 8acb9eba691b..1399b5dc646c 100644 --- a/drivers/s390/net/ism_drv.c +++ b/drivers/s390/net/ism_drv.c @@ -660,7 +660,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (ret) goto err_disable; - ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (ret) goto err_resource;