From patchwork Sat Jul 10 07:02:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12368371 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 7D65DC07E95 for ; Sat, 10 Jul 2021 07:08:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 40AB961166 for ; Sat, 10 Jul 2021 07:08:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40AB961166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=PvIq6KJw+FA3Y1a0dPdryBbKSyJl00M7oTq3q00JPB4=; b=KOVedo3y8VpSnd tzD35jwD0BW8njHqp8oU/iYzLJ3pn8u/ebRULqnZ+vvy/jijn9dVhK1qL+H0OotNHBsE/ZF2x2ldW cSmsPajzjKolWzU44AzJwTJSmiJU+BiApRB2toyoYVor5oJvxdSaQ4xcKKXZK1ocuNCox1f+ite9o VgJ1A6hY86nQjpAKzDMLQjKsQpXCjUF9D4+E7lY2nk4GgXTUUE9ryApTkuf+9M8Cctl+VlOtMb3ME FOthBCB5R3Hu0i+yB58IE9lXbqR/e6r+6T9l4a6KB3bZN6aR+1qqFyk/A7YxoGDqzzqB28WABzpoN BbnXVWKK6q5/fZNva3DQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m270F-003BAL-35; Sat, 10 Jul 2021 07:02:19 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2709-003B85-25 for linux-arm-kernel@lists.infradead.org; Sat, 10 Jul 2021 07:02:14 +0000 Received: by mail-pl1-x633.google.com with SMTP id h1so6203121plf.6 for ; Sat, 10 Jul 2021 00:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ETf7pOEa7vSxLlHOHWrCI0L1NDAZ4Qs1/MDoyQ30i9c=; b=lB9cYyqpUjUkPkf04lKmAg6MHYoaHoM1BMqSMScPrqEHGVr1VWJYWSZLyvAOCYlA8F q5nYqinJ8ROUd9upqlTRFHuZb2LIo3aQUGZ9TfypTDAMdAuyrv4HYxoELmmY2dqoG9l0 SjBygYJbqizSXGOcUYC/+M5/njz6vAZWNdoBL71hDHw1GdEWwvcl4C9+m7ISFfCtq16x qktvBFGTF9P7bWASi6dCTnc25I3zd3H+iRA7pr0SvyJuHPAcg0wpfG7URCFjhFaBrr52 q4TY+wLRP0QIc9u4zN08Eaau5QbnOsEN5cwVVSeqewBck2wnjAdfpC5JFRqZIQOUQchu 7JlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ETf7pOEa7vSxLlHOHWrCI0L1NDAZ4Qs1/MDoyQ30i9c=; b=YvxWbwtWkFvXfdi5d39hrcl5zfuWJg7jeK9DD2bc6Pni7YgcCLWOeJhxqzBqzhDavk d0YAtk2HGQ/01xv3wj+9VzyL5ke8rGdTlmNwuJ1FCLOIkK5NJdfg08cjwAy1FEZt80qa FcbYw71alj4Yya8fNZ3zCfX1DRQly0HMO2PAdppt/L8+74yIkupL8Q+L3mdAI3YoW3TP rLhgBJyana+YaNzydPuBUtD+NB6oaqQdJ0bgCsIa3a/Od1PZhCoRtVkW61AMcPTWkL3M HZfzmhB++tNBEEt9F1EnY3bDo6qZANR5WPWArdfB33m0yX3v7nbgfvH+e2dB51MbHJyT sYOA== X-Gm-Message-State: AOAM532fRSHPPpEG6EhbWNjkLnyKAHk2O7DtD1GrOFu7yMSa85Q+0K0V 498vHsUN2RBPRu/RVMBaEqVN+glh1bqO+AQB X-Google-Smtp-Source: ABdhPJyn1QuKxnthyYisrDWv3egVrcLnyGkTYowcKSgAEMw5SQA/TId6HXA4lPRJhNkc2zKYkwmX2A== X-Received: by 2002:a17:902:ed84:b029:129:73d9:b83d with SMTP id e4-20020a170902ed84b029012973d9b83dmr31014378plj.43.1625900531889; Sat, 10 Jul 2021 00:02:11 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id r14sm4068429pfg.161.2021.07.10.00.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 00:02:11 -0700 (PDT) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH 1/2] coresight: tmc-etr: Correct memory sync ranges in SG mode Date: Sat, 10 Jul 2021 15:02:05 +0800 Message-Id: <20210710070206.462875-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210710_000213_174664_85D6D461 X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Current code syncs the buffer range is [offset, offset+len), it doesn't consider the case when the trace data is wrapped around, in this case 'offset+len' is bigger than 'etr_buf->size'. Thus it syncs buffer out of the memory buffer, and it also misses to sync buffer from the start of the memory. This patch corrects the memory sync ranges, when detects the wrapping around case, it splits into two chunks: one chunk is the tail of the buffer and another chunk is from the start of the buffer after wrapping around. Signed-off-by: Leo Yan --- .../hwtracing/coresight/coresight-tmc-etr.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 888b0f929d33..a1afefcbf175 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -780,7 +780,23 @@ static void tmc_etr_sync_sg_buf(struct etr_buf *etr_buf, u64 rrp, u64 rwp) else etr_buf->len = ((w_offset < r_offset) ? etr_buf->size : 0) + w_offset - r_offset; - tmc_sg_table_sync_data_range(table, r_offset, etr_buf->len); + + if (r_offset + etr_buf->len > etr_buf->size) { + int len1, len2; + + /* + * If trace data is wrapped around, sync AUX bounce buffer + * for two chunks: "len1" is for the trace date length at + * the tail of bounce buffer, and "len2" is the length from + * the start of the buffer after wrapping around. + */ + len1 = etr_buf->size - r_offset; + len2 = etr_buf->len - len1; + tmc_sg_table_sync_data_range(table, r_offset, len1); + tmc_sg_table_sync_data_range(table, 0, len2); + } else { + tmc_sg_table_sync_data_range(table, r_offset, etr_buf->len); + } } static const struct etr_buf_operations etr_sg_buf_ops = { From patchwork Sat Jul 10 07:02:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12368373 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 DF2F4C07E95 for ; Sat, 10 Jul 2021 07:08:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 ADF5D613D2 for ; Sat, 10 Jul 2021 07:08:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADF5D613D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Gult1jc7XwyzgvywW8G8su+Uv3/vWqb6ZWthOx25soY=; b=qseV7XjoTLu1AW lZ6tuSnCA8uaVYEfc4LZYHplx4a3wAY0S05A5qIabqbnlRgD57H8Milp+bXQE0nVaLqDG3F3w2vnx mvEJMR3B3jayhEOCk37CXJkeIF4KaMMy1nGcfyJ83msl8BDqxnA9+k5oU6/fJf1Jhr0Sbo2UWZH52 EdkT59nxh0XPblf60tQ68Yr6wZFqNeqohl+DJxypDgIs14JvYgtg7uufinKWBXhPeM0DAPacflMZa 2YSd9T5cUaH5Z0+SGfWuosHEczVcShfWteA4D9bBJkQCEdvFfr1Zb3fpvf0/17fhNr0pDH8ppNCQP OWgmHoveyQGdJOT28FGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m270X-003BIf-01; Sat, 10 Jul 2021 07:02:37 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m270B-003B9R-Ra for linux-arm-kernel@lists.infradead.org; Sat, 10 Jul 2021 07:02:17 +0000 Received: by mail-pf1-x42c.google.com with SMTP id o201so5814636pfd.1 for ; Sat, 10 Jul 2021 00:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hdw+Y8ePcpmL93WaBQ0NtdSK7j8tLADFniGhpLrQBiU=; b=bdC7FTR5+xw2eR02RQ9QsXTfdLuJ126SHouurAJiP27yYqtJUyGmkdS3coEOXUEPtQ yqKhjiZql05paXY9mqrwG5MVzcUC8CDa4CK3jn/fUzv92go2aHfabbl9ANsm1/he9Pjw CNROE0P7Ody7lUY7hW4X3KN1KKmUn4U4NMRcErbNrUv19JabgRXbR0b1wpPkgg0M8ABj MSgBCeExz3pkgeRqyWaDr/b2Rd2UOn2f4PqKMKHsM/1YmMChOpoURgrSipcAcWIqeG14 HKg/uAJhIs5GjrLld1B03n98R4FBhdQT+YwtboBflz1MAli2Cn6TYSudWPmbCpMJ09y9 0jgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hdw+Y8ePcpmL93WaBQ0NtdSK7j8tLADFniGhpLrQBiU=; b=It8oRXgxk/9voetlF9NdxHVeoTavJWy+M19P/5XknC42fnLyUW/ns3qYU18WDGzG9C XGKFrMTFlgxj2Ktb5iHZceev+a+xDw4NEmtQ+8rjiRSbiRbEJS+DCFkJs3ibW1DM78tT f8YUySTmwFz4Z14RGp3M1fMXuThVfdeabvcEO8HTQTZFNp8p6Uwywd7M7Abe7SCFWi3Y cjo2OyXDvSVOlmoknujs0rzzs7s4b7DcxfcqWrmiVxuElUVvOLE7oWpBTgV0vwd7FUlA Nt7qQ6FFkKmILKQAa6DMOQbSYOWpfZVAFSKK8cV1JEQQD5UiVOsMnCtjhgM8EqZD/JXe l4ag== X-Gm-Message-State: AOAM533cMyc7jm2K6SVLV9rzYWo1Nrijug+7THowhyfHTszzNuc29Y30 LGW9BeR+6Fguc+0aoUSUlNQErw== X-Google-Smtp-Source: ABdhPJw1YrMyuMsavMpXYW2qL9XqrZ9zFOmfQUKlYRGLVdvCaxcSqODVE7xWaz100nmymTp5sKZ6Ng== X-Received: by 2002:a05:6a00:1988:b029:324:2bf0:d769 with SMTP id d8-20020a056a001988b02903242bf0d769mr22671401pfl.68.1625900534724; Sat, 10 Jul 2021 00:02:14 -0700 (PDT) Received: from localhost ([103.127.241.250]) by smtp.gmail.com with ESMTPSA id 198sm7286710pfw.21.2021.07.10.00.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 00:02:14 -0700 (PDT) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH 2/2] coresight: catu: Correct memory sync ranges in catu mode Date: Sat, 10 Jul 2021 15:02:06 +0800 Message-Id: <20210710070206.462875-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710070206.462875-1-leo.yan@linaro.org> References: <20210710070206.462875-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210710_000215_935523_F20A089C X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Current code misses to handle the case for the trace wrapping around, thus it fails to sync the complete memory ranges in catu mode. This patch corrects the memory sync ranges, when detects the wrapping around case, it splits into two chunks: one chunk is the tail of the buffer and another chunk is from the start of the buffer after wrapping around. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-catu.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index e0740c6dbd54..634af451f0d3 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -323,7 +323,24 @@ static void catu_sync_etr_buf(struct etr_buf *etr_buf, u64 rrp, u64 rwp) } etr_buf->offset = r_offset; - tmc_sg_table_sync_data_range(catu_table, r_offset, etr_buf->len); + + if (r_offset + etr_buf->len > etr_buf->size) { + int len1, len2; + + /* + * If trace data is wrapped around, sync AUX bounce buffer + * for two chunks: "len1" is for the trace date length at + * the tail of bounce buffer, and "len2" is the length from + * the start of the buffer after wrapping around. + */ + len1 = etr_buf->size - r_offset; + len2 = etr_buf->len - len1; + tmc_sg_table_sync_data_range(catu_table, r_offset, len1); + tmc_sg_table_sync_data_range(catu_table, 0, len2); + } else { + tmc_sg_table_sync_data_range(catu_table, r_offset, + etr_buf->len); + } } static int catu_alloc_etr_buf(struct tmc_drvdata *tmc_drvdata,