From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751222AbdAMHwt convert rfc822-to-8bit (ORCPT ); Fri, 13 Jan 2017 02:52:49 -0500 Received: from mx5-04.smtp.antispamcloud.com ([95.211.112.140]:38856 "EHLO mx5-04.smtp.antispamcloud.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbdAMHwr (ORCPT ); Fri, 13 Jan 2017 02:52:47 -0500 X-Greylist: delayed 1590 seconds by postgrey-1.27 at vger.kernel.org; Fri, 13 Jan 2017 02:52:46 EST Subject: Re: [PATCH] i2c: i2c-cadence: Don't register the adapter until it's ready To: Vladimir Zapolskiy , References: <1483613240-32501-1-git-send-email-mike.looijmans@topic.nl> <428e8fc8-8b23-8e2c-763e-d977aaa98691@mleia.com> CC: , , , , From: Mike Looijmans Organization: TOPIC Message-ID: <469bf72b-70e6-24d2-99b1-79b6f0a635bb@topic.nl> Date: Fri, 13 Jan 2017 07:40:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <428e8fc8-8b23-8e2c-763e-d977aaa98691@mleia.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8BIT X-Originating-IP: [192.168.80.121] X-EXCLAIMER-MD-CONFIG: 9833cda7-5b21-4d34-9a38-8d025ddc3664 X-EXCLAIMER-MD-BIFURCATION-INSTANCE: 0 X-Originating-IP: 37.74.225.130 X-SpamExperts-Domain: topic.nl X-SpamExperts-Username: 37.74.225.128/28 Authentication-Results: antispamcloud.com; auth=pass smtp.auth=37.74.225.128/28@topic.nl X-SpamExperts-Outgoing-Class: unsure X-SpamExperts-Outgoing-Evidence: Combined (0.11) X-Filter-ID: s0sct1PQhAABKnZB5plbIbbvfIHzQjPVmPLZeVYSu3xU9luQrU+8/8qthi+0Jd/W/95+6ZE6dI+d FNTaLLKrTD4PkK8WOoKuw32u9iEtZmisSr42qUwvK7U11fJ5smF5bE7GwnNXTE7JFCR1ojdwNJq9 aafjg9jU5T6tqFLFy1IddBokma+BTIL0RMmcH9L3qzidFIfN0rUjiPbeeWlOrGbjO41FyBEqIaDu dcVplPGNaieKxw/vh63RdlaW2Zj1hcQD6Dxo9kokFZNwiacNPxeTCKssqlJePCDBHWfCYUvWOATT vnG+QUCcfrSs6FZc7tZ3vKwSN7Mv0HNteAusUZ8BuYwGqmI8Tx/Ism0pnCcmlWACu0WC7nIKSPYV aBAAdpU0oUDqng6Dyy2mQeofiQNVm/yRKI8ztnVD2jOcbyZ1el35jO+WJBgrWGjAavfuifnL+9wg oTj4ygNPw1XfN1IUJ2+rCMPpQhII5VkEVC//8GRISD+lYCwA5l6/Q4nfg8y63jKKBrO1BroJmvb9 eS8/gEZbIQzNpzl9FXiGPzJpwWXpE+sdjNmnXWjiNaLzU4EFnW2XgX+M1ZN6UZmlFVODLzPsd/iT v744WiqgNunTiEw2ui8TVPldBCj8jBATWTBGqdJt0f5T8QbPnFgP6qI5l+bukEPAN7a+1bvsjnfH 1FXJXnmz6ZcnEF2vNYMbTGNEHIeqEJHEXRcDdYgtoPFSqLjY6w6DP6U9VKa5TZ6Gs9HjdrlYbXkZ KU5GQmOJ6T38BJSNojNDpUW6fi2LXxOYKPlFHKsvscBZavl0uOQdppT9lvbvmoHXGpx+nFAzkDjS NwwBRVNX6ntpIckc7xgnaJOjCcy4XjEIC7jARxivQFL+nnEMeVSV4g+WikfyYVqEq5W3ohlLdxCO ttwUiHkMLWk/C0vLNlLzxrmqyasvHzab8A/sH35ju6jIKmqhMFAPAXvhbstCZwQvpf5MTUdiS+j4 Sw+g8M3VsAwTvxPdAHbWWtpoym+/H8NlV8unA6rM1qp8QY90buwLoh2HbIazSxPqavlzLTC6THuF HAM= X-Report-Abuse-To: spam@quarantine2.antispamcloud.com X-Recommended-Action: accept Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06-01-17 22:34, Vladimir Zapolskiy wrote: > Hello Mike, > > On 01/05/2017 12:47 PM, Mike Looijmans wrote: >> The driver calls i2c_add_adapter before writing to config registers, >> resulting in dmesg output like this, where devices fail to initialize: >> >> cdns-i2c ff030000.i2c: timeout waiting on completion >> pca953x 1-0041: failed reading register >> pca953x: probe of 1-0041 failed with error -110 >> at24 1-0050: 512 byte 24c04 EEPROM, writable, 1 bytes/write >> cdns-i2c ff030000.i2c: 100 kHz mmio ff030000 irq 197 >> >> The adapter is being used before it completed the "probe". To fix >> this, make "i2c_add_adapter" the last thing it calls in probe. >> It also makes sense to show the adapter initialization before >> the devices on the bus. > > commonly "it also" in a commit message means a change, which should be done > separately, and this is the case here as well. > > Because the adapter registration i2c_add_adapter() can fail, information > about the adapter initialization would be expected only in case of > successful registration. I would argue that the "info" message means "the I2C adapter is ready for transaction now, and we'll start initializing devices on the bus". That is the case before it calls i2c_add_adapter(). When i2c_add_adapter() runs, it will start probing devices on the bus. This yields very confusing output, as it will output things in a reversed order: - device X on I2C bus - device Y on I2C bus - cdns-i2c ff030000.i2c: 100 kHz mmio ff030000 irq 197 This is especially confusing if there are multiple I2C adapters with muxes behind them, the order then becomes like this: - Device X on bus 0 - Mux A on bus 0 registering bus 2, 3 and 4 - I2C controller for bus 0 - Device Y on bus 1 - I2C controller for bus 1 - Device Z on bus 2 - etc.. > The information sent to the kernel log buffer here is quite trivial, > probably dev_info() can be just removed, but in any case it should be > a separate change. Fine with me too. > >> Signed-off-by: Mike Looijmans > > -- > With best wishes, > Vladimir > Kind regards, Mike Looijmans System Expert TOPIC Products Materiaalweg 4, NL-5681 RJ Best Postbus 440, NL-5680 AK Best Telefoon: +31 (0) 499 33 69 79 E-mail: mike.looijmans@topicproducts.com Website: www.topicproducts.com Please consider the environment before printing this e-mail