Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp915053iog; Wed, 15 Jun 2022 15:33:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vtbP9fSLl2RwltK5FvvpumuZ1fZlzLItKHVxoKUNmGc6Azn85wCZbrvtfXKGimQ/BcIA3s X-Received: by 2002:a63:f04e:0:b0:3ff:af9d:5387 with SMTP id s14-20020a63f04e000000b003ffaf9d5387mr1754980pgj.514.1655332421967; Wed, 15 Jun 2022 15:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655332421; cv=none; d=google.com; s=arc-20160816; b=osu8VRs7OOsBa8TOsXvvdcGjbvsjNCbfg7zpFGRlTgPN2W4LdeFHQ++KWNnZ6Q3GDL vVFYeskW6GCyWg/l1LSdZeMv5WOYa47oCQhhM9GOjnUhJ/6f5FB158ccsgNLzHvlXSPG 0PnQXJ9pdjZB8zl84nIaHWhcsKETu3o/A24FW9bwdJO3V0blTgwA9Psdm01T8UQa5dLJ W4XukrB3qopBKMotuB7Nh2k44Esyr0mkXjoV84g5Os8sVAFFBSxo+78mkiIR+1dP5lXa m7BPz/Eow39kpTXRz4nfomDhUB1sRR0QGoqwUhPSZvpCKk4jYb5F6E0bv9NAsUI/lWKv iYCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=HC+ZIIgu0AuRJsQ4cSENaTkiJ70Jvb1rgMWH4vROX98=; b=xxm0bJM5SQLMJukG07qcO+6M6O6Ci97XLn5SPyif9K60bf006rdUt41jQGbkHTR1Up oAkaxiK5Uvn7jgjx0rIeB+L2tutmGAstzbacVUUmUsKnr1VSVI/walgMIg3zOZs/OrJZ BBjNDtQx+znuJzhVBLTJqfT8zzQD0goJRQs4+j9huvzrr37xaMUGXiKt/lIb5Dhm3xPE 8CgAOYsozNWb82x1x1S2Xcc4WyEO/6lZXnx+Jg4XnSCvnScvWFiHxAIN/mVLXUTANDjV AmL0hFxLZGkfsKacAUkExQu3gu+vGSKpY2dydoP0JA6t2IVstZV05FQTA0U4fYyHPyvi 3jHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=NYJ1SEnZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a056a00181200b005227ed4e0fdsi553840pfa.134.2022.06.15.15.33.30; Wed, 15 Jun 2022 15:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=NYJ1SEnZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346917AbiFOWWb (ORCPT + 99 others); Wed, 15 Jun 2022 18:22:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236639AbiFOWW3 (ORCPT ); Wed, 15 Jun 2022 18:22:29 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D81612B8; Wed, 15 Jun 2022 15:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655331733; bh=7Nz3pQkBpBxV+DkrOjcNVQfPVA5p4xkVtV9V6hPRVM8=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=NYJ1SEnZz+enh6MvRSRIj+TS9Esvz6eKEiD63SPVr2FTZjBYKj4G8ySaa0aCXCkjE Bi4ij6O2iCJ7gt5xgc1Fd4RtZ17knq8XdjaHlI8y5Qblmgl6nyhtAZh2/LMIOyLKF5 uBYD1J22I7Ud5ccF7JNMBfSCQytI8nFT2sZK2Jjw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.0.33] ([46.223.2.17]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MPGRp-1oMgWG1zYr-00Pgxa; Thu, 16 Jun 2022 00:22:13 +0200 Subject: Re: [PATCH v5 07/10] tmp, tmp_tis: Implement usage counter for locality To: Jarkko Sakkinen Cc: peterhuewe@gmx.de, jgg@ziepe.ca, stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, l.sanfilippo@kunbus.com, lukas@wunner.de, p.rosenberger@kunbus.com References: <20220610110846.8307-1-LinoSanfilippo@gmx.de> <20220610110846.8307-8-LinoSanfilippo@gmx.de> From: Lino Sanfilippo Message-ID: <2b9e9b38-5ed7-aff1-9ead-534e9d857eda@gmx.de> Date: Thu, 16 Jun 2022 00:22:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:VhHTR5MUWapQwJwyqqOUTn/M2J7ABp8kLCBSIPYlwZTW/h4SvTX cxqQCuPX6ayPrM8lK9eAYLAs9fQDLROLQrDhu2oRNZrxgk7lk+yY84YPGJ8Ru0XmLk337TJ r8slzK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AqAnysoJXyxy1+3Ryy6gs1yohwI8wCAt qFXivYjcgbG+ag3th1Ct0CW/FuIPZj8hdwQjb7PBOzaHxMr3ohiHf7wa/Ykpudlz/JKLcFzTc agCJHPS7uh00oroGr/TC0vxUky6RA86wOJWkEihahHER/s8ZnA6svonfTquLRdwhUJkyznUaL eYjz4jFvt9icflX7S0uvyF+1LE9jWCv+mwdNoSrjCblmERFXbKgQxj+jA== X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 15.06.22 at 20:23, Jarkko Sakkinen wrote: > On Fri, Jun 10, 2022 at 01:08:43PM +0200, LinoSanfilippo@gmx.de wrote: >> From: Lino Sanfilippo >> >> Implement a usage counter for the (default) locality used by the TPM TI= S >> driver: >> Request the locality from the TPM if it has not been claimed yet, other= wise >> only increment the counter. Also release the locality if the counter is= 0 >> otherwise only decrement the counter. Ensure thread-safety by protectin= g >> the counter with a mutex. >> >> This allows to request and release the locality from a thread and the >> interrupt handler at the same time without the danger to interfere with >> each other. >> >> Signed-off-by: Lino Sanfilippo >> --- >> drivers/char/tpm/tpm_tis_core.c | 30 ++++++++++++++++++++++++++++-- >> drivers/char/tpm/tpm_tis_core.h | 2 ++ >> 2 files changed, 30 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis= _core.c >> index 028bec44362d..0ef74979bc2c 100644 >> --- a/drivers/char/tpm/tpm_tis_core.c >> +++ b/drivers/char/tpm/tpm_tis_core.c >> @@ -158,16 +158,26 @@ static bool check_locality(struct tpm_chip *chip,= int l) >> return false; >> } >> >> +static int release_locality_locked(struct tpm_tis_data *priv, int l) >> +{ >> + tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY); > > nit: empty line here > > Also it would not hurt to prefix it with tpm_tis. > > This is for simple and practical reasons, like grepping. I don't > mind if you do that also for other functions (if you want to). > Ok, will do so. Regards, Lino