From patchwork Thu Feb 8 23:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 770952 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 1035A50A8C; Thu, 8 Feb 2024 23:14:37 +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=1707434080; cv=none; b=D7u5JoFGlnHHiUAK7lLXG5eP8nBabwQf5HNZl9nDBegcZomSqXx+TP4FS2t62RQxBqU3QoYD78gHRURO6MuZUv/q6InmPFXXXaxbJHBZ6hS9cQuF49fLF5eVN9EU8JGjr3z3fkV8QP1XNVAGrJRqYXpMC5aQetVoyhXz9+eEdnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707434080; c=relaxed/simple; bh=Ug45xHk+xy84mO+G0Mu7yWycvffGSHKXzcE/I/5ssZ4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kl/8LQzApYMKmCctTVsUcJoCLva4FMCFVONttOtOj0moixrllmkAII4bCJC1c5nSiWlgtS4Hxq80aCctOqmf99C2aaBc6peZC11UbVhxvp4vkf0eiHXZ4IpC+1z+U9LkgvtaFOSVSKUgk4dQQqpS/uUknNXXOWTYwQOesljnfjo= 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=b1IIRgRI; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="b1IIRgRI" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 418NBZW0010685; Thu, 8 Feb 2024 23:14:22 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=j5g8dyzHs41c6UacW6fN XqfVWRX2FAOh81uCqGT3fVg=; b=b1IIRgRI9Y3rDo9o1v+mJBDCSk/G8qmyyUtK tDmfvywEQJkiypsg9bIyeq5EIMikvgRK+QpSLFhPaAO2T2R9RmeNjCNswYndQj0u 4qYCytNNlUJnu2BHCM/A2iwSaQcxuzFC4AmboH2miMml6h7paXWAeRwPrq1N+Hfi pqrJG5rgJqXrXUIrTmwcPAylsv7z78FNjtJi6MmYEQ8lIRpyMOEa709naLgKH25/ l+rGHFtLAA26pyuMQnHdn4HL0xiKqEm3hdK0V4DUbRzpk6bMKYFRE2ATvUxx0Th/ Hf3UkA8xZCBmmiMorh5hCEE4qw0TD67zUESK0grKphITm16Ciw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w4rk82k4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 23:14:22 +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 418NEL58013127 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 8 Feb 2024 23:14:21 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; Thu, 8 Feb 2024 15:14:20 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v14 19/53] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Date: Thu, 8 Feb 2024 15:13:32 -0800 Message-ID: <20240208231406.27397-20-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240208231406.27397-1-quic_wcheng@quicinc.com> References: <20240208231406.27397-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-arm-msm@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: FvOl3IrFiGh03MGDjQEdJROYhqaxJB-9 X-Proofpoint-ORIG-GUID: FvOl3IrFiGh03MGDjQEdJROYhqaxJB-9 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-08_11,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 phishscore=0 priorityscore=1501 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 impostorscore=0 mlxlogscore=504 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402080131 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 | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index e4c13f056c1a..ae28dac7a747 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2360,7 +2360,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; @@ -2375,28 +2375,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 504a6f1586b5..3acbf23095e9 100644 --- a/drivers/usb/host/xhci-sideband.c +++ b/drivers/usb/host/xhci-sideband.c @@ -278,7 +278,7 @@ EXPORT_SYMBOL_GPL(xhci_sideband_enable_interrupt); */ int xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, - bool ip_autoclear) + int intr_num, bool ip_autoclear) { int ret = 0; @@ -292,7 +292,7 @@ xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, } sb->ir = xhci_create_secondary_interrupter(xhci_to_hcd(sb->xhci), - num_seg); + num_seg, intr_num); if (!sb->ir) { ret = -ENOMEM; goto out; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 96f9d1b38ff5..60abbc4103fd 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1836,7 +1836,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 a749ae307ba7..1026502739c5 100644 --- a/include/linux/usb/xhci-sideband.h +++ b/include/linux/usb/xhci-sideband.h @@ -58,7 +58,7 @@ 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); + int intr_num, bool ip_autoclear); void xhci_sideband_remove_interrupter(struct xhci_sideband *sb);