From patchwork Tue Jan 2 21:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 184511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4703814dyb; Tue, 2 Jan 2024 14:01:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvpq31pi578QXNRykhJOmSWY/RXWKAsHAmTxUa83bb0bOtrigg22jKELeNGXreDjowc551 X-Received: by 2002:a05:6122:2389:b0:4b6:b647:db94 with SMTP id bu9-20020a056122238900b004b6b647db94mr3314476vkb.10.1704232883895; Tue, 02 Jan 2024 14:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704232883; cv=none; d=google.com; s=arc-20160816; b=a6nPjCRc0Z2SVTiS+js4PW+1yKkWfcQ2xT7261vtPmd/hCkARJc+k2YmAABmzprYu/ 80lMHrZxi94p/AkIIAYr3UcdhoK+f0t4DQwBRY+dSMPKj+/FItkj2OQKsCQSUDUbvviM wvWqy2D/8q6deMIxFLpAG87FusLjJ4/yj8JGLd6XJ5zESEmZlaXUDP7rTTCRdx3qQqjo q59G2NqQU5BvDLiWZPXJh6Ftlq7KMXgU/i7W2E1OgFI3ZBJIneg2e9M8wjHPkL6nCJya FQsQBUyhb3wfenhO1dBDIzeKSOfC3PNUWelA3dCIwmQHp/wwtCK1jbHAwg3nguhDzVf5 ekSQ== ARC-Message-Signature: i=1; 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=q9wsZr9hk6oekRD8z74N6sV+NK+QirK5GCM36reO4w4=; fh=0KzismZj+xI0Z//ZGdqKIH/FO9LtSZM7Yj4P0VtrCz0=; b=QGAHqfpzzv1lnhvSqk2qWMPHuS9jVSOW9xN9PCW2AEn0emV3g347iCgukIi3cBjRO3 bO7pAfT2ltzwRqXlRQjEJAz3GBt1JUNtwD1Vz0IPstOEOWKS9LYty4JWJBq9SGp9VDnx n3bW3y0nDGcgIAeHhcsjFGs7sMjCIwACxrG2dYqIhoge49xed2ZtJtSxZq1AYSIj9RdH m4SdAo9rCDUt22b4gM27qIXWI2zz8PlTHzWQuI5xEWCYOTXnqRcLl1xGPzo5MfAZfHzL 7Ztfwlf87HytBNHZS1Gviv7S7fKuyQuWpa/NWgglaEfheP2lDPXLgWyzjgfitZPKTOgU TOUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=H4Jc+V2N; spf=pass (google.com: domain of linux-kernel+bounces-14898-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14898-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n2-20020a1fd602000000b004b6c5d0b9a9si3930232vkg.141.2024.01.02.14.01.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 14:01:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14898-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=H4Jc+V2N; spf=pass (google.com: domain of linux-kernel+bounces-14898-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14898-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9A8661C218D5 for ; Tue, 2 Jan 2024 22:01:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1749224C1; Tue, 2 Jan 2024 21:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="H4Jc+V2N" X-Original-To: linux-kernel@vger.kernel.org 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 09478200A8; Tue, 2 Jan 2024 21:46:59 +0000 (UTC) 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 (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 402L6Sq7010362; Tue, 2 Jan 2024 21:46:20 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=q9wsZr9hk6oekRD8z74N 6sV+NK+QirK5GCM36reO4w4=; b=H4Jc+V2NjL5VlMgio9c4TdQ3AOdoNKXiKqBU yheg4Kip6haaIC/6Sval6swOAvTgnCUlnF72eZt5UmWEbFCA+KELZtrt8yoe8qh8 M+tlCAhiYSQjzJEHOn9wjskhIlpY6vw1MNuUtyVpsVE7bVXP89mOG9FVPL9uInPL Xnd1VBkpeX8YWVcyrkX/Crx5P2He+HLdFWxH5/KLxXscqDcksyaWJHf2sKU9mDw3 uBy8A/SUeMeNE+qF0ej/6W4qXe64wlcV7kZaX2HYgkntYYBsPO2L4fzdMKpXLL9f 4NaWXw/g2UmYbU6zE6a0RCjfd+k3nZcPjEZVFMGuw8S6CoJkCg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vcbnb1s69-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jan 2024 21:46:20 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 402LkJeA011445 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 2 Jan 2024 21:46:19 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, 2 Jan 2024 13:46:18 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v12 05/41] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Date: Tue, 2 Jan 2024 13:45:13 -0800 Message-ID: <20240102214549.22498-6-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240102214549.22498-1-quic_wcheng@quicinc.com> References: <20240102214549.22498-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: nalasex01c.na.qualcomm.com (10.47.97.35) 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: DxoHaRYs5rb6PjZUYpL96ixGnqo4_gPu X-Proofpoint-GUID: DxoHaRYs5rb6PjZUYpL96ixGnqo4_gPu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 mlxlogscore=662 mlxscore=0 bulkscore=0 impostorscore=0 suspectscore=0 clxscore=1015 malwarescore=0 spamscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401020161 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787017700343412733 X-GMAIL-MSGID: 1787017700343412733 Some clients may operate only on a specific XHCI interrupter instance. Allow for the associated class driver to request for the interrupter that it requires. Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-mem.c | 30 ++++++++++++++++-------------- drivers/usb/host/xhci-sideband.c | 4 ++-- drivers/usb/host/xhci.h | 2 +- include/linux/usb/xhci-sideband.h | 3 ++- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 5bf74c37cbf6..8e24342a19c5 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2356,7 +2356,7 @@ xhci_add_interrupter(struct xhci_hcd *xhci, struct xhci_interrupter *ir, } struct xhci_interrupter * -xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg) +xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg, int intr_num) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct xhci_interrupter *ir; @@ -2371,28 +2371,30 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg) return NULL; spin_lock_irq(&xhci->lock); - - /* Find available secondary interrupter, interrupter 0 is reserved for primary */ + /* Find available secondary interrupter, interrupter 0 is reserverd for primary */ for (i = 1; i < xhci->max_interrupters; i++) { - if (xhci->interrupters[i] == NULL) { - err = xhci_add_interrupter(xhci, ir, i); - break; + if ((intr_num > 0 && i == intr_num) || intr_num <= 0) { + if (xhci->interrupters[i] == NULL) { + err = xhci_add_interrupter(xhci, ir, i); + if (err) { + spin_unlock_irq(&xhci->lock); + goto free_ir; + } + break; + } } } - spin_unlock_irq(&xhci->lock); - if (err) { - xhci_warn(xhci, "Failed to add secondary interrupter, max interrupters %d\n", - xhci->max_interrupters); - xhci_free_interrupter(xhci, ir); - return NULL; - } - xhci_dbg(xhci, "Add secondary interrupter %d, max interrupters %d\n", i, xhci->max_interrupters); return ir; + +free_ir: + xhci_free_interrupter(xhci, ir); + + return NULL; } EXPORT_SYMBOL_GPL(xhci_create_secondary_interrupter); diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideband.c index eb5ac5fc5c09..624044dc6228 100644 --- a/drivers/usb/host/xhci-sideband.c +++ b/drivers/usb/host/xhci-sideband.c @@ -243,13 +243,13 @@ EXPORT_SYMBOL_GPL(xhci_sideband_get_event_buffer); * Returns 0 on success, negative error otherwise */ int -xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg) +xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, int intr_num) { if (sb->ir) return -EBUSY; sb->ir = xhci_create_secondary_interrupter(xhci_to_hcd(sb->xhci), - num_seg); + num_seg, intr_num); if (!sb->ir) return -ENOMEM; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 37887c2f0653..966681195e41 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2090,7 +2090,7 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, void xhci_free_container_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); struct xhci_interrupter * -xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg); +xhci_create_secondary_interrupter(struct usb_hcd *hcd, int num_seg, int intr_num); void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct xhci_interrupter *ir); void xhci_skip_sec_intr_events(struct xhci_hcd *xhci, diff --git a/include/linux/usb/xhci-sideband.h b/include/linux/usb/xhci-sideband.h index 823f9314d93a..3ff0afbf3a05 100644 --- a/include/linux/usb/xhci-sideband.h +++ b/include/linux/usb/xhci-sideband.h @@ -54,7 +54,8 @@ struct sg_table * xhci_sideband_get_event_buffer(struct xhci_sideband *sb); int -xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg); +xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, + int intr_num); void xhci_sideband_remove_interrupter(struct xhci_sideband *sb);