From patchwork Wed Sep 16 14:43:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11780549 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09C78112E for ; Wed, 16 Sep 2020 19:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A273520708 for ; Wed, 16 Sep 2020 19:07:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fb1AO2a+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727512AbgIPTHW (ORCPT ); Wed, 16 Sep 2020 15:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727378AbgIPRpB (ORCPT ); Wed, 16 Sep 2020 13:45:01 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 120BEC00217B for ; Wed, 16 Sep 2020 07:44:07 -0700 (PDT) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D080B276; Wed, 16 Sep 2020 16:43:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1600267432; bh=tQYjFCCN8ddzM6Kx7mSraUhUsSEme+lC3H0Pj6RtIi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fb1AO2a+G+GhHaKP2/JuS8UysSKCFqT4hrKyazGS/EX1yqzHF3jkrf6Wpj0fPhmQu y0iaEL8KA3PzuVKnfd25lutgMt2zLaEi22lhkGP5WQa5abXbvWDFbBzZAVBNOGl4/q R02rwfUtAbf5h5N2P1oB7AKeMxIR2f9FNP4WgGRc= From: Kieran Bingham To: Laurent Pinchart , linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham Subject: [VSP-Tests PATCH 1/3] gen-lut: Update for python3 Date: Wed, 16 Sep 2020 15:43:00 +0100 Message-Id: <20200916144302.1483470-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916144302.1483470-1-kieran.bingham@ideasonboard.com> References: <20200916144302.1483470-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Python2 has now gone end-of-life and is discontinued. Update the gen-lut utility to use python3 directly, converting xrange usages to range, and using bytearray to store the tables and write them directly removing the discontinued file object. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- data/frames/gen-lut.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/data/frames/gen-lut.py b/data/frames/gen-lut.py index 07889b11f4ac..335b9f1613bc 100755 --- a/data/frames/gen-lut.py +++ b/data/frames/gen-lut.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # SPDX-License-Identifier: GPL-2.0-or-later # SPDX-FileCopyrightText: 2016 Renesas Electronics Corporation @@ -49,26 +49,26 @@ def clu_value(x, y, z, scale, a, freq, weights): return (z, y, x, 0) def generate_clu(config): - clu = [] + clu = bytearray() - for z in xrange(17): - for y in xrange(17): - for x in xrange(17): + for z in range(17): + for y in range(17): + for x in range(17): clu.extend(clu_value(x, y, z, **config[1])) - file('clu-%s.bin' % config[0], 'wb').write(''.join([chr(c) for c in clu])) + open('clu-%s.bin' % config[0], 'wb').write(clu) def gamma(vin, gamma, scale): return int(255 * scale * math.pow(vin / 255., gamma)) def generate_lut(config): - lut = [] - for i in xrange(256): + lut = bytearray() + for i in range(256): lut.extend([gamma(i, g, config[1]) for g in config[2:]]) lut.append(0) - file('lut-%s.bin' % config[0], 'wb').write(''.join([chr(c) for c in lut])) + open('lut-%s.bin' % config[0], 'wb').write(lut) def main(argv): From patchwork Wed Sep 16 14:43:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11780991 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1243814F6 for ; Wed, 16 Sep 2020 21:00:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD5F92087D for ; Wed, 16 Sep 2020 21:00:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cyEa0EER" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726868AbgIPVAr (ORCPT ); Wed, 16 Sep 2020 17:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbgIPQaY (ORCPT ); Wed, 16 Sep 2020 12:30:24 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD0ADC00217D for ; Wed, 16 Sep 2020 07:45:15 -0700 (PDT) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D876426B; Wed, 16 Sep 2020 16:43:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1600267446; bh=vqpEThUN815HEH+3aLWRHIezd8cwcQPFVZJ1JB5ol3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cyEa0EERzK7jTN3/LryXkFHi0vYRckamY4HtrbJdcnMuHwwS5QJmGr8rFMJ+EgTa1 ftQQ8lU4G1lZCg2ByUqnMMODrru2XONUWmlTqA79dt1+LXFgAybe1Ux9gyMiRF3kcX 8bUHeUIScAvFd09n5BsXt129ULM41tRyOQ1SvL+I= From: Kieran Bingham To: Laurent Pinchart , linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham Subject: [VSP-Tests PATCH 2/3] src: monotonic-ts: Monotonic timestamp logging Date: Wed, 16 Sep 2020 15:43:01 +0100 Message-Id: <20200916144302.1483470-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916144302.1483470-1-kieran.bingham@ideasonboard.com> References: <20200916144302.1483470-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Introduce a new utility which prefixes a monotonic timestamp rendered in the same format as the kernel logs to all lines fed in through stdin. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/Makefile | 10 +++++++--- src/monotonic-ts.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/monotonic-ts.c diff --git a/src/Makefile b/src/Makefile index d7f901f58be6..67216e81ffc4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,18 +7,22 @@ CFLAGS ?= -O0 -g -W -Wall -Wno-unused-parameter -Iinclude LDFLAGS ?= LIBS := -lm GEN-IMAGE := gen-image +MONOTONIC_TS := monotonic-ts %.o : %.c $(CC) $(CFLAGS) -c -o $@ $< -all: $(GEN-IMAGE) +all: $(GEN-IMAGE) $(MONOTONIC_TS) $(GEN-IMAGE): gen-image.o $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) +$(MONOTONIC_TS): monotonic-ts.o + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) + clean: -rm -f *.o - -rm -f $(GEN-IMAGE) + -rm -f $(GEN-IMAGE) $(MONOTONIC_TS) install: - cp $(GEN-IMAGE) $(INSTALL_DIR)/ + cp $(GEN-IMAGE) $(MONOTONIC_TS) $(INSTALL_DIR)/ diff --git a/src/monotonic-ts.c b/src/monotonic-ts.c new file mode 100644 index 000000000000..fcb671e06d27 --- /dev/null +++ b/src/monotonic-ts.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* SPDX-FileCopyrightText: 2020 Kieran Bingham */ + +#include +#include +#include + +int main(int argc, char ** argv) +{ + struct timespec tp; + char *line = NULL; + size_t size = 0; + const char *label = ""; + + if (argc > 1) + label = argv[1]; + + /* + * Explicitly set line buffering on stdin to be sure it is delivered + * in a timely fashion for our timestamping purposes when data is fed + * through a pipe. + */ + setlinebuf(stdin); + + do { + if (getline(&line, &size, stdin) <= 0) + break; + + clock_gettime(CLOCK_MONOTONIC, &tp); + printf("[%ld.%.9ld]%s %s", tp.tv_sec, tp.tv_nsec, label, line); + } while (!feof(stdin)); + + free(line); + + return 0; +} + From patchwork Wed Sep 16 14:43:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11780721 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0785792C for ; Wed, 16 Sep 2020 20:13:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A12B821973 for ; Wed, 16 Sep 2020 20:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WubxhDC6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbgIPUM7 (ORCPT ); Wed, 16 Sep 2020 16:12:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbgIPRdO (ORCPT ); Wed, 16 Sep 2020 13:33:14 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B5F2C00217E for ; Wed, 16 Sep 2020 07:45:22 -0700 (PDT) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B21E8276; Wed, 16 Sep 2020 16:44:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1600267453; bh=ClfTBU2oKtwuGypifBfbjNA/ULvcIj2ZbeAYGXeUp9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WubxhDC6QnK9LfyNcWkuC349DR61c7NJIbqlLWhuKL0UUM5MGd/ubUEgaL05K9OIJ 27aIecZwhsFMGwwX+qxypg+oE/z12PpN9CaimihWtGbXI49hyViZqx8izqMyg7zKlB wknKo1MrI/TvGG/OLBmKxEtiBq8BQi1Xn76w7bEY= From: Kieran Bingham To: Laurent Pinchart , linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham Subject: [VSP-Tests PATCH 3/3] scripts/logger: Use new monotonic-ts tool Date: Wed, 16 Sep 2020 15:43:02 +0100 Message-Id: <20200916144302.1483470-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916144302.1483470-1-kieran.bingham@ideasonboard.com> References: <20200916144302.1483470-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Utilise the new monotonic timestamping tool to remove the manual parsing of timestamps via /proc/timer_list which can only be read by root. This also simplifies the processing required and contains all timestamping actions within a single process space. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- scripts/logger.sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/scripts/logger.sh b/scripts/logger.sh index 97e1f582da2b..452ebc8c82ba 100755 --- a/scripts/logger.sh +++ b/scripts/logger.sh @@ -2,23 +2,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later # SPDX-FileCopyrightText: 2016 Renesas Electronics Corporation -now() { - awk '/^now/ {time=$3; printf("[%u.%06u]", time / 1000000000, (time % 1000000000) / 1000) ; exit}' /proc/timer_list -} - label=${1:+ [$1]} TRACE_MARKER=/sys/kernel/debug/tracing/trace_marker -if [ -e $TRACE_MARKER ]; then - extra_log_files=$TRACE_MARKER +if [ -e $TRACE_MARKER ] && [ $(id -u) == 0 ]; then + ./monotonic-ts $label | tee -a $TRACE_MARKER +else + ./monotonic-ts $label fi - -while read line ; do - newline="$(now)$label $line" - - echo "$newline" - - for f in $extra_log_files; do - echo "$newline" >> $f; - done; -done