Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1281159pxf; Fri, 26 Mar 2021 05:04:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjaNBitlJYcSmnZfkV+5y8p4Y/X/VCapwk2/HFLr1gGRIDZJHRUDE+79xM8M9VWSCx9zkL X-Received: by 2002:a17:906:4d85:: with SMTP id s5mr14796255eju.43.1616760294518; Fri, 26 Mar 2021 05:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616760294; cv=none; d=google.com; s=arc-20160816; b=xrigyJExvTodMkivQwiyByxmu8hP+9phZ5CCxjK2UnL36aRUbmg2UwkzFfO84K2v30 iXfn/5XTtJS3clqZQfr5mStLzC6ne9r6Ov6ADi/3A8MpXlCkv/FGX5SMQqFeHptQzzzH V5jsQEHohdyu+FrHZlcAm8AeSIqx992g4lixyHTJuqHuXlB8Yo4zwhKDPaFMUyBlg2Wr fJ+fmDBrlb7TnKAg2DkeRf7/oJrHtKoilv5GaEdlirOUu0hps9k+sQGIadg+Q0/Ynwix iw3pFr38m8WnTEPgh8JySGMH7G8fJmOgNTDakqI0Ri2kTE3s38TORpRgy9nJqSIrGXfm Vrwg== 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:from:references :to:subject; bh=FgT3HpMSoqCbP3dwNbGavqDRcTdljtBTiTcbeOZL5Uo=; b=PKQYKrdBapU8x/0Mqr8MGf3KDD5erbURxTtVM0tJkc7NltwwEMwRbiII++uJYTnlof MzCyhAR10mGBRGsmgQ+P/bm0RS1TWNFHgXXWTa5C1+lzKpCAh0ZZ0RQ7mvNDUOBjA2mW 4SxRqaTNgFAO+3fdTHSdzlHr3WqBz6H7ZuJ4BgJ+cJIyaB8sdMpMdkl50r4HF2IhABOO hNH0sFyhKHCIHU5CT9ozG16aH0ce3CzxeEpQ1pOcFu6nFDAQGQYJsP4MMz8RI2L2ASGg 6PMUcv8oV07ZgXHPOtRnBEmFJhzyZehNAF4PKt4uBCdey7cMlXuecTROMkkgx53O5BTv v1yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de4si6352113ejc.539.2021.03.26.05.04.30; Fri, 26 Mar 2021 05:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbhCZMDb (ORCPT + 99 others); Fri, 26 Mar 2021 08:03:31 -0400 Received: from foss.arm.com ([217.140.110.172]:57970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbhCZMDP (ORCPT ); Fri, 26 Mar 2021 08:03:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7444A143D; Fri, 26 Mar 2021 05:03:14 -0700 (PDT) Received: from [10.57.27.121] (unknown [10.57.27.121]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B0E5C3F7D7; Fri, 26 Mar 2021 05:03:11 -0700 (PDT) Subject: Re: [PATCH] usb: gadget: aspeed: set port_dev dma mask To: rentao.bupt@gmail.com, Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , kernel test robot , Masahiro Yamada , Sasha Levin , Ryan Chen , Thomas Tai , Konrad Rzeszutek Wilk , Christoph Hellwig , Benjamin Herrenschmidt , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Tao Ren References: <20210326070214.6719-1-rentao.bupt@gmail.com> From: Robin Murphy Message-ID: <10920f34-289c-feac-79b6-71bff2aea67d@arm.com> Date: Fri, 26 Mar 2021 12:03:03 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210326070214.6719-1-rentao.bupt@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-03-26 07:02, rentao.bupt@gmail.com wrote: > From: Tao Ren > > Set aspeed-usb vhub port_dev's dma mask to pass the dma_mask test in > "dma_map_page_attrs" function, and the dma_mask test was added in > 'commit f959dcd6ddfd ("dma-direct: Fix potential NULL pointer > dereference")'. > > Below is the backtrace without the patch: > [<80106550>] show_stack+0x20/0x24 > [<80106868>] dump_stack+0x28/0x30 > [<80823540>] __warn+0xfc/0x110 > [<8011ac30>] warn_slowpath_fmt+0xb0/0xc0 > [<8011ad44>] dma_map_page_attrs+0x24c/0x314 > [<8016a27c>] usb_gadget_map_request_by_dev+0x100/0x1e4 > [<805cedd8>] usb_gadget_map_request+0x1c/0x20 > [<805cefbc>] ast_vhub_epn_queue+0xa0/0x1d8 > [<7f02f710>] usb_ep_queue+0x48/0xc4 > [<805cd3e8>] ecm_do_notify+0xf8/0x248 > [<7f145920>] ecm_set_alt+0xc8/0x1d0 > [<7f145c34>] composite_setup+0x680/0x1d30 > [<7f00deb8>] ast_vhub_ep0_handle_setup+0xa4/0x1bc > [<7f02ee94>] ast_vhub_dev_irq+0x58/0x84 > [<7f0309e0>] ast_vhub_irq+0xb0/0x1c8 > [<7f02e118>] __handle_irq_event_percpu+0x50/0x19c > [<8015e5bc>] handle_irq_event_percpu+0x38/0x8c > [<8015e758>] handle_irq_event+0x38/0x4c > > Signed-off-by: Tao Ren > --- > drivers/usb/gadget/udc/aspeed-vhub/dev.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/gadget/udc/aspeed-vhub/dev.c b/drivers/usb/gadget/udc/aspeed-vhub/dev.c > index d268306a7bfe..9eb3904a6ff9 100644 > --- a/drivers/usb/gadget/udc/aspeed-vhub/dev.c > +++ b/drivers/usb/gadget/udc/aspeed-vhub/dev.c > @@ -569,6 +569,7 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx) > device_initialize(d->port_dev); > d->port_dev->release = ast_vhub_dev_release; > d->port_dev->parent = parent; > + d->port_dev->dma_mask = parent->dma_mask; This might happen to work out, but is far from correct. Just wait until you try it on a platform where the USB controller is behind an IOMMU... It looks like something is more fundamentally wrong here - the device passed to DMA API calls must be the actual hardware device performing the DMA, which in USB-land I believe means the controller's sysdev. Robin. > dev_set_name(d->port_dev, "%s:p%d", dev_name(parent), idx + 1); > rc = device_add(d->port_dev); > if (rc) >