Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp625237pxb; Tue, 19 Oct 2021 09:35:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyULpVTtC9FmgRSK/JZAw01guiwRVDjDqvRrq7F7TZ4IPdbxKH8HXJO40jJBaVSQazATPtF X-Received: by 2002:a17:90b:4c8d:: with SMTP id my13mr899472pjb.101.1634661337670; Tue, 19 Oct 2021 09:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634661337; cv=none; d=google.com; s=arc-20160816; b=o9udFQSyvDkHEzai+cx1me7BwQPCmK1pVDcwv39+Ocx4mx7z5QL83sjkGp2DLTmyk9 sybkW+1j/Z3aBP7tuzo9EGC4mnpiF4cuw0upArfWfRmcjOME/QwFawXRg8jS+j+HZYlC 6/aLrPaFWv91mLmd2pEJDNPdF5MV0ZjgZu9lLXnwUD6fI5sUDkFDTYdJrxfIfUI6OcFc N+HSA+BRHHqTiXSpkahyfppcSF8cK5ALK9A0RJo4kSrQ6cdJWRKiJyGJMqC4J1tgAwXw NrNtudQLzbU5X7Ac6ve1odoOn5dvCVUfeRPL8e8MfWSCIy7epMGQjRno6rgPai7na7cl ItlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AzDBWi/UDaz/yaxBJFLTaoMdRBr9BMob0yWLj5VCGm8=; b=I/WM9m/m3AFA0citDfvPKL/4FgNwFJCg+uosztncz5U2E+yZmdwhxbUromI23rlR/W IuQxQS693DazH9VA4lxVPIwRhHiG7hQcpQpNJ52uv3T7RtFiMYmNiZU6gUxe+ngyk3/1 d9mgTMI98546ZRq1BrkBnAZ/SWVb370pfDGSnZ1/v/oKsZhB6ybVMVplUJvgBW8FoLaY C4UmJOdhQM5yNkMFXyiJgDkNPT54GTruyfZD96RO5KTHrrJRRXIQXA1gqgv2Kh7h3Hcz 1Xr6ETVoCQPouuTKUWvoZxZckZKAxkYWFDe4ELJ5fDj1NWcDT19P+xVJ5XXQJjI4Q8o4 SgCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si10773528ply.108.2021.10.19.09.35.23; Tue, 19 Oct 2021 09:35:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234608AbhJSQgC (ORCPT + 99 others); Tue, 19 Oct 2021 12:36:02 -0400 Received: from foss.arm.com ([217.140.110.172]:51706 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234456AbhJSQfq (ORCPT ); Tue, 19 Oct 2021 12:35:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AFCFC13D5; Tue, 19 Oct 2021 09:33:32 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 45B043F694; Tue, 19 Oct 2021 09:33:31 -0700 (PDT) From: Suzuki K Poulose To: will@kernel.org, mathieu.poirier@linaro.org Cc: catalin.marinas@arm.com, anshuman.khandual@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, maz@kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Suzuki K Poulose Subject: [PATCH v6 12/15] coresight: trbe: Make sure we have enough space Date: Tue, 19 Oct 2021 17:31:50 +0100 Message-Id: <20211019163153.3692640-13-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20211019163153.3692640-1-suzuki.poulose@arm.com> References: <20211019163153.3692640-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The TRBE driver makes sure that there is enough space for a meaningful run, otherwise pads the given space and restarts the offset calculation once. But there is no guarantee that we may find space or hit "no space". Make sure that we repeat the step until, either : - We have the minimum space OR - There is NO space at all. Cc: Anshuman Khandual Cc: Mathieu Poirier Cc: Mike Leach Cc: Leo Yan Reviewed-by: Mathieu Poirier Reviewed-by: Anshuman Khandual Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-trbe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 02a639ece2af..11ff33ec83b9 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -477,10 +477,14 @@ static unsigned long trbe_normal_offset(struct perf_output_handle *handle) * If the head is too close to the limit and we don't * have space for a meaningful run, we rather pad it * and start fresh. + * + * We might have to do this more than once to make sure + * we have enough required space. */ - if (limit && ((limit - head) < trbe_min_trace_buf_size(handle))) { + while (limit && ((limit - head) < trbe_min_trace_buf_size(handle))) { trbe_pad_buf(handle, limit - head); limit = __trbe_normal_offset(handle); + head = PERF_IDX2OFF(handle->head, buf); } return limit; } -- 2.25.4