From patchwork Mon Feb 22 17:47:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Edmondson X-Patchwork-Id: 12099239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F77C433E6 for ; Mon, 22 Feb 2021 17:59:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D53964E15 for ; Mon, 22 Feb 2021 17:59:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D53964E15 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lEFUk-000416-7F for qemu-devel@archiver.kernel.org; Mon, 22 Feb 2021 12:59:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEFJd-00015d-56; Mon, 22 Feb 2021 12:48:13 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:34382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEFJZ-0001xz-48; Mon, 22 Feb 2021 12:48:12 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11MHk05J104190; Mon, 22 Feb 2021 17:48:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=n+lKAr5wPlx5Suvo076gmSldbFvr+FgIfT5qMxLaMws=; b=aflXo3YqhYOnwo+LvCQ45tjcltcVMOIpUQDQesEE9Frj9HaLwtk51d+n9wl1y0YcRjwy PDpqQYn7k55usWSoMkHgNCV40wG6TkCanlvgs279eDvAvmasDvCVeBE3+8wRVZzYRzJd UdXIPGhw+jQgJ+XaNuSUPumrOUlQzceIZKr6fZpHnDTNVmjTUDXJCBfpc7wvt8YovaHu gCn2GAK3d5tapoPd5Yn65bkKIw20GwJBDKkOu9yh1aWEuTPtKn/kcg12Nxo0hoLl1YLU TUOoYn3i5vsx0pYnMKaUc+c1NVM7IUMKhI5cadEyUewnqq/ndUkZCDkxT6rOMdMQZbQJ LQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 36tsuqvj2j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 17:48:06 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11MHkPu7106492; Mon, 22 Feb 2021 17:48:06 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by userp3030.oracle.com with ESMTP id 36ucbwdp2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 17:48:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DFskhWi/rbw7V53y3kjtuiGbr7D9xUIfZpAFhv7F9ErlTdhTEUdykQLIvdchU1b+A8c487fkyYCnwantH6lysBfaTCWzRJODqWLLHiTZavEtp8HJ0Vi3YlrTu3kj6C9mET5sj7x3wlq4XDvNDSPeTRJM87n0zd75ZYfbx77gyquAiAvA41yyW7/v77qmvTi14zbEq24uuqLXXa2h3+JxA9gUq4OyMQG5KMwB5wag0pwrv6N5PM/+fMGfndEg4aJ59aV6FRfFFYdWMBl6FoY/7sgribf1HF6yc60Qae5qZybh3AyM6fV9Iz5m3zNazj3Cr0/U7sWPid+vxJtG+YdNrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n+lKAr5wPlx5Suvo076gmSldbFvr+FgIfT5qMxLaMws=; b=AsnjR4+q+Q2HMuBG8uUf0EmE9shXGo76kCm1vkGpJL/BO7a+xIlTjYS5vvH9ZaSqmBSjoFDtk0DbcjbBc/Ej/TRJSwR4MGjMC5D63/u2xkGQks0CdRFD32eTYYyKolrYm9K6v9m94r43XwS/vgzMVxS2cJOG1NqAw/Mfv8OzAZjm09Trfb4h0JyNgCKjtyfCq2GJxUq54fkpkn++KD1iwtcN7+zlCCvrXVBbKYMyndjZaRbBtfab8rGkt/+nb9A/+tGidIHp9AQIRXwtknNRXWN9OzIQiB0bfR7IJ8JEtERXELC22RTMjf6DR3iAVP18TKlYRjdzHsMBd0403Y7nKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n+lKAr5wPlx5Suvo076gmSldbFvr+FgIfT5qMxLaMws=; b=jeOKnwXtB5mlYjNTJYcvtF1SeIXVIau3C4GQgdE7S2uJ182CcaCXvxWEQ6EaCti3Z06UUzhkBCJXYgWMBAa8cO+ff66fB3eJDz+GrH6rHYji+CzsaIoJK/+DXS/9kIh7NegungzZfgP2hBrzMV+vEh6v/k1C+XLsvV02g7568kk= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=oracle.com; Received: from DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) by DM6PR10MB3466.namprd10.prod.outlook.com (2603:10b6:5:17e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.31; Mon, 22 Feb 2021 17:48:04 +0000 Received: from DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934]) by DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934%5]) with mapi id 15.20.3868.033; Mon, 22 Feb 2021 17:48:04 +0000 From: David Edmondson To: qemu-devel@nongnu.org Subject: [RFC PATCH v3 1/3] hw/pflash_cfi*: Replace DPRINTF with trace events Date: Mon, 22 Feb 2021 17:47:55 +0000 Message-Id: <20210222174757.2329740-2-david.edmondson@oracle.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210222174757.2329740-1-david.edmondson@oracle.com> References: <20210222174757.2329740-1-david.edmondson@oracle.com> X-Originating-IP: [2001:8b0:bb71:7140:64::1] X-ClientProxiedBy: LO2P265CA0448.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::28) To DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from disaster-area.hh.sledj.net (2001:8b0:bb71:7140:64::1) by LO2P265CA0448.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.31 via Frontend Transport; Mon, 22 Feb 2021 17:48:02 +0000 Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 6169700c; Mon, 22 Feb 2021 17:47:57 +0000 (UTC) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f817c62a-afe6-4e69-841f-08d8d75a00fe X-MS-TrafficTypeDiagnostic: DM6PR10MB3466: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NHkSNAUxmHFuHLRyimNAdtOcMip/K37ehf04HQNt9Epq7Gb2NDqUG6achDdh4hctHjejq8n30/htvw6NEukplSieDA9pUjb/q2tv1NnMlXWBGtZV/rRHeQhFH6NkgSGrHrTig+Fclki4TzgAZ/jADE258HohsEshqf0pvWZ0acvsptiOpp2asIf7bd6M8WX7/ZI/tiyhmPpZSMyoytutXz0jYBj1v5woBCXhtS5ChuOABIIZxFB30cQBQcypM5wtaty+n1iIZLiAn3pKl2ZD/uic6C/FZ0SjZAXIPy0pfOULAutUtmOppniqEruSeEFID5zEI2Hzl+7u5po/PcGMPTEdcSkrXakCUIejIZrr9MExlATDWR9BDsjokDyPU+pUrsyIYkPjTB3upbdYtCNI331ckXIwmcpdk+1zGyBcVjSL/cdmmKdCaI+TsFu34bE8UU02hA9bNItvdeDBAEvcSz1KFwXZHdqU6qOJbZJ0vxRmbsWSA7sPcxdP8RfqcbraRxvLWuZow7HQI9WXk9ov4Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR10MB3148.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(136003)(346002)(366004)(39860400002)(376002)(54906003)(478600001)(44832011)(316002)(83380400001)(52116002)(86362001)(186003)(66946007)(66476007)(66556008)(36756003)(8936002)(107886003)(4326008)(5660300002)(30864003)(2616005)(1076003)(8676002)(2906002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?0WC03Wktl5UkoRaSv2d5og5Pa85z3p?= =?utf-8?q?nh6OY8ZGO2lq1i7FCPfXswiYNiEH/cWhCwV9cD3Iejr6nkYQpTANSmh95w/ig3ztl?= =?utf-8?q?3g36PL96ElPVDEz1t5JSPbzbqQpBMsFEWGGMNDryW6bq/6IjoNVviAwBk5gObjLj3?= =?utf-8?q?EiCnjTJCzCGKv3IkhDDDBC6K62vT7Sj6zY5kTuaPzgxUngAa/atHtxg3GI82de1hf?= =?utf-8?q?MnD4IJZlwUzV/VMz01rGUp0hrfQBdO3bK0eYFPthaQnl/D0LuSSlPONb2r0mnYlVO?= =?utf-8?q?udiujWKbKvjrNuuZDpvU7hNeSKdC3MGzAYhN4xtRbY+DByqt6eYfAsLYRGyrlbUhA?= =?utf-8?q?h2w2sprrB4sJoyp/tTf0wKu7Z/yxDQMVAIx//S4nD3cQDRMmypePSPHmQj3Kt8bS3?= =?utf-8?q?ZgExmawPYQCXJzfGYmhBTLL70W57dTPQJw0nEDzCL7G3Lp3uvnpkosj4zubiVlonc?= =?utf-8?q?eCASY3eonK/ak3j8bxy5mOExry3xmjxPnGjhsaCaMa0RcXToIcS9irMZLWYpEjL7O?= =?utf-8?q?0TgYSDh91LrMQM3zLVh4p6Rg2qca9G7TuQXw7y6kmLywpRlpxFlHNtcVcqEq5j01x?= =?utf-8?q?nrWKI2pmJm793zhZQyVDfofSngKrEQX6O7wofa8NqGMeWZL4lFwuOWQZaAU5b9Hww?= =?utf-8?q?wYGrYwdzpkT4DMBGgZrjx7OVSBkjU+TFQzJbfHjeXtAMbO1y3jOel+qVwmNlBZy+p?= =?utf-8?q?a6dXWBo8xZc6bPX8dZ9XL2MQto2CaTOJeUQZhUElgmybLDXYs8YqkwSrPpz0k8HmC?= =?utf-8?q?5JXIbXLcIog7ODXR1eO0v80QIPUBmu/qRYItKp8gTljdFiEvmim2JtL1NzL0SIC9v?= =?utf-8?q?5sOHM53icrMzSD5rSEAKFV70JDp0BKSJwe01KMrHWjpFoLPZp5lddbcP02hsYAWOS?= =?utf-8?q?86DZlBmu/cng0Owl3bL5pvCpaji5ll+lAKxXvDSgw2oAt8wulvstaKtb8iXiuiLYP?= =?utf-8?q?8ZzwrW/W/L7dEsk6/HcUsrBk8fStwCKyEmAsPyPtU4m2sR0bxA4rdoONF57njNPzR?= =?utf-8?q?WkzBzP5OHHIjxPYkSZMdoNZMoUqv2lviUXKgG+YskTMizj5sM/F+9MGGcMq+6ia2M?= =?utf-8?q?O1VCunfYo7rx4LtF3smeRagznmwdN6r66orqWbN/kZa4CgUQRUIbTm5gyMjQe+jam?= =?utf-8?q?Kp7skRq++w2fSYS1nMKItFjyoIQgeQobBYd0pWKfYFUBl7NLORliA402X113smR/y?= =?utf-8?q?tZz8MacaC2adDzIrBoq5Rq91PsqvlOVUwcdxQewYoEzHxNdZc0E38Qha/zpmANQ0M?= =?utf-8?q?pMnWTphKEPuc00Z3fJJGNRDu1PktDtNpL84g=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f817c62a-afe6-4e69-841f-08d8d75a00fe X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3148.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2021 17:48:03.8922 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5sxtL3q+iHuhvWfG4j1ewtOQGfhxf/xTX8kO8Kig9VdFqFZ13bqYR0QkJPYcndGGfWh+NevoSQ/t5CN8y0h8WtlXO8BQ3FFISlOAS1c4O9M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3466 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9903 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220158 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9903 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 mlxscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220158 Received-SPF: pass client-ip=156.151.31.86; envelope-from=david.edmondson@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , David Edmondson , =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Rather than having a device specific debug implementation in pflash_cfi01.c and pflash_cfi02.c, use the standard tracing facility. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: David Edmondson --- hw/block/pflash_cfi01.c | 78 +++++++++++++++++------------------------ hw/block/pflash_cfi02.c | 75 +++++++++++++++------------------------ hw/block/trace-events | 39 ++++++++++++++++----- 3 files changed, 91 insertions(+), 101 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 22287a1522..9e1f3b42c6 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -56,16 +56,6 @@ #include "sysemu/runstate.h" #include "trace.h" -/* #define PFLASH_DEBUG */ -#ifdef PFLASH_DEBUG -#define DPRINTF(fmt, ...) \ -do { \ - fprintf(stderr, "PFLASH: " fmt , ## __VA_ARGS__); \ -} while (0) -#else -#define DPRINTF(fmt, ...) do { } while (0) -#endif - #define PFLASH_BE 0 #define PFLASH_SECURE 1 @@ -152,10 +142,8 @@ static uint32_t pflash_cfi_query(PFlashCFI01 *pfl, hwaddr offset) * wider part. */ if (pfl->device_width != 1 || pfl->bank_width > 4) { - DPRINTF("%s: Unsupported device configuration: " - "device_width=%d, max_device_width=%d\n", - __func__, pfl->device_width, - pfl->max_device_width); + trace_pflash_unsupported_device_configuration( + pfl->name, pfl->device_width, pfl->max_device_width); return 0; } /* CFI query data is repeated, rather than zero padded for @@ -205,14 +193,14 @@ static uint32_t pflash_devid_query(PFlashCFI01 *pfl, hwaddr offset) switch (boff & 0xFF) { case 0: resp = pfl->ident0; - trace_pflash_manufacturer_id(resp); + trace_pflash_manufacturer_id(pfl->name, resp); break; case 1: resp = pfl->ident1; - trace_pflash_device_id(resp); + trace_pflash_device_id(pfl->name, resp); break; default: - trace_pflash_device_info(offset); + trace_pflash_device_info(pfl->name, offset); return 0; } /* Replicate responses for each device in bank. */ @@ -260,10 +248,9 @@ static uint32_t pflash_data_read(PFlashCFI01 *pfl, hwaddr offset, } break; default: - DPRINTF("BUG in %s\n", __func__); abort(); } - trace_pflash_data_read(offset, width, ret); + trace_pflash_data_read(pfl->name, offset, width, ret); return ret; } @@ -277,7 +264,7 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset, switch (pfl->cmd) { default: /* This should never happen : reset state & treat it as a read */ - DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd); + trace_pflash_read_unknown_state(pfl->name, pfl->cmd); pfl->wcycle = 0; /* * The command 0x00 is not assigned by the CFI open standard, @@ -313,7 +300,7 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset, */ ret |= pfl->status << 16; } - DPRINTF("%s: status %x\n", __func__, ret); + trace_pflash_read_status(pfl->name, ret); break; case 0x90: if (!pfl->device_width) { @@ -328,14 +315,14 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset, switch (boff) { case 0: ret = pfl->ident0 << 8 | pfl->ident1; - trace_pflash_manufacturer_id(ret); + trace_pflash_manufacturer_id(pfl->name, ret); break; case 1: ret = pfl->ident2 << 8 | pfl->ident3; - trace_pflash_device_id(ret); + trace_pflash_device_id(pfl->name, ret); break; default: - trace_pflash_device_info(boff); + trace_pflash_device_info(pfl->name, boff); ret = 0; break; } @@ -380,7 +367,7 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset, break; } - trace_pflash_io_read(offset, width, ret, pfl->cmd, pfl->wcycle); + trace_pflash_io_read(pfl->name, offset, width, ret, pfl->cmd, pfl->wcycle); return ret; } @@ -410,7 +397,7 @@ static inline void pflash_data_write(PFlashCFI01 *pfl, hwaddr offset, { uint8_t *p = pfl->storage; - trace_pflash_data_write(offset, width, value, pfl->counter); + trace_pflash_data_write(pfl->name, offset, width, value, pfl->counter); switch (width) { case 1: p[offset] = value; @@ -449,7 +436,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, cmd = value; - trace_pflash_io_write(offset, width, value, pfl->wcycle); + trace_pflash_io_write(pfl->name, offset, width, value, pfl->wcycle); if (!pfl->wcycle) { /* Set the device in I/O access mode */ memory_region_rom_device_set_romd(&pfl->mem, false); @@ -463,14 +450,13 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, goto mode_read_array; case 0x10: /* Single Byte Program */ case 0x40: /* Single Byte Program */ - DPRINTF("%s: Single Byte Program\n", __func__); + trace_pflash_write(pfl->name, "single byte program (0)"); break; case 0x20: /* Block erase */ p = pfl->storage; offset &= ~(pfl->sector_len - 1); - DPRINTF("%s: block erase at " TARGET_FMT_plx " bytes %x\n", - __func__, offset, (unsigned)pfl->sector_len); + trace_pflash_write_block_erase(pfl->name, offset, pfl->sector_len); if (!pfl->ro) { memset(p + offset, 0xff, pfl->sector_len); @@ -481,25 +467,25 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, pfl->status |= 0x80; /* Ready! */ break; case 0x50: /* Clear status bits */ - DPRINTF("%s: Clear status bits\n", __func__); + trace_pflash_write(pfl->name, "clear status bits"); pfl->status = 0x0; goto mode_read_array; case 0x60: /* Block (un)lock */ - DPRINTF("%s: Block unlock\n", __func__); + trace_pflash_write(pfl->name, "block unlock"); break; case 0x70: /* Status Register */ - DPRINTF("%s: Read status register\n", __func__); + trace_pflash_write(pfl->name, "read status register"); pfl->cmd = cmd; return; case 0x90: /* Read Device ID */ - DPRINTF("%s: Read Device information\n", __func__); + trace_pflash_write(pfl->name, "read device information"); pfl->cmd = cmd; return; case 0x98: /* CFI query */ - DPRINTF("%s: CFI query\n", __func__); + trace_pflash_write(pfl->name, "CFI query"); break; case 0xe8: /* Write to buffer */ - DPRINTF("%s: Write to buffer\n", __func__); + trace_pflash_write(pfl->name, "write to buffer"); /* FIXME should save @offset, @width for case 1+ */ qemu_log_mask(LOG_UNIMP, "%s: Write to buffer emulation is flawed\n", @@ -507,10 +493,10 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, pfl->status |= 0x80; /* Ready! */ break; case 0xf0: /* Probe for AMD flash */ - DPRINTF("%s: Probe for AMD flash\n", __func__); + trace_pflash_write(pfl->name, "probe for AMD flash"); goto mode_read_array; case 0xff: /* Read Array */ - DPRINTF("%s: Read array mode\n", __func__); + trace_pflash_write(pfl->name, "read array mode"); goto mode_read_array; default: goto error_flash; @@ -522,7 +508,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, switch (pfl->cmd) { case 0x10: /* Single Byte Program */ case 0x40: /* Single Byte Program */ - DPRINTF("%s: Single Byte Program\n", __func__); + trace_pflash_write(pfl->name, "single byte program (1)"); if (!pfl->ro) { pflash_data_write(pfl, offset, value, width, be); pflash_update(pfl, offset, width); @@ -553,7 +539,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, } else { value = extract32(value, 0, pfl->bank_width * 8); } - DPRINTF("%s: block write of %x bytes\n", __func__, value); + trace_pflash_write_block(pfl->name, value); pfl->counter = value; pfl->wcycle++; break; @@ -567,7 +553,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, } else if (cmd == 0xff) { /* Read Array */ goto mode_read_array; } else { - DPRINTF("%s: Unknown (un)locking command\n", __func__); + trace_pflash_write(pfl->name, "unknown (un)locking command"); goto mode_read_array; } break; @@ -575,7 +561,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, if (cmd == 0xff) { /* Read Array */ goto mode_read_array; } else { - DPRINTF("%s: leaving query mode\n", __func__); + trace_pflash_write(pfl->name, "leaving query mode"); } break; default: @@ -603,7 +589,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, hwaddr mask = pfl->writeblock_size - 1; mask = ~mask; - DPRINTF("%s: block write finished\n", __func__); + trace_pflash_write(pfl->name, "block write finished"); pfl->wcycle++; if (!pfl->ro) { /* Flush the entire write buffer onto backing storage. */ @@ -642,7 +628,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, break; default: /* Should never happen */ - DPRINTF("%s: invalid write state\n", __func__); + trace_pflash_write(pfl->name, "invalid write state"); goto mode_read_array; } return; @@ -653,7 +639,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, "\n", __func__, offset, pfl->wcycle, pfl->cmd, value); mode_read_array: - trace_pflash_reset(); + trace_pflash_reset(pfl->name); memory_region_rom_device_set_romd(&pfl->mem, true); pfl->wcycle = 0; pfl->cmd = 0x00; /* This model reset value for READ_ARRAY (not CFI) */ @@ -1022,7 +1008,7 @@ static void postload_update_cb(void *opaque, int running, RunState state) qemu_del_vm_change_state_handler(pfl->vmstate); pfl->vmstate = NULL; - DPRINTF("%s: updating bdrv for %s\n", __func__, pfl->name); + trace_pflash_postload_cb(pfl->name); pflash_update(pfl, 0, pfl->sector_len * pfl->nb_blocs); } diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 7962cff745..b6de18d3ad 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -48,14 +48,6 @@ #include "migration/vmstate.h" #include "trace.h" -#define PFLASH_DEBUG false -#define DPRINTF(fmt, ...) \ -do { \ - if (PFLASH_DEBUG) { \ - fprintf(stderr, "PFLASH: " fmt, ## __VA_ARGS__); \ - } \ -} while (0) - #define PFLASH_LAZY_ROMD_THRESHOLD 42 /* @@ -220,7 +212,7 @@ static void pflash_timer(void *opaque) { PFlashCFI02 *pfl = opaque; - trace_pflash_timer_expired(pfl->cmd); + trace_pflash_timer_expired(pfl->name, pfl->cmd); if (pfl->cmd == 0x30) { /* * Sector erase. If DQ3 is 0 when the timer expires, then the 50 @@ -233,11 +225,10 @@ static void pflash_timer(void *opaque) uint64_t timeout = pflash_erase_time(pfl); timer_mod(&pfl->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + timeout); - DPRINTF("%s: erase timeout fired; erasing %d sectors\n", - __func__, pfl->sectors_to_erase); + trace_pflash_erase_timeout(pfl->name, pfl->sectors_to_erase); return; } - DPRINTF("%s: sector erase complete\n", __func__); + trace_pflash_erase_complete(pfl->name); bitmap_zero(pfl->sector_erase_map, pfl->total_sectors); pfl->sectors_to_erase = 0; reset_dq3(pfl); @@ -262,7 +253,7 @@ static uint64_t pflash_data_read(PFlashCFI02 *pfl, hwaddr offset, { uint8_t *p = (uint8_t *)pfl->storage + offset; uint64_t ret = pfl->be ? ldn_be_p(p, width) : ldn_le_p(p, width); - trace_pflash_data_read(offset, width, ret); + trace_pflash_data_read(pfl->name, offset, width, ret); return ret; } @@ -325,7 +316,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width) switch (pfl->cmd) { default: /* This should never happen : reset state & treat it as a read*/ - DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd); + trace_pflash_read_unknown_state(pfl->name, pfl->cmd); pfl->wcycle = 0; pfl->cmd = 0; /* fall through to the read code */ @@ -338,7 +329,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width) toggle_dq2(pfl); /* Status register read */ ret = pfl->status; - DPRINTF("%s: status %" PRIx64 "\n", __func__, ret); + trace_pflash_read_status(pfl->name, ret); break; } /* Flash area read */ @@ -363,7 +354,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width) default: ret = pflash_data_read(pfl, offset, width); } - DPRINTF("%s: ID " TARGET_FMT_plx " %" PRIx64 "\n", __func__, boff, ret); + trace_pflash_read_done(pfl->name, boff, ret); break; case 0x10: /* Chip Erase */ case 0x30: /* Sector Erase */ @@ -375,7 +366,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width) toggle_dq6(pfl); /* Status register read */ ret = pfl->status; - DPRINTF("%s: status %" PRIx64 "\n", __func__, ret); + trace_pflash_read_status(pfl->name, ret); break; case 0x98: /* CFI query mode */ @@ -386,7 +377,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width) } break; } - trace_pflash_io_read(offset, width, ret, pfl->cmd, pfl->wcycle); + trace_pflash_io_read(pfl->name, offset, width, ret, pfl->cmd, pfl->wcycle); return ret; } @@ -415,9 +406,8 @@ static void pflash_sector_erase(PFlashCFI02 *pfl, hwaddr offset) SectorInfo sector_info = pflash_sector_info(pfl, offset); uint64_t sector_len = sector_info.len; offset &= ~(sector_len - 1); - DPRINTF("%s: start sector erase at %0*" PRIx64 "-%0*" PRIx64 "\n", - __func__, pfl->width * 2, offset, - pfl->width * 2, offset + sector_len - 1); + trace_pflash_sector_erase_start(pfl->name, pfl->width * 2, offset, + pfl->width * 2, offset + sector_len - 1); if (!pfl->ro) { uint8_t *p = pfl->storage; memset(p + offset, 0xff, sector_len); @@ -438,7 +428,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, uint8_t *p; uint8_t cmd; - trace_pflash_io_write(offset, width, value, pfl->wcycle); + trace_pflash_io_write(pfl->name, offset, width, value, pfl->wcycle); cmd = value; if (pfl->cmd != 0xA0) { /* Reset does nothing during chip erase and sector erase. */ @@ -496,27 +486,24 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, return; } if (boff != pfl->unlock_addr0 || cmd != 0xAA) { - DPRINTF("%s: unlock0 failed " TARGET_FMT_plx " %02x %04x\n", - __func__, boff, cmd, pfl->unlock_addr0); + trace_pflash_unlock0_failed(pfl->name, boff, cmd, pfl->unlock_addr0); goto reset_flash; } - DPRINTF("%s: unlock sequence started\n", __func__); + trace_pflash_write(pfl->name, "unlock sequence started"); break; case 1: /* We started an unlock sequence */ check_unlock1: if (boff != pfl->unlock_addr1 || cmd != 0x55) { - DPRINTF("%s: unlock1 failed " TARGET_FMT_plx " %02x\n", __func__, - boff, cmd); + trace_pflash_unlock1_failed(pfl->name, boff, cmd); goto reset_flash; } - DPRINTF("%s: unlock sequence done\n", __func__); + trace_pflash_write(pfl->name, "unlock sequence done"); break; case 2: /* We finished an unlock sequence */ if (!pfl->bypass && boff != pfl->unlock_addr0) { - DPRINTF("%s: command failed " TARGET_FMT_plx " %02x\n", __func__, - boff, cmd); + trace_pflash_write_failed(pfl->name, boff, cmd); goto reset_flash; } switch (cmd) { @@ -527,10 +514,10 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, case 0x90: /* Autoselect */ case 0xA0: /* Program */ pfl->cmd = cmd; - DPRINTF("%s: starting command %02x\n", __func__, cmd); + trace_pflash_write_start(pfl->name, cmd); break; default: - DPRINTF("%s: unknown command %02x\n", __func__, cmd); + trace_pflash_write_unknown(pfl->name, cmd); goto reset_flash; } break; @@ -548,7 +535,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, } goto reset_flash; } - trace_pflash_data_write(offset, width, value, 0); + trace_pflash_data_write(pfl->name, offset, width, value, 0); if (!pfl->ro) { p = (uint8_t *)pfl->storage + offset; if (pfl->be) { @@ -586,8 +573,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, } /* fall through */ default: - DPRINTF("%s: invalid write for command %02x\n", - __func__, pfl->cmd); + trace_pflash_write_invalid(pfl->name, pfl->cmd); goto reset_flash; } case 4: @@ -600,8 +586,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, goto check_unlock1; default: /* Should never happen */ - DPRINTF("%s: invalid command state %02x (wc 4)\n", - __func__, pfl->cmd); + trace_pflash_write_invalid_state(pfl->name, pfl->cmd, 5); goto reset_flash; } break; @@ -613,12 +598,11 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, switch (cmd) { case 0x10: /* Chip Erase */ if (boff != pfl->unlock_addr0) { - DPRINTF("%s: chip erase: invalid address " TARGET_FMT_plx "\n", - __func__, offset); + trace_pflash_chip_erase_invalid(pfl->name, offset); goto reset_flash; } /* Chip erase */ - DPRINTF("%s: start chip erase\n", __func__); + trace_pflash_chip_erase_start(pfl->name); if (!pfl->ro) { memset(pfl->storage, 0xff, pfl->chip_len); pflash_update(pfl, 0, pfl->chip_len); @@ -632,7 +616,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, pflash_sector_erase(pfl, offset); break; default: - DPRINTF("%s: invalid command %02x (wc 5)\n", __func__, cmd); + trace_pflash_write_invalid_command(pfl->name, cmd); goto reset_flash; } pfl->cmd = cmd; @@ -683,19 +667,18 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, return; default: /* Should never happen */ - DPRINTF("%s: invalid command state %02x (wc 6)\n", - __func__, pfl->cmd); + trace_pflash_write_invalid_state(pfl->name, pfl->cmd, 6); goto reset_flash; } break; /* Special values for CFI queries */ case WCYCLE_CFI: case WCYCLE_AUTOSELECT_CFI: - DPRINTF("%s: invalid write in CFI query mode\n", __func__); + trace_pflash_write(pfl->name, "invalid write in CFI query mode"); goto reset_flash; default: /* Should never happen */ - DPRINTF("%s: invalid write state (wc 7)\n", __func__); + trace_pflash_write(pfl->name, "invalid write state (wc 7)"); goto reset_flash; } pfl->wcycle++; @@ -704,7 +687,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value, /* Reset flash */ reset_flash: - trace_pflash_reset(); + trace_pflash_reset(pfl->name); pfl->bypass = 0; pfl->wcycle = 0; pfl->cmd = 0; diff --git a/hw/block/trace-events b/hw/block/trace-events index c1537e3ac0..a715a2e173 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -6,15 +6,36 @@ fdc_ioport_write(uint8_t reg, uint8_t value) "write reg 0x%02x val 0x%02x" # pflash_cfi01.c # pflash_cfi02.c -pflash_reset(void) "reset" -pflash_timer_expired(uint8_t cmd) "command 0x%02x done" -pflash_io_read(uint64_t offset, unsigned size, uint32_t value, uint8_t cmd, uint8_t wcycle) "offset:0x%04"PRIx64" size:%u value:0x%04x cmd:0x%02x wcycle:%u" -pflash_io_write(uint64_t offset, unsigned size, uint32_t value, uint8_t wcycle) "offset:0x%04"PRIx64" size:%u value:0x%04x wcycle:%u" -pflash_data_read(uint64_t offset, unsigned size, uint32_t value) "data offset:0x%04"PRIx64" size:%u value:0x%04x" -pflash_data_write(uint64_t offset, unsigned size, uint32_t value, uint64_t counter) "data offset:0x%04"PRIx64" size:%u value:0x%04x counter:0x%016"PRIx64 -pflash_manufacturer_id(uint16_t id) "Read Manufacturer ID: 0x%04x" -pflash_device_id(uint16_t id) "Read Device ID: 0x%04x" -pflash_device_info(uint64_t offset) "Read Device Information offset:0x%04"PRIx64 +pflash_chip_erase_invalid(const char *name, uint64_t offset) "%s: chip erase: invalid address 0x%" PRIx64 +pflash_chip_erase_start(const char *name) "%s: start chip erase" +pflash_data_read(const char *name, uint64_t offset, unsigned size, uint32_t value) "%s: data offset:0x%04"PRIx64" size:%u value:0x%04x" +pflash_data_write(const char *name, uint64_t offset, unsigned size, uint32_t value, uint64_t counter) "%s: data offset:0x%04"PRIx64" size:%u value:0x%04x counter:0x%016"PRIx64 +pflash_device_id(const char *name, uint16_t id) "%s: read device ID: 0x%04x" +pflash_device_info(const char *name, uint64_t offset) "%s: read device information offset:0x%04" PRIx64 +pflash_erase_complete(const char *name) "%s: sector erase complete" +pflash_erase_timeout(const char *name, int count) "%s: erase timeout fired; erasing %d sectors" +pflash_io_read(const char *name, uint64_t offset, unsigned int size, uint32_t value, uint8_t cmd, uint8_t wcycle) "%s: offset:0x%04" PRIx64 " size:%u value:0x%04x cmd:0x%02x wcycle:%u" +pflash_io_write(const char *name, uint64_t offset, unsigned int size, uint32_t value, uint8_t wcycle) "%s: offset:0x%04"PRIx64" size:%u value:0x%04x wcycle:%u" +pflash_manufacturer_id(const char *name, uint16_t id) "%s: read manufacturer ID: 0x%04x" +pflash_postload_cb(const char *name) "%s: updating bdrv" +pflash_read_done(const char *name, uint64_t offset, uint64_t ret) "%s: ID:0x%" PRIx64 " ret:0x%" PRIx64 +pflash_read_status(const char *name, uint32_t ret) "%s: status:0x%x" +pflash_read_unknown_state(const char *name, uint8_t cmd) "%s: unknown command state:0x%x" +pflash_reset(const char *name) "%s: reset" +pflash_sector_erase_start(const char *name, int width1, uint64_t start, int width2, uint64_t end) "%s: start sector erase at: 0x%0*" PRIx64 "-0x%0*" PRIx64 +pflash_timer_expired(const char *name, uint8_t cmd) "%s: command 0x%02x done" +pflash_unlock0_failed(const char *name, uint64_t offset, uint8_t cmd, uint16_t addr0) "%s: unlock0 failed 0x%" PRIx64 " 0x%02x 0x%04x" +pflash_unlock1_failed(const char *name, uint64_t offset, uint8_t cmd) "%s: unlock0 failed 0x%" PRIx64 " 0x%02x" +pflash_unsupported_device_configuration(const char *name, uint8_t width, uint8_t max) "%s: unsupported device configuration: device_width:%d max_device_width:%d" +pflash_write(const char *name, const char *str) "%s: %s" +pflash_write_block(const char *name, uint32_t value) "%s: block write: bytes:0x%x" +pflash_write_block_erase(const char *name, uint64_t offset, uint64_t len) "%s: block erase offset:0x%" PRIx64 " bytes:0x%lx" +pflash_write_failed(const char *name, uint64_t offset, uint8_t cmd) "%s: command failed 0x%" PRIx64 " 0x%02x" +pflash_write_invalid(const char *name, uint8_t cmd) "%s: invalid write for command 0x%02x" +pflash_write_invalid_command(const char *name, uint8_t cmd) "%s: invalid command 0x%02x (wc 5)" +pflash_write_invalid_state(const char *name, uint8_t cmd, int wc) "%s: invalid command state 0x%02x (wc %d)" +pflash_write_start(const char *name, uint8_t cmd) "%s: starting command 0x%02x" +pflash_write_unknown(const char *name, uint8_t cmd) "%s: unknown command 0x%02x" # virtio-blk.c virtio_blk_req_complete(void *vdev, void *req, int status) "vdev %p req %p status %d" From patchwork Mon Feb 22 17:47:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Edmondson X-Patchwork-Id: 12099233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A00EC433DB for ; Mon, 22 Feb 2021 17:50:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E510E6186A for ; Mon, 22 Feb 2021 17:50:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E510E6186A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lEFLt-0002vW-18 for qemu-devel@archiver.kernel.org; Mon, 22 Feb 2021 12:50:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEFJb-00013N-VW; Mon, 22 Feb 2021 12:48:11 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:34386) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEFJZ-0001y2-5p; Mon, 22 Feb 2021 12:48:11 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11MHk3r6104226; Mon, 22 Feb 2021 17:48:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=jk2R58gq0UYjjMx2VkQKAlIeZKH8PUpycv1oXRGJIC8=; b=lpyjrJsubpIU5OpfM/22KD4YLbZkBc6ItWcktCpXfiHatP0ii4RXo7KTXIfg252zE93u OnjxnV1qQFiAD6x6nosge5hnHSPOMwhkQeaCGYjf/zcnmV4Akz7OEP3eCRgvZfhiRcfb 7+wdFSrmHv5AooqMEgUWl5AP1sdxe7/kK+uT5kFzqLXM5ng0wd6Ihu/5kLmZqO+oBaT5 CDwVahAIUWSAndsAw0kmPVtW23v1l1v9PtOLNSSXx+elBycWcINtcqd5trDPVlweW2bl E3amEtZE1yUm7Sinvzw/p127rIb5qxXUgUtFWWMbux4J+J6KkYMtQAzxgYFAD9KuarEE Sw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 36tsuqvj2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 17:48:07 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11MHkPu8106492; Mon, 22 Feb 2021 17:48:07 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by userp3030.oracle.com with ESMTP id 36ucbwdp2k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 17:48:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=geVJfkoYPoBz1oC0kg4ViheExqOpEAjL8tAliDaHzG9aqQlKEIZ8/SLggE4CPPYQIXZBPYdnv9FWZgVoddMJdcE1uJqYhVydxL2XbwrUn23amTq3i+PsyKrIe5Yjug5FJFlz/wBTXgalB4xzvJS2QEP97Z8Y246VhcgmZU3sult7lKVb34cH2Tnfxgzrr6C21NryPovvYH13R2o8SyTB/OVME+ew/boxfXYDGY1BhHo2SVeRGjue8VbcQ9AYhDqZ+DYdnFmUG0TCl7EwahoI4GtSvVIzXh5HO+8caVnkxQaCAvTLlV8OcNazfny+T5vstqvHXmWANNRUjFk+Q/fdjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jk2R58gq0UYjjMx2VkQKAlIeZKH8PUpycv1oXRGJIC8=; b=Mmyn25DL5PIFTgJMSTlUO/u7BB3Y2zXwxDj6QqZlsAiKS/vgExjvKTyVYfmbKe1m93uQgWLNdAbVwNV2+J8+aZwBn0UdocXFxUjUKEjUHWxdOfCmh+a4dElM5p8QYbHLB3HmGHjsv2P3AZ9d9LlhRDE2rPVIxOiNXMsHIMivrQF3Vyr9rwS/oDY0KHo0H3MBhGlDu21jk+SuKsljsBVnfF1NnY7CoBKjc+ap+2x5p2ouDV0vR9UqKGicOXISp5d7/OJ/XpvRVQfTjf8O9Vkq23UFRQwe0wcFHVj6hiCJd7zMpEZZMt1dx6g6eKbblOZBl8I5FVx0ab+yXdH0Kj12RA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jk2R58gq0UYjjMx2VkQKAlIeZKH8PUpycv1oXRGJIC8=; b=sWJj/3nsRS7PnW4BicCgUiNf/xaY1/6nGzEIIkJhWOSSpcjw9T5g1Cvwu2SG4wqpW0j0K9oNXyCT8fTr+pF6fI/v2bOW95lRhV+asH6e1mv0Y1CjmlaCLo5qaUbqS6k8fsB9sBNpH5w4iiJbSpja5t/Jb2tkhlC2ZwTR0iVC8KA= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=oracle.com; Received: from DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) by DM6PR10MB3466.namprd10.prod.outlook.com (2603:10b6:5:17e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.31; Mon, 22 Feb 2021 17:48:05 +0000 Received: from DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934]) by DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934%5]) with mapi id 15.20.3868.033; Mon, 22 Feb 2021 17:48:05 +0000 From: David Edmondson To: qemu-devel@nongnu.org Subject: [RFC PATCH v3 2/3] hw/pflash_cfi01: Correct the type of PFlashCFI01.ro Date: Mon, 22 Feb 2021 17:47:56 +0000 Message-Id: <20210222174757.2329740-3-david.edmondson@oracle.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210222174757.2329740-1-david.edmondson@oracle.com> References: <20210222174757.2329740-1-david.edmondson@oracle.com> X-Originating-IP: [2001:8b0:bb71:7140:64::1] X-ClientProxiedBy: LO2P265CA0448.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::28) To DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from disaster-area.hh.sledj.net (2001:8b0:bb71:7140:64::1) by LO2P265CA0448.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.31 via Frontend Transport; Mon, 22 Feb 2021 17:48:04 +0000 Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id ea7c68c5; Mon, 22 Feb 2021 17:47:57 +0000 (UTC) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11dcd2ab-7edc-439c-304e-08d8d75a01c9 X-MS-TrafficTypeDiagnostic: DM6PR10MB3466: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HBQIlCJ26vg9b3zTUJrToBCK4yRlk4D/9uPwBkgpO3yfSP14RH8ffoEDOBX9tSDiWbfKkhc+eninjJHM+qlKiCoZ7tpYt9iA/NKx0DvxFh1LHsH8KoScYvYHcdbftvRuE1xeU1SnbXd114l0aPeeJAoxkaHkdDU9i52kn+diihlrNQjr9f0LHvPTXvPE3XqNLFi65IM6CtnlD1au+kWrDJOPVaz6FJlXjuscV5lCwvew897vF52MJVJF8IWymgw3O04cOptoN95Nxo1RZNakT6focwrzJYfB5RQ+KBaMUe4z0+XMHf5GBrb4LoTM0c5k8TKXV7IsDVE17QbUw0yknSmQi5HGrGbvoH68xmAClI+nGxHBGzaUk+72PbnTtWR6PxgronvSgZt6+9zzLpS7BEN9d83j1n6JdAWhGXO+m+bscUsleYK7vr+jlDtR0WneiXreqtok5Cg+cpaHH3+E5m6zbxwcs9eiVNUMZQBUMJESVnaqaoMHjtdVWsZzmXdHjSWY73mW9NbVj5uRwSCPig== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR10MB3148.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(136003)(346002)(366004)(39860400002)(376002)(54906003)(478600001)(44832011)(316002)(83380400001)(52116002)(86362001)(186003)(66946007)(66476007)(66556008)(36756003)(8936002)(107886003)(4326008)(5660300002)(2616005)(4744005)(1076003)(8676002)(2906002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?3qR671tQjBO2c7vU4ZlEdFE3lIcmwa?= =?utf-8?q?6ssCE88BeCtwq5gA6YUcguIXw8Bek3d+7OBqCr7FwVOVGQL1Z8WPIJ69GqWsXWAK5?= =?utf-8?q?MQ7pbxmtMHeYuslDX9LWaDtB3yRvhKsMplo4omhRZJ/xmGhd6HMVdKbFQ2Mru+hIf?= =?utf-8?q?Mt+aHliPondc+3UBk9TRF5tu8+xBZyJ4yAQZhQ4GdM3wytGNFBle22I8z8nFk1JW4?= =?utf-8?q?AC1qG7tfVyyaVw9wZmdL+J0IHYBxgwiSmw4q1frfAsUt7mfwXGRyR0dMjU93HwY+q?= =?utf-8?q?sKqyQIXGr/M0yrKLo4DbYPLoSbeNB6GhGyA7bjtWeoxBagGOdeZi/WR5gadau6H8g?= =?utf-8?q?lM8kES9ikYiRDS/PuqNTU65srpz+WShkSj38P9ASVIpQcaIpGt2nj5rcsEpGJFZhJ?= =?utf-8?q?AOTlCJ86cf5r5WvAEJ98eRr6iEAwZgALhsPEpwuI8aH5Rf/r8fG3gryrzYVBkBYXp?= =?utf-8?q?5W6dTrcJAdafSaCfM4CSFN6IJZ6Tb26buQWAZ7IiS4V9Q6AHyHqSqTajJk88mfPdX?= =?utf-8?q?HK5V3Mx41WFn4HWZ15DMUXzOBeZVBWQZpciSD7KHmoiyL9hwPgULSC0QWAKGzYOQm?= =?utf-8?q?xIDOlf0m6ufFPGOM8NPxcJ+EHSig3+Zgk/woV2OOsS3AKtaCE+/aK4PRKrVyXNuc7?= =?utf-8?q?dWYcGxt7AIuThImSHg1/9Gtk87VPQKPKrzbexUM09L7Av2mHSuQ2FwsHNf0kDui6y?= =?utf-8?q?xapjKT4ePSWzD5nxSK6wEPc3afmc+njrTlc4WshiufPY6oI7fTDMD2GB/x7XlsU9o?= =?utf-8?q?XkbeQcgaAOM4XNju6f7tyKmGftp3PkGuzv3F8Ows6Kj32zwRuzdHOtgPeoCeLD5zh?= =?utf-8?q?TtnViPyp7cfKtfuilGLxk2XgTQ/dncbrGyYJhew0xnK7PIwDF8Kl734NEhlxiWa3L?= =?utf-8?q?vln4KTN4EsJJrIzowkpTWgDO+CaCHvKG6WwRisbvoJZzj40k+xnxuemomBBENgHBR?= =?utf-8?q?q2X+JxmmHxE8J9c07dIjJFCZylUjQqNnPmX5UUHSgR4WeliuCcJ5id4O0A8MnHAK/?= =?utf-8?q?pbP6I+IoNIIbyDGGtd5XUZuGP/VjQ3bncTHg/vDr5A3718YaPI+zKVns9fBePT0x6?= =?utf-8?q?vgX8V6CanmtJhC0VthiZdQkMLo5CBzeE1vHme06JeJ365OUeDM/63yW5Aug2+gjpT?= =?utf-8?q?mRgpVSB/MpDsM2cvaUpxia99c2Ab2sAlCPzzZoTug1AksZYoZlyjKtDfC6MS/l5bQ?= =?utf-8?q?xi2DsKZCM+0ue7it6AzrcAmaNAbdqIBAaQnF/BXhB7/5OZnlfFp1EZQPWlhtziThh?= =?utf-8?q?Y9uxzEWiYpw6+HouMuk9c4Qx76fj7tKvb7Zg=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11dcd2ab-7edc-439c-304e-08d8d75a01c9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3148.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2021 17:48:05.2794 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AgE2s7zXSpfe2c5cdPJ70Y2W95L9XtNZG/cNUQbwn8zXwbgOgLvkYvYC34mrdw1ZOyG93sAMiUH0SCmt4RDX9K03Koo4U5AxjTT/PZ00ing= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3466 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9903 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220158 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9903 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 mlxscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220158 Received-SPF: pass client-ip=156.151.31.86; envelope-from=david.edmondson@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , David Edmondson , =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" PFlashCFI01.ro is a bool, declare it as such. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: David Edmondson --- hw/block/pflash_cfi01.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 9e1f3b42c6..6b21b4af52 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -72,7 +72,7 @@ struct PFlashCFI01 { uint8_t max_device_width; /* max device width in bytes */ uint32_t features; uint8_t wcycle; /* if 0, the flash is read normally */ - int ro; + bool ro; uint8_t cmd; uint8_t status; uint16_t ident0; @@ -738,7 +738,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) return; } } else { - pfl->ro = 0; + pfl->ro = false; } if (pfl->blk) { From patchwork Mon Feb 22 17:47:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edmondson X-Patchwork-Id: 12099259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5DBDC433DB for ; Mon, 22 Feb 2021 18:03:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 576E7601FF for ; Mon, 22 Feb 2021 18:03:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 576E7601FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lEFYB-0007Py-7J for qemu-devel@archiver.kernel.org; Mon, 22 Feb 2021 13:03:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEFJe-00017l-3B; Mon, 22 Feb 2021 12:48:14 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:36462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEFJb-0001yX-MZ; Mon, 22 Feb 2021 12:48:13 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11MHj4OZ016586; Mon, 22 Feb 2021 17:48:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ypuTXNuO87SdchQg32SdoBnDfoPAwjYhfVBv2VIK0G4=; b=Y6dFKJ5zcXwnWlCweqk0sxHdNcpW71xx2BoPKXwAMdLlnLZ1524yyJu88p6I22K/4Ckr 7fahS0ceQIpZkm2oUHgCHjLhFWJJut67zs4+d4a00yd4iUz23pGZpAO6Dqs/4M0l6b9m 1YeH55e/dipXyjwV3kwYlJlAJ3aj0p0j350oNrERgtKk35Dlkz0/tIasGJpO4Ld9YxCU 0+wf/w7IdVJbSNKoGm+7X/KfwhPyCOSW5sK9X/5ay649PiyGHunzOerHaoRGIP/NVi8d lyCScqbXGNURgTGcybI08mnbrH2C/Ls1Cf2WxNGqMWNHymu1McNnvInsJV6a6Id3gdXA qA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36ugq3bddj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 17:48:09 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11MHkVJ5050614; Mon, 22 Feb 2021 17:48:08 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by aserp3020.oracle.com with ESMTP id 36ucaxbrnb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 17:48:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SEtNW+cbAPmfEl0tQFuaPuiLx5Pn//9CsOREU5jggEhhdd5ZAKORqkWx/t9pNJcapzcs6AXuS/g5wmdM35uzryFdASJpIJSn3WgFGsgnMYr8iiEZVcid2jYi0Rzt2nm4k7x28WhXVPxwMooSGg+2wqzt8UU9Q+25KK+ARkM19tVizGkIIugByODcuj7j5yfE7bgxhg3Cuw/vkeUxdu4hxmtrOFFgKGSBVmGwJNLC9ZBznsybDuq14uhWM6oavYDNWqXuub5ewKtVbNHoZC3VCj/1uw87Xgs8YUG00Xk4UpQOZ/Bvp6Ij83DuU/XRGF0TxtWocDameLBvcccJiR3ZIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ypuTXNuO87SdchQg32SdoBnDfoPAwjYhfVBv2VIK0G4=; b=PGBqZEbeXn1QG5cx43YaXNkZ7y2/06tqJfTJB4zmbGCugdIwZn2nHXoMip3tLRB9Xaqv/9iMaLlefltG/l2WYVf83xtn23Fp3ZSL8oI/KcNxTDaANCM4eQb6f+r1NWj0kYdv4PgK9YrNojihOwbu8Los/2hFn42BSiTKiywofVKET0v7uFlr1zj6dLFC1jQorXdXaTGbqYUh61ua/CmO8p/8U8IwhfRso4lHuodwHG/iBHsCNEy+VhiomLxudyFHrbYPuKlfOH5zy77+2xX+aZ5rywUT5dabi6QwEMr5cBrBoGhZA6shKq6clifImw3HkKLoA4BJ7W1fBjOrpWrTwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ypuTXNuO87SdchQg32SdoBnDfoPAwjYhfVBv2VIK0G4=; b=vR4kgjrcODduptUe0N0/EMtiOPXDw4QuRqzA9Gn7hdP6apcmAInLQ8/PE/bvZrrOLeY6qH0AD4aj40kimfJK1gmv3T6F1WWniQF9kMedzfZPVumrqSNowKPSes1G4mUQzpUFoPZx4FFZIgo7WSqFKgmNLQz9wFAEGQI5zmI8rKo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) by DM6PR10MB3466.namprd10.prod.outlook.com (2603:10b6:5:17e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.31; Mon, 22 Feb 2021 17:48:06 +0000 Received: from DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934]) by DM6PR10MB3148.namprd10.prod.outlook.com ([fe80::f871:5965:2081:3934%5]) with mapi id 15.20.3868.033; Mon, 22 Feb 2021 17:48:06 +0000 From: David Edmondson To: qemu-devel@nongnu.org Subject: [RFC PATCH v3 3/3] hw/pflash_cfi01: Allow devices to have a smaller backing device Date: Mon, 22 Feb 2021 17:47:57 +0000 Message-Id: <20210222174757.2329740-4-david.edmondson@oracle.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210222174757.2329740-1-david.edmondson@oracle.com> References: <20210222174757.2329740-1-david.edmondson@oracle.com> X-Originating-IP: [2001:8b0:bb71:7140:64::1] X-ClientProxiedBy: LO4P123CA0091.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:191::6) To DM6PR10MB3148.namprd10.prod.outlook.com (2603:10b6:5:1a4::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from disaster-area.hh.sledj.net (2001:8b0:bb71:7140:64::1) by LO4P123CA0091.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:191::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.31 via Frontend Transport; Mon, 22 Feb 2021 17:48:05 +0000 Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 8a4ffe3f; Mon, 22 Feb 2021 17:47:57 +0000 (UTC) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c792b23-d239-4981-c190-08d8d75a029f X-MS-TrafficTypeDiagnostic: DM6PR10MB3466: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:655; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BKamgR/0F4JI02dNkrtXYsUJSpZfy4b/6Vy5xNBivoHIWKD/vsp2JHzPYlGSwrf90Y4ZaW7qBD1gbTp+FmTkbMkKLQN6lTWZUGglofqmcJ1RHVxwshwoIMw2jUpl8Kuhbdlr+j4RaatBQgAHnDcQhUHkYPTed8JFO6a/VvX3LWScdn8k5hNehZZ/bzSA32/97QiSkMx6kqfm9CF1yt+76/VC5wxnQDhOTlVtKv8tKdh4PrUvHQZbGP9X9l7+nfjXQw0zQjxPGgoejH2Ak0HPh7PYl5GWRsiWU8bbWZKfKR/RVFvI190X1wUrGriSS01+2XwIMHpETmNdkuHXOcCYAdT6otjP7c/gSb9S/AJFXEM+J7WGQGCUDWOtub1ScCJkmZhxL9XcVhbd8RBWYnPKvnNI89R2Ii3Ufj6Agdl+aauQR8JUaAoJFmX8I12M/XxfPX/yPpd1KKq/DS/qxfw/ucwy5n+EPuFFA2fEpjhDwMFwBUhNl0GJVenWsCDEw0pcArB5CBvA0vcmEB0MfE1cKA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR10MB3148.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(136003)(346002)(366004)(39860400002)(376002)(54906003)(478600001)(44832011)(316002)(83380400001)(52116002)(86362001)(186003)(66946007)(66476007)(66556008)(36756003)(8936002)(107886003)(4326008)(5660300002)(2616005)(1076003)(8676002)(2906002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3QfSFCrJaN8+brosXR3HpsVv278l4vT9aY7xJHIFEqO15YALr1Q1dRQrZUTx5evBaTrT1dFtBxngaTaGn8qjfh2llUHTI5ATWGF1YQ69UDWqUeFxJYRMlvI7T+1mipKIxxy0xTRSf5T1gPL+0jX7gKC6ZdmBtEshRi/CCzVxBZ0F5FKyKOaaQa2ltK1W/ZoC2sSModKIkehe3e6QWCFOIMQla6zWzosMf91vt1+gcXuaoHuCWjN0XocBBjf1fZUsNU48to4NApcHTVidHGkLzYn89ZU5ZFjhYtRAR3zX1AXHAbZgnGqtuH5rY8OHcqfGedoXIgDX+2OCzPRa8YNpT+uzpWvCVWEV06SreWhbIo+tQ282lwZ/CCFaKiBDoS5a7lvsYkqG86lAs/HPhaER0n3McJCzpfjlRLiz6egEvHqPJi2ST2DmUvRVOGg+eI18jf6HFQrNZ46XQ9Im4Lb2fr0WMR+QMikMB0/ih9QvUMEJPpWuEAiN1OwU2JCmE7EDYADIxnnvOr9Lpk/wogQ888pB+5Nx9xCaVRfs3b23LX2aoDEXMz9P/8akeuFHrYC+7ouiPgpwxtIDFpDiPFJliVivNWmV/oFaOfuPvXntMOiWI3OhBdgbOwnh/LKeX6rak7Qc1q0tL/+nHeO9nxvIv5PF5hnp8PdDPHzhKDxG4Fl1GExLd2OMZMxSrxlKZH2YLJhgM9THUe3pXWjPs+0psrfXkY10ML8nOqkQZ4HPhiRMWa/CHXV7NmfXoIk6q6uPTfO38fcOXusAcqeCgsZZx6mlre9CuGIoAK5PXYSkL8jtJfTiwxr7luQGUuahaq5Lppmfo7VPzo9AAOONUkiN/DtJpio2ATdj6vyamGY3nGiS/boZ4xaDuw/FCLaOgNuTakMhvhLn6lCUgNqdTfLNAOh0GnOJci0bXSqgOvsWkqeOfM2KNvTB0xCJ2gbzn7vHSq5RB0Z0mLF2k5EZnVMhMgOt//UMkZmpb/7F8X6dgPEijmxvQuQ4adIx1mTGS37ZAePgCJqg/P/ITlDmX0ZwhVIYOAZK8N6rX/nP5p5SaiD3cNcPxriRMB0vq7lCZ+nVDF7EOW58fDAzwxcnXjeQIjWf9LjNS0aJ1iLIhvMT0ykBwkfUWkK+QmpPBZ4wI2EiMZe0YGdiZ2LG/pvB5OxeJMIcj8GKL+MZpEtBxjzGZAC9tXnEtfqdWF/WsYzB5pUY7kdhX63JICDRqUGNPWKVrTGxnQ+E2qEfLKp6lsSGQh9NVt2jpdR973WHXEySlGUH4ogzaty1tuyMrYeyTNBzrE9HH1JdX1KhGDIum8igR7talbNvW3dB32YlwMbzl8jJoEE5Tair7aN1wKyq1BjJlw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c792b23-d239-4981-c190-08d8d75a029f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3148.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2021 17:48:06.5447 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XdZbLY0y2oHy6GdCHhziY14AJ9mVxA68uz6MXYwbBRfsUg7lrROtgOisMN0eKdlOQH8HQLGPNf8vupTTmGKs0csuDh7eNKS5IsitRr3NKEM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3466 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9903 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220158 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9903 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220158 Received-SPF: pass client-ip=156.151.31.85; envelope-from=david.edmondson@oracle.com; helo=userp2120.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , David Edmondson , =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Allow the backing device to be smaller than the extent of the flash device by mapping it as a subregion of the flash device region. Return zeroes for all reads of the flash device beyond the extent of the backing device. For writes beyond the extent of the underlying device, fail on read-only devices and discard them for writable devices. Signed-off-by: David Edmondson --- hw/block/pflash_cfi01.c | 106 ++++++++++++++++++++++++++++++++-------- hw/block/trace-events | 3 ++ 2 files changed, 88 insertions(+), 21 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 6b21b4af52..4b6cbc85f6 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -83,6 +83,8 @@ struct PFlashCFI01 { uint64_t counter; unsigned int writeblock_size; MemoryRegion mem; + MemoryRegion mem_outer; + char outer_name[64]; char *name; void *storage; VMChangeStateEntry *vmstate; @@ -425,7 +427,6 @@ static inline void pflash_data_write(PFlashCFI01 *pfl, hwaddr offset, } break; } - } static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, @@ -646,8 +647,45 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, } -static MemTxResult pflash_mem_read_with_attrs(void *opaque, hwaddr addr, uint64_t *value, - unsigned len, MemTxAttrs attrs) +static MemTxResult pflash_outer_read_with_attrs(void *opaque, hwaddr addr, + uint64_t *value, + unsigned len, + MemTxAttrs attrs) +{ + PFlashCFI01 *pfl = opaque; + + trace_pflash_outer_read(pfl->name, addr, len); + *value = 0; + return MEMTX_OK; +} + +static MemTxResult pflash_outer_write_with_attrs(void *opaque, hwaddr addr, + uint64_t value, + unsigned len, + MemTxAttrs attrs) +{ + PFlashCFI01 *pfl = opaque; + + trace_pflash_outer_write(pfl->name, addr, len); + if (pfl->ro) { + return MEMTX_ERROR; + } else { + /* Discard writes. */ + warn_report_once("%s: attempt to write outside of the backing block device " + "(offset " TARGET_FMT_plx ") ignored", pfl->name, addr); + return MEMTX_OK; + } +} + +static const MemoryRegionOps pflash_cfi01_outer_ops = { + .read_with_attrs = pflash_outer_read_with_attrs, + .write_with_attrs = pflash_outer_write_with_attrs, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + +static MemTxResult pflash_mem_read_with_attrs(void *opaque, hwaddr addr, + uint64_t *value, unsigned len, + MemTxAttrs attrs) { PFlashCFI01 *pfl = opaque; bool be = !!(pfl->features & (1 << PFLASH_BE)); @@ -660,8 +698,9 @@ static MemTxResult pflash_mem_read_with_attrs(void *opaque, hwaddr addr, uint64_ return MEMTX_OK; } -static MemTxResult pflash_mem_write_with_attrs(void *opaque, hwaddr addr, uint64_t value, - unsigned len, MemTxAttrs attrs) +static MemTxResult pflash_mem_write_with_attrs(void *opaque, hwaddr addr, + uint64_t value, unsigned len, + MemTxAttrs attrs) { PFlashCFI01 *pfl = opaque; bool be = !!(pfl->features & (1 << PFLASH_BE)); @@ -684,7 +723,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) { ERRP_GUARD(); PFlashCFI01 *pfl = PFLASH_CFI01(dev); - uint64_t total_len; + uint64_t outer_len, inner_len; int ret; uint64_t blocks_per_device, sector_len_per_device, device_len; int num_devices; @@ -702,7 +741,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) return; } - total_len = pfl->sector_len * pfl->nb_blocs; + outer_len = pfl->sector_len * pfl->nb_blocs; /* These are only used to expose the parameters of each device * in the cfi_table[]. @@ -717,33 +756,58 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) } device_len = sector_len_per_device * blocks_per_device; - memory_region_init_rom_device( - &pfl->mem, OBJECT(dev), - &pflash_cfi01_ops, - pfl, - pfl->name, total_len, errp); - if (*errp) { - return; - } - - pfl->storage = memory_region_get_ram_ptr(&pfl->mem); - sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem); - if (pfl->blk) { uint64_t perm; + pfl->ro = !blk_supports_write_perm(pfl->blk); perm = BLK_PERM_CONSISTENT_READ | (pfl->ro ? 0 : BLK_PERM_WRITE); ret = blk_set_perm(pfl->blk, perm, BLK_PERM_ALL, errp); if (ret < 0) { return; } + + inner_len = blk_getlength(pfl->blk); + + if (inner_len > outer_len) { + error_setg(errp, + "block backend provides %" HWADDR_PRIu " bytes, " + "device limited to %" PRIu64 " bytes", + inner_len, outer_len); + return; + } } else { pfl->ro = false; + inner_len = outer_len; } + trace_pflash_realize(pfl->name, pfl->ro, inner_len, outer_len); + + snprintf(pfl->outer_name, sizeof(pfl->outer_name), + "%s container", pfl->name); + memory_region_init_io(&pfl->mem_outer, OBJECT(dev), + &pflash_cfi01_outer_ops, + pfl, pfl->outer_name, outer_len); + + memory_region_init_rom_device(&pfl->mem, OBJECT(dev), + &pflash_cfi01_ops, + pfl, pfl->name, inner_len, errp); + if (*errp) { + return; + } + + memory_region_add_subregion(&pfl->mem_outer, 0, &pfl->mem); + + pfl->storage = memory_region_get_ram_ptr(&pfl->mem); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem_outer); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem); + if (pfl->blk) { - if (!blk_check_size_and_read_all(pfl->blk, pfl->storage, total_len, - errp)) { + int ret = blk_pread(pfl->blk, 0, pfl->storage, inner_len); + + if (ret < 0) { + error_setg_errno(errp, -ret, + "cannot read %" HWADDR_PRIu + " bytes from block backend", inner_len); vmstate_unregister_ram(&pfl->mem, DEVICE(pfl)); return; } diff --git a/hw/block/trace-events b/hw/block/trace-events index a715a2e173..85b501e23e 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -17,10 +17,13 @@ pflash_erase_timeout(const char *name, int count) "%s: erase timeout fired; eras pflash_io_read(const char *name, uint64_t offset, unsigned int size, uint32_t value, uint8_t cmd, uint8_t wcycle) "%s: offset:0x%04" PRIx64 " size:%u value:0x%04x cmd:0x%02x wcycle:%u" pflash_io_write(const char *name, uint64_t offset, unsigned int size, uint32_t value, uint8_t wcycle) "%s: offset:0x%04"PRIx64" size:%u value:0x%04x wcycle:%u" pflash_manufacturer_id(const char *name, uint16_t id) "%s: read manufacturer ID: 0x%04x" +pflash_outer_read(const char *name, uint64_t addr, unsigned int len) "%s: addr:0x%" PRIx64 " len:%d" +pflash_outer_write(const char *name, uint64_t addr, unsigned int len) "%s: addr:0x%" PRIx64 " len:%d" pflash_postload_cb(const char *name) "%s: updating bdrv" pflash_read_done(const char *name, uint64_t offset, uint64_t ret) "%s: ID:0x%" PRIx64 " ret:0x%" PRIx64 pflash_read_status(const char *name, uint32_t ret) "%s: status:0x%x" pflash_read_unknown_state(const char *name, uint8_t cmd) "%s: unknown command state:0x%x" +pflash_realize(const char *name, bool ro, uint64_t blk_len, uint64_t total_len) "%s: ro:%d blk_len:0x%" PRIx64 " total_len:0x%" PRIx64 pflash_reset(const char *name) "%s: reset" pflash_sector_erase_start(const char *name, int width1, uint64_t start, int width2, uint64_t end) "%s: start sector erase at: 0x%0*" PRIx64 "-0x%0*" PRIx64 pflash_timer_expired(const char *name, uint8_t cmd) "%s: command 0x%02x done"