Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5259273rdb; Wed, 13 Dec 2023 03:57:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEq2TliR/8X55UfWZQE+YRYnkhgwPNlOwtFTradzgNTEsxUkoIFWZgaBrEGORM4HbsBcY0D X-Received: by 2002:a05:6a21:27a9:b0:191:60f5:2a9 with SMTP id rn41-20020a056a2127a900b0019160f502a9mr3938143pzb.80.1702468632595; Wed, 13 Dec 2023 03:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702468632; cv=none; d=google.com; s=arc-20160816; b=ZgDN0j1SW9tkl0YGWCmitKz8b1l3p9ytnBDpX7XmdTnvh+3qn84f35BIVQA36KZPOr tiG4i6tlHbCpxzCZh46kxYKMynBbwRKzhWInr2z9hzpOLX/LmMSfpIQV3Wv8CsfzPPUi o1LURbJTpXAqXZC/CGTiPvRFjwhWVAZD102YMstFok82qk4sjTGwYuKtDLp83ptoQlCg cauPP61D29EDmpcPO50pqohOpxMuo72WboDivg6kuCgeQ1hgA+cONFanXEAGF84Ob3pP 7K0NXnFE2rF83MuBACw57a2p9OiG7Qkt6iOPFM0/ZT/ZgMHNAC5SJS57amoqwt4Qup47 zNFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=JcaHOo5mJcjcACNZaFUyycf3JCGnruoZJKzRAvj1Ps4=; fh=rS280mNVbCTmTIo5+yBM6Tl2NzpUfwzzTdZikW3+zSI=; b=MvuLWbFcUXn5bkYJgxrzJYM5D7zr88sbqaRKFP0yRWkz7Vy91amgiIw1A8kbuDW0jQ maqLPjlCelwi8RPf0eab5d3tZdegD1AhhuMyv6XjladeWS1XWIdzyb5qiS5XnHMMB69K mc69A9m2/MsircKi1Xgo8Hdspqx4Lg66euD49QR4spDmTx26zHlP0T9Qps3hF0AWlFwR S7dEW4GY3ZuTac4yapWnPutcCbYN3R2gf0UlhCPIKHZbED5/JCHLEpSl92u0kujLFGRf clZOzhPxL/eSHYnh/0EUzMwo9jmT6SKIQ6ujvvIgVwTjWlbXCU8KQtA5TAQ6XLsCCxtd NC6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=JlVl611l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q13-20020a056a00088d00b006d08892e9f8si5431207pfj.124.2023.12.13.03.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 03:57:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=JlVl611l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3CB278182DC1; Wed, 13 Dec 2023 03:57:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233478AbjLML4t (ORCPT + 99 others); Wed, 13 Dec 2023 06:56:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233380AbjLML4s (ORCPT ); Wed, 13 Dec 2023 06:56:48 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C33CB0; Wed, 13 Dec 2023 03:56:54 -0800 (PST) Received: from [192.168.88.20] (91-158-149-209.elisa-laajakaista.fi [91.158.149.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B78914A9; Wed, 13 Dec 2023 12:56:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702468567; bh=LpozRU9I0yUBeNC+SLVevsZLHwzso4Nd9+gU5TUH4t8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=JlVl611lQFRznEIx5K/5KizQsqy0aIQk6E+5jngYPjQW28ZGLNboaYKl/jr2elrUS WeAmY4PWI5wYvX2CjFhEiWp6MG6Yn4j2qqmDgrcq8SNUdwjwkPRS7Ex7xqD81aZUU0 x6d40lkrjHIumtFUOooPw9gtzkYyFtqL4khvSCgg= Message-ID: <0722393c-8107-4a8f-b3ab-1bbb347a6f1b@ideasonboard.com> Date: Wed, 13 Dec 2023 13:56:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [v2] media: i2c: mt9m114: use fsleep() in place of udelay() Content-Language: en-US To: Laurent Pinchart Cc: Arnd Bergmann , Sakari Ailus , Mauro Carvalho Chehab , Nathan Chancellor , Jacopo Mondi , Hans Verkuil , Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20231213112322.1655236-1-arnd@kernel.org> <5c5647d5-b389-4d71-9062-3a9921212079@ideasonboard.com> <20231213114812.GB769@pendragon.ideasonboard.com> From: Tomi Valkeinen Autocrypt: addr=tomi.valkeinen@ideasonboard.com; keydata= xsFNBE6ms0cBEACyizowecZqXfMZtnBniOieTuFdErHAUyxVgtmr0f5ZfIi9Z4l+uUN4Z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fWtp+VnwNGc6nq5IQDESH mvQcsFS7d3eGVI6eyjCFdcAO8eMAEQEAAcLBXwQYAQIACQUCTqazRwIbDAAKCRD6PaqMvJYe 9fA7EACS6exUedsBKmt4pT7nqXBcRsqm6YzT6DeCM8PWMTeaVGHiR4TnNFiT3otD5UpYQI7S suYxoTdHrrrBzdlKe5rUWpzoZkVK6p0s9OIvGzLT0lrb0HC9iNDWT3JgpYDnk4Z2mFi6tTbq xKMtpVFRA6FjviGDRsfkfoURZI51nf2RSAk/A8BEDDZ7lgJHskYoklSpwyrXhkp9FHGMaYII m9EKuUTX9JPDG2FTthCBrdsgWYPdJQvM+zscq09vFMQ9Fykbx5N8z/oFEUy3ACyPqW2oyfvU CH5WDpWBG0s5BALp1gBJPytIAd/pY/5ZdNoi0Cx3+Z7jaBFEyYJdWy1hGddpkgnMjyOfLI7B CFrdecTZbR5upjNSDvQ7RG85SnpYJTIin+SAUazAeA2nS6gTZzumgtdw8XmVXZwdBfF+ICof 92UkbYcYNbzWO/GHgsNT1WnM4sa9lwCSWH8Fw1o/3bX1VVPEsnESOfxkNdu+gAF5S6+I6n3a ueeIlwJl5CpT5l8RpoZXEOVtXYn8zzOJ7oGZYINRV9Pf8qKGLf3Dft7zKBP832I3PQjeok7F yjt+9S+KgSFSHP3Pa4E7lsSdWhSlHYNdG/czhoUkSCN09C0rEK93wxACx3vtxPLjXu6RptBw 3dRq7n+mQChEB1am0BueV1JZaBboIL0AGlSJkm23kw== In-Reply-To: <20231213114812.GB769@pendragon.ideasonboard.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 03:57:09 -0800 (PST) On 13/12/2023 13:48, Laurent Pinchart wrote: > On Wed, Dec 13, 2023 at 01:40:54PM +0200, Tomi Valkeinen wrote: >> On 13/12/2023 13:23, Arnd Bergmann wrote: >>> From: Arnd Bergmann >>> >>> With clang-16, building without COMMON_CLK triggers a range check on >>> udelay() because of a constant division-by-zero calculation: >>> >>> ld.lld: error: undefined symbol: __bad_udelay >>>>>> referenced by mt9m114.c >>>>>> drivers/media/i2c/mt9m114.o:(mt9m114_power_on) in archive vmlinux.a >>> >>> In this configuration, the driver already fails to probe, before >>> this function gets called, so it's enough to suppress the assertion. >>> >>> Do this by using fsleep(), which turns long delays into sleep() calls >>> in place of the link failure. >>> >>> This is probably a good idea regardless to avoid overly long dynamic >>> udelay() calls on a slow clock. >>> >>> Cc: Sakari Ailus >>> Fixes: 24d756e914fc ("media: i2c: Add driver for onsemi MT9M114 camera sensor") >>> Signed-off-by: Arnd Bergmann >>> --- >>> drivers/media/i2c/mt9m114.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c >>> index 0a22f328981d..68adaecaf481 100644 >>> --- a/drivers/media/i2c/mt9m114.c >>> +++ b/drivers/media/i2c/mt9m114.c >>> @@ -2116,7 +2116,7 @@ static int mt9m114_power_on(struct mt9m114 *sensor) >>> duration = DIV_ROUND_UP(2 * 50 * 1000000, freq); >>> >>> gpiod_set_value(sensor->reset, 1); >>> - udelay(duration); >>> + fsleep(duration); >>> gpiod_set_value(sensor->reset, 0); >>> } else { >>> /* >> >> I think this is fine, so: >> >> Reviewed-by: Tomi Valkeinen >> >> But: If we don't have COMMON_CLK (or rather, I think, HAVE_CLK), the >> freq will be zero at compile time. So won't the compiler give a warning >> for the DIV_ROUND_UP() call? >> >> Interestingly, for me, this doesn't give a div-by-zero warning: >> >> int x; >> int y = 0; >> x = DIV_ROUND_UP(10, y); >> >> but this does: >> >> int x; >> const int y = 0; >> x = DIV_ROUND_UP(10, y); >> >> And looks like this gives the warning too: >> >> int x; >> const int y = 0; >> if (y) >> x = DIV_ROUND_UP(10, y); >> >> So, I think, the code in the driver could fail to compile at some later >> point, if the compiler warnings are improved (?), or if someone adds a >> 'const' in front of 'long freq = clk_get_rate(sensor->clk);' line. >> >> Maybe worry about that if it actually happens =). > > Maybe :-) I would be tempted to make VIDEO_CAMERA_SENSOR depend on > COMMON_CLK. I think HAVE_CLK would be more correct. Tomi