Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp272641pxb; Mon, 2 Nov 2020 21:59:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYPft59yOEB/oD4lgJKzxOdU76+leiXOFibyx7UUynHwR/Ss8FHoJ1Acc+IIazQ5vEgL6v X-Received: by 2002:a17:906:edaf:: with SMTP id sa15mr15718766ejb.454.1604383194289; Mon, 02 Nov 2020 21:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604383194; cv=none; d=google.com; s=arc-20160816; b=dJCuJxEaRfUuldSj4rjSd4PuFh8rbWrEBpSfIMBJvxlPYINA8/F9wxHcFBi7oPJHHr I95b0/DdSblowWp89kaPpgyRtGyvAhpIGHHZopRP/9BYM2VUp1sMrX67CgRhYfKLMDLQ etzEdVBNuduPSYic7GNIG04VL8lsL3F+Tly9jBtR6yQ73taYkMqhE8ko/j6wcbC9uf68 /G8xE5WfrsUuQ4lPEpFKX8hTD214z5x1yqK8HKGwrLzfd7Y2w8CZ1pzfPy0bY8fIcTXH kJj8dHwUO0KsbbXyYFotkZKhqo4jD235CNeNVxhKJ9t4ZffKg4qPZ/cmjDmeoWPB1Heq cqUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject :dkim-signature; bh=ISCp/k9iAd9MHlIzbF+VLFLF2B9AGbwsrcc2H51zWw4=; b=yiaCFkYy7liWiUM9OgxT5v7qxFz6JftrnKddgwWNDwxVVCfhOcXgTGJPZgUQ7gWUt4 lLVLkrsg3KCpyjYBGUdQAqok03HqipeHfSrZ29GftRRTLIvnTrf4ImVqKtc4LPqBhzRP m2k7g2N80CzeqeXjKf3kD0ZR43nBPlBsg1DlO2mzX9HvbgRfA4V/hw3HLzG1RuYvmheB 17LiwNdiW9uC8l+v+S9Q3YjNQA/MfDrxLkT9VO4TCzxeLZxYbwtTYprqkpF+zd66qhMU Z7ydJr1B7zmltAVryyZBRQLjCzL42kF+TJSL8EAN/eDKBD+4ibG3D5GCGsnKhip4t1WJ OtRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fnarfbargle.com header.s=mail header.b=xHIQoZoB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fnarfbargle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn1si13281861edb.319.2020.11.02.21.59.31; Mon, 02 Nov 2020 21:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fnarfbargle.com header.s=mail header.b=xHIQoZoB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fnarfbargle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726115AbgKCF6S (ORCPT + 99 others); Tue, 3 Nov 2020 00:58:18 -0500 Received: from ns3.fnarfbargle.com ([103.4.19.87]:49320 "EHLO ns3.fnarfbargle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbgKCF6R (ORCPT ); Tue, 3 Nov 2020 00:58:17 -0500 Received: from srv.home ([10.8.0.1] ident=heh12358) by ns3.fnarfbargle.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1kZpJ6-0006Tu-2a; Tue, 03 Nov 2020 13:56:36 +0800 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fnarfbargle.com; s=mail; h=Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:References:Cc:To:From:Subject; bh=ISCp/k9iAd9MHlIzbF+VLFLF2B9AGbwsrcc2H51zWw4=; b=xHIQoZoBsebAFKc9gusvWs/9bnxmnyNgCCxVl6mcrWJTZ/pheTl4CMf8DO9gRJKiwwrpLc3Rf8nckr1LDB46nq99B7q0oigFqIo5fmDCH1X66EJAwvw5yrM2Zc0hdzAIg4quf1kb6UfDN7z/NY7EEIG6o5mqoYwOrj0hwTr93kI=; Subject: Re: [REGRESSION] hwmon: (applesmc) avoid overlong udelay() From: Brad Campbell To: Andreas Kemnade , Guenter Roeck Cc: Arnd Bergmann , rydberg@bitmath.org, Jean Delvare , linux-hwmon@vger.kernel.org, "linux-kernel@vger.kernel.org" , hns@goldelico.com References: <20200930105442.3f642f6c@aktux> <20200930164446.GB219887@roeck-us.net> <20201002002251.28462e64@aktux> <7543ef85-727d-96c3-947e-5b18e9e6c44d@roeck-us.net> <20201006090226.4275c824@kemnade.info> Message-ID: <68467f1b-cea1-47ea-a4d4-8319214b072a@fnarfbargle.com> Date: Tue, 3 Nov 2020 16:56:32 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------260640A5259521660CE4A5E1" Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------260640A5259521660CE4A5E1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 3/11/20 10:56 am, Brad Campbell wrote: > > I've examined the code in VirtualSMC and I'm not convinced we were not waiting on the wrong bits. > > #define SMC_STATUS_AWAITING_DATA  BIT0  ///< Ready to read data. > #define SMC_STATUS_IB_CLOSED      BIT1  /// A write is pending. > #define SMC_STATUS_BUSY           BIT2  ///< Busy processing a command. > #define SMC_STATUS_GOT_COMMAND    BIT3  ///< The last input was a command. > #define SMC_STATUS_UKN_0x16       BIT4 > #define SMC_STATUS_KEY_DONE       BIT5 > #define SMC_STATUS_READY          BIT6  // Ready to work > #define SMC_STATUS_UKN_0x80       BIT7  // error > > Any chance you could try this patch? It's ugly, hacked together and currently fairly undocumented, but if it works I'll figure out how to clean it up (suggestions welcome). > It works on my MacbookPro 11,1. I had some time so I spent a bit of time refactoring and trying to clarify the magic numbers. I also did some fuzzing of the SMC and figured out where we can loosen the masks. This has some debug code in it to identify if any wait loops exceed 1 loop and if the SMC is reporting anything other than a clear "I'm waiting" prior to each command. You might see some of these : [ 51.316202] applesmc: wait_status looping 2: 0x44, 0x40, 0x4e [ 60.002547] applesmc: wait_status looping 2: 0x44, 0x40, 0x4e [ 60.130754] applesmc: wait_status looping 2: 0x44, 0x40, 0x4e I did some heavy tests and found that with the delays at the bottom of the loop about 50% of calls required no delay at all before a read or write and the other 50% require a single delay. I can count on one hand the number of times it's exceeded 1 loop, and the max thus far has been 5 loops. We've been treating bit 0x04 as an ack, but from my testing on the machine and what I've seen in the SMC emulator code it actually means "I'm busy in the middle of a command". Bit 0x02 seems to mean "I'm doing something and I *will* ignore anything you send me". Bit 0x08 means "The last thing I got was a valid command, so start sending me data". By testing and waiting for 0x02 to clear before sending or reading I haven't seen any need for retries. On my unit bit 0x40 is always active. It may not be on others. The emulator calls it a status ready, so it's tested for but that is consolidated in wait_status so it can be commented out if it doesn't work on your machine. The thing with bit 0x04 is the SMC clears it when it's no longer busy. So the last byte of data sent for a command sees it clear that bit. That explains the timeouts but the command still works. As far as the SMC is concerned it's got all the data and gone off to do its thing, but applesmc was waiting for the bit to be set. When it's in the middle of a command (from the first command byte until the last data byte is received) I've never seen bit 0x04 cleared, so using it as an "ack" works, but as said upward in the thread "probably by accident". So this code tests for an "idle" SMC before it sends a command. In this context idle just means bit 0x02 isn't set. If the SMC gets into an undefined state it can leave other bits set, but a new write with a valid command will reset the internal state machine and bring it back into line. Bit 0x08 should always be set after it has received a valid command. I've gone belt and braces by checking the status before and after each command, but with the intention of trying to catch and log anything that goes awry. Like I said above, in 50% of cases I see zero delays required so I thought testing before the delay was a worthwhile win. If anyone with a Mac having a conventional SMC and seeing issues on 5.9 could test this it'd be appreciated. I'm not saying this code is "correct", but it "works for me". If anyone actually knows what they're doing and wants to "correct" me, it'd be appreciated also. Regards, Brad --------------260640A5259521660CE4A5E1 Content-Type: text/plain; charset=UTF-8; name="smc.patch.5" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smc.patch.5" ZGlmZiAtLWdpdCBhL2RyaXZlcnMvaHdtb24vYXBwbGVzbWMuYyBiL2RyaXZlcnMvaHdtb24v YXBwbGVzbWMuYwppbmRleCBhMTg4ODc5OTBmNGEuLmFiYjA2ZmJlN2JjMSAxMDA2NDQKLS0t IGEvZHJpdmVycy9od21vbi9hcHBsZXNtYy5jCisrKyBiL2RyaXZlcnMvaHdtb24vYXBwbGVz bWMuYwpAQCAtNDIsNiArNDIsMTYgQEAKIAogI2RlZmluZSBBUFBMRVNNQ19NQVhfREFUQV9M RU5HVEggMzIKIAorLyogQXBwbGUgU01DIHN0YXR1cyBiaXRzICovCisjZGVmaW5lIFNNQ19T VEFUVVNfQVdBSVRJTkdfREFUQSAgMHgwMSAgLy8vPCBEYXRhIHdhaXRpbmcgdG8gYmUgcmVh ZAorI2RlZmluZSBTTUNfU1RBVFVTX0lCX0NMT1NFRCAgICAgIDB4MDIgIC8vLyBBIHdyaXRl IGlzIHBlbmRpbmcgLyB3aWxsIGlnbm9yZSBpbnB1dAorI2RlZmluZSBTTUNfU1RBVFVTX0JV U1kgICAgICAgICAgIDB4MDQgIC8vLzwgQnVzeSBpbiB0aGUgbWlkZGxlIG9mIGEgY29tbWFu ZC4KKyNkZWZpbmUgU01DX1NUQVRVU19HT1RfQ09NTUFORCAgICAweDA4ICAvLy88IFRoZSBs YXN0IGlucHV0IHdhcyBhIGNvbW1hbmQuCisjZGVmaW5lIFNNQ19TVEFUVVNfVUtOXzB4MTYg ICAgICAgMHgxMAorI2RlZmluZ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