From nobody Wed Nov 27 11:53:35 2024 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 E6511BE5D; Fri, 11 Oct 2024 00:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728605254; cv=none; b=Ortu8/30S0pfPZv7eep2OAngr7aL+LzbhLgZIR2AeMQU5evgSvoz46PRM0c6Nfc4UNILsb2Tz7oJRZ2sUQVyiuEUVsEURIgYCZ401sgqqAAm9p6rgDdVz7XWGswtyq9YjgOERouzTpgrX3T96k6ODn3DKOlWbXtIZcBOnk1MEWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728605254; c=relaxed/simple; bh=k5pZXz7zhxPw2OQXkssRZiGR5LwzKnHF+F0otCkTWrY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HLoiQgjNpHhnjr6YrsRJN7NxJgTSR34CMmrgmt4dfeHOJR/z/mnbS2MX05iduPUydOGGs0GKR2TzLkh5GgCeTk6ijIR6PfrPvUgxE660RyVLuI6jYuCT0Q5yRan6z5ZZXQQL7ZL8B3JkzIi9gpy4Fu5T1LDdZVAGJZW6DNlgBdk= 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=L7yL9UG3; arc=none smtp.client-ip=205.220.168.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="L7yL9UG3" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49AAbcQt020047; Fri, 11 Oct 2024 00:07:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= /U7Wd7+Vcr+CGbwCDV49RDGBeJTU3cSkWA6J+KzK5+Y=; b=L7yL9UG3kTPa4d/m 9noJxjYVVRCbxtqAz7a6Sc1wylBQmydaQPtRZ7KDuqVTE0fzJMHR3BiCu9nGUU0s KIHZPGasgB3I/cPH55IbDD5l8OgMWidnApfEmdN8/oaD/h8tn9nMLobck58XV9Ml 28tHBFTEwsqymrBUhGHyViMUWsPlXZ6YrmpnVvnaK7MTxNSRWKuSCZT5A/B58DFx A2gNXfh0piTZ7NGzPjG0Y8zG6qVD/qWRufADQpAguGbxg2YbB9XFqvyXn99Y6Zgr pzHSJWtrrscvIn+7B1m3/bjWJ5pEldoAj9GfEUs+mHw0t9UJvqZcmunk4a0z49qz nLeYSw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 426db7hvjn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Oct 2024 00:07:07 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49B076l3009065 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Oct 2024 00:07:06 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.1544.9; Thu, 10 Oct 2024 17:07:06 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , , Wesley Cheng Subject: [PATCH v28 07/33] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Date: Thu, 10 Oct 2024 17:05:58 -0700 Message-ID: <20241011000650.2585600-14-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241011000650.2585600-1-quic_wcheng@quicinc.com> References: <20241011000650.2585600-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-Transfer-Encoding: quoted-printable 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: CAmj-r76pVE7T_T4CGH5Aa349Zt-uVKD X-Proofpoint-GUID: CAmj-r76pVE7T_T4CGH5Aa349Zt-uVKD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=823 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 clxscore=1015 spamscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410100158 Content-Type: text/plain; charset="utf-8" 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 | 24 ++++++++++++++---------- drivers/usb/host/xhci-sideband.c | 5 +++-- drivers/usb/host/xhci.h | 2 +- include/linux/usb/xhci-sideband.h | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 5e022ce3a8fe..80cd77fe3dec 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2340,14 +2340,15 @@ xhci_add_interrupter(struct xhci_hcd *xhci, struct = xhci_interrupter *ir, =20 struct xhci_interrupter * xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs, - u32 imod_interval) + u32 imod_interval, unsigned int intr_num) { struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); struct xhci_interrupter *ir; unsigned int i; int err =3D -ENOSPC; =20 - if (!xhci->interrupters || xhci->max_interrupters <=3D 1) + if (!xhci->interrupters || xhci->max_interrupters <=3D 1 || + intr_num >=3D xhci->max_interrupters) return NULL; =20 ir =3D xhci_alloc_interrupter(xhci, segs, GFP_KERNEL); @@ -2355,15 +2356,18 @@ xhci_create_secondary_interrupter(struct usb_hcd *h= cd, unsigned int segs, return NULL; =20 spin_lock_irq(&xhci->lock); - - /* Find available secondary interrupter, interrupter 0 is reserved for pr= imary */ - for (i =3D 1; i < xhci->max_interrupters; i++) { - if (xhci->interrupters[i] =3D=3D NULL) { - err =3D xhci_add_interrupter(xhci, ir, i); - break; + if (!intr_num) { + /* Find available secondary interrupter, interrupter 0 is reserved for p= rimary */ + for (i =3D 1; i < xhci->max_interrupters; i++) { + if (!xhci->interrupters[i]) { + err =3D xhci_add_interrupter(xhci, ir, i); + break; + } } + } else { + if (!xhci->interrupters[intr_num]) + err =3D xhci_add_interrupter(xhci, ir, intr_num); } - spin_unlock_irq(&xhci->lock); =20 if (err) { @@ -2379,7 +2383,7 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd= , unsigned int segs, i, imod_interval); =20 xhci_dbg(xhci, "Add secondary interrupter %d, max interrupters %d\n", - i, xhci->max_interrupters); + ir->intr_num, xhci->max_interrupters); =20 return ir; } diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideb= and.c index 248d9713570e..d04cf0af57ae 100644 --- a/drivers/usb/host/xhci-sideband.c +++ b/drivers/usb/host/xhci-sideband.c @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(xhci_sideband_get_event_buffer); */ int xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, - bool ip_autoclear, u32 imod_interval) + bool ip_autoclear, u32 imod_interval, int intr_num) { int ret =3D 0; =20 @@ -273,7 +273,8 @@ xhci_sideband_create_interrupter(struct xhci_sideband *= sb, int num_seg, } =20 sb->ir =3D xhci_create_secondary_interrupter(xhci_to_hcd(sb->xhci), - num_seg, imod_interval); + num_seg, imod_interval, + intr_num); if (!sb->ir) { ret =3D -ENOMEM; goto out; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index e37d27190e3c..b4b411d63694 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1833,7 +1833,7 @@ 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, unsigned int segs, - u32 imod_interval); + u32 imod_interval, unsigned 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-sid= eband.h index bc5b56a77e37..f0223c5535e0 100644 --- a/include/linux/usb/xhci-sideband.h +++ b/include/linux/usb/xhci-sideband.h @@ -59,7 +59,7 @@ xhci_sideband_get_event_buffer(struct xhci_sideband *sb); =20 int xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, - bool ip_autoclear, u32 imod_interval); + bool ip_autoclear, u32 imod_interval, int intr_num); =20 void xhci_sideband_remove_interrupter(struct xhci_sideband *sb);