Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp450795pxt; Fri, 6 Aug 2021 06:05:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXW2Jnnvvz1ze2dJRKIpks85uuTCV4+aGOmRIgGy71nd+QLA9h+c2CgPbDLjJzkBX9DJI9 X-Received: by 2002:aa7:d593:: with SMTP id r19mr12691040edq.372.1628255133283; Fri, 06 Aug 2021 06:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628255133; cv=none; d=google.com; s=arc-20160816; b=woAcfUpVxHSLmo0YaiQbE9nadhZX0F0drYvYYzHlQt0VBBqyuQe3USjl1RtrsQK6jb E7qN9jEyooZXFy19NcsFdtJM+6Um8tZCZzYmQaqmLIXIo9hZuE1Rbo39Hd6TH/77EI/r Owzwx1JUGOzdcfx8hZw0fVAh6Di5va4hYtQp/+KNWjZrvIo6COZtzkpMGcFKsRqe4wQ3 2mjp7fDSqT9m2yfPxiU/wMMgoX2Iwk5YV5gQlRUIplc4xCutSlH7J1spSR8xzrZ59PnA RPGrov9btErLTR2Y3mOQadlUlfoKqL6bmVimsZNOhL7oXB4MnmfnJyDPVvECYe0M7Kbk yJAg== 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=EA8/NMEQ1/xPrB1n9sMj1XYF0fWKh0U0LaqEd2bvscI=; b=0jKV9yoK6dp5G+ul8c5A6y4bCXBnGTtAaCdqJeeCALyKcX5vXFhCdZ5ibD3QDQV6+M b8k3jsM8cHugZGqjlMA/m9CoD9EBcKpRWiNXDx47kp5n4s8eJXT6NBkpwI0pFkV1Zyrx qVLFSGnEUeyjgv2buNGOPKsPY/CjeMHy6uE+VrpPt9AQIQmm3hEHuIaxngR8Zyu9WoIm gwjTiZTSpwcwlGwu9mTEangB1gcgi2IEHK2xWoPK+ZcfIJj67McTGzYrBRGdKTv7HOtA jBT8adQL/mjGYAGcJN6qGIW1T6zMzvmkFc9qMjqmvpeXd6U8se25v7IIHMb9KT16KQ4k 0zIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IVThQKyv; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd6si9040274edb.119.2021.08.06.06.05.03; Fri, 06 Aug 2021 06:05:33 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=IVThQKyv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243778AbhHFIPc (ORCPT + 99 others); Fri, 6 Aug 2021 04:15:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243770AbhHFIPK (ORCPT ); Fri, 6 Aug 2021 04:15:10 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FB07C06179F; Fri, 6 Aug 2021 01:14:51 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id m10-20020a17090a34cab0290176b52c60ddso16310438pjf.4; Fri, 06 Aug 2021 01:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=EA8/NMEQ1/xPrB1n9sMj1XYF0fWKh0U0LaqEd2bvscI=; b=IVThQKyvn2gxNJXnpFLRy2/6zL46SUnW9e68RZRuqE0OJSSzaeKQCfdAaCrcwSefTV 9mXe3B/Hsky78FMQ7M5DXshJVKO176KLEh2fqyi72GPa3f0qvamAIdR5IlxaBbVuuosz yOTQthryqUIGVGGXuVGZGAlRp2iPuXSGySJcw+JD+3FoeQiBgVQf5j5fnuOD+b4OUZsU XZ3kgOlzGypYT8bCQ7giTdHs+DjDCWTZEX+TV0pgVYkrDi6+iqz69fwXmtvgEA/kyded RnqD6PtrgKyOheu/asqpIq4ddrKVzakkLAeVe0SiCc3qSlde04Orp4+i/yXSWjU9rRmh naxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EA8/NMEQ1/xPrB1n9sMj1XYF0fWKh0U0LaqEd2bvscI=; b=Soncf3bWIGQWwCkqnXOP6zUwG8xyZ0jYm8KYIwfMzogPMiJT5XeSix+00NTMtqM/SF joOeZvCQFqLuYVK4ZAb32d8tKwb3j6SCPMbBEuZ0Lk0oMOV590jdUH/cEd3D51A/GWIW u9oM+tum1WAxZvaWgqmC5KR8cwB2bBkfSzd23VJVdW63DOUCzm0FoXkMnzM+OQbG8whx 1bklcy0hO2El9icNvti4utwY4AMO56H6WdXeo6+V1LQhW6u2kE5nXPtOqBcm6TTTPKSE MJY7GN8bQ5cuTh6SNZFTG3WCWmxTp9ATgmii1+st/N5cEQ63d7vb/8G4dyRklwAV1QJt oPsQ== X-Gm-Message-State: AOAM532oxNlQGiTzKk8JHk6uX9X0k37z1Al0NoTYAZqzYozRWdLIw7JP bKoTxChKzZbbSr8j5BmZiBFVMGfOrQApo8Dg X-Received: by 2002:a62:b414:0:b029:317:52d:7fd5 with SMTP id h20-20020a62b4140000b0290317052d7fd5mr9568253pfn.30.1628237690428; Fri, 06 Aug 2021 01:14:50 -0700 (PDT) Received: from [192.168.0.104] ([122.187.88.150]) by smtp.gmail.com with ESMTPSA id k200sm9829958pfd.46.2021.08.06.01.14.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Aug 2021 01:14:50 -0700 (PDT) Subject: Re: [BUG] mmc_regulator_set_ocr can't cope with regulator-fixed To: Mark Brown , Peter Geis Cc: Jaehoon Chung , Ulf Hansson , Liam Girdwood , Rob Herring , linux-mmc@vger.kernel.org, Linux Kernel Mailing List , "open list:ARM/Rockchip SoC..." , devicetree@vger.kernel.org References: <20210805124650.GM26252@sirena.org.uk> <20210805130842.GO26252@sirena.org.uk> From: Ravikumar Kattekola Message-ID: <81006771-99bf-a5f9-4001-2cf3dc84f69d@gmail.com> Date: Fri, 6 Aug 2021 13:44:45 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210805130842.GO26252@sirena.org.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Resending my reply as my Mail client settings prevented delivery On 05/08/21 6:38 pm, Mark Brown wrote: > On Thu, Aug 05, 2021 at 08:58:58AM -0400, Peter Geis wrote: >> On Thu, Aug 5, 2021 at 8:47 AM Mark Brown wrote: > >>> One thing to watch out for with this approach is if there's things that >>> really need a specific voltage to be set then you'll have to stop those >>> things happening if you've got a voltage regulator that can't deliver a >>> voltage in the required range. I don't know if this affects MMC or not, >>> if it's just a case of being less efficient it's not such an issue. > >> Yeah, but if this is a fixed regulator and it's a problem, then the >> hardware is screwed anyways. > > Well, the fact that the voltage is being changed at runtime indicates > that we're changing something from whatever was in the fixed setup - it > can sometimes be that we don't have access to some higher performance or > lower power features for example. That's not ideal but works perfectly > safely. > Suggested approach of checking "mmc->ocr_avail" might work. But, IMO mmc core should check if the voltage can be changed or not before trying to do regulator_set_voltage() in mmc_regulator_set_ocr(). Wouldn't that be better and solve this issue for other hosts as well. Something like below in mmc_regulator_set_ocr (): + result = regulator_check_voltage_constraints(supply, + min_uV, max_uV); + if(!result) { + result = regulator_set_voltage(supply, min_uV, max_uV); + if (result != -EINVAL && !mmc->regulator_enabled) { + result = regulator_enable(supply); + if (!result) + mmc->regulator_enabled = true; + } We could wrap the existing check_voltage function +/* Check voltage constraints helper function */ +int regulator_check_voltage_constraints(struct regulator *regulator, + int min_uV, int max_uV) +{ + return regulator_check_voltage(regulator->rdev, &min_uV, &max_uV); +} +EXPORT_SYMBOL_GPL(regulator_check_voltage_constraints); I hope this makes sense. Regards, RK