Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2626196rdb; Wed, 4 Oct 2023 07:01:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuxi9hH4lJCfIfA/RqoMyhIT814ctVU2Gfi+TWwik3ATbrkVPYBgEY+QJ7MB/k593/IuRF X-Received: by 2002:a05:6a20:158e:b0:15c:b7ba:1671 with SMTP id h14-20020a056a20158e00b0015cb7ba1671mr3475071pzj.2.1696428089752; Wed, 04 Oct 2023 07:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696428089; cv=none; d=google.com; s=arc-20160816; b=RRk+q3loWeR074aU1g4ZVg0Q3dPgYhNS/QtuVQCT3X5DPAvwP62tbPvU7IzwahlQJF ddCUwgA1BH4CC/yzmOJNXUwyf4tl7IwcEh862dWvbJoQq3ttHKFaP5I8PBzBnUw8CFui FOlns/4NmwHdzT7R2mx90gNk1PIlXGKzj1oDoN2oWmae2N+e5gClu7wd4mYeX8o5sdk8 9Ph8s3yp4VIWnPms5vUkuJRyNkJPu955jyyFwR8quE3tIaonH7bAh3t5XunIVePwqvim 94F3WTvkn264/7qPWOBI+4DXw0+yuWNhbXSSRoyJtkRR1Rw4dDXYw2YKkjzEZwwEkWpo tBmw== 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:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=IzDOZnnw18DAlDQQVlc0Y6Ed7ERGINOVCWO7IyRizEs=; fh=8a18DXXDq2Tvs+R9ZWloKqGMfcUAeypSShovfW1sjxg=; b=zrhLYa2/pznF6CLbSl2SWxEXMjjf4Cw/tLrWjcaNQlOp8VtloiLuvYecaITE/ZzUZA 229tICcPU4DsXcq7ul21zsTHbkw/vwqB5duhhMwl5FPFRwWFNsa8FgFqEWWme7qKjs9M T17cWwntzJeK5TWnK7sBPISWWKK+0xQhAiDrowmxG2ERCIiXntE7GPDQ4wehB69srzDW U2Fd9VgDERKrRTU3w/Op0+gRJCq2iUrVTqUozwAAXxnvl/RRB4JqZxaBXdR4HK2Y1Psw RrUdtJdR2LuNDiatFlgC6cHAN6v9Ej2YS0DrRxMrv9EmvooISmnuO6u8GAwDkS5AyWMt 5c6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wn2eAFRI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q24-20020a635c18000000b00585a5433e55si3779195pgb.143.2023.10.04.07.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 07:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wn2eAFRI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 75DF681AB521; Wed, 4 Oct 2023 07:01:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242743AbjJDOAv (ORCPT + 99 others); Wed, 4 Oct 2023 10:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242720AbjJDOAu (ORCPT ); Wed, 4 Oct 2023 10:00:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E9E6C1; Wed, 4 Oct 2023 07:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696428047; x=1727964047; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ND6e8zppS+/0buxG1psBpDzddtzWLjPsHvkMnqKjyIs=; b=Wn2eAFRIHsJsYhhqLHmhuuhM9SxbbJRL6dXf8bdsYVnvVmTgSMHEzN1O cSQVCETWJt0xyohJH3Vjgea7XCjcdhZtmsSNkiQUWtZmj0kyxpzv2qYKx ODx6D76BqwdMQ52fHyrHr5DNUxqBhZXJQT1/VYu82Pjaq/wxIinD7TOD6 Jv3Lo+Q5AMn7GMV1l/N276Ln7XfLsodSmxyAmAkOOh78W2DXx0sOTyWfK HdsZI3Bp5e6btSgdkW9iwcEjU+9FuQR437PIXOJRsVgDTF6NfFtWmPvjw AyTPrVLJNA/06GJKqYPnCIsxcmW6qqZYJv0VwhbxKFCPnxYMb7nqw3yIG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10853"; a="382040999" X-IronPort-AV: E=Sophos;i="6.03,200,1694761200"; d="scan'208";a="382040999" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2023 07:00:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10853"; a="1082512034" X-IronPort-AV: E=Sophos;i="6.03,200,1694761200"; d="scan'208";a="1082512034" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.199]) ([10.237.72.199]) by fmsmga005.fm.intel.com with ESMTP; 04 Oct 2023 07:00:41 -0700 Message-ID: <843897f1-3ce5-f8da-5f10-7d8a68849fd2@intel.com> Date: Wed, 4 Oct 2023 17:02:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.13.0 Subject: Re: [PATCH v7 01/33] xhci: add support to allocate several interrupters To: Wesley Cheng , Mathias Nyman , gregkh@linuxfoundation.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, srinivas.kandagatla@linaro.org, bgoswami@quicinc.com, Thinh.Nguyen@synopsys.com Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org References: <20230921214843.18450-1-quic_wcheng@quicinc.com> <20230921214843.18450-2-quic_wcheng@quicinc.com> <10ad0613-7e88-dbe8-c5a2-d535f8e9db03@linux.intel.com> Content-Language: en-US From: Mathias Nyman In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 07:01:21 -0700 (PDT) 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 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 Thanks -Mathias