From patchwork Sat Oct 17 12:31:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1383648 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=lxMAb45n; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4CD2V55FCLz9sT6 for ; Sat, 17 Oct 2020 23:32:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 989CE82318; Sat, 17 Oct 2020 14:32:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="lxMAb45n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 12007822C8; Sat, 17 Oct 2020 14:32:31 +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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 555C9821A4 for ; Sat, 17 Oct 2020 14:32:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1602937940; bh=HkaaTjXt+BV7V80oqLVNPLeizBuU6U5s1K7wgPG8eIw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=lxMAb45nDfFQzEaTtDn2/vZyyJ4IqasYEw8eR3qzloVa5UUdyLI9o/0bg0o4aNJdD /wovwkYRcOq/bYiGyPi4L93sqWKJNa/F+SOaeQKbqIFTDmEm78J500+sEIV8TNDgmY O6P6ZfVAl4mE9lfeHS4K+zzv0ZIvPqqVVOUEY1NA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MfpOd-1jwvjZ2g8H-00gLHa; Sat, 17 Oct 2020 14:32:20 +0200 From: Heinrich Schuchardt To: Simon Glass Cc: Bin Meng , Peng Fan , Baruch Siach , Masahiro Yamada , Andy Shevchenko , Wolfgang Wallner , Sean Anderson , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 2/3] log: allow for message continuation Date: Sat, 17 Oct 2020 14:31:58 +0200 Message-Id: <20201017123159.172357-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201017123159.172357-1-xypron.glpk@gmx.de> References: <20201017123159.172357-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VoNoVvsfqjgCWAQTcMAjeaBXAEx8egolRADfNqkL1PAozC6icw5 7sQq/vPFfCZ5NGDTwOEBz9U0TqK2IXZ4f+u8RLqcsoY+5vbLGejmAiPwp8sJxBBu6WbCLBd 6A2nj4CBBTcfc7A5F8hFx3H4C7hFPZ2/E2fF1m9yUqkjCe8x2WF4y/RfstuFevWoXIikhPy QRiduirpxFSoymo+gc0bQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ACpVHi8QqUw=:Bo2bX3ivmyxAsnSJknYbS1 icyIJtAOTSU96awcmDCI14CEuKCcD74jfcIXQ0wFY+rE56x2LczOUDtUL7jG8lR0xsEgsYU35 ykGAO5Ij3Tr5dneTnuVmbnd8Tl99KiY2suT6gFjzL/Ib3xyVNdmwOLRgqN2X5jkxP6dpnTdw1 dGq2MUtXZdpWrg8+QifYXaPQs9a3exLIb+xAJobEg8sRP4UZ//SmbFDCTVYPriOtmuxsvBTqj E737YpBOR63ECvYNQz9nskj71RbxCdAoE/mTi9W6HP+h4Q0OFSIvtI3Fr0DtPh9OMNdUYD2gI nFoEx+46XzvIR34S/nevGn5Owt4eIjS3i8OLIr869Zush7iAwtuQAHdk/gc9g/gNKQXgiu/+j /Td879YCqvp6/xW4v3PAKl7kMRdvyrZrxHnvcSGzcxVLHQmTLw8SpnV6k9RtNCdtRExKNReB+ orCk+TUWeqUV8xZxKqnvA/ONQll+J9Xvr3QkIsfx2H+A2Z6uKT5CRxXA8hj1CSivLo1el+jOc YGPlIe0ntr5x17DS1huzajJQ+/7WMOUvhX9WdK2JC/YgrP/CFVFy+pCl62Sn4ktBv5LMOkuuC t8WvwkgN+fFVygY8znb9Z817lzY6F9XQy7a22V2yG/+xNEx8kLmYMJm0ATXxXzIIFmceXbaI/ jLTyLX3UkL58h12DlAqoW1BCWm4CnYSUIxxuQJuhvDBei1HQ5DHQT0f5VigNxepqac8x03kiZ qdyYOxyaum51iee7wBwfAHiKnYkh7AfXWAb9F53psFut9K6cGe0h5h2vUqXEXZcSqjfCakQAR Fq2WZvDj88IfatJ7WVmzsIvjVhRUmbt7RUrUd053GRLgtBfhwJ8Nme1ZIU6WUPRWNb79sJOHy uq+8jOxgwdyBFEtPW2Cg== 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.102.3 at phobos.denx.de X-Virus-Status: Clean Some drivers use macro pr_cont() for continuing a message sent via printk. Hence if we want to convert printk messaging to using the logging system, we must support continuation of log messages too. As pr_cont() does not provide a message level we need a means of remembering the last log level. With the patch a pseudo log level LOGL_CONT as well as a pseudo log category LOGC_CONT are introduced. Using these results in the application of the same log level and category as in the previous log message. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2: replace static variables by global data --- common/log.c | 23 ++++++++++++++++++----- doc/develop/logging.rst | 6 ++++++ include/asm-generic/global_data.h | 12 ++++++++++++ include/log.h | 2 ++ 4 files changed, 38 insertions(+), 5 deletions(-) -- 2.28.0 diff --git a/common/log.c b/common/log.c index f95f09c1b6..58be9f7440 100644 --- a/common/log.c +++ b/common/log.c @@ -186,10 +186,12 @@ static bool log_passes_filters(struct log_device *ldev, struct log_rec *rec) * log_dispatch() - Send a log record to all log devices for processing * * The log record is sent to each log device in turn, skipping those which have - * filters which block the record + * filters which block the record. * - * @rec: Log record to dispatch - * @return 0 (meaning success) + * All log messages created while processing log record @rec are ignored. + * + * @rec: log record to dispatch + * Return: 0 msg sent, 1 msg not sent while already dispatching another msg */ static int log_dispatch(struct log_rec *rec) { @@ -201,7 +203,7 @@ static int log_dispatch(struct log_rec *rec) * as this might result in infinite recursion. */ if (gd->processing_msg) - return 0; + return 1; /* Emit message */ gd->processing_msg = true; @@ -221,6 +223,12 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, struct log_rec rec; va_list args; + /* Check for message continuation */ + if (cat == LOGC_CONT) + cat = gd->logc_prev; + if (level == LOGL_CONT) + level = gd->logl_prev; + rec.cat = cat; rec.level = level & LOGL_LEVEL_MASK; rec.force_debug = level & LOGL_FORCE_DEBUG; @@ -236,7 +244,10 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, gd->log_drop_count++; return -ENOSYS; } - log_dispatch(&rec); + if (!log_dispatch(&rec)) { + gd->logc_prev = cat; + gd->logl_prev = level; + } return 0; } @@ -376,6 +387,8 @@ int log_init(void) if (!gd->default_log_level) gd->default_log_level = CONFIG_LOG_DEFAULT_LEVEL; gd->log_fmt = log_get_default_format(); + gd->logc_prev = LOGC_NONE; + gd->logl_prev = LOGL_INFO; return 0; } diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst index 7ce8482ab6..c36f6bbbe4 100644 --- a/doc/develop/logging.rst +++ b/doc/develop/logging.rst @@ -38,6 +38,9 @@ There are a number logging levels available, in increasing order of verbosity: * LOGL_DEBUG_CONTENT - Debug message showing full message content * LOGL_DEBUG_IO - Debug message showing hardware I/O access +To continue a log message in a separate call of function log() use + +* LOGL_CONT - Use same log level as in previous call Logging category ---------------- @@ -56,6 +59,9 @@ The following main categories are defined: * LOGC_DT - Related to device tree control * LOGC_EFI - Related to EFI implementation +To continue a log message in a separate call of function log() use + +* LOGC_CONT - Use same category as in previous call Enabling logging ---------------- diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index db83f59ceb..0157af1aa4 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -371,6 +371,18 @@ struct global_data { * while another message is being processed. */ bool processing_msg; + /** + * @logc_prev: logging category of previous message + * + * This value is used as logging category for continuation messages. + */ + int logc_prev; + /** + * @logl_pref: logging level of the previous message + * + * This value is used as logging level for continuation messages. + */ + int logl_prev; #endif #if CONFIG_IS_ENABLED(BLOBLIST) /** diff --git a/include/log.h b/include/log.h index 4acc087b2e..73cfb6153c 100644 --- a/include/log.h +++ b/include/log.h @@ -38,6 +38,7 @@ enum log_level_t { LOGL_FIRST = LOGL_EMERG, LOGL_MAX = LOGL_DEBUG_IO, + LOGL_CONT = -1, /* Use same log level as in previous call */ }; /** @@ -63,6 +64,7 @@ enum log_category_t { LOGC_COUNT, /* Number of log categories */ LOGC_END, /* Sentinel value for a list of log categories */ + LOGC_CONT = -1, /* Use same category as in previous call */ }; /* Helper to cast a uclass ID to a log category */