From patchwork Tue Jul 5 19:23:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1652696 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=JpUR59ih; 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 4Lct1G160qz9s07 for ; Wed, 6 Jul 2022 05:25:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDD7F84550; Tue, 5 Jul 2022 21:23:47 +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="JpUR59ih"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F1ED84544; Tue, 5 Jul 2022 21:23:44 +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-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) (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 A601A8452D for ; Tue, 5 Jul 2022 21:23:41 +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-lj1-x22c.google.com with SMTP id r9so15748099ljp.9 for ; Tue, 05 Jul 2022 12:23:41 -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=47IXeMH0RhY1Xc5GoWO50NViCV/PAPrGWAJY9u6LNQ0=; b=JpUR59ihvkfl7M8MnijoLitRkEWUQMIbsuCEhZ/2yJl6uD/NwYP262/A6IX3dGKPGW kGB3NsCUJ9C+WhlbxOt1tktyaDurdgW56cWABZLJP13yMGpxNWG+BBD+rCSF3Oo19dym 2NHzp6hyahbLJnguYNLNFxHHSrdEEmywbgXlWnz3nO6b+OZJ1iYrsqjmuYpFZsYb/OCh eQojTPbtMq1fsAvb46Pt4n6XTSBEaKyF2j+jh7tLDKks/6WD45dIPAlWPQYrRVd2GNkJ hYTbR0sZiX7il46Xx+tHWw7Er5D+Z1PqL1rI3mC/g+4vxKxWqjlQQNyA9/QPXq6cKKfc f6cw== 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=47IXeMH0RhY1Xc5GoWO50NViCV/PAPrGWAJY9u6LNQ0=; b=HybOCUK5aiYyveP2Htis1Ilr0wjR1EUAcZyg3txqSUDIBv9SjrxX3QPMOwTA2+h9jH Yp+5PXRDMmQeKtzA1vZkKEDMZfMdX0QZYPLQv9LKVwG2AUiDnSPd4nevlvucew2TEGqO GDpzEzVmfjDS9X5ellCsrbMgzw4rGO7ReOiTQFV40fAMnPfnTdNab+HauUSQ65fg55wC LPPZJUNrMnJbvZxtpP+5O6c9PYJi/II9IQ5EDNS7waCFenejz/qcJ9mvOOzlhtbXD87R aL4lDKvSkBMTf4bnTywudCTFLuaGezkBzawucCae1qeY4jpyTTHbrUgqds5k0/5yntz6 yujA== X-Gm-Message-State: AJIora/22aizhGQuqceK+NNgw9hsJQh72OuhGg0481CQWBLUl4XaFbN7 reuTXDp+CMSQwANePV7nWZWT7HY2E5aU/g== X-Google-Smtp-Source: AGRyM1tEnupNfHKHS1p3u23ZrvldwWAlvQ2VXdqvflX7gFZT4TqoaWgohn5Az7j+MItffY5KaFruBg== X-Received: by 2002:a05:651c:b25:b0:25b:bb66:94f7 with SMTP id b37-20020a05651c0b2500b0025bbb6694f7mr20368137ljr.333.1657049020917; Tue, 05 Jul 2022 12:23:40 -0700 (PDT) Received: from cryobook.. ([93.188.34.55]) by smtp.gmail.com with ESMTPSA id x9-20020a056512078900b0047f6c48a603sm5850157lfr.202.2022.07.05.12.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 12:23:40 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Adrian Fiergolski , Michal Simek , Jorge Ramirez-Ortiz , Ricardo Salveti , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v11 10/13] fpga: zynqmp: optimize zynqmppl_load() code Date: Tue, 5 Jul 2022 22:23:17 +0300 Message-Id: <20220705192320.415861-11-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220705192320.415861-10-oleksandr.suvorov@foundries.io> References: <20220705192320.415861-1-oleksandr.suvorov@foundries.io> <20220705192320.415861-2-oleksandr.suvorov@foundries.io> <20220705192320.415861-3-oleksandr.suvorov@foundries.io> <20220705192320.415861-4-oleksandr.suvorov@foundries.io> <20220705192320.415861-5-oleksandr.suvorov@foundries.io> <20220705192320.415861-6-oleksandr.suvorov@foundries.io> <20220705192320.415861-7-oleksandr.suvorov@foundries.io> <20220705192320.415861-8-oleksandr.suvorov@foundries.io> <20220705192320.415861-9-oleksandr.suvorov@foundries.io> <20220705192320.415861-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.6 at phobos.denx.de X-Virus-Status: Clean Optimize function code preparing to add secure bitstream types support. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- (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);