Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1003023iob; Fri, 13 May 2022 19:15:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzx269vy37hNZsbprQXLJC+y/I2/BnnC5aUExMCxeSGVlBnXMMajuJ92Lu6MTf8iihUxor1 X-Received: by 2002:a05:600c:4fd4:b0:394:8e96:6d3b with SMTP id o20-20020a05600c4fd400b003948e966d3bmr6918582wmq.180.1652494555167; Fri, 13 May 2022 19:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652494555; cv=none; d=google.com; s=arc-20160816; b=koLxKD1w9hoZcSY1+Fl+grz+93Vbg5IkPmqZNcrvUw5Di/yMw9i6hGP2lYuyMysVWY EMluV+qUrMJsbYIV0k4SsCyGygDWkA0YnQVMz9v3KU0Zt5scLbXrzfi3Epgd/I9grqKK eMecZwkhyLwfUtpyBEQFB/HV0wLMQTCtnPayl4J0P7NIj1bmBFg4EPec5eB5PwwTldco 2zI6rlRTerJIRMssSDCxfRyxifdLNwGuXXBlGe+/Iz8tjkhDTr6RfK3o3j+d9NjczmVj WCgtQHiwf9SLB1gy+q2dUYxVT7v479+neNiIQsLe4o87+3SdRE8WMjvLYu+uBe0gx7vJ Pnng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Z5u5ylCzELQyiB4xWzYqra66IiKkZsmM+FDAUwo8Pbw=; b=R3TUbBSBvsxyZsdSuBz8T44B+8t/JdxvP6qQAnQMIWqYajQY6L2vruIhuR5vpJrk2f nuf8heVBPUlN+cCUV9saNjWawrZ4UoZl64Y8dtdmhgvlaP6r4XDevLUmuNbxVjvD3xYe JdjEm0NTWpKHKbAxkeWC67PAyiR3oDB0JGK7LwNbNml1+hcka/iN0Ux0TzSjutA+4CN+ 4283okXuaqRYdAMHQZumXVU6mtPfT8RmgEvDKtmf0nElKLAz/UaFUrKNEwzMi98wYXuJ PDfJ027aWDuZKiNtvkP8DPOxdhFeoMDin4eligOxZgvM5/+HzTW0Q6ppPdzwmxUM4LiW URmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="nO/Q31FD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i16-20020adfa510000000b0020c6ee414desi3341777wrb.316.2022.05.13.19.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="nO/Q31FD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 87D624AA2F6; Fri, 13 May 2022 17:33:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384660AbiEMVZd (ORCPT + 99 others); Fri, 13 May 2022 17:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358795AbiEMVZa (ORCPT ); Fri, 13 May 2022 17:25:30 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCDD8663FD for ; Fri, 13 May 2022 14:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652477128; x=1684013128; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=l6Vls9wnN+x00vvDZEEHtOYdZPzsd8ahPI1ukzsIW6A=; b=nO/Q31FD+tqSRLnr5rJ+KbWanPdla8H2wpg9JU9hCwj0Rp2NQNDknYqO 5khjTFzgOqJh5MychSdM+XAPGLj4cBpNqlr9XQdHqjmB+5uBYRL+zdPhq QMMev1r2nU5Fb6ltC9H16pDLkMWTHvZFk/Otn9kRNLMmA18B69dMkulBt gOVnMlNe8WyL5yoAO1yjnVFT9iNQIzPQk+ciUKp4dqFJStkblWbNDigtp teR7oVJIh9AzI66F7ja0Nx/pkoUuH6DkYMjjJ2z8wmYoSqU/1XeFN5L6L bqgAbl33qPdU6eSH7dxZNeheDeM3RhH1YNZNrdwA+i/NyOH15pFFRnIF3 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10346"; a="270350414" X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="270350414" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 14:25:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="712562541" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga001.fm.intel.com with ESMTP; 13 May 2022 14:25:28 -0700 Date: Fri, 13 May 2022 14:29:03 -0700 From: Ricardo Neri To: Thomas Gleixner Cc: x86@kernel.org, Tony Luck , Andi Kleen , Stephane Eranian , Andrew Morton , Joerg Roedel , Suravee Suthikulpanit , David Woodhouse , Lu Baolu , Nicholas Piggin , "Ravi V. Shankar" , Ricardo Neri , iommu@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 15/29] x86/hpet: Add helper function hpet_set_comparator_periodic() Message-ID: <20220513212903.GF22683@ranerica-svr.sc.intel.com> References: <20220506000008.30892-1-ricardo.neri-calderon@linux.intel.com> <20220506000008.30892-16-ricardo.neri-calderon@linux.intel.com> <87mtfufifa.ffs@tglx> <87ilqifhxj.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ilqifhxj.ffs@tglx> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 06, 2022 at 11:51:52PM +0200, Thomas Gleixner wrote: > On Fri, May 06 2022 at 23:41, Thomas Gleixner wrote: > > On Thu, May 05 2022 at 16:59, Ricardo Neri wrote: > >> Programming an HPET channel as periodic requires setting the > >> HPET_TN_SETVAL bit in the channel configuration. Plus, the comparator > >> register must be written twice (once for the comparator value and once for > >> the periodic value). Since this programming might be needed in several > >> places (e.g., the HPET clocksource and the HPET-based hardlockup detector), > >> add a helper function for this purpose. > >> > >> A helper function hpet_set_comparator_oneshot() could also be implemented. > >> However, such function would only program the comparator register and the > >> function would be quite small. Hence, it is better to not bloat the code > >> with such an obvious function. > > > > This word salad above does not provide a single reason why the periodic > > programming function is required and better suited for the NMI watchdog > > case and then goes on and blurbs about why a function which is not > > required is not implemented. The argument about not bloating the code > > with an "obvious???" function which is quite small is slightly beyond my > > comprehension level. > > What's even more uncomprehensible is that the patch which actually sets > up that NMI watchdog cruft has: > > > + if (hc->boot_cfg & HPET_TN_PERIODIC_CAP) > > + hld_data->has_periodic = true; > > So how the heck does that work with a HPET which does not support > periodic mode? If the HPET channel does not support periodic mode (as indicated by the flag above), it will read the HPET counter into a local variable, increment that local variable, and write comparator of the HPET channel. If the HPET channel does support periodic mode, it will not kick it again. It will only kick a periodic HPET channel if needed (e.g., if the NMI watchdog was idle of watchdog_thresh changed its value). > > That watchdog muck will still happily invoke that set periodic function > in the hope that it works by chance? It will not. It will check hld_data->has_periodic and act accordingly. FWIW, I have tested this NMI watchdog with periodic and non-periodic HPET channels. Thanks and BR, Ricardo