Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2040982yba; Thu, 25 Apr 2019 09:40:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxM7Veim5ubL+MF5cnop21PIZu2Ky5Fn8FOnnt634ZkqSsJwHbXOqjjLLHjBDfh7eRqDN3Y X-Received: by 2002:a62:a513:: with SMTP id v19mr40848019pfm.212.1556210399990; Thu, 25 Apr 2019 09:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556210399; cv=none; d=google.com; s=arc-20160816; b=qGgB8Xs1am23dqMTmHzGqrjdHsOB9qgXzyaC0clgpAX3e1cQJyyjzTVzDN80qxQrnn lhrzHSdqkIQeo2z3FAqDNQ6NglIPzBauKUPCgn/mX4EfaRLK4OiCXjAC1CHdgL3cak/B /PulxrVLAxkGcoU4soLIxL4cwS6Iemc3rpznZdoFqDK+yp1X3i3Qk36fhdWNo3cueL2i qPyxt/6B8vsf4VohvBJi4GpigmmMZewJIIAp6rSRkDouaWzzTPtd4JHdpgjBHNI7Vq8N pvY0i6EI3Z4qZ/nMD0dM3RGW6vrSsl6hUjTCLnA7AHs5TVx0M2pI06opjy6iQe2p7DQw 0csw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=fl0Q26TSyAS1CLV5E5zbgGUhF3tegDCC4U6TpeCsIt8=; b=EDQhz7OrNRSaRQDY3mdcBbLPR8CJm6GQ6fCcDVYqjp6ggQ8bpR0XNOg/5e3scmV+PK oqn/2T7ihDi950uyyhyx0WQo8eOKm7f98j15ePz+zvLv9nrEBpx9EjOhdJeDXulCSUSG H+Wd/wxOpCd1i+dGOXwFxJzTYWnQ40gPDLK9Px4xw99tlp7cw2vGg+Wv9xZtt11T/dB8 U8TB11uFwXmlBO0L3lTC14MEkalxhlK6Z7sOwWDndWNxw3I/UUIjy8BwK5W4LYjb5Xgm pLGkIjAERJ2KfBv/JJnEFViRVXOhh/+1tKElw32otTDEFvjmUi8y0agyeT0ZoUWc+7G6 LTPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si22318529plp.278.2019.04.25.09.39.44; Thu, 25 Apr 2019 09:39:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729494AbfDYQZS (ORCPT + 99 others); Thu, 25 Apr 2019 12:25:18 -0400 Received: from inva021.nxp.com ([92.121.34.21]:35684 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbfDYQZS (ORCPT ); Thu, 25 Apr 2019 12:25:18 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id C4B16200204; Thu, 25 Apr 2019 18:25:15 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id AD120200080; Thu, 25 Apr 2019 18:25:15 +0200 (CEST) Received: from fsr-ub1864-014.ea.freescale.net (fsr-ub1864-014.ea.freescale.net [10.171.95.219]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 3D1B22061F; Thu, 25 Apr 2019 18:25:15 +0200 (CEST) From: =?UTF-8?q?Horia=20Geant=C4=83?= To: Herbert Xu Cc: "David S. Miller" , Aymen Sghaier , Laurentiu Tudor , Vakul Garg , Franck Lenormand , Iuliana Prodan , Marcin Niestroj , linux-crypto@vger.kernel.org, NXP Linux Team Subject: [PATCH 0/7] crypto: caam - IOMMU support Date: Thu, 25 Apr 2019 19:24:54 +0300 Message-Id: <20190425162501.4565-1-horia.geanta@nxp.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch set adds support in caam drivers (caam/jr, caam/qi, caam/qi2) for the crypto engine to work behind an IOMMU. The changes consist in: 1. Deferred probing support -caam/jr - top level drivers are converted to "libraries"; this also fixes the issue reported previously by Marcin: https://patchwork.kernel.org/cover/10558409/ -caam/qi - use the newly added QBMan functions (*) to decide whether to defer caam controller probing or not 2. Fixing spurios memory accesses, that lead to IOMMU access faults -crypto engine prefetches S/G table entries in chunks of 4 (64 bytes), and driver has to make sure memory is allocated and mapped -crypto engine tries to prefetch S/G table entries when input / output is marked as scattered, even though length is zero 3. Getting rid of platform device created by caam/qi There are inherent problems with platform device being created dynamically (and not relying on the existence of a DT node). 4. Update phys -> virt address translation in case IOMMU is present iova -> phys -> virt 5. Fix the device used for key buffers DMA mapping Key buffers are incorrectly DMA mapped using a job ring device, since they are accessed eventually by the QI - this creating an ICID / stream ID mismatch at IOMMU level. Tests were performed on: -LS1046A - caam/jr and caam/qi - job ring and queue interface -LS1088A - caam/jr and caam/qi2 - job ring and dpsec interface There are some dependencies (see below). While not everything is in place, I would like at least to patches 1-8/9 being reviewed & merged. i. Patch 9/9 (crypto: caam - defer probing until QMan is available) should NOT be merged, since there are compilation dependencies on the patch series: (*) Prerequisites for NXP LS104xA SMMU enablement https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=98625 ii. U-boot updates for LS1088A (needed for caam/jr ICID programming) [U-Boot,1/2] armv8: fsl-layerscape: add missing sec jr base address defines https://patchwork.ozlabs.org/patch/1059256/ [U-Boot,2/2] armv8: ls1088a: add icid setup for platform devices https://patchwork.ozlabs.org/patch/1059259/ Horia Geantă (7): crypto: caam - avoid S/G table fetching for AEAD zero-length output crypto: caam - fix S/G table passing page boundary crypto: caam - convert top level drivers to libraries crypto: caam/qi - don't allocate an extra platform device crypto: caam/qi - fix address translations with IOMMU enabled crypto: caam/qi - DMA map keys using proper device crypto: caam - defer probing until QMan is available drivers/crypto/caam/Kconfig | 46 ++++------- drivers/crypto/caam/Makefile | 18 ++--- drivers/crypto/caam/caamalg.c | 72 ++++++++--------- drivers/crypto/caam/caamalg_qi.c | 124 +++++++++++++++--------------- drivers/crypto/caam/caamalg_qi2.c | 72 +++++++++++++---- drivers/crypto/caam/caamhash.c | 81 ++++++------------- drivers/crypto/caam/caampkc.c | 57 +++----------- drivers/crypto/caam/caamrng.c | 54 ++----------- drivers/crypto/caam/ctrl.c | 124 ++++++++++++++++++------------ drivers/crypto/caam/desc_constr.h | 11 +++ drivers/crypto/caam/intern.h | 102 ++++++++++++++++++++++-- drivers/crypto/caam/jr.c | 43 +++++++++++ drivers/crypto/caam/qi.c | 52 ++++++------- 13 files changed, 465 insertions(+), 391 deletions(-) -- 2.17.1