From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71DD0C433F5 for ; Fri, 15 Oct 2021 15:50:43 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53A4061164 for ; Fri, 15 Oct 2021 15:50:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 53A4061164 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAFDF8382C; Fri, 15 Oct 2021 17:50:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1634313041; bh=E9Z0qqMERFEEF4Y6Zcny3ZF5Zjfu+B3Lk5YBEkFeq74=; h=From:Subject:To:Cc:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ib2qZGtc2ETxQqTPLIlzTd8IhCQrmODPVeNfYooehsB66xN+EPZj8dG8jUF6n39XB epF6Mmex9cli9P+LZNQBG/1/yod09M/t4TYzZsuGPQTewEFDmVHYLLZYrJKt/CILLp 6se61ThKVZaarOlsY/4rxhmM+ffQkl3GNUzRV68UYcYT/i023kVqgIda6ys7HCZGLC o+lPJcaF+AaGvelBKsyfyPheVv5IGecx8lFEiIMS+VERKW1Nlym7MqHcyoBiYBPhmW XtwaugfDa7lfn4C+IMC7wOckxigEme5i/eWG/LThq8zqPWM6iClFbEDcifgF17ciX2 peMJIMLmzh2jQ== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C127C836DE; Fri, 15 Oct 2021 17:50:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1634313022; bh=E9Z0qqMERFEEF4Y6Zcny3ZF5Zjfu+B3Lk5YBEkFeq74=; h=From:Subject:To:Cc:References:Date:In-Reply-To:From; b=uTyN2p9vqpM0aYJXRT/a8cPQnxkbBxHRVLlNPvviiTr16W7tG9HMJ5oI2e2ymo6+s oTNcLvxDroE5tt76NAGWJJcw2CTs7enpaSxFJz5wbk1quCr3nOZF/dW4WEnbrscBSJ ETu5wZx4FIVLgZXk5rVZ+n1vMAytDgtW/Xm3FUWGP0w/xE+5pn45acvH4WVaqNs/qP RaeQ7m3lxmwiEUA3GmK709WI9ivjExY8a3bzxnJ2ALGp6obvCGAfdYbpcsTKvk6fG9 AvPyZ8v+eVHTWH1IGE7EMGD/uziMumMyu30Ke4tlbVwIJTO1xEMZdEeBuC5aF+qEqi w1dOHOdSs6BkA== From: Marek Vasut Subject: Re: [PATCH] loads: Block writes into LMB reserved areas of U-Boot To: Simon Glass Cc: U-Boot Mailing List , Marek Vasut , Tom Rini References: <20211010215241.872206-1-marek.vasut@gmail.com> Message-ID: <69e586a7-7fb3-e530-d0f2-196ebb59b098@denx.de> Date: Fri, 15 Oct 2021 16:23:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On 10/14/21 5:10 PM, Simon Glass wrote: [...] >> @@ -137,6 +138,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc, >> >> static ulong load_serial(long offset) >> { >> + struct lmb lmb; >> char record[SREC_MAXRECLEN + 1]; /* buffer for one S-Record */ >> char binbuf[SREC_MAXBINLEN]; /* buffer for binary data */ >> int binlen; /* no. of data bytes in S-Rec. */ >> @@ -147,6 +149,9 @@ static ulong load_serial(long offset) >> ulong start_addr = ~0; >> ulong end_addr = 0; >> int line_count = 0; >> + long ret; >> + >> + lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); >> >> while (read_record(record, SREC_MAXRECLEN + 1) >= 0) { >> type = srec_decode(record, &binlen, &addr, binbuf); >> @@ -172,7 +177,14 @@ static ulong load_serial(long offset) >> } else >> #endif >> { >> + ret = lmb_reserve(&lmb, store_addr, binlen); >> + if (ret) { >> + printf("\nCannot overwrite reserved area (%08lx..%08lx)\n", >> + store_addr, store_addr + binlen); >> + return ret; >> + } >> memcpy((char *)(store_addr), binbuf, binlen); >> + lmb_free(&lmb, store_addr, binlen); >> } >> if ((store_addr) < start_addr) >> start_addr = store_addr; >> -- >> 2.33.0 >> > > Reviewed-by: Simon Glass > > This code looks OK but I don't know what lmb_reserve() and lmb_free() > do. Can you add comments to the header file? Not here, the entire LMB stuff needs (better) documentation, that's where (all) such clarification should go.