From patchwork Fri Jan 21 21:17:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Schlabbach X-Patchwork-Id: 533992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F3DBC433F5 for ; Fri, 21 Jan 2022 21:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233176AbiAUVRu (ORCPT ); Fri, 21 Jan 2022 16:17:50 -0500 Received: from mout.gmx.net ([212.227.17.20]:42589 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbiAUVRt (ORCPT ); Fri, 21 Jan 2022 16:17:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1642799868; bh=iGmYZIqWAKnKoIOYDwGIKZjktLKBzUwZpfPSjAROdLM=; h=X-UI-Sender-Class:From:To:Subject:Date; b=MfIxkYpRUlgZmCucakMdEn2Pkieu833ykUbxJUS3XaDCQC0IUiLbvYDf5sQVKZdzP EnAW1QJ+GD4T1dim+5wh7JekV3jqxHtQtdtB9CIMBJIkXMCmTCEzx0YUxYXx7G9c6g P3VRszH9IIjgbcCwsjTsGOylqGfg9V6nGPeITEXc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [91.65.109.130] ([91.65.109.130]) by web-mail.gmx.net (3c-app-gmx-bap04.server.lan [172.19.172.74]) (via HTTP); Fri, 21 Jan 2022 22:17:47 +0100 MIME-Version: 1.0 Message-ID: From: Robert Schlabbach To: linux-media@vger.kernel.org Subject: [PATCH 0/1] media: dvb-core: Enhance shared multi-frontend support Date: Fri, 21 Jan 2022 22:17:47 +0100 Importance: normal Sensitivity: Normal X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TvxL2t9cwtBc05P6+TEK9P4RYdRy/PfL4ufKUjXU7fwj5 qNhD832ivaPt6huOPLytBW3t+0lspyIYy4xjOpNy8HWpvbEO5qsmPLwScQPIos8WG/fWZsTqR oR0cLsX Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org I'm currently developing a driver for a receiver with multiple frontends which cannot be used simultaneously, and found that employing the mfe_shared field to exhibit that restriction leads to terrible behavior towards applications: - the unavailable frontend device cannot be opened at all, not even in read- only mode to just query information about the frontend - and really terrible: the open() call is blocked for a whopping 5 seconds! The user experience ended up being this (/dev/dvb/adapter0/frontend0 was already in use): $ robscan [5 seconds delay] Could not open /dev/dvb/adapter0/frontend1, device is busy Available Frontends and Supported Delivery Systems: 1: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-T/T2) 2: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-C) [shared frontend is missing] Select Frontend: 1 ERROR: Could not select frontend Silicon Labs Si2183: Device or resource busy The actually busy frontend /dev/dvb/adapter0/frontend0 could be queried for its name and supported delivery systems and the error when trying to use it came back immediately, so I thought I want the shared frontend to exhibit the same behavior, i.e. allow it being queried for its name and supported delivery systems, and reject write access with -EBUSY without delay. So I developed the attached patch for dvb_core.c which allows setting the mfe_shared field to 2 to achieve this behavior. Using this setting in my driver yielded the desired result: $ robscan Available Frontends and Supported Delivery Systems: 1: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-T/T2) 2: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-C) 3: /dev/dvb/adapter0/frontend1: Silicon Labs Si2183 (DVB-S/S2) Select Frontend: 3 ERROR: Could not select frontend Silicon Labs Si2183: Device or resource busy No delays, the unavailable frontend can be shown with name and supported delivery systems, and trying to use it gives the same result as for the frontend device currently in use. I left the existing uses of the mfe_shared field untouched so that existing drivers continue to function as before. Maybe some would already work by just setting the field to 2, but I did not take the time to thoroughly review their code, nor do I have those devices available to do regression testing with. So for now, only my driver would take advantage of this. I intend to submit my device driver once it is finished. Signed-off-by: Robert Schlabbach Tested-by: Robert Schlabbach