Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3978678imm; Mon, 15 Oct 2018 07:16:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV62oFf4OEcAte/wBNk5vj2Z79BXlmPbMYV7sO4QG1gF/ID/DY6GnC5hT341c+Z3S04AEtfkY X-Received: by 2002:a17:902:a9c8:: with SMTP id b8-v6mr16969339plr.225.1539612984331; Mon, 15 Oct 2018 07:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539612984; cv=none; d=google.com; s=arc-20160816; b=y2etj/n6JqUShs4etXviIAxsiWvYGBvmx+LMavn2xoWm6W+ZBNHVahNGCwMq2ORUw3 9Wpk1nMlcdENfc0qr0Lm2Az36WgwJ9l5+SYTzdrNfLmHlpUxPRtOiZxWGve5QWHt1nce psfiVIwj+aSFSY+EoruFpyJKo7Y/4RbNRKCOt3qyR3/0t1sRS+Eu9WLjTY75h1bwGmNM Z9ZVzAkfGoeNEdT43T6dJAon9+8Zj2hQNxCOkLf3Uuc7FxyB3v50v5VwvgN9glUgrWMV lsnhjyQEjCljMbsNq2qdIrhq6oRRTWCXmDqSaBZm3RQpeg++hv2PNLp4rftsSPTur0At 0geQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=NSmwQdn7heEO8aH9byt+iVftOIgFzEnIJLLW1+LrvaI=; b=pWSRp/Rdyv6zNBX2UyGxS776QMcRSQsCcSmmSXbPiqgPw08GJf1xFLH14gQtA7tjTV z9b3TAi77jfBuTZA0LeHfct76o3bNpo0zOUEFr7dvFFaUzyY/MoGEaq7Y0052+78OwXs 8shtRWUdAoWySzctAkht4vLecQHA6OiDe8Hf9rgIZgL44a1m/j7tXwnqGdH6hSIAXCeE UZKVjMhdp+TsvK3+zBlylysLgSGUdY5jahiGnnUpIWdJVdB16HC6gY+1dCv6mrwZ+2FD QzfjKJyW78T+T4cw+rySCOXIVZfxacounJpM7QY+QJ8+zzEqPMWFovASu7um4MdZ/UtF KMnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1-v6si10527003pgi.439.2018.10.15.07.16.07; Mon, 15 Oct 2018 07:16:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbeJOWBN (ORCPT + 99 others); Mon, 15 Oct 2018 18:01:13 -0400 Received: from mga07.intel.com ([134.134.136.100]:17328 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbeJOWBN (ORCPT ); Mon, 15 Oct 2018 18:01:13 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Oct 2018 07:15:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,384,1534834800"; d="scan'208";a="81346025" Received: from mylly.fi.intel.com (HELO [10.237.72.66]) ([10.237.72.66]) by orsmga007.jf.intel.com with ESMTP; 15 Oct 2018 07:15:41 -0700 Subject: Re: [PATCH v3 1/3] x86: baytrail/cherrytrail: Rework and move P-Unit PMIC bus semaphore code To: Wolfram Sang , Hans de Goede Cc: Andy Shevchenko , Mika Westerberg , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <20181011142911.13750-1-hdegoede@redhat.com> <20181011142911.13750-2-hdegoede@redhat.com> <20181014131724.GA863@kunai> From: Jarkko Nikula Message-ID: Date: Mon, 15 Oct 2018 17:15:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181014131724.GA863@kunai> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/14/2018 04:17 PM, Wolfram Sang wrote: > On Thu, Oct 11, 2018 at 04:29:09PM +0200, Hans de Goede wrote: >> On some BYT/CHT systems the SoC's P-Unit shares the I2C bus with the >> kernel. The P-Unit has a semaphore for the PMIC bus which we can take to >> block it from accessing the shared bus while the kernel wants to access it. >> >> Currently we have the I2C-controller driver acquiring and releasing the >> semaphore around each I2C transfer. There are 2 problems with this: >> >> 1) PMIC accesses often come in the form of a read-modify-write on one of >> the PMIC registers, we currently release the P-Unit's PMIC bus semaphore >> between the read and the write. If the P-Unit modifies the register during >> this window?, then we end up overwriting the P-Unit's changes. >> I believe that this is mostly an academic problem, but I'm not sure. >> >> 2) To safely access the shared I2C bus, we need to do 3 things: >> a) Notify the GPU driver that we are starting a window in which it may not >> access the P-Unit, since the P-Unit seems to ignore the semaphore for >> explicit power-level requests made by the GPU driver >> b) Make a pm_qos request to force all CPU cores out of C6/C7 since entering >> C6/C7 while we hold the semaphore hangs the SoC >> c) Finally take the P-Unit's PMIC bus semaphore >> All 3 these steps together are somewhat expensive, so ideally if we have >> a bunch of i2c transfers grouped together we only do this once for the >> entire group. >> >> Taking the read-modify-write on a PMIC register as example then ideally we >> would only do all 3 steps once at the beginning and undo all 3 steps once >> at the end. >> >> For this we need to be able to take the semaphore from within e.g. the PMIC >> opregion driver, yet we do not want to remove the taking of the semaphore >> from the I2C-controller driver, as that is still necessary to protect many >> other code-paths leading to accessing the shared I2C bus. >> >> This means that we first have the PMIC driver acquire the semaphore and >> then have the I2C controller driver trying to acquire it again. >> >> To make this possible this commit does the following: >> >> 1) Move the semaphore code from being private to the I2C controller driver >> into the generic iosf_mbi code, which already has other code to deal with >> the shared bus so that it can be accessed outside of the I2C bus driver. >> >> 2) Rework the code so that it can be called multiple times nested, while >> still blocking I2C accesses while e.g. the GPU driver has indicated the >> P-Unit needs the bus through a iosf_mbi_punit_acquire() call. >> >> Signed-off-by: Hans de Goede > > For the record: once the designware maintainers are okay with this > change, I am also okay with it going via the x86 platform tree. > Acked-by: Jarkko Nikula Tested-by: Jarkko Nikula