From patchwork Fri Dec 15 21:49:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 179585 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9603768dys; Fri, 15 Dec 2023 14:03:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnnqzjWM83HobWWW0wTFvoEJvCPVO62/0Go7CPMnM4d67EwIalLoCx8mSWl2A+o6+5btrj X-Received: by 2002:a17:906:cc4e:b0:a02:38a2:4d79 with SMTP id mm14-20020a170906cc4e00b00a0238a24d79mr6362264ejb.41.1702677820538; Fri, 15 Dec 2023 14:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702677820; cv=none; d=google.com; s=arc-20160816; b=p0ooqkiC9P45pfTzcZ8/1L0LNWS5yGmmdQRZjfzxxC6NZRSI+Zdo8M+970D/ll2mBL dPQIsAAC5cx+NzIDSqQhdAArDo96u7rcxX/yY+8fVooDWDkwkVMn+ej7Q/VCl35e4/Tf 7dpuVozJmGLMcqjI1JENfUSoN0Q2VwcY65/5L3IQAwEQesRJEhtJY9cKeAFRPDrm5nU/ 1CoTYUY64TXttkbzxcZv3QogGMIx+g0D3xNF6j70XI6Ldhy0AdY023bVVJSmoaBUAbHw bm4WnbwWv42qSiBN5RjXXe6U3R0i50y7tvd5qz9je3cwYhBWgaM8t8B+t/+Ur5vlCWUu UszQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1714-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d13-20020a170906344d00b009dde1e064f2si8009616ejb.431.2023.12.15.14.03.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 14:03:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1714-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1714-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 01B211F23715 for ; Fri, 15 Dec 2023 22:03:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0390969796; Fri, 15 Dec 2023 21:50:40 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785387098744343560 X-GMAIL-MSGID: 1785387098744343560 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);