From patchwork Thu Nov 21 07:27:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 179915 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3215666ilf; Wed, 20 Nov 2019 23:27:51 -0800 (PST) X-Google-Smtp-Source: APXvYqw/BHf68j56En1EtSZLchit0+iKZo8vB5hXgsR50Ye60jRLM0hNAnvZL7rKIRkUzIh4o5Y0 X-Received: by 2002:a17:906:378d:: with SMTP id n13mr12050890ejc.260.1574321271393; Wed, 20 Nov 2019 23:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574321271; cv=none; d=google.com; s=arc-20160816; b=EmQ9t4EpDTorhVL6pu98S47FWCBn6A6+C8jBCHraTDQQEMKKKcDLIKFossn1EMvk8B IHIkOFBmUjlSBLeCRzrFCb3lYqFPQRDabLoRO8bfva1erpyhbAiz30HCwxkgpsa7OPYb vmbfdldDwLJJuzTxM+2JiKM2nqgTBnPCnG/yRbWKhekRx25vgRtmPhNTGjcD1xv7P8fF PB82LLI2j2Iyj5yGG7reuc13f3nZD4v0hQGQYOfPPI+MTJ5brGEv1VIP8PYjq2UoL2I+ UQp0k5EbcN0dxX/K06DAGeKAc7OodrlE942pCUlN1lAqBMJo+YiTgRGTxi/j3SvRJFM+ 40Uw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=avftAO4KNvNoNRnpg3sOK4jR51D3tqR6xIXLBziuwm4=; b=vEFoBYs82VAFq6R1UE7j8YWtXsrX7lVbTcMVtp1nnw0+jKco2p9Ltx99DaoLNtLQmA lyn36YWECTzG6bN/BjSzu/kZCdTc/fdDgM8oHI+aZtZTiRmHLehf/2m8o1RmWNI7RsRD OmR8tWMNqX6spFOuDZhtQlEJmoQqH3gF4ryDbL8vXrOVUgW14NjqXQ5wJ+ehgQjIk4W7 pfVUgaS58whOaSXkVV5luVnVF2xV0f4uUpQ5F1x0ccbyW7sE3ho92yIoAGt04spZ3xlV 6d3G4FTc3s8wiPU6mmRkTbJv8W6Fb6JISlujea3hbyPSYcPcGGcj5IwRRowD/KXa+JCy wQyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mCpZyDZv; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si1225116ejz.12.2019.11.20.23.27.51; Wed, 20 Nov 2019 23:27:51 -0800 (PST) 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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mCpZyDZv; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbfKUH1t (ORCPT + 3 others); Thu, 21 Nov 2019 02:27:49 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:46102 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbfKUH1q (ORCPT ); Thu, 21 Nov 2019 02:27:46 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xAL7RUiO121185; Thu, 21 Nov 2019 01:27:30 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1574321250; bh=avftAO4KNvNoNRnpg3sOK4jR51D3tqR6xIXLBziuwm4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=mCpZyDZvfCGTIzoWPtVWDzd/XcwuhhgyfatJ71YIw2A08zGYBfbsHvqg/ygBnziSy wYnHN1xcpFE2ROUvGff8vSH37e/o/2DaB9+NK3hENqkcTj2xygch2uefBMdUz7Shtt XHDslgQY30nvqlK1pfqjE3fHX8ndLEQip6hbGzAw= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xAL7RUQK006777 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Nov 2019 01:27:30 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 21 Nov 2019 01:27:29 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 21 Nov 2019 01:27:29 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xAL7RNTr079857; Thu, 21 Nov 2019 01:27:26 -0600 From: Peter Ujfalusi To: , , , , CC: , , , Subject: [PATCH 1/3] crypto: atmel-aes - Retire dma_request_slave_channel_compat() Date: Thu, 21 Nov 2019 09:27:21 +0200 Message-ID: <20191121072723.28479-2-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191121072723.28479-1-peter.ujfalusi@ti.com> References: <20191121072723.28479-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The driver no longer boots in legacy mode, only via DT. This makes the dma_request_slave_channel_compat() redundant. If ever the filter function would be executed it will return false as the dma_slave is not really initialized. Switch to use dma_request_chan() which would allow legacy boot if ever needed again by configuring dma_slave_map for the DMA driver. At the same time skip allocating memory for dma_slave as it is not used anymore. Signed-off-by: Peter Ujfalusi --- drivers/crypto/atmel-aes.c | 50 ++++++++------------------------------ 1 file changed, 10 insertions(+), 40 deletions(-) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index f24af212260b..363a2f3b1e9e 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "atmel-aes-regs.h" #include "atmel-authenc.h" @@ -2381,39 +2380,23 @@ static void atmel_aes_buff_cleanup(struct atmel_aes_dev *dd) free_page((unsigned long)dd->buf); } -static bool atmel_aes_filter(struct dma_chan *chan, void *slave) -{ - struct at_dma_slave *sl = slave; - - if (sl && sl->dma_dev == chan->device->dev) { - chan->private = sl; - return true; - } else { - return false; - } -} - static int atmel_aes_dma_init(struct atmel_aes_dev *dd, struct crypto_platform_data *pdata) { - struct at_dma_slave *slave; - dma_cap_mask_t mask; - - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); + int ret; /* Try to grab 2 DMA channels */ - slave = &pdata->dma_slave->rxdata; - dd->src.chan = dma_request_slave_channel_compat(mask, atmel_aes_filter, - slave, dd->dev, "tx"); - if (!dd->src.chan) + dd->src.chan = dma_request_chan(dd->dev, "tx"); + if (IS_ERR(dd->src.chan)) { + ret = PTR_ERR(dd->src.chan); goto err_dma_in; + } - slave = &pdata->dma_slave->txdata; - dd->dst.chan = dma_request_slave_channel_compat(mask, atmel_aes_filter, - slave, dd->dev, "rx"); - if (!dd->dst.chan) + dd->dst.chan = dma_request_chan(dd->dev, "rx"); + if (IS_ERR(dd->dst.chan)) { + ret = PTR_ERR(dd->dst.chan); goto err_dma_out; + } return 0; @@ -2421,7 +2404,7 @@ static int atmel_aes_dma_init(struct atmel_aes_dev *dd, dma_release_channel(dd->src.chan); err_dma_in: dev_warn(dd->dev, "no DMA channel available\n"); - return -ENODEV; + return ret; } static void atmel_aes_dma_cleanup(struct atmel_aes_dev *dd) @@ -2609,14 +2592,6 @@ static struct crypto_platform_data *atmel_aes_of_init(struct platform_device *pd if (!pdata) return ERR_PTR(-ENOMEM); - pdata->dma_slave = devm_kzalloc(&pdev->dev, - sizeof(*(pdata->dma_slave)), - GFP_KERNEL); - if (!pdata->dma_slave) { - devm_kfree(&pdev->dev, pdata); - return ERR_PTR(-ENOMEM); - } - return pdata; } #else @@ -2643,11 +2618,6 @@ static int atmel_aes_probe(struct platform_device *pdev) } } - if (!pdata->dma_slave) { - err = -ENXIO; - goto aes_dd_err; - } - aes_dd = devm_kzalloc(&pdev->dev, sizeof(*aes_dd), GFP_KERNEL); if (aes_dd == NULL) { err = -ENOMEM; From patchwork Thu Nov 21 07:27:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 179914 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3215659ilf; Wed, 20 Nov 2019 23:27:51 -0800 (PST) X-Google-Smtp-Source: APXvYqycowgfvZJVFc3vXIkKI5/pLmAebL7OHxKDgYhPySy0WJZwZl+bxvOoEWv/VHqJcrPfInhU X-Received: by 2002:a17:906:ce2f:: with SMTP id sd15mr12292179ejb.270.1574321271076; Wed, 20 Nov 2019 23:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574321271; cv=none; d=google.com; s=arc-20160816; b=wlxhcv5VhRmMfdkdzkcGD4+VNyFkVtdaT8vjMOJps/cGNXpUDx56/pjOnh84kIOgDS wFMx4S9ftVrqsh/rBN3jagPLw3BiQtwoBqxbQ5nyxjdJ2eR2x64VHaGSsSPlLX6JrDxf bi/DJ75oVv+lmwsvdStyuvrwz4oGzNIHfCJHCG3dDWYXjvU5Eq9WVXggOp5LGO5wh92w RxUcpox8JDkcqUTzk7RFFsd3x7zmilQQACFg/hbsJf4mZu4LP567vw6dO7opVbAr9L8h X9Q94rEtyjIiYQWkeHJnxAcDRhDh1RXDMMptOta7ZLQEBKCN+q6Q3KO05uKFXsknlM3J 3uTw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RcakxV3bAZDzJDpxzPCwkMvlEl/J6Nybe5yk/wSebPw=; b=0DvlFGdrUVeYJLF5A5p1ZGpHkRAOrc6YgVSiNlHd/jqeEHYvopu+NJ5IZN1a+gUz1G ltjZypRQ+pjaY9U6N5EjdBTdMU5Oh5V2F/+IColM4A8lgVRSPKVUjMtSst7rC5oaTA/h aTH9XAvt9Wi+ittzugc2VxUW4fHFR7SaWtKBgerXrqAZ838pfM2EXRt07H/Y9/jx+qUd grVQlBXzuTMb99z3eq0awth18zH9S9S3UD5TpkgsgVCwFc5VAm2gpEVuqJy5zZBgzhsK SI8rMN3O42Ja3iEeM/0FS1VM/rzZ4vnCSVhIZ1Fk4LZzVAIQ+mDmeedYbYbxURd/EjP8 jKNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LyrJZ7l5; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si1225116ejz.12.2019.11.20.23.27.50; Wed, 20 Nov 2019 23:27:51 -0800 (PST) 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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LyrJZ7l5; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727106AbfKUH1s (ORCPT + 3 others); Thu, 21 Nov 2019 02:27:48 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:50826 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbfKUH1r (ORCPT ); Thu, 21 Nov 2019 02:27:47 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xAL7RYMn081649; Thu, 21 Nov 2019 01:27:34 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1574321254; bh=RcakxV3bAZDzJDpxzPCwkMvlEl/J6Nybe5yk/wSebPw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LyrJZ7l5EFx4+cBCDrc/0Y9TB6hzkinL+YsqSDleFRTXSO0RH/YA8xbG3okajL2y8 WOddJlxOJfvTcUKwv9QKnH2lttt81nuzCmxLXFZfL/9nDYxk4oLduo1S/jqB0vdPtm rKO0gouc0UrNrjIHDq99JRUANZF3ruYCyCNqOK1o= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xAL7RYGN013855 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Nov 2019 01:27:34 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 21 Nov 2019 01:27:34 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 21 Nov 2019 01:27:34 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xAL7RNTt079857; Thu, 21 Nov 2019 01:27:31 -0600 From: Peter Ujfalusi To: , , , , CC: , , , Subject: [PATCH 3/3] crypto: atmel-tdes - Retire dma_request_slave_channel_compat() Date: Thu, 21 Nov 2019 09:27:23 +0200 Message-ID: <20191121072723.28479-4-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191121072723.28479-1-peter.ujfalusi@ti.com> References: <20191121072723.28479-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The driver no longer boots in legacy mode, only via DT. This makes the dma_request_slave_channel_compat() redundant. If ever the filter function would be executed it will return false as the dma_slave is not really initialized. Switch to use dma_request_chan() which would allow legacy boot if ever needed again by configuring dma_slave_map for the DMA driver. At the same time skip allocating memory for dma_slave as it is not used anymore. Signed-off-by: Peter Ujfalusi --- drivers/crypto/atmel-tdes.c | 47 ++++++++++--------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c index 1a6c86ae6148..44fdc7456769 100644 --- a/drivers/crypto/atmel-tdes.c +++ b/drivers/crypto/atmel-tdes.c @@ -702,31 +702,17 @@ static int atmel_tdes_crypt(struct ablkcipher_request *req, unsigned long mode) return atmel_tdes_handle_queue(ctx->dd, req); } -static bool atmel_tdes_filter(struct dma_chan *chan, void *slave) -{ - struct at_dma_slave *sl = slave; - - if (sl && sl->dma_dev == chan->device->dev) { - chan->private = sl; - return true; - } else { - return false; - } -} - static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd, struct crypto_platform_data *pdata) { - dma_cap_mask_t mask; - - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); + int ret; /* Try to grab 2 DMA channels */ - dd->dma_lch_in.chan = dma_request_slave_channel_compat(mask, - atmel_tdes_filter, &pdata->dma_slave->rxdata, dd->dev, "tx"); - if (!dd->dma_lch_in.chan) + dd->dma_lch_in.chan = dma_request_chan(dd->dev, "tx"); + if (IS_ERR(dd->dma_lch_in.chan)) { + ret = PTR_ERR(dd->dma_lch_in.chan); goto err_dma_in; + } dd->dma_lch_in.dma_conf.direction = DMA_MEM_TO_DEV; dd->dma_lch_in.dma_conf.dst_addr = dd->phys_base + @@ -739,10 +725,11 @@ static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd, DMA_SLAVE_BUSWIDTH_4_BYTES; dd->dma_lch_in.dma_conf.device_fc = false; - dd->dma_lch_out.chan = dma_request_slave_channel_compat(mask, - atmel_tdes_filter, &pdata->dma_slave->txdata, dd->dev, "rx"); - if (!dd->dma_lch_out.chan) + dd->dma_lch_out.chan = dma_request_chan(dd->dev, "rx"); + if (IS_ERR(dd->dma_lch_out.chan)) { + ret = PTR_ERR(dd->dma_lch_out.chan); goto err_dma_out; + } dd->dma_lch_out.dma_conf.direction = DMA_DEV_TO_MEM; dd->dma_lch_out.dma_conf.src_addr = dd->phys_base + @@ -760,8 +747,9 @@ static int atmel_tdes_dma_init(struct atmel_tdes_dev *dd, err_dma_out: dma_release_channel(dd->dma_lch_in.chan); err_dma_in: - dev_warn(dd->dev, "no DMA channel available\n"); - return -ENODEV; + if (ret != -EPROBE_DEFER) + dev_warn(dd->dev, "no DMA channel available\n"); + return ret; } static void atmel_tdes_dma_cleanup(struct atmel_tdes_dev *dd) @@ -1212,12 +1200,6 @@ static struct crypto_platform_data *atmel_tdes_of_init(struct platform_device *p if (!pdata) return ERR_PTR(-ENOMEM); - pdata->dma_slave = devm_kzalloc(&pdev->dev, - sizeof(*(pdata->dma_slave)), - GFP_KERNEL); - if (!pdata->dma_slave) - return ERR_PTR(-ENOMEM); - return pdata; } #else /* CONFIG_OF */ @@ -1311,10 +1293,7 @@ static int atmel_tdes_probe(struct platform_device *pdev) goto err_pdata; } } - if (!pdata->dma_slave) { - err = -ENXIO; - goto err_pdata; - } + err = atmel_tdes_dma_init(tdes_dd, pdata); if (err) goto err_tdes_dma;