From mboxrd@z Thu Jan 1 00:00:00 1970 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=-4.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 A13FCC07E99 for ; Mon, 12 Jul 2021 11:11:55 +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 6469E610CD for ; Mon, 12 Jul 2021 11:11:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6469E610CD 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IKDOJZY/2onay7yy9PTEetB+1O6OGa2tJvmEeTDxg80=; b=23JlaYPwnd6/6a Z9dly0TjYoz9YKbVGXuCWgQRWZi0khijekC98vjrkzp2keL07k07QTpMp3hta3NYSv88oqsn5ZAKB Tc1uibnLf5QHbp/IVL8XvOHZO3YKFiPnjkNIb3v0YmeMomFhX598xcx1jCiGM120PRhGjIdY12rwM 8ImTgd3vqLLBihKWpcjJAJiwHpo8juNfi48FWQKbXxAxXGFK2zzYV1kdv2KdOy3HY373SlCPv6rB/ JY2VGdMcTUVjHlaPnX4ZuKPgcQ0FGbEP4JrWC7VQFjM4ID2ez+zsD50TqYbG3Hc1G5n3/9Da8QSFl xDJKP5pshmX/7MZB3WOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2tpQ-00769s-Bl; Mon, 12 Jul 2021 11:10:24 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2tpL-00768N-Sk for linux-arm-kernel@lists.infradead.org; Mon, 12 Jul 2021 11:10:21 +0000 Received: by mail-pg1-x535.google.com with SMTP id 62so17874979pgf.1 for ; Mon, 12 Jul 2021 04:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mOkBIZLIeAFbFCMFR/viBqHY84MUzJTBfuuK1u/iBTY=; b=yWo6g9kq4FtQt5BFXBVAv6l81+P0WtMWep5RJ49fykxTBmL+1nfy2nSUNO8c08Hksl 8AsvQaUQwH5kl3PHJjb3+HirKXGjpHBkPEUZTjl0rpYqJafV+rrSouhm12vGLCEI5BYq aaEB8hgwcwXX7Hatwz9TLW72LTyPdqHv5PuZHkq697fJ4mfBS1HmWOClb/lUBYPgpGRj VcBm/k+IbWTGZsSDyF7eKUYi+viUh8phbUmEJUGVGxH/Nb9c/nI/eYOLLPXZvB7o/mWW +cSsb7DMbsQ2CFrQRO4c/JmFms7CVExM4H2hsfI8kOB5qiRV5GNSDJsy7TIhtYDs8l9U pxDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mOkBIZLIeAFbFCMFR/viBqHY84MUzJTBfuuK1u/iBTY=; b=dm0/SbuwZl/XCbcLAXsisFC9cUP4BYYTWScmTexgbJegWPTJd39A3K0Rv+uNOVG8PR 6s6ClJqQdKkiKuy2Px4UgK0+vViMGYsxXHMVVsGEeDUrxT93E2B+NSENPq00z9vqfNnY RqRFXhGLhIC9dDGDubLonkM2DG5dTB1oMejLIgAU66rnYKaLoj5pPg4vGw+y92pp543U /ef5QK4E+DlgIpMBcVDZefqW3FFpZt3b6tNs8B1B/evgGiXgeuHcu/EoNCQNwbZ6GFIE +u5mB54Fgvi4V40CagyC0TY8b0FhSU58bux7o8PjKUDBeSaRCHyPbbjT8vLCavbu9be4 TaXA== X-Gm-Message-State: AOAM530f9h5MdtAiZPRNpRJ/mlYmT1y0bVW6zigoKGbXg6laVc/Uc7bn M8yL7mN+BOokV7AZvNxRECy0FgNqsuREQy7S X-Google-Smtp-Source: ABdhPJwo9OUfj5vfhm9oKgftct1A0S8rMDCPBIwMSm1BjNLOM0PUqGq4oY3OLpyzHtR0LgzMz+vsfg== X-Received: by 2002:a65:5648:: with SMTP id m8mr53749684pgs.93.1626088219352; Mon, 12 Jul 2021 04:10:19 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([202.155.204.36]) by smtp.gmail.com with ESMTPSA id h11sm2008521pjv.57.2021.07.12.04.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 04:10:18 -0700 (PDT) Date: Mon, 12 Jul 2021 19:10:14 +0800 From: Leo Yan To: Suzuki K Poulose Cc: Mathieu Poirier , Mike Leach , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] coresight: tmc-etr: Correct memory sync ranges in SG mode Message-ID: <20210712111014.GC704210@leoy-ThinkPad-X240s> References: <20210710070206.462875-1-leo.yan@linaro.org> <3038eb59-155c-5c3d-18e3-e45e56b52523@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3038eb59-155c-5c3d-18e3-e45e56b52523@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210712_041019_975637_A4CCD2D8 X-CRM114-Status: GOOD ( 19.74 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 12, 2021 at 11:25:54AM +0100, Suzuki Kuruppassery Poulose wrote: > Hi Leo, > > On 10/07/2021 08:02, Leo Yan wrote: > > 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. > > > > I doubt this claim is valid. We do the sync properly, taking the page > corresponding to the "offset" wrapping it around in "page" index. > > Here is the code : > > > > void tmc_sg_table_sync_data_range(struct tmc_sg_table *table, > u64 offset, u64 size) > { > int i, index, start; > int npages = DIV_ROUND_UP(size, PAGE_SIZE); > struct device *real_dev = table->dev->parent; > struct tmc_pages *data = &table->data_pages; > > start = offset >> PAGE_SHIFT; > for (i = start; i < (start + npages); i++) { > index = i % data->nr_pages; > dma_sync_single_for_cpu(real_dev, data->daddrs[index], > PAGE_SIZE, DMA_FROM_DEVICE); > } > } > > > See that the npages accounts for the "size" requested and we wrap the > "index" by the total number of pages in the buffer and pick the right > page. > > So, I think this fix is not needed. Ouch, you are right :) Let's drop these two patches. Thanks, Leo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel