Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp187913pxb; Tue, 21 Sep 2021 23:05:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZzeLADKdPs9czm/WL3QwhWiMoX4WajAb1gu85ZgDExx43xb90bbkJVM/ZAnOaf7Y5IkMD X-Received: by 2002:a05:6638:203:: with SMTP id e3mr3370969jaq.88.1632290752845; Tue, 21 Sep 2021 23:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632290752; cv=none; d=google.com; s=arc-20160816; b=GUgowxrdMLOfbbF6X5RwkAucJMewQhuJ4pYkGgIuvaqPiLiKh/u2aIia5543Kod5xC JPz/KFYc27d+lyJEa1pipLCM6avGSWD/gkGaJHCW7IVDjNPWqwwggNTnql7DmcPmzM3s 9FK+PPB+vdJuhfPlZAay3VkoN+/AGG2irXNKQryK3cS+ZQr1V++ZiYWWxgHpAqZQMw7v A0QfJbmlCJPDTYZg9dV8cfA50EyzcPNYqlp0xJciHN2Ajk59M8eD2WnfK28uannkl3mO +//17GL6yPWcVkIYtdHUBp5QUQdAIp8PJSUby5QnbS7P9uY95sHAygCLRB4b3aOiKrlD e9Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=E8PWpzGE4nXx9yLcpibeowYfrua7uZ6eTJJKaxClepM=; b=ZKrJ4tfOpeS+Yb2BnbgYUS+RW3NwLwNuV0vLlXCMM1Nemg5Z4CghIvZKuXXdZD4Hiz mXdvKKgPc7zrAiyDhQlyrKZorV+jEeAqxubafntxE+QMeJ042CXvnCp9MDHUlA29PXNQ 8rMVtvOG4pwmaQmSURjHJRE7GyrAEsFj6jvVqymbI69++0cWUDAcBtTgvtjU7CR8seq9 y+Uy9d0qIi/WzTI3GjjUW+BAxkmljmHMSSy/KO9dBFPZUmAvc7X6zJeWW1YTC0vu6YWD k1mS4ndZcav6b40ZSotaAXpsEA754rftouGPllOb3GYK/CCCqOUT1dX7TNP20f+R411a m1wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S1fWqCKT; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l126si1266752ioa.77.2021.09.21.23.05.16; Tue, 21 Sep 2021 23:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S1fWqCKT; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232392AbhIVGGP (ORCPT + 99 others); Wed, 22 Sep 2021 02:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231908AbhIVGGO (ORCPT ); Wed, 22 Sep 2021 02:06:14 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 616FFC061574; Tue, 21 Sep 2021 23:04:45 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id w17so3273128wrv.10; Tue, 21 Sep 2021 23:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=E8PWpzGE4nXx9yLcpibeowYfrua7uZ6eTJJKaxClepM=; b=S1fWqCKTc+U3XKV5MShwR46eahJQSdbw+NMA8XAWaqVGE4gxmVvz/ieJJpTPvygGB+ NNN5aTQCiy5LkLq8A9yKOgrmXJlT3dt1rY51hmAS9BwwbIGAmyUshJArA5LNHHbEqGG6 vpMogiWPbwy7kMJ/XJta/8xaIXkqvkd5SlmkQmn852FfcsPb1bj9sfRgfVakG8YEmd28 OhxgMrpK7MglhTkJqlaS3vCa5Vn4cXfJ2pmqYfjihzGZEeYcM92zU/EhXXMCPetBA/kc 9yQ+S8F6dX/34PidSe5ZanAPHXbo5xw4HI+KcwnVlFAYllBy+RA01+pglKkhtXw0Ejzm ssMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=E8PWpzGE4nXx9yLcpibeowYfrua7uZ6eTJJKaxClepM=; b=uX8MH3NvH6BKFjlNF7jVnzAIW86aq0+Qhwds7asLOaEd0knm1TlZ5uk2kOsPSdvaVB HiOPy/QHduUmDeyt+4xWLvF5ahfpXYnF7nphozPj4mh+VUsxtaccVq6PsHjYOYuiDD53 3WsknmnP6eJAmj3dNJa0lRyeDXlNJBn7dhkXjV3bR+vz8QXmdNL5a5YP+zM9Ymo7/6iA vRVesDix/xk5Lazee1Vt3/gaIMvV7eKPzvH/yUb4tnFBeSk5dEIezQEvtd2cC9te0Ao2 SB/9mF9EPPmXFvtal1InKGW8qFEP9DZjRHYm8nUiESakq6/heRmjD438Sxdlt1VXb6pa m2OA== X-Gm-Message-State: AOAM531viWYQCs6zI5S/LJX86Za4hYxFjppWckv5IAEeIB1GoV3XBfDb aKB9Uv3UjD3Y7I5XfDBlGQY= X-Received: by 2002:adf:a745:: with SMTP id e5mr28523356wrd.406.1632290683592; Tue, 21 Sep 2021 23:04:43 -0700 (PDT) Received: from Red ([2a01:cb1d:3d5:a100:264b:feff:fe03:2806]) by smtp.googlemail.com with ESMTPSA id o1sm1071032wru.91.2021.09.21.23.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 23:04:43 -0700 (PDT) Date: Wed, 22 Sep 2021 08:04:39 +0200 From: Corentin Labbe To: Emmanuel Gil Peyrot Cc: linux-crypto@vger.kernel.org, Ash Logan , Jonathan =?iso-8859-1?Q?Neusch=E4fer?= , Herbert Xu , "David S. Miller" , Rob Herring , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 1/4] crypto: nintendo-aes - add a new AES driver Message-ID: References: <20210921213930.10366-1-linkmauve@linkmauve.fr> <20210921213930.10366-2-linkmauve@linkmauve.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210921213930.10366-2-linkmauve@linkmauve.fr> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Le Tue, Sep 21, 2021 at 11:39:27PM +0200, Emmanuel Gil Peyrot a écrit : > This engine implements AES in CBC mode, using 128-bit keys only. It is > present on both the Wii and the Wii U, and is apparently identical in > both consoles. > > The hardware is capable of firing an interrupt when the operation is > done, but this driver currently uses a busy loop, I’m not too sure > whether it would be preferable to switch, nor how to achieve that. > > It also supports a mode where no operation is done, and thus could be > used as a DMA copy engine, but I don’t know how to expose that to the > kernel or whether it would even be useful. > > In my testing, on a Wii U, this driver reaches 80.7 MiB/s, while the > aes-generic driver only reaches 30.9 MiB/s, so it is a quite welcome > speedup. > > This driver was written based on reversed documentation, see: > https://wiibrew.org/wiki/Hardware/AES > > Signed-off-by: Emmanuel Gil Peyrot > Tested-by: Emmanuel Gil Peyrot # on Wii U [...] > +static int > +do_crypt(const void *src, void *dst, u32 len, u32 flags) > +{ > + u32 blocks = ((len >> 4) - 1) & AES_CTRL_BLOCK; > + u32 status; > + u32 counter = OP_TIMEOUT; > + u32 i; > + > + /* Flush out all of src, we can’t know whether any of it is in cache */ > + for (i = 0; i < len; i += 32) > + __asm__("dcbf 0, %0" : : "r" (src + i)); > + __asm__("sync" : : : "memory"); > + > + /* Set the addresses for DMA */ > + iowrite32be(virt_to_phys((void *)src), base + AES_SRC); > + iowrite32be(virt_to_phys(dst), base + AES_DEST); Hello Since you do DMA operation, I think you should use the DMA-API and call dma_map_xxx() This will prevent the use of __asm__ and virt_to_phys(). Regards