Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp51343pxb; Tue, 12 Jan 2021 19:46:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyv6sXsjGhWNy2wb8QwWGTGt1pd+W3ndr2jU7uHH//cEDV1saZvnvhSjUbzaOYfw3zj87ha X-Received: by 2002:a17:906:29cd:: with SMTP id y13mr87987eje.453.1610509578905; Tue, 12 Jan 2021 19:46:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610509578; cv=none; d=google.com; s=arc-20160816; b=Xr5JTKVBnpoXhL2IoXny9b7jiMhO8/JHpm+Nzgew1qcaUO4TxF3uIKmGmZxfxpS/Nu 1DgClYKULkWxtjKXfZ2q87YnM0hJZDAoeNn0hAY5PLMkv+wI1ETu+8oVajHVx7umUxSZ d8/wjvQYMmDGoNLFWnw3r+etk5VSGcLK7JRoYPVSyByR9lwuPH2JIERBsg/79ONsEB2p AoVYDXv8VpJebE3E6/FaQII8/YsuiJGteOycJf5dwYpu05BDRr1O0fU1Xz5BCd+g0p1z Gbc7SJfnWPTUu4iP7Qf9V+vZrs4AgVoi/jvNQ/xMlscizlyXUqPqDTvsSiNUDzsxMQLV cyJQ== 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=0faBkKVnGjK86Bfi/i5EydCAe51o7MyF6TfUs9NIwkg=; b=CZPQBjpCUoHOPLhzddeogHigzdRb1C5Fm+xamyyUJIV1wc7j0772Lfowg7KuctlOs0 TLVUQx5i84tcAoJ9BolXuy6GnyooDRjYuBqUHkhy8/oOX/CJzA+YmzBbZVbBrHItu9tb U/kH74zU93wIB/vJIfNDf2JS/duBrPxFb3ROjIlzxPIno7B3VTXdoQzSfP7YEEuBApIn TIbXm9lzoXqdVv/g47c3Cyd2sMcfs7bovKaz1e/FJRO1cc1hPgzRKUNBbSec6BAfgDwM kDE2TQy2UCnwJtqw+jh1E1OGz6ssnCt/cQFwAttPSsIQxYr7OWSKYJKjxygcgAiLP9iQ aA/Q== 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 b39si171365edf.1.2021.01.12.19.45.56; Tue, 12 Jan 2021 19:46:18 -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 S1728628AbhAMDQ3 (ORCPT + 99 others); Tue, 12 Jan 2021 22:16:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:39364 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728105AbhAMDQ2 (ORCPT ); Tue, 12 Jan 2021 22:16:28 -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 E72E6AD11; Wed, 13 Jan 2021 03:15:46 +0000 (UTC) From: Davidlohr Bueso To: jacmet@sunsite.dk Cc: gregkh@linuxfoundation.org, sergei.shtylyov@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, dave@stgolabs.net, Davidlohr Bueso Subject: [PATCH v2] usb/c67x00: Replace tasklet with work Date: Tue, 12 Jan 2021 19:15:37 -0800 Message-Id: <20210113031537.79859-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. c67x00_do_work() will now run in process context and have further concurrency (tasklets being serialized among themselves), but this is done holding the c67x00->lock, so it should be fine. Furthermore, this patch fixes the usage of the lock in the callback as otherwise it would need to be irq-safe. Signed-off-by: Davidlohr Bueso --- Changes from v1: cleaned up busted white spaces. drivers/usb/c67x00/c67x00-hcd.h | 2 +- drivers/usb/c67x00/c67x00-sched.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/c67x00/c67x00-hcd.h b/drivers/usb/c67x00/c67x00-hcd.h index 6b6b04a3fe0f..6332a6b5dce6 100644 --- a/drivers/usb/c67x00/c67x00-hcd.h +++ b/drivers/usb/c67x00/c67x00-hcd.h @@ -76,7 +76,7 @@ struct c67x00_hcd { u16 next_td_addr; u16 next_buf_addr; - struct tasklet_struct tasklet; + struct work_struct work; struct completion endpoint_disable; diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c index e65f1a0ae80b..c7d3e907be81 100644 --- a/drivers/usb/c67x00/c67x00-sched.c +++ b/drivers/usb/c67x00/c67x00-sched.c @@ -1123,24 +1123,26 @@ static void c67x00_do_work(struct c67x00_hcd *c67x00) /* -------------------------------------------------------------------------- */ -static void c67x00_sched_tasklet(struct tasklet_struct *t) +static void c67x00_sched_work(struct work_struct *work) { - struct c67x00_hcd *c67x00 = from_tasklet(c67x00, t, tasklet); + struct c67x00_hcd *c67x00; + + c67x00 = container_of(work, struct c67x00_hcd, work); c67x00_do_work(c67x00); } void c67x00_sched_kick(struct c67x00_hcd *c67x00) { - tasklet_hi_schedule(&c67x00->tasklet); + queue_work(system_highpri_wq, &c67x00->work); } int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00) { - tasklet_setup(&c67x00->tasklet, c67x00_sched_tasklet); + INIT_WORK(&c67x00->work, c67x00_sched_work); return 0; } void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00) { - tasklet_kill(&c67x00->tasklet); + cancel_work_sync(&c67x00->work); } -- 2.26.2