Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1896226rdh; Tue, 26 Sep 2023 06:51:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIxXupABck0+DRtRWkDpbFjhqYtlN6DgMiJ6+/sdEe6SB9Dl0HZea1fvo34jumU80l1G10 X-Received: by 2002:a17:903:2289:b0:1c1:f15c:976f with SMTP id b9-20020a170903228900b001c1f15c976fmr7963495plh.26.1695736282166; Tue, 26 Sep 2023 06:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695736282; cv=none; d=google.com; s=arc-20160816; b=eKXKmeEnW+rw/oVvSny3juODJh6R/kPgIQDSK0vj8SddUzdZ87jqIZWUy6oG1U6H5p ZXhVe8tQSUG/oY64ZmHZBwjxUWxcLX1jomuYjfv2Do8fBQBRwF8P1XYqrBqZAtfSd9UR Fkgjw96z1gMmG2BC0CNIrlFFf1gqCq5UYhuPigZWUp12abNONaUTJ52Pw5yZt7loKb6H UpTmZc2QA13UrZ0mV22AQzXCoBS1E0LsNuXJMUDjRGGtSJMKmsFlT1+XAnilw1YRabBu 9Y9bnI/5avFshk01jwBPePnMQ+y0gi8P9TqvP3zsIZQT+ajziTSLzfcTGKPmgb37LfND 1WEw== 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=1hA28nfmDNZCbL4Ew/7n+0PE3pEqWXZnhkySX1hHyL4=; fh=8Ch4NK8sSBDV6Yvct4R90GQFiNrq8AYWlLbezwI6uN8=; b=Jpw2GGn8wRCkTZ1v15h9ml9QpHJcorR5s5FXOEsUAH3FVK0go8D2XLFkmsLgpeJipL vNdRahidIcvCOnfiIFnSTtsXcCogyatBHS5yU8fM4zKw/3EtAD99f/saM7HTggdGCf6u kp+lFmEQjJ4UlWE8s+c9uJImVJm5vMbjUtQTQC+/he5JIBzPT5Fz3PlRIx2m0abtJu0M oAVNUr3lQZ6+uSUfEosPMK4doxqzDoWx9WICbuCJljd7G9zWeCAG9D54Dwa/X9UZqRH1 YhUXdtHfwVB3+gUvtkoaDapG9lNNrbadAQHJaBHRDgDHEQswU3wXHV+hL1LocMWcq7qu f4uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Kv93Zju4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l19-20020a170902f69300b001c5de4a5b4esi13031919plg.597.2023.09.26.06.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 06:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Kv93Zju4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4F6F58189098; Tue, 26 Sep 2023 05:43:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234536AbjIZMnc (ORCPT + 99 others); Tue, 26 Sep 2023 08:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233232AbjIZMnb (ORCPT ); Tue, 26 Sep 2023 08:43:31 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37818E5; Tue, 26 Sep 2023 05:43:24 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5344d996bedso2768329a12.3; Tue, 26 Sep 2023 05:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695732202; x=1696337002; darn=vger.kernel.org; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=1hA28nfmDNZCbL4Ew/7n+0PE3pEqWXZnhkySX1hHyL4=; b=Kv93Zju4/FKUwKzWH79hP/4d4Batk8oKPirBimT8+9QBRDVtdQz6y+PHmtDTsaF6Bn 8PJHey3yotRq7f80QaoDSgzVVwfql+EbVkHE+c9gSRkAvtMy2g9KHhxE/ex+Ylim0onE BeoexZpjuj9MwmC1glCxLh8moMrTmyC/Htloj6vpJxGF1EevZEwc5hEVWGrp6JQ/7YS2 /EjxonCreYv9CaHK8tIsGyfQUoLLA7bV22RvQR9Q6j6EcVppiD6lahRGQo4hZUPEn4+z oZjiGOLschMqQKaOQG2CNhNJSabzS/T5ZLxkF14cYmU5EurxSaJ6CEsw1wbCeft6kP6n hEVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695732202; x=1696337002; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1hA28nfmDNZCbL4Ew/7n+0PE3pEqWXZnhkySX1hHyL4=; b=QGnyyYKc6a3YuGFR17s7+dQpXsa4lqx+ZKS/G591xV+5ujH6F/xNJUtcb6R86X81kb /z9gCO0JF01MRWtdQXXVIP+nJzRyl90i7Xyg9FY5KRF/2P4SpJx+pykstYQBIcXu7XKy ZMjvcjpEKMC+4MfZR7L69npaRHpL6hAzDkbwHNRusCJkDxTl1e7syOSHg5oqGG5wOqmq liYn4E6RxeWqed97y1mPSrvBhuMAMSbhzkR5NwxCM4nmmoHtCz6hTgJ8NpWq/TtbrHRN zrR10UL7nSuCUbAkbM1GnFJEvJzy2y4D9yTFFMqSsavDjGoOEgJ+8IGeOGFl8ddW4W5B oiyw== X-Gm-Message-State: AOJu0Yz6BTeubo59TTFn8VJSykEVpzUn/hI+cbOBEnZVvJrJK+krAsgl ND3RU/RONJ1gxs/0fPW4M/gY1Bdl//w= X-Received: by 2002:a05:6402:150d:b0:530:8801:47aa with SMTP id f13-20020a056402150d00b00530880147aamr8268057edw.19.1695732202444; Tue, 26 Sep 2023 05:43:22 -0700 (PDT) Received: from [192.168.1.10] ([95.43.220.235]) by smtp.googlemail.com with ESMTPSA id l24-20020aa7c318000000b00533349696f1sm6736617edq.16.2023.09.26.05.43.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2023 05:43:22 -0700 (PDT) Subject: Re: [PATCH v5 2/2] media: rc: remove ir-rx51 in favour of generic pwm-ir-tx To: Sean Young Cc: linux-media@vger.kernel.org, Tony Lindgren , Russell King , Mauro Carvalho Chehab , Thierry Reding , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Timo Kokkonen , =?UTF-8?Q?Pali_Roh=c3=a1r?= , "Sicelo A . Mhlongo" , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org References: <99f0042f-538c-bcaf-96fd-bac24a87f88e@gmail.com> From: Ivaylo Dimitrov Message-ID: <1715e2bf-5d02-4f20-1476-29a1fdf350b1@gmail.com> Date: Tue, 26 Sep 2023 15:43:18 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 05:43:37 -0700 (PDT) On 26.09.23 г. 10:16 ч., Sean Young wrote: > On Mon, Sep 25, 2023 at 07:06:44PM +0300, Ivaylo Dimitrov wrote: >> On 1.09.23 г. 17:18 ч., Sean Young wrote: >>> The ir-rx51 is a pwm-based TX driver specific to the N900. This can be >>> handled entirely by the generic pwm-ir-tx driver, and in fact the >>> pwm-ir-tx driver has been compatible with ir-rx51 from the start. >>> >> >> Unfortunately, pwm-ir-tx does not work on n900. My investigation shows that >> for some reason usleep_range() sleeps for at least 300-400 us more than what >> interval it is requested to sleep. I played with cyclictest from rt-tests >> package and it gives similar results - increasing the priority helps, but I >> was not able to make it sleep for less that 300 us in average. I tried >> cpu_latency_qos_add_request() in pwm-ir-tx, but it made no difference. >> >> I get similar results on motorola droid4 (OMAP4), albeit there average sleep >> is in 200-300 us range, which makes me believe that either OMAPs have issues >> with hrtimers or the config we use has some issue which leads to scheduler >> latency. Or, something else... > > The pwm-ir-tx driver does suffer from this problem, but I was under the > impression that the ir-rx51 has the same problem. > Could you elaborate on the "pwm-ir-tx driver does suffer from this problem"? Where do you see that? ir-rx51 does not suffer from the same problem (albeit it has its own one, see bellow) >> In either case help is appreciated to dig further trying to find the reason >> for such a big delay. > > pwm-ir-tx uses usleep_range() and ir-rx51 uses hrtimers. I thought that > usleep_range() uses hrtimers; however if you're not seeing the same delay > on ir-rx51 then maybe it's time to switch pwm-ir-tx to hrtimers. > usleep_range() is backed by hrtimers already, however the difference comes from how hrtimer is used in ir-rx51: it uses timer callback function that gets called in softirq context, while usleep_range() puts the task in TASK_UNINTERRUPTIBLE state and then calls schedule_hrtimeout_range(). For some reason it takes at least 200-400 us (on average) even on OMAP4 to switch back to TASK_RUNNING state. The issue with ir-rx51 and the way it uses hrtimers is that it calls pwm_apply_state() from hrtimer function, which is not ok, per the comment here https://elixir.bootlin.com/linux/v6.6-rc3/source/drivers/pwm/core.c#L502 I can make pwm-ir-tx switch to hrtimers, that's not an issue, but I am afraid that there is some general scheduler or timers (or something else) issue that manifests itself with usleep_range() misbehaving. > I don't have a n900 to test on, unfortunately. > I have and once I have an idea what's going on will port pwm-ir-tx to hrtimers, if needed. Don't want to do it now as I am afraid the completion I will have to use will have the same latency problems as usleep_range() Thanks, Ivo > Thanks > Sean >