From patchwork Tue Oct 27 00:16:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1388234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKtwB2ZQQz9sRK for ; Tue, 27 Oct 2020 12:12:10 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dVDYsQdD; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CKtw96R9xzDqLv for ; Tue, 27 Oct 2020 12:12:09 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dVDYsQdD; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CKsh2462szDqRZ for ; Tue, 27 Oct 2020 11:16:34 +1100 (AEDT) Received: by mail-pf1-x443.google.com with SMTP id j18so7156699pfa.0 for ; Mon, 26 Oct 2020 17:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lt3BgpTFJ1RPgyyGpnoAE9m9bo/L3J4nb/f2r1TAJE4=; b=dVDYsQdDhx/pAoiYssEqFOaAbxqV+Zutmxlw8aMhD9UaJs3i19/VEEWWSrvrH4BG02 nid6UvgKA9VrFrpfY9CvGceKrcmUScKFDEGk9gVNWPetb5Ojo/2orY6sUkbZ01mJAZum R7kLlgrRqr+uYWPojHD3ROgZgzR6vN2k9OiipVlICpA7qboLPxPd89rAhoN8Hd+EiWd3 l3UH7GEBwNv19sOwb4wdQqs+gHnJD9joG5Ek826zuB/qKaUU5VpBgWC/x1HKnusZ85br bzSUgkila8gwuRv0J1oUtGF2R3NmqmBdwizS/kCKo/Dp24VxPKfxZgkcj8/k9jXhAmiV vYtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lt3BgpTFJ1RPgyyGpnoAE9m9bo/L3J4nb/f2r1TAJE4=; b=bDue7HXqQNs1UK/vt1BPDzKoRU3HjOWham0FDX7iy3epLerbytsxJGm3EwFlS4+4ee Q75DsD7qpVcLccNKbasd3my5cJAum0NlwHjSAaNVK2MwrmHTehrvNKdLW6Nk3VRS+wiY aiRXFlXrbQapWxsocm6jsDfulcODSeToW1mhiS3Cumi3OCzFwRdrt64/gjqI2YShdLuy FQUE2onNXW8K/s8VQDzm2X6ScYEmOQixN1aa2cDGIS6lx/NOMyqjdEe81RKjIzGfvA8b qFkyJxbQnY8Xx2hJGAazWtPzvp5frlu/qbnQ3FCRr6T4fb13pYSkO+qI0xylzumHS/1b duuw== X-Gm-Message-State: AOAM533JLE+SKckFAEl/SxJaenAA7vjOtqhcwQL0TI5nuJ0BT/Jk4K3d QdYNMwKKCgEeJcz7STvrpU1kUh2ovn8= X-Google-Smtp-Source: ABdhPJw4v8wqIv2kXPz6XdX1gYNdKo2TpRTWPUsH4PZDS1G6mB+zQtHuYZpw10u6dMYElaBmx+XQGg== X-Received: by 2002:a63:4661:: with SMTP id v33mr19347561pgk.163.1603757791197; Mon, 26 Oct 2020 17:16:31 -0700 (PDT) Received: from localhost.ibm.com (123-243-71-5.static.tpgi.com.au. [123.243.71.5]) by smtp.gmail.com with ESMTPSA id y8sm12926267pfg.104.2020.10.26.17.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 17:16:30 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 27 Oct 2020 11:16:12 +1100 Message-Id: <20201027001612.148724-4-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201027001612.148724-1-oohall@gmail.com> References: <20201027001612.148724-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 4/4] libflash/mbox: Use lpc fw space copy functions X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Oliver O'Halloran Reviewed-by: Vasant Hegde --- libflash/mbox-flash.c | 67 ++----------------------------------------- 1 file changed, 2 insertions(+), 65 deletions(-) diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c index 6da77d7fc9a0..f2f808cb432e 100644 --- a/libflash/mbox-flash.c +++ b/libflash/mbox-flash.c @@ -147,79 +147,16 @@ static int lpc_window_read(struct mbox_flash_data *mbox_flash, uint32_t pos, void *buf, uint32_t len) { uint32_t off = mbox_flash->read.lpc_addr + (pos - mbox_flash->read.cur_pos); - int rc; - - prlog(PR_TRACE, "Reading at 0x%08x for 0x%08x offset: 0x%08x\n", - pos, len, off); - - while(len) { - uint32_t chunk; - uint32_t dat; - - /* XXX: make this read until it's aligned */ - if (len > 3 && !(off & 3)) { - rc = lpc_read(OPAL_LPC_FW, off, &dat, 4); - if (!rc) { - /* - * lpc_read swaps to CPU endian but it's not - * really a 32-bit value, so convert back. - */ - *(__be32 *)buf = cpu_to_be32(dat); - } - chunk = 4; - } else { - rc = lpc_read(OPAL_LPC_FW, off, &dat, 1); - if (!rc) - *(uint8_t *)buf = dat; - chunk = 1; - } - if (rc) { - prlog(PR_ERR, "lpc_read failure %d to FW 0x%08x\n", rc, off); - return rc; - } - len -= chunk; - off += chunk; - buf += chunk; - } - return 0; + return lpc_fw_read(off, buf, len); } static int lpc_window_write(struct mbox_flash_data *mbox_flash, uint32_t pos, const void *buf, uint32_t len) { uint32_t off = mbox_flash->write.lpc_addr + (pos - mbox_flash->write.cur_pos); - int rc; - - - prlog(PR_TRACE, "Writing at 0x%08x for 0x%08x offset: 0x%08x\n", - pos, len, off); - while(len) { - uint32_t chunk; - - if (len > 3 && !(off & 3)) { - /* endian swap: see lpc_window_write */ - uint32_t dat = be32_to_cpu(*(__be32 *)buf); - - rc = lpc_write(OPAL_LPC_FW, off, dat, 4); - chunk = 4; - } else { - uint8_t dat = *(uint8_t *)buf; - - rc = lpc_write(OPAL_LPC_FW, off, dat, 1); - chunk = 1; - } - if (rc) { - prlog(PR_ERR, "lpc_write failure %d to FW 0x%08x\n", rc, off); - return rc; - } - len -= chunk; - off += chunk; - buf += chunk; - } - - return 0; + return lpc_fw_write(off, buf, len); } static uint64_t mbox_flash_mask(struct mbox_flash_data *mbox_flash)