Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp682751iob; Thu, 28 Apr 2022 09:39:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYVf74ptpnoByJ5XyX3N9Tv3/xufXrGmlAwd8IxAFYSBpdhuzXvrKWCx+tdGlnBR9oRXpD X-Received: by 2002:a17:90b:4c44:b0:1d9:f9e1:25a with SMTP id np4-20020a17090b4c4400b001d9f9e1025amr13608944pjb.39.1651163990907; Thu, 28 Apr 2022 09:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651163990; cv=none; d=google.com; s=arc-20160816; b=zzsN814eoD8EXDN573uOD+NNtps+DpnoqXgHMgrYTcWxTr0pu6kGDf2TFtjXEPX2OU chLyDsjR89wYsDdVZVAuTphjfnaeQM0PjG19fjv5zS6fH9OlsY2uKVjZ37gz0cy0FJOp 9b0cv8+rGRS3at9lbHohakXwjbyYxMMkYw7x8eZWk7WLASQ32UpNgLCu2RRvRTkVS0q9 nLT7WhCrf47azxTnzZY8yISub/o2uTG8BhYqpjwsbEZAG5P/rlzFvZ0WHTwHG4an9afy KcVL5Q7+KpzLjWuwhbl+uak4SW7/cZKIDiw8i+hFuP4mFW7PtJmEy918EXHaTHoSOfvH 3dJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=+FKbXAWsq9Mqdus+lprW3EOSeJ0UupcmkNQVe+AVMlk=; b=Ti0npXx39YMGoSqWcuFLjjNxkA0kNM4rWKClslhUmY4L3rfERLwMFAosvgtX01OIw9 n3NS4/+gYPVtT/vCC0PY5pI1nK72xLBL1PujSll8BljrEcgTw1j/JUnPwu0yFmxJ+FI7 ssGD6ZS8VsB3vGWmIDpoAgUKIZZEmZwwuGZ/cC/pCCh+N4IFcgwlsaj+kb2PlHeoHc/5 OsGhO92ZGuM9WPpM8St0NaxxVk25nevNbU/3kBp0/YWM6x9OieUJZhc0f7WiwX5DWen5 ivgsjMl2OmpdZtbXLI13IaO9ERob6rGSeR75q2+SP3dbSNmNu5dehN4vNkD7yZ2PvmSj D+oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EtEZL6LX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pt15-20020a17090b3d0f00b001dbcf49fbb3si2147028pjb.50.2022.04.28.09.39.33; Thu, 28 Apr 2022 09:39:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EtEZL6LX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346036AbiD1MaT (ORCPT + 99 others); Thu, 28 Apr 2022 08:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346227AbiD1MaM (ORCPT ); Thu, 28 Apr 2022 08:30:12 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C13F17CB0B; Thu, 28 Apr 2022 05:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651148817; x=1682684817; h=to:cc:references:from:subject:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=uWpsrfMCGcdP4sBCZpdV/K9nXsH6L4kQovbP/bC7oiM=; b=EtEZL6LXBy5f+wWZaMasunOM0ZkDPJVe26PdJxpW6Ke7x3KrOo/fQdiP U1vUnm+KSUGocnqZP71JDY7K0P+xvsZa8tpLJvxKh5SxNwmNJLAlSMPsl aYr7ng9e4jBJEXn57YGdKeb6vlQwk4b/OWBcvjWIn22+nPIwAnqIkEONq gDJ2MsiqLlzHZ3FVA3OPs1onbt8UStmtYVBm5x1MfCrzuo54IHJXHom0O GM0ABBMYmDZvlZFgdMR/pY0jjiCYba8mLDFDZE9/j26PMu1EtsZqv0/tS dwUuKMJYJ3jdJcb9kSkUAYhDXdwjjGopxayR701qVKrGeS9bcj460Azjg Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10330"; a="246832536" X-IronPort-AV: E=Sophos;i="5.90,295,1643702400"; d="scan'208";a="246832536" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2022 05:26:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,295,1643702400"; d="scan'208";a="878583949" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.199]) ([10.237.72.199]) by fmsmga005.fm.intel.com with ESMTP; 28 Apr 2022 05:26:49 -0700 To: Jung Daehwan Cc: Mathias Nyman , Greg Kroah-Hartman , "open list:USB XHCI DRIVER" , open list , Howard Yen , Jack Pham , Puma Hsu , "J . Avila" , sc.suh@samsung.com, Krzysztof Kozlowski References: <1650964728-175347-1-git-send-email-dh10.jung@samsung.com> <1650964728-175347-6-git-send-email-dh10.jung@samsung.com> <20220428030319.GA139938@ubuntu> From: Mathias Nyman Subject: Re: [PATCH v4 5/5] usb: host: add xhci-exynos driver Message-ID: <0f84e8d4-451f-693a-d098-517dc6235a0f@linux.intel.com> Date: Thu, 28 Apr 2022 15:28:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20220428030319.GA139938@ubuntu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28.4.2022 6.03, Jung Daehwan wrote: > On Wed, Apr 27, 2022 at 07:25:21PM +0300, Mathias Nyman wrote: >> On 26.4.2022 12.18, Daehwan Jung wrote: >>> This driver is for Samsung Exynos xhci host conroller. It uses xhci-plat >>> driver mainly and extends some functions by xhci hooks and overrides. >>> >>> It supports USB Audio offload with Co-processor. It only cares DCBAA, >>> Device Context, Transfer Ring, Event Ring, and ERST. They are allocated >>> on specific address with xhci hooks. Co-processor could use them directly >>> without xhci driver after then. >>> >>> Signed-off-by: Daehwan Jung >> >> I have to agree with Krzysztof's comments, this is an odd driver stub. >> >> Perhaps open up a bit how the Exynos offloading works so we can figure out >> in more detail what the hardware needs from software. >> >> (...) > >>> +static int xhci_alloc_segments_for_ring_uram(struct xhci_hcd *xhci, >>> + struct xhci_segment **first, struct xhci_segment **last, >>> + unsigned int num_segs, unsigned int cycle_state, >>> + enum xhci_ring_type type, unsigned int max_packet, gfp_t flags, >>> + u32 endpoint_type) >>> +{ >>> + struct xhci_segment *prev; >>> + bool chain_links = false; >>> + >>> + while (num_segs > 0) { >>> + struct xhci_segment *next = NULL; >>> + >>> + if (!next) { >>> + prev = *first; >>> + while (prev) { >>> + next = prev->next; >>> + xhci_segment_free(xhci, prev); >>> + prev = next; >>> + } >>> + return -ENOMEM; >> >> This always return -ENOMEM > > Yes. it's right to return error here. > Still don't think that is the case. So if the num_segs value passed to a function named xhci_alloc_segments_for_ring_uram() is anything else than 0, it will automatically return -ENOMEM? >> >> Also this whole function never allocates or remaps any memory. > > This fuctions is for link segments. Right below function(xhci_ring_alloc_uram) > allocates. Still doesn't allocate any ring segments. Below function only allocates memory for the ring structure that contains pointers to segments. > >> >>> + } >>> + xhci_link_segments(prev, next, type, chain_links); >>> + >>> + prev = next; >>> + num_segs--; >>> + } >>> + xhci_link_segments(prev, *first, type, chain_links); >>> + *last = prev; >>> + >>> + return 0; >>> +} >>> + >>> +static struct xhci_ring *xhci_ring_alloc_uram(struct xhci_hcd *xhci, >>> + unsigned int num_segs, unsigned int cycle_state, >>> + enum xhci_ring_type type, unsigned int max_packet, gfp_t flags, >>> + u32 endpoint_type) >>> +{ >>> + struct xhci_ring *ring; >>> + int ret; >>> + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; >>> + >>> + ring = kzalloc_node(sizeof(*ring), flags, dev_to_node(dev)); >>> + if (!ring) >>> + return NULL; >>> + >>> + ring->num_segs = num_segs; >>> + ring->bounce_buf_len = max_packet; >>> + INIT_LIST_HEAD(&ring->td_list); >>> + ring->type = type; >>> + if (num_segs == 0) >>> + return ring; >>> + >>> + ret = xhci_alloc_segments_for_ring_uram(xhci, &ring->first_seg, >>> + &ring->last_seg, num_segs, cycle_state, type, >>> + max_packet, flags, endpoint_type); >>> + if (ret) >>> + goto fail; >>> + >>> + /* Only event ring does not use link TRB */ >>> + if (type != TYPE_EVENT) { >>> + /* See section 4.9.2.1 and 6.4.4.1 */ >>> + ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= >>> + cpu_to_le32(LINK_TOGGLE); >> >> No memory was allocated for trbs > > Allcation function for trbs are missed. It's done by ioremap. > I will add it on next submission. Thanks for the comment. > >> >> A lot of this code seems to exists just to avoid xhci driver from allocating >> dma capable memory, we can refactor the existing xhci_mem_init() and move >> dcbaa and event ring allocation and other code to their own overridable >> functions. >> >> This way we can probably get rid of a lot of the code in this series. > > Yes right. I think it's proper. Do you agree with it or have better way > to do it? Could be, but I don't have a good picture of how this Exynos audio offloading works, so it's hard to guess. Thanks -Mathias