From patchwork Wed Feb 28 01:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 207625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3090787dyb; Tue, 27 Feb 2024 18:17:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVRISAGYm9EOkjt5gI9xrL/v96MplJ/6tQnsfxXu/TXz1v8Nd8IBUSh4JBGv8gYVHRmTaZ/RNNm7lxR/4cg0gnhxuzHIQ== X-Google-Smtp-Source: AGHT+IEbpkAfE/XSNi7rYipFz11CgUay7aWnzWnGMQZb0BiiwY0xclIn2IEuwUwFiwl2X3Nfn13a X-Received: by 2002:aa7:8450:0:b0:6e4:5cf5:1b5b with SMTP id r16-20020aa78450000000b006e45cf51b5bmr10141870pfn.30.1709086664890; Tue, 27 Feb 2024 18:17:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709086664; cv=pass; d=google.com; s=arc-20160816; b=aVLLGLqytJOmaB/gemGhWUFBsd1J3P+JbAEG5ctDkXqU2UqCny3jYYE44MYSZR3nTK sRcCL+CFB+abf4hvV7L7thgOqTWubMqZc1WyHlWaAbrzBMRyVrlzIdXPcgNHxPm0Oje8 Q8QmmpQlU9jQ8P+04ktpmUxTMlRFIKLuBGGEZg09QUZcgQBlE13qXacfkc9DyXNO1l7P WYzmWuOxKfi4FuloX4BARADKZgyQOzPr2Qw8e7sUBbBDHcccTJoczOUkUzlpovM6Z/zL 2f9akSy+KdH5nYDtMW95X2IQEXFFfQqscL3v4srVNgRVuHEjbriT7RH7BcVPRaPtMMGv WisA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R0hg4dDBYEp27ZuNyVb3W+iuKNUNsrbwtnpJmQVwa24=; fh=VKrp0Y7I/+wT36BfKZ6oI/4N9BIwFCn9zerObkOrgGw=; b=RMBunk6u5e8BDHlvc3cxKu5koHTIPIknUvRiHgIOFpp1cWVHWkjEBHmaPhTjP92gvx XLlkXdhfJ+N0LSJJyeSQizu221eFD26ZEAev76LgZ8psWi2EmTUL0zo8d1sqOMB3FqQ5 iHjWJEtlLl3X+ye3mC2Y+Zo6jVfiRfHZCrDGn77LylQaCuLdOPs30OL6qHtSQjQXyqXZ vonOY80K3qdPFhXkXKu4YBl6C/4tXn80YVLFOAs5kbhY5Hq1x/DjRKVeTzd7voAElOZH 5FtLpR/057VHIxT9V9DOT1cEldTpiWDLDL+wZX7Y3N7/xLU1Yva13+44lWIWc5ySne+v TwbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=K+Eg91CZ; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-84348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84348-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y134-20020a62ce8c000000b006e558a20e88si920519pfg.208.2024.02.27.18.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:17:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=K+Eg91CZ; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-84348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84348-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6A1D0B307B3 for ; Wed, 28 Feb 2024 01:44:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8345744368; Wed, 28 Feb 2024 01:37:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="K+Eg91CZ" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E17744A32; Wed, 28 Feb 2024 01:36:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709084214; cv=none; b=CK62m0E9pQlmieRjWULbnuV/M9xYM8OvhBMJFUYvy+bCfd0WztjOUINSo/Tziwlg5DNTxzGGNKD2+9rl5XLXwb0PYaO+gguCok4SlIQH4tccQVANO1XoA2LsMRFbLHZ5S+7O97peCjPY+gHcfrYkF+0IeEFqDsxs/yOImYJV0Ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709084214; c=relaxed/simple; bh=SI/xXqTaKb918srbROgcUJ5EMq0uUfJ689ErJLs6vMk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DgzJOfIGHo+JiQCoSfNr+R9GvOPRCyzvX09Pmn/9BVOCM6Dm8OLPl2Qt5SNH3hRWxI+4YO8LyShQlxHFXcMK4dPScATo/03xZaRU8CfbWIrBbLiQ3O4X9qxSAhJ9thXAta5pzDylwBXoxgSf+nxjAF710NwAFMIwi7YluLgNTyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=K+Eg91CZ; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41S1Wc7p023297; Wed, 28 Feb 2024 01:36:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=R0hg4dDBYEp27ZuNyVb3 W+iuKNUNsrbwtnpJmQVwa24=; b=K+Eg91CZSzMcFbC+Jd1/agFdDpzliMnIaUcM 7pASHG3tksI1NhxVPe13ZsRu7Z+YgAF6nTA/Uq7VHF0jO4P5UokoR4HIbxlSZ3BQ ZuwmyVbT+wdy1Mx3VXW9IhrYpGUf+Ph3HFvxJ1Ljj/3iz7x1+j0uQjjZLwd3XOYq Vzs0Qcng1zQ92b0PF4A7VZl9LwH1tyYhs2QMpcfvh+VgvFU3yYt0kn6OTNxMkz2a rWdVw7HWFKI8xOMZDBwtmXcHWg3BGDg9CbLyBl+esQ7PBwnNb+/6etR+1RfGpCBM 45Q4Muc7xSTr1MiO709137pkNOkG2451FfUWWShMd63Syts5EQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wh507b3eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Feb 2024 01:36:32 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41S1aVkw004868 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Feb 2024 01:36:31 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 27 Feb 2024 17:36:30 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v18 06/41] usb: host: xhci-sideband: Expose a sideband interrupter enable API Date: Tue, 27 Feb 2024 17:35:44 -0800 Message-ID: <20240228013619.29758-7-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240228013619.29758-1-quic_wcheng@quicinc.com> References: <20240228013619.29758-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: bxmNfsJeQWP77JuqhKPdrEuOlGHHALGF X-Proofpoint-GUID: bxmNfsJeQWP77JuqhKPdrEuOlGHHALGF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-27_11,2024-02-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 clxscore=1015 mlxscore=0 malwarescore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=981 priorityscore=1501 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402280011 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792107259043021848 X-GMAIL-MSGID: 1792107259043021848 Some use cases maybe require that the secondary interrupter's events to be handled by the OS. In this case, configure the IMOD and the skip_events property to enable the interrupter's events. By default, assume that the secondary interrupter doesn't want to enable OS event handling. Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-sideband.c | 28 ++++++++++++++++++++++++++++ include/linux/usb/xhci-sideband.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideband.c index 0944bf31d772..504a6f1586b5 100644 --- a/drivers/usb/host/xhci-sideband.c +++ b/drivers/usb/host/xhci-sideband.c @@ -237,6 +237,30 @@ xhci_sideband_get_event_buffer(struct xhci_sideband *sb) } EXPORT_SYMBOL_GPL(xhci_sideband_get_event_buffer); +/** + * xhci_sideband_enable_interrupt - enable interrupt for secondary interrupter + * @sb: sideband instance for this usb device + * @imod_interval: number of event ring segments to allocate + * + * Enables OS owned event handling for a particular interrupter if client + * requests for it. In addition, set the IMOD interval for this particular + * interrupter. + * + * Returns 0 on success, negative error otherwise + */ +int xhci_sideband_enable_interrupt(struct xhci_sideband *sb, u32 imod_interval) +{ + if (!sb || !sb->ir) + return -ENODEV; + + xhci_set_interrupter_moderation(sb->ir, imod_interval); + sb->ir->skip_events = false; + xhci_enable_interrupter(sb->ir); + + return 0; +} +EXPORT_SYMBOL_GPL(xhci_sideband_enable_interrupt); + /** * xhci_sideband_create_interrupter - creates a new interrupter for this sideband * @sb: sideband instance for this usb device @@ -275,6 +299,8 @@ xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, } sb->ir->ip_autoclear = ip_autoclear; + /* skip events for secondary interrupters by default */ + sb->ir->skip_events = true; out: mutex_unlock(&sb->mutex); @@ -297,6 +323,8 @@ xhci_sideband_remove_interrupter(struct xhci_sideband *sb) return; mutex_lock(&sb->mutex); + if (!sb->ir->skip_events) + xhci_disable_interrupter(sb->ir); xhci_remove_secondary_interrupter(xhci_to_hcd(sb->xhci), sb->ir); sb->ir = NULL; diff --git a/include/linux/usb/xhci-sideband.h b/include/linux/usb/xhci-sideband.h index 1035dae43cee..a749ae307ba7 100644 --- a/include/linux/usb/xhci-sideband.h +++ b/include/linux/usb/xhci-sideband.h @@ -54,6 +54,8 @@ xhci_sideband_get_endpoint_buffer(struct xhci_sideband *sb, struct sg_table * xhci_sideband_get_event_buffer(struct xhci_sideband *sb); +int xhci_sideband_enable_interrupt(struct xhci_sideband *sb, u32 imod_interval); + int xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, bool ip_autoclear);