Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2563241rdb; Mon, 12 Feb 2024 08:43:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFd/7t2zUD+XDseI64/jVBuu9O2vtRFxdT4Ap6sZirwnrQaH0WVsK4tRSlL8eqj1xyK/QR9 X-Received: by 2002:a05:6358:c97:b0:17a:e17f:7f01 with SMTP id o23-20020a0563580c9700b0017ae17f7f01mr4559804rwj.23.1707756182638; Mon, 12 Feb 2024 08:43:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707756182; cv=pass; d=google.com; s=arc-20160816; b=dfHSq01p1D9pCzJ5GSZWp4ElRlTRxPFN5sVtxYe+hGfpAmeksbWqh9nOHK9r09qHUl 86sp1Z0/TpvlmWAMEmixhpl6TlIXfsmC/WYtSWmzVa+mP8+Kc20DWihELlw8q5Bn0nY4 HU7yC7d2IbQpfIs5v9HCK2AblMpI1ZusHtzba2TEyUEw9WcdiJQSx1KQ9JL454+skPFs mVQNVtOkUTrwslBKpQ15MopwI7+yPqg2nW9ma8sM9d/6ZOjjEsssLzBEX5MPqkb0PCtJ PPU0uS2sUHxY9dXvqybUMHrbKfCqJba/kQf2DQqzIV2uVOJclkrHtBEMRjutnrPWFcIx 8ciA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=lYKonIxNQx7PqoN00UERqZN/YHljfdRvnIU5JTsFjXU=; fh=PT/4GW6PISjmb7MvqCMxir3tle2X+YXmOifX1AAOWKY=; b=k8bjS0XeEo/thQZa9uU8u2XW7KYxjmFNjbOXmGBL6kO/EXE4Nz9Tt2uKMNRQltYSrb ZDpqjMw8IUPxSgBhVKnuMMmY+YSNDnvCQPENCupe/MwaI4/IwQCtrGZyotn7iylXdE8b 41Dm8RuaJtp1z9jIcotYGfWvN16o4P4CrcsZkWvDbcefErou2HM29S7HDPPHY1C5NZd6 Wizq2ADuL8u9+BYbXj0j3wJlY7tzJOSv+ULe5kdgRY5Tz+9dxUSZZToLwFqowJ4S4n0P vXEfmXgtcVnT6rwR/zpQgZtYYZVaX+r1Qbk8MqWiqViY/YvJF1Dl+mzJBIF13X1WBmuD gQDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZyxTWdzl; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61997-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXduoXkhIv9qtajchNt+/fYTL3/rtOH+CEPRTyQVT3vgs0rRL9kzDljz/N99DRR/Z3Cx95t2h35oHzf9Frr+ztkOAHg1zJAU/lmCY72FA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id iy2-20020a0562140f6200b0067a8bf10affsi773313qvb.220.2024.02.12.08.43.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:43:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZyxTWdzl; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61997-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 63EDA1C21FEC for ; Mon, 12 Feb 2024 16:43:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F2133EA96; Mon, 12 Feb 2024 16:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZyxTWdzl" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B658B3E496; Mon, 12 Feb 2024 16:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755968; cv=none; b=NIq+qwS14pBBysVjjGVVny+pcPP0tKWJzlKejHGDZiDMyxkR/EMsPyrkISPBHq/46YAAiQpO1UZK/jcTW/7tR8Sv3GpHDJN7XiM5ogNBqBfS6vy1Pzrr3ZXpcRF+yVM7on/zFGCNCl980KaJm8f6sOBbiZWW2vAfWQCUWfvrTks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755968; c=relaxed/simple; bh=709knkAaP8MjULstfYL4E5uSLG2m2pepQhQRAsUmO4M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pg7u/kGfIHGXsJAA0V6f3M2hith2AKOZfRAK6Dk/F+zKgAMbNaRHb+FKww5d9U5HKJubywxZuhqwsv2KRuAqYB3hsk53Bgddp9Y074Ejwg45SUfeQmYozshrro3tt1bgcitQWOUO9Cpj86k3hNNevY9z3q/QhDZi0u3M2dbBMCA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZyxTWdzl; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707755967; x=1739291967; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=709knkAaP8MjULstfYL4E5uSLG2m2pepQhQRAsUmO4M=; b=ZyxTWdzlk5pTvAItvtZ2XpDq6TEjT1zP98Qtgc4Sftt752Z36TJYg1Jq mDLGz8PWkq96X1YViA9AHGeVAeVzJN8dysQSfsILTtGZ2zB8Lqm8veiId pCf0Vr6mU020YdFyuIUSMQMWrKV85d+oRWBBg0bp0jQkt1TtK+qGW09Rl qoF8V+TOHPtYBadAJysUJR6jTSA+/auYbXMb075ydHoT6s9EhASim67XZ XmP+cjzU4yTUsdCb2amNa2zMaLTMQic22xqkAwAHrfJNGolEqUn+T1MPb S8wTmq2zFb7z7jQSg93hDsnGaoJQ8nTa/Abz+baMHnjhjaRwh1lWzqMMW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="1646427" X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="1646427" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 08:39:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,264,1705392000"; d="scan'208";a="2815060" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [10.246.113.42]) ([10.246.113.42]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 08:39:25 -0800 Message-ID: Date: Mon, 12 Feb 2024 09:39:24 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] dmaengine: idxd: Clear Event Log head in idxd upon completion of the Enable Device command To: Fenghua Yu , Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel , Lingyan Guo References: <20240209191851.1050501-1-fenghua.yu@intel.com> <36895817-8f71-461a-93e0-5db1a39cd3c4@intel.com> <18761e12-822a-16b4-fdc5-0ac889b1693c@intel.com> Content-Language: en-US From: Dave Jiang In-Reply-To: <18761e12-822a-16b4-fdc5-0ac889b1693c@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/10/24 6:49 PM, Fenghua Yu wrote: > Hi, Dave, > > On 2/9/24 12:17, Dave Jiang wrote: >> >> >> On 2/9/24 12:18 PM, Fenghua Yu wrote: >>> If Event Log is supported, upon completion of the Enable Device command, >>> the Event Log head in the variable idxd->evl->head should be cleared to >>> match the state of the EVLSTATUS register. But the variable is not reset >>> currently, leading mismatch of the variable and the register state. >>> The mismatch causes incorrect processing of Event Log entries. >>> >>> Fix the issue by clearing the variable after completion of the command. >> >> Should this be done in idxd_device_clear_state() instead? > > If clear evl->head in idxd_device_clear_state(), evl->head still mismatches head in EVLSTATUS in some cases. > > For exmample, when a few event log entries are logged and then device is disabled, head in EVLSTATUS is still a valid non-zero value. Clearing evl->head in idxd_device_clear_state() when disabling device makes evl->head and head in EVLSTATUS mismatched. > > I haven't thought a failure test case when they mismatch in these cases though. > > But while thinking evl->head more, I wonder why is it even needed? > > head of event log can always be read from EVLSTATUS instead of from its shadow evl->head. And reading head from EVLSTATUS won't degrade performance because tail is always read from EVLSTATUS whenever head is read (no matter from evl->head or from EVLSATUS). > > To avoid any mismatch issue/trouble, I think the right fix is to remove head definition in struct idxd_evl and always read head from EVLSTATUS. > > Do you think this is the right fix? I was to avoid register reads during event processing. But if you think there's no performance impact then feel free to read directly from the register. > > Thanks. > > -Fenghua