From patchwork Sat Jun 11 22:06:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1642484 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=PoNGOEAR; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LLBnP4SfJz9s07 for ; Sun, 12 Jun 2022 08:09:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8856C8445E; Sun, 12 Jun 2022 00:07:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="PoNGOEAR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3BC984438; Sun, 12 Jun 2022 00:07:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9E84384420 for ; Sun, 12 Jun 2022 00:07:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-lf1-x12f.google.com with SMTP id s6so3507024lfo.13 for ; Sat, 11 Jun 2022 15:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C5ESLZOM8yYQSYwjOk8dMRJ1W5vWl3Yyt9dVhNAgp3o=; b=PoNGOEARZj5zFKpMoyA5cnU6q30nX48boSWjsZaSA8ZRG6Ywq8Uqi00QfyCJXn8RlS FC/jHGpYsITxhN4ej19dbqBwp4atlvzPdZrTelZacXaWQfWAS17Yxg8TztwO5FLklzGB 71QE7FCt9VP2+A0DNfAfdVNVGzJWcH7fvdeLqcu1JVhFA6w4EpK4NXk5X32/8bgrmXiZ a9qzTNbMDeLfM8i56b0nNjEY345Xeh0qhs2krN2J3xCp32Hfa/W1MW9s7ehA9hfMR4ax 5n7bkUCQtuE4/AvZX+eSaqI1Xiu3bFfNctE0pn1VeBVJuURR9TZUynh5YSzYsFuD8K05 p76g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C5ESLZOM8yYQSYwjOk8dMRJ1W5vWl3Yyt9dVhNAgp3o=; b=ROAI6Gbc0t/dRPYznVMw+1zIzTFRDAyb14RTdutl26fJBgHD+DbY082ZsbzALfmyrR Ks3sQT3phs/VkkJHacodHrOe8g51TRNHSz444swGzBzFme6tBn1/vdS2s0jFPsSbeKml GY0XP6zwZ4LYmZYxELRXQWawzQ9Rslk9qiq4lhNUm09vRuokHZgyTSbxB4Irf//KJ5i/ XykiInldKRaUCe2lKtB4DS5d8j5gZryRSRS47b/J9X3KcpcBYDGSjmrnvmXJOq5Ba9dt 1g72rnFNFerH94uhDJ5nsVMUyPGXrDkTZd3H8ANG2n1X4x3oovCgiaoKB06K+F0zHoC5 6DUw== X-Gm-Message-State: AOAM530kfWJGZDEJGEqdI+f4PkY7bC7ozsXUo3aG/jTbNKUatA42/K4i 2QfyKjR+EjTWejk99/gjCuM4m58OMhHMuQ== X-Google-Smtp-Source: ABdhPJzwpzGt+KH36/8sOwJMydFtThYi/b/ia3PrWF8vT5bbdWoYTTa/4HcmMUMQT7wZh4tbhWm6IQ== X-Received: by 2002:ac2:55ae:0:b0:479:606:a3e9 with SMTP id y14-20020ac255ae000000b004790606a3e9mr30529400lfg.146.1654985231760; Sat, 11 Jun 2022 15:07:11 -0700 (PDT) Received: from cryobook.. ([93.188.34.55]) by smtp.gmail.com with ESMTPSA id c30-20020a2ebf1e000000b0025583eb9becsm433623ljr.69.2022.06.11.15.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jun 2022 15:07:11 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Michal Simek , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v10 10/13] fpga: zynqmp: optimize zynqmppl_load() code Date: Sun, 12 Jun 2022 01:06:51 +0300 Message-Id: <20220611220654.103236-11-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220611220654.103236-10-oleksandr.suvorov@foundries.io> References: <20220611220654.103236-1-oleksandr.suvorov@foundries.io> <20220611220654.103236-2-oleksandr.suvorov@foundries.io> <20220611220654.103236-3-oleksandr.suvorov@foundries.io> <20220611220654.103236-4-oleksandr.suvorov@foundries.io> <20220611220654.103236-5-oleksandr.suvorov@foundries.io> <20220611220654.103236-6-oleksandr.suvorov@foundries.io> <20220611220654.103236-7-oleksandr.suvorov@foundries.io> <20220611220654.103236-8-oleksandr.suvorov@foundries.io> <20220611220654.103236-9-oleksandr.suvorov@foundries.io> <20220611220654.103236-10-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Optimize function code preparing to add secure bitstream types support. Signed-off-by: Oleksandr Suvorov --- (no changes since v1) drivers/fpga/zynqmppl.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c index 239c498f7b5..6959b8ae97e 100644 --- a/drivers/fpga/zynqmppl.c +++ b/drivers/fpga/zynqmppl.c @@ -199,46 +199,45 @@ static int zynqmp_validate_bitstream(xilinx_desc *desc, const void *buf, return 0; } -static int zynqmp_load(xilinx_desc *desc, const void *buf, size_t bsize, - bitstream_type bstype, int flags) +static int zynqmp_load(xilinx_desc *desc, const void *buf, + size_t bsize, bitstream_type bstype, + int flags) { ALLOC_CACHE_ALIGN_BUFFER(u32, bsizeptr, 1); u32 swap = 0; ulong bin_buf; int ret; u32 buf_lo, buf_hi; + u32 bsize_req = (u32)bsize; u32 ret_payload[PAYLOAD_ARG_CNT]; - bool xilfpga_old = false; + + debug("%s called!\n", __func__); if (zynqmp_firmware_version() <= PMUFW_V1_0) { puts("WARN: PMUFW v1.0 or less is detected\n"); puts("WARN: Not all bitstream formats are supported\n"); puts("WARN: Please upgrade PMUFW\n"); - xilfpga_old = true; - if (zynqmp_validate_bitstream(desc, buf, bsize, bsize, &swap)) + if (zynqmp_validate_bitstream(desc, buf, bsize, + bsize, &swap)) return FPGA_FAIL; bsizeptr = (u32 *)&bsize; flush_dcache_range((ulong)bsizeptr, (ulong)bsizeptr + sizeof(size_t)); + bsize_req = (u32)(uintptr_t)bsizeptr; bstype |= BIT(ZYNQMP_FPGA_BIT_NS); + } else { + bstype = 0; } bin_buf = zynqmp_align_dma_buffer((u32 *)buf, bsize, swap); - debug("%s called!\n", __func__); flush_dcache_range(bin_buf, bin_buf + bsize); buf_lo = (u32)bin_buf; buf_hi = upper_32_bits(bin_buf); - if (xilfpga_old) - ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo, - buf_hi, (u32)(uintptr_t)bsizeptr, - bstype, ret_payload); - else - ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo, - buf_hi, (u32)bsize, 0, ret_payload); - + ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo, buf_hi, + bsize_req, bstype, ret_payload); if (ret) printf("PL FPGA LOAD failed with err: 0x%08x\n", ret);