Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp678593pxb; Thu, 25 Feb 2021 12:10:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxYhLSlc1of6XWlwJOC1jYKoG+5pPE2cJ7W3/f0+n6mlfpt7VduCMCfOilwff2gukfEwP+ X-Received: by 2002:a05:6402:17e7:: with SMTP id t7mr4634502edy.44.1614283852261; Thu, 25 Feb 2021 12:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614283852; cv=none; d=google.com; s=arc-20160816; b=Hyh1O1eL8JYlLxOO5bMehU8Ki9ieIsAasaH4i/yrLEqDxRC0ViD0vPgvNVbl7+6E+b 29Lhgsqz4OV8Hpr2LsBIavfo/VWJvjnMRb6/0b9CHwFiwEKY0DIqYKK4Kf9ry8ZClYho Yt+bqYA7L9IYMn0n7+KCO0P0TlsnNbO5Pf2LGW9Ycwy0BgKCst31lV9rKBTHiFUdmPiP tHOJN+Gm7BFaDE1ypeKelnC0VxBGjQQusZN924e02AO9N6Suc+aeZvTq9Op3ao4wr/i7 z34vjDP+zz3ycC+Mi+309Cz5eXY3ZIUAokj+WtGV3hSbJOGa0g55qNx+YruPNEM65uqR E14g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RjeINcz/Rd536f/bo6FhqRgVRcp3IkVrBQtAQ7gr6Qc=; b=dJVmrKLFqAghEFYd90RnrpYC3CFGK0UByphbWpUzXhwXRB4ZtUNBMY393fbGthu5Xh DE7Bhp37cVNtgaDgW8k0gQmKFwQnmJ7ExzLkUdMs4e65dUA+HS8b7ZG1trdb4vVlU1eS 3yqnQpxXBE/8hHW70s8o0iw+qTZzmIeMa2b+KqcbMKw1x2w+Sh5ud9kOFDJsgBt3BLwn tWciKhd6a7wRvL5XHmhHqxlynDXPYgko7nPNwwjVyFkkCkV0nDt5CdvCUd9m7R4fmNzJ w58CBloCa3iEy/MftqvtJP+KVN8hpEASeAkld+rz2cULO7gUR6QrGvJpyTMEhBuiCP3a 248g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HB+M50wR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s21si4096727ejj.271.2021.02.25.12.10.29; Thu, 25 Feb 2021 12:10:52 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HB+M50wR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233556AbhBYUJ6 (ORCPT + 99 others); Thu, 25 Feb 2021 15:09:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:60182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232686AbhBYUJ5 (ORCPT ); Thu, 25 Feb 2021 15:09:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1F6DA64F18 for ; Thu, 25 Feb 2021 20:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614283757; bh=kLTa/ubC5MochBZlwWejAWH8i38DT4RgDPx/X3yeOzc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HB+M50wRHdwO/ucVOsAAXf1v2xWYkj4i2rP7Mt0ZG5fAXfaM1eVekZ4cz2EKC0HfC hvoIgj4gj1rMeiMs9MeVDpjKZnJsGBD3YcXtfTUdxbMP8SBmm58k4c0AWK6LBjVSSs /40rAI32LbzVUHZAc/RFHum2O7k5JBq2YyV6tVAbFApwQCmRlTqgQeR5j+AzA1r/pP EtrbDnb+y1GqTwsXAFYAMUQQGXWXqygxS7gFRySQ9zDUDlxCIPcQVOH2HXwdWrn5Dc I9ApDojD+MskbMzkXR8optf+ve8O/G9XBwwXnXk4LDoiazBNBEZbRXnpgKU3vle6i8 mlT29ulV9QnBA== Received: by mail-ot1-f41.google.com with SMTP id x9so2575907otp.8 for ; Thu, 25 Feb 2021 12:09:17 -0800 (PST) X-Gm-Message-State: AOAM533MuVmFHzhLWxjZyn1LVLHqzen0bPgwGxf7PWiCi6IKSxm9/AhL LeQeKO5FHrcYviUi9qEWawG8MJYYoKSeRSa1Ous= X-Received: by 2002:a9d:7f11:: with SMTP id j17mr3778751otq.251.1614283756180; Thu, 25 Feb 2021 12:09:16 -0800 (PST) MIME-Version: 1.0 References: <20210225094324.3542511-1-arnd@kernel.org> <20210225164522.GA3554437@xps15> In-Reply-To: <20210225164522.GA3554437@xps15> From: Arnd Bergmann Date: Thu, 25 Feb 2021 21:08:58 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] coresight: etm4x: work around clang-12+ build failure To: Mathieu Poirier Cc: Suzuki K Poulose , Alexander Shishkin , Nathan Chancellor , Nick Desaulniers , Arnd Bergmann , Mike Leach , Leo Yan , Greg Kroah-Hartman , Sai Prakash Ranjan , coresight@lists.linaro.org, Linux ARM , "linux-kernel@vger.kernel.org" , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 5:45 PM Mathieu Poirier wrote: > On Thu, Feb 25, 2021 at 10:42:58AM +0100, Arnd Bergmann wrote: > > index 15016f757828..4cccf874a602 100644 > > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > > @@ -691,13 +691,13 @@ static void etm4_disable_hw(void *info) > > "timeout while waiting for PM stable Trace Status\n"); > > > > /* read the status of the single shot comparators */ > > - for (i = 0; i < drvdata->nr_ss_cmp; i++) { > > + for (i = 0; i < min_t(u32, drvdata->nr_ss_cmp, ETM_MAX_SS_CMP); i++) { > > config->ss_status[i] = > > etm4x_relaxed_read32(csa, TRCSSCSRn(i)); > > } > > > > /* read back the current counter values */ > > - for (i = 0; i < drvdata->nr_cntr; i++) { > > + for (i = 0; i < min_t(u32, drvdata->nr_cntr, ETMv4_MAX_CNTR); i++) { > > This patch will work and I'd be happy to apply it if this was the only instance, > but there are dozens of places in the coresight drivers where such patterns are > used. Why are those not flagged as well? And shouldn't the real fix be with > clang? This is the only one I see in randconfig build tests. In fact I only actually see the second one of the two causing problems, but it seemed silly to change only one of them. I had not noticed the other similar loops that use etm4x_read32() instead of etm4x_relaxed_read32(). I first suspected that the memory clobber in __iormb() prevents the compiler from running into the same problem there, but changing all etm4x_read32() to etm4x_relaxed_read32() did not make it show up in other places either. While I expect this will be fixed in mainline clang, the workaround should be harmless and let us use the existing releases as well. Arnd