Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp682492pxb; Thu, 14 Jan 2021 16:22:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe4Im5WfTkYPqmXW60+HYJ6NNQ7BJsrGnvYVun7HyDhuhuztD5ewySEDRXMGI8/Y8GMypE X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr6860518ejo.479.1610670165460; Thu, 14 Jan 2021 16:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610670165; cv=none; d=google.com; s=arc-20160816; b=una2WLmLHzt+BH7Wes1g/nbeOmfL7bqyyDJ9izgZUuLQey8rI9kYsUds26EgLXk+1A 3nj9RGJ14uW6L/x+2W9BpeB2BzZhhrcHf9GPmyRANHB9c1mjcF06s1/IAbwofCWE0aBH ir1d3pac1ta+b86CI+ckov9kX5nVTOGQrLNPT1Mw2hsihupovE6enJfX52sql5FAuePI RBwTIEQkFAsxjq/TUGRlPAHIPjOflNx2tttpWg1RJI1QFrrq1FSkNSw4Ls81NVD5lxTU mnGyiibg/MHrJv0fZyP27Nb3zZqFVfLK1Fn08WFQFktiEYTbJGNhrLXyVmqXXbhCaZUp +ANw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zt1gojRQ8y+kQrUr8XZf/h3nxFRhRnyC1cuRKGOl51A=; b=wy2rXboLa0AKsQolMVb48ZtDZZLcYVvTTV008/le4OqEhjVNUwRHGbb/Y/rmk0hTSY z0BhrIMP9WcOJU669zt8VkRcQGhLtw4sZZjbEzAI20EfEE+0oFDuAFlZSVX1kAChJWcO AwHkm4peyUaA/BH77dWkz0WBLiR9mRfBeFhPGvq+OzPEf4i7KmWYzUiTmCS0L5eWZ1CR +qMEwjUJoge/M9iII1DMilvZ1pkLF9ckB6JAsB3mo/bmU7VMyHm4nl7Po+Vbvvtw7v7i KU4SRnGbeZS3+DqJzo/KCjakUC0HRTq696ddidOXRk1r5BdLJ+m7N7AQoUIvX+A/2hQ4 b8Sw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si1068168edm.151.2021.01.14.16.22.21; Thu, 14 Jan 2021 16:22:45 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731263AbhAOAVH (ORCPT + 99 others); Thu, 14 Jan 2021 19:21:07 -0500 Received: from mx2.suse.de ([195.135.220.15]:47292 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731197AbhAOAVG (ORCPT ); Thu, 14 Jan 2021 19:21:06 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D245DB2D0; Fri, 15 Jan 2021 00:20:24 +0000 (UTC) From: Davidlohr Bueso To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, dave@stgolabs.net, Davidlohr Bueso Subject: [PATCH] platform/goldfish: Convert pipe tasklet to threaded irq Date: Thu, 14 Jan 2021 16:20:14 -0800 Message-Id: <20210115002014.117528-1-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. A more suitable equivalent is to converted to threaded irq instead and deal with the signaled pipes in task context. Signed-off-by: Davidlohr Bueso --- drivers/platform/goldfish/goldfish_pipe.c | 28 +++++++++-------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 1ab207ec9c94..b67539f9848c 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -212,9 +212,6 @@ struct goldfish_pipe_dev { int version; unsigned char __iomem *base; - /* an irq tasklet to run goldfish_interrupt_task */ - struct tasklet_struct irq_tasklet; - struct miscdevice miscdev; }; @@ -577,10 +574,10 @@ static struct goldfish_pipe *signalled_pipes_pop_front( return pipe; } -static void goldfish_interrupt_task(unsigned long dev_addr) +static irqreturn_t goldfish_interrupt_task(int irq, void *dev_addr) { /* Iterate over the signalled pipes and wake them one by one */ - struct goldfish_pipe_dev *dev = (struct goldfish_pipe_dev *)dev_addr; + struct goldfish_pipe_dev *dev = dev_addr; struct goldfish_pipe *pipe; int wakes; @@ -599,13 +596,14 @@ static void goldfish_interrupt_task(unsigned long dev_addr) */ wake_up_interruptible(&pipe->wake_queue); } + return IRQ_HANDLED; } static void goldfish_pipe_device_deinit(struct platform_device *pdev, struct goldfish_pipe_dev *dev); /* - * The general idea of the interrupt handling: + * The general idea of the (threaded) interrupt handling: * * 1. device raises an interrupt if there's at least one signalled pipe * 2. IRQ handler reads the signalled pipes and their count from the device @@ -614,8 +612,8 @@ static void goldfish_pipe_device_deinit(struct platform_device *pdev, * otherwise it leaves it raised, so IRQ handler will be called * again for the next chunk * 4. IRQ handler adds all returned pipes to the device's signalled pipes list - * 5. IRQ handler launches a tasklet to process the signalled pipes from the - * list in a separate context + * 5. IRQ handler defers processing the signalled pipes from the list in a + * separate context */ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id) { @@ -645,8 +643,7 @@ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id) spin_unlock_irqrestore(&dev->lock, flags); - tasklet_schedule(&dev->irq_tasklet); - return IRQ_HANDLED; + return IRQ_WAKE_THREAD; } static int get_free_pipe_id_locked(struct goldfish_pipe_dev *dev) @@ -811,12 +808,10 @@ static int goldfish_pipe_device_init(struct platform_device *pdev, { int err; - tasklet_init(&dev->irq_tasklet, &goldfish_interrupt_task, - (unsigned long)dev); - - err = devm_request_irq(&pdev->dev, dev->irq, - goldfish_pipe_interrupt, - IRQF_SHARED, "goldfish_pipe", dev); + err = devm_request_threaded_irq(&pdev->dev, dev->irq, + goldfish_pipe_interrupt, + goldfish_interrupt_task, + IRQF_SHARED, "goldfish_pipe", dev); if (err) { dev_err(&pdev->dev, "unable to allocate IRQ for v2\n"); return err; @@ -874,7 +869,6 @@ static void goldfish_pipe_device_deinit(struct platform_device *pdev, struct goldfish_pipe_dev *dev) { misc_deregister(&dev->miscdev); - tasklet_kill(&dev->irq_tasklet); kfree(dev->pipes); free_page((unsigned long)dev->buffers); } -- 2.26.2