Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2930723rdb; Wed, 4 Oct 2023 16:43:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcTabVsDFDBo5c5E1x92eXIWMRsK9cZtUf3T9L26UBTm5G1OEkErf+R0M1z0sTC6wPekLK X-Received: by 2002:a17:90b:1801:b0:268:314f:8f35 with SMTP id lw1-20020a17090b180100b00268314f8f35mr3523590pjb.6.1696463013387; Wed, 04 Oct 2023 16:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696463013; cv=none; d=google.com; s=arc-20160816; b=GGsDeyyqO7Xu93mPNB9hNsvS7LXKt11qHH3M5R9Mhstz0w+jrE5ucnS8zHHiMSRHPS coDFgT475M3/xD5scwKPD2l/d2M8hf/Y9cWuP6gFM3/SDFywW0DkBFmKjjMQufaooYrw pQ4cThfV3Gh/kQq3I6BR9N8YxHRJ1yrYMfLp1DiguK89IRieOYHxIjvjaiLQYy6p1o6I LlSWFaxUEf6Bmg/lw2KM9aKzNGy8vZIH1e+eredvr0FqhBmJ/NkrlYvw2fo/J/pAUi7F 1qNwzJHNNMLOrZjj4UQZqfM/8KrHeS/rYhEMqMwSEc1s7R9097U5zTsjao4fovyen/Y1 DTvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=1AtYsGZ3CJV+ChxDmOyWt3a/katMWjh5SobmXd2knI4=; fh=BB2r2JHm5DlC+7rT7R1/NTC3Q/lb1+ZmjVEGuLRhmos=; b=beS1eIeWNV+hlsBESCZeD4kmK2Kuz7D2p+tiHCbbjrTsZN3qKo6QCwWgAD7wZnlaAk oqiUckh8D1B9IVUeqt+4G1gO3xr0sakGtx1cfWROKAgB27Bxxi4EJkGR0Ftzm3fcK4j+ 4W0uvalNKA2WRisN8GncQcPuBjcvrOy1f6NEhSR2rKzeEb141dS53j1l9Opdu4n51BnN QceChjesd3qp852CJBC1Gt4DxSyivpQWywm2UOby/6QC7EvsDELwj2T8/TzQm+Ot/OX0 evZy7oV45NGU4OUA2K6o7/tBMchVc6S7lPXk6eDChxfSWqkdCCOAAxZRrKX6y2SkN/w3 XG3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AkZGFcn9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id d3-20020a17090a6f0300b00263a99b8448si351217pjk.113.2023.10.04.16.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 16:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AkZGFcn9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 37AFC830F577; Wed, 4 Oct 2023 16:43:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240754AbjJDXnL (ORCPT + 99 others); Wed, 4 Oct 2023 19:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233418AbjJDXnK (ORCPT ); Wed, 4 Oct 2023 19:43:10 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0CB9C0; Wed, 4 Oct 2023 16:43:06 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 394NQtre007061; Wed, 4 Oct 2023 23:42:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : from : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=1AtYsGZ3CJV+ChxDmOyWt3a/katMWjh5SobmXd2knI4=; b=AkZGFcn9l0wUpiYUYDo0de0rwqq1vOso3dvzi2YOgCxSjw2HeBvrEwuUnD1IXz+H1Sla UxypH2Q0RZ1I5P3jS+fojDTYgO8QEYyP8EqGjXvS1ogTqIkC8xg8/iDazThhPrNSTE68 WjERFw4u9TvFUhAiw5WnD4+P1tF4rOJWKoPL+M2V4dz+VQI0Ax3yZ7nFeAls2T6kAgF2 313TRwsvYh6ZvIRZbEOk3SUeQBLHzVXQLmHnfB5Jh2Z5C7RuE7/IhyDWl6rtuilke/9x A/0d1j2tx2dcJKqIt3bNIKsbOSGrnEdQfV6R64erGeffwj+4yeW6v9kzfCcwkDyR3KGb bQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3th2d6t86j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Oct 2023 23:42:42 +0000 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 394NgeXW007409 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 4 Oct 2023 23:42:40 GMT Received: from [10.71.112.36] (10.80.80.8) 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.36; Wed, 4 Oct 2023 16:42:40 -0700 Message-ID: Date: Wed, 4 Oct 2023 16:42:39 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v7 01/33] xhci: add support to allocate several interrupters Content-Language: en-US From: Wesley Cheng To: Mathias Nyman , Mathias Nyman , , , , , , , , , , , , , , CC: , , , , References: <20230921214843.18450-1-quic_wcheng@quicinc.com> <20230921214843.18450-2-quic_wcheng@quicinc.com> <10ad0613-7e88-dbe8-c5a2-d535f8e9db03@linux.intel.com> <843897f1-3ce5-f8da-5f10-7d8a68849fd2@intel.com> <2127ef61-e263-2a0e-438a-6baa125aa70d@quicinc.com> In-Reply-To: <2127ef61-e263-2a0e-438a-6baa125aa70d@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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: pkdpDepHsXU-32eg42MlL4wPtE2a5sj8 X-Proofpoint-GUID: pkdpDepHsXU-32eg42MlL4wPtE2a5sj8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-04_13,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=785 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040173 X-Spam-Status: No, score=1.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 04 Oct 2023 16:43:18 -0700 (PDT) X-Spam-Level: * Hi Mathias, On 10/4/2023 11:35 AM, Wesley Cheng wrote: > Hi Mathias, > > On 10/4/2023 7:02 AM, Mathias Nyman wrote: >> On 2.10.2023 23.07, Wesley Cheng wrote: >>> Hi Mathias, >>> >>> On 9/28/2023 3:31 AM, Mathias Nyman wrote: >>>> On 22.9.2023 0.48, Wesley Cheng wrote: >>>>> From: Mathias Nyman >>>>> >>>>> Modify the XHCI drivers to accommodate for handling multiple event >>>>> rings in >>>>> case there are multiple interrupters.  Add the required APIs so >>>>> clients are >>>>> able to allocate/request for an interrupter ring, and pass this >>>>> information >>>>> back to the client driver.  This allows for users to handle the >>>>> resource >>>>> accordingly, such as passing the event ring base address to an >>>>> audio DSP. >>>>> There is no actual support for multiple MSI/MSI-X vectors. >>>>> >>>>> Factoring out XHCI interrupter APIs and structures done by Wesley >>>>> Cheng, in >>>>> order to allow for USB class drivers to utilze them. >>>>> >>>>>   } >>>>> +void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct >>>>> xhci_interrupter *ir) >>>>> +{ >>>>> +    struct xhci_hcd *xhci = hcd_to_xhci(hcd); >>>>> +    unsigned int intr_num; >>>>> + >>>>> +    /* interrupter 0 is primary interrupter, don't touchit */ >>>>> +    if (!ir || !ir->intr_num || ir->intr_num >= >>>>> xhci->max_interrupters) { >>>>> +        xhci_dbg(xhci, "Invalid secondary interrupter, can't >>>>> remove\n"); >>>>> +        return; >>>>> +    } >>>>> + >>>>> +    /* fixme, should we check xhci->interrupter[intr_num] == ir */ >>>>> +    spin_lock(&xhci->lock); >>>> >>>> Needs to be spin_lock_irq() ir spin_lock_irqsave() as xhci->lock is >>>> used in interrupt handler. >>>> >>>> >>>>> +    intr_num = ir->intr_num; >>>>> +    xhci_free_interrupter(xhci, ir); >>>>> +    xhci->interrupters[intr_num] = NULL; >>>>> +    spin_unlock(&xhci->lock); >>>> >>>> likewise >>>> >>> >>> Let me check these again.  In general, I think I will use both the >>> xhci->mutex and xhci->lock where needed, because I believe we'd run >>> into sleep while atomic issues >>> while freeing the DMA memory.  Will rework this and submit in the >>> next rev. >>> >> >> Maybe we need to split xhci_free_interrupter() into separate remove >> and free functions >> > > Thanks for sharing the work you've been doing.  Yes, I did something > similar as well on my end, but will refactor in your code and re-test. > >> Did some work on this, and on the sideband api in general. >> >> Code still has a lot of FIXMEs, and it's completely untested, but to >> avoid us >> from doing duplicate work I pushed it to my feature_interrupters >> branch anyway >> >> git://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git >> feature_interrupters >> https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=feature_interrupters >> > > Ok.  Initial look at it seems like it will be fine, but will integrate > and make changes where needed. > Had to make some minor tweaks here and there, but nothing major. Was able to validate the changes on my end, and they look good. Will test a bit more, and include these in my next submission. Will try to address your FIXME tags as well. Thanks Wesley Cheng