Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2854104imm; Sun, 14 Oct 2018 06:18:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV63kDAkEf6wMX+GCjc3029EsO8P4QnV+7WoQrUEbXmh5iXy73JwfueJOSAYb6Hvg8NEGFwhO X-Received: by 2002:a62:c60a:: with SMTP id m10-v6mr13725888pfg.15.1539523122582; Sun, 14 Oct 2018 06:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539523122; cv=none; d=google.com; s=arc-20160816; b=pyUSJjvQyisQzID2wZtAcEGeluEWK8pEkwhKko6fAsfj5QiCHEkNhZMb/QI49Ay9k4 mLD5vYAqPivzPCw58zJfqu7bkQVE1tN87rQAwLml3oK5emNs7WQAABrSOcjd64OaVlU0 A02fGZsQBXsj1h7f/5HVv7xVAod4lGb87fmf4E4X2aA60Lv1P8AtqXUELU6bX6jyqvoz bTFzbwgs1orxDlQMVwGji22D7/1KPZ8KZkkw11V5NQmm+6MCi/QhRtzYpDEwKWTu+JFX kLWF0l9dOfH00MDOC3O46HfoRM9RQKvHfC1WHecDkFU3xq4RFlU6tIWzYg4G5m6+CQ8C qcwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ALUckj3SbrDiHj4Vr4DIIqNRod6YLNzctTRXX3+L2tM=; b=m8yKzOv4oDSV5vYxJgO3jFo18ieEMmFqtE2tK9bYM3TB7sE9VmjFjZtWwsAjRq63Uy xKFNeXtq/bRbIRXE2OeFV/RZ1IVo98g3U0a3iV1BfeqJpWFkSL9cTD9Iv/NQJI9VFy2X hudvA+JPeAk9YcXlZCJGsh3qn0RSUdL7FTyf80c8yrYuLz7hM+SmkXAvUpuT2TIZmWp4 M2Z944IYUVFjXrYpqRa/kc1f+2u0NFFyY7uquRDJuDflajI7xeevfSPUI54rWomcuB31 Fo6zuI3zjWRsz4BOvprEh5ybZt3JE4wtUW/4HTYAQkFToyaJD9VMMTIBLwRb7dJKvY4K itYQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6-v6si7828624plf.164.2018.10.14.06.18.04; Sun, 14 Oct 2018 06:18:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbeJNU6Z (ORCPT + 99 others); Sun, 14 Oct 2018 16:58:25 -0400 Received: from sauhun.de ([88.99.104.3]:35280 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbeJNU6Z (ORCPT ); Sun, 14 Oct 2018 16:58:25 -0400 Received: from localhost (mue-88-130-99-254.dsl.tropolys.de [88.130.99.254]) by pokefinder.org (Postfix) with ESMTPSA id DB3382C786F; Sun, 14 Oct 2018 15:17:24 +0200 (CEST) Date: Sun, 14 Oct 2018 15:17:24 +0200 From: Wolfram Sang To: Hans de Goede Cc: Jarkko Nikula , 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 Subject: Re: [PATCH v3 1/3] x86: baytrail/cherrytrail: Rework and move P-Unit PMIC bus semaphore code Message-ID: <20181014131724.GA863@kunai> References: <20181011142911.13750-1-hdegoede@redhat.com> <20181011142911.13750-2-hdegoede@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <20181011142911.13750-2-hdegoede@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 i= t. >=20 > Currently we have the I2C-controller driver acquiring and releasing the > semaphore around each I2C transfer. There are 2 problems with this: >=20 > 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. >=20 > 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 enteri= ng > 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. >=20 > 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. >=20 > For this we need to be able to take the semaphore from within e.g. the PM= IC > 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. >=20 > This means that we first have the PMIC driver acquire the semaphore and > then have the I2C controller driver trying to acquire it again. >=20 > To make this possible this commit does the following: >=20 > 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. >=20 > 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. >=20 > 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. --9jxsPFA5p3P2qPhR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAlvDQeAACgkQFA3kzBSg Kba8cw//bcFMGnUf5u7LGI5EJg3nCoZhj4aZTu/Z4yxcWFtkgN3duynk3hnf5NiM XcbT+8L/nIsvg2JhvBcGFAkFk4qIbMS5sibBWxAjrDpxR2welru8R+gk0kLqyxIL LPT81ikAVz/nZ9Qd3smDu8cel6N2uu7bYGHwQdXszdp74prV64ZBbiByaV29zy59 LjvyW8+mBHszrrbnJu80VjmAhGFb2eYk8n7j/Csa/WdYZMZRxCTxkXzc2wmJva87 m3ZH132QJ73GLpnY4+Ey1idJyWrob65IXi3A3UklKsbzPWJWAyGuZPlr7O9/Ttx/ jYUvW7qJrA8+GmwPkbGRx9eL7oAT+ixZDAUEvi2ASxysh6e+pluvZTvM0S1gyU0/ Fh3fOLu/QmALd7ki3urs7fPJR113JU5eyQeF4FLQu2JUW0KPlLjTL07PlciEOqDK hQIjWnGbJTi+5wsrQI0PC2D1GqmBvhT384ZvnT4GAL4kbog7ZAuiBtcKG5lgGOup DHWkBHokM2zSMAsbYCnDbBcK4zVC54OR715w6hcFAlld3Tr3UZI0Y764zZ9R6moz SPntQgy8ABOVdpOWY4yLZinkxRXDb0sJ8LNefF6C5UoJ7ht//BKvMdustiHE4yr6 16wk5RxkAnB0jvGMcPrTYhVYXJqvRnYoXfCwJRG26vTQl6ygsFU= =iVmh -----END PGP SIGNATURE----- --9jxsPFA5p3P2qPhR--