Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6980378rdb; Fri, 15 Dec 2023 14:00:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCKMMNue0mQSulHMNiE9+J8NyJ1HDvzayRyKq9DYb3XuQOc9Zuv7vwrrvF1Faab9/XpAoV X-Received: by 2002:a05:6e02:3891:b0:35f:7df4:ceac with SMTP id cn17-20020a056e02389100b0035f7df4ceacmr4039744ilb.13.1702677628915; Fri, 15 Dec 2023 14:00:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702677628; cv=none; d=google.com; s=arc-20160816; b=lnyF0dcuUNfNM4/SIqxNDcRAejpgdRQEo5udwm6/3VfP133ohp+fECjnbFE3JxjeXs qi9cch/YZA5gog+NkTSPAJJNIwbGQmfDtiBXAZ3yUm0amlAi79aJr1QXbqxlAPClpRb3 ZbTvZVAeazht/qkYX4ffyuy+F40JLzJwm0oIFyJDlgykD46iPtxdfTQXOPd3zyYRzvUr ++8ds0QWPVzSoaryFQIxvsyWbHhrCe380IeWhqaanraekCkWInikiADwe6cAEOMci+gc WAAEmBDjYkKjUy/M4B8EHURG3ERAvvolmq7HXxzoE4zbqGcALIgZT9MvuEm0gpIx3Ybb ypTw== 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=F9EsDsEmonnf56TTy08hstKG+rHNI/jRvNHtJbUP1Hm8y/w0fkD1cLrU9arPnubfA1 AJ4vyKVwCTeGmka0BDACDOpI2i4xG7OGGC9BoIeIniMx+J8BXoFhmB1/EaIb101lA+am n9FN3OrdJJHIo1obEFo4UEtPB18NMDWWyrW6ysOOm5ZKpUa9N+lKlnYDgwUXR+xXhBhI r7s5EXtvWVxJVlo8XG80M2iLZRRsLnYuFKemTj0SRvBVM+5HkG5uCzmPXVA7OYLYWWSV piWICMMriqgLygyoj7cDWgEjTpxdtE68Prn34w+7UO77CdhTe1u7FudML7uUBWG0i/rT 0Zbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=i9+XhRiV; spf=pass (google.com: domain of linux-kernel+bounces-1714-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1714-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y38-20020a634966000000b005c666ab748bsi12727820pgk.335.2023.12.15.14.00.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 14:00:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1714-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=i9+XhRiV; spf=pass (google.com: domain of linux-kernel+bounces-1714-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1714-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 858FF280FB4 for ; Fri, 15 Dec 2023 22:00:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FA3F7CDA4; Fri, 15 Dec 2023 21:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="i9+XhRiV" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 C5C7570990; Fri, 15 Dec 2023 21:50:34 +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 (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BFICufM018057; Fri, 15 Dec 2023 21:50:08 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=i9+XhRiVUinf62GXHrhlztr2bZ/UiDisMEQA lkOJnq+DQLL5WSAjTaMQcrG+crbyJE3OOCV0aMZQsJrBZCXlqu9721ySlw7me8Zs FTYm44JXJiXvJZ1exdUN2e3VMX6Z6ithwLvSdsgmJTOadPgXOWDvLI7aUUS0khso 6/tn+R8mEEJXKm6m9mIu/9jVRyZrtyBtco76s/NJg4vVr86glihUMWDmiDerb3hD KYy74ys/ERJ5QPnOHoYFmaVSjvdyoM2DNv0xUBWLoBan1I9gW9yrxmcuPa5eCN1r DlVCqvPsbRblatVP0B16hdSobF5BJX0N9L9MWS1FuAg4OIV9Wg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v0up20gj0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 21:50:08 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BFLo7kL031379 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 21:50:07 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; Fri, 15 Dec 2023 13:50:06 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v10 05/41] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Date: Fri, 15 Dec 2023 13:49:19 -0800 Message-ID: <20231215214955.12110-6-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231215214955.12110-1-quic_wcheng@quicinc.com> References: <20231215214955.12110-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 Content-Type: text/plain 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-GUID: Vs9MvHT2FyNcssrHT_nc3ibWWyVyFFC- X-Proofpoint-ORIG-GUID: Vs9MvHT2FyNcssrHT_nc3ibWWyVyFFC- 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_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=666 impostorscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312150152 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);