From patchwork Wed Nov 2 05:43:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 690259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t7xqh0bRJz9t2G for ; Wed, 2 Nov 2016 16:44:16 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3t7xqg6qR9zDvPH for ; Wed, 2 Nov 2016 16:44:15 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3t7xqK3X9WzDvJV for ; Wed, 2 Nov 2016 16:43:57 +1100 (AEDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uA25hnvJ096887 for ; Wed, 2 Nov 2016 01:43:55 -0400 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0b-001b2d01.pphosted.com with ESMTP id 26f61hjkyb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 02 Nov 2016 01:43:54 -0400 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Nov 2016 15:43:52 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 2 Nov 2016 15:43:50 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id AC7833578058 for ; Wed, 2 Nov 2016 16:43:49 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uA25hnRC20840560 for ; Wed, 2 Nov 2016 16:43:49 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uA25hnFt004253 for ; Wed, 2 Nov 2016 16:43:49 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uA25hnSc004245; Wed, 2 Nov 2016 16:43:49 +1100 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 20849A01AB; Wed, 2 Nov 2016 16:43:49 +1100 (AEDT) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Wed, 2 Nov 2016 16:43:29 +1100 X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161102054329.9851-1-cyril.bur@au1.ibm.com> References: <20161102054329.9851-1-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110205-0004-0000-0000-000001AE22BB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110205-0005-0000-0000-000008FF71A5 Message-Id: <20161102054329.9851-2-cyril.bur@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-02_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611020106 Subject: [Skiboot] [PATCH 2/2] platforms/mambo: Support large unaligned reads X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Recent changes to the skiboot resource loading code means that reads for BOOTKERNEL and ROOTFS partitions will be exactly the number of bytes required and no longer the (inaccurate) partition total size which happened to be block size aligned. Error when booting in mambo: 1140078: (1140078): [ 0.001132323,3] FLASH: failed to read content size 14252376 BOOTKERNEL partition, rc -1 Signed-off-by: Cyril Bur [initial review and changes by Mikey Neuling] Signed-off-by: Michael Neuling --- platforms/mambo/mambo.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c index bd151ed..7f910b2 100644 --- a/platforms/mambo/mambo.c +++ b/platforms/mambo/mambo.c @@ -131,22 +131,29 @@ static int bogus_disk_read(struct blocklevel_device *bl, uint64_t pos, void *buf uint64_t len) { struct bogus_disk_info *bdi = bl->priv; - int rc; + int rc, read_sectors = 0; char b[BD_SECT_SZ]; - if ((len % BD_SECT_SZ) == 0) - return callthru_disk_read(bdi->id, buf, pos/BD_SECT_SZ, + if (len >= BD_SECT_SZ) { + rc = callthru_disk_read(bdi->id, buf, pos/BD_SECT_SZ, len/BD_SECT_SZ); + if (rc) + return rc; + read_sectors = (len / BD_SECT_SZ); + } - /* We don't support block reads > BD_SECT_SZ */ - if (len > BD_SECT_SZ) - return OPAL_PARAMETER; + if ((len % BD_SECT_SZ) == 0) + return 0; - /* Skiboot does small reads for system flash header checking */ - rc = callthru_disk_read(bdi->id, b, pos/BD_SECT_SZ, 1); + /* + * Read any unaligned data into a temporaty buffer b, then copy + * to buf + */ + rc = callthru_disk_read(bdi->id, b, (pos/BD_SECT_SZ) + read_sectors, 1); if (rc) return rc; - memcpy(buf, &b[pos % BD_SECT_SZ], len); + memcpy(buf + (read_sectors * BD_SECT_SZ) , &b[pos % BD_SECT_SZ], + len - (read_sectors * BD_SECT_SZ)); return rc; }