Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp130062rwb; Wed, 10 Aug 2022 16:17:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5XFm+bsbTouN/n+PleoLLv/5irsRP5+EfrreyGyqveFkbGHeOLR6IqsYltLlGjzNmPDHHO X-Received: by 2002:a05:6402:5508:b0:43a:896e:8edd with SMTP id fi8-20020a056402550800b0043a896e8eddmr28619184edb.203.1660173468046; Wed, 10 Aug 2022 16:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660173468; cv=none; d=google.com; s=arc-20160816; b=wae3M2ZofY/NYhfXmgE8gTJGm7caNqCjJkq+U4701n+39AtYVVYI2tC2WdvEqtJSxl 7l5cAgqXHaFCoSaQ322apyZ9ddGmJuhsySrUON7Mg1Hk5U0OM9Q+Q91aFsyqVgSZfUZj CfnaOrbBZ1zl4zXQ/45QdUOohEHfPKkSkuVkoMusJsvHKVY0g2CuKLQiV3XlQ6jti1IL XJh6bRZ17zjyITyYJrLr26bVJTBGzJ23+qZF9FZVoEKRlN4vcSHg9gSlee2SRGDOtYHF IRs19aWIurq9/OIUDVpTqzRmSq6uJMh58VxSpSkqS9twchoHkD47B/L9OX7Fpk63oF34 7z7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IYUblAxSUIQ6YomS6SAe7QOiq/9tC9/LzRRTchU+IxE=; b=B/ljdllvgj3WxL29TBPK4HxcHbXE4SbQzI65HD2MhRNSNHqOm0s/2zcVkM8IJYGKaY +DzbKQTS9+LflaFNJhe10gen8Eo6UKC3pjXbT9S8JxeMK4omWSyMYW/3ugWMFwhkQxSr neyyndldQS3IbuIuvC2qJHZMBOkwbOzub7lF/XfUizrevmjV91MC3hdIcMLlMU2u3yNX l0jR0OesJfZyeoeQ8gVvRPH6DpZr34upFC8V3BK9VOana77UR0fSJlnQvrLOqmV4lvjX ccLwwNkB2Ty5CwTEj4NZU2Ox3nd4SfIF9MGZa5UFlcPZOF2WX8S9bwILsvCHLTL1pKfE vKFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qns1rAkQ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a17090607c600b0073105edc5f9si5157458ejc.378.2022.08.10.16.17.21; Wed, 10 Aug 2022 16:17:48 -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=@google.com header.s=20210112 header.b=qns1rAkQ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233597AbiHJXJa (ORCPT + 99 others); Wed, 10 Aug 2022 19:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbiHJXJ2 (ORCPT ); Wed, 10 Aug 2022 19:09:28 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C556374CD0 for ; Wed, 10 Aug 2022 16:09:27 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id 13so14101495plo.12 for ; Wed, 10 Aug 2022 16:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=IYUblAxSUIQ6YomS6SAe7QOiq/9tC9/LzRRTchU+IxE=; b=qns1rAkQK4/otY2irw1U49E0MjSMaYOnuN2cHpSDDAsxpMr5u17jjwVx4NNtrzv+xg OWMBGgJzYQB0Hx1dcA5B0UmbJLjUz3WsHnMhVE34YBV1OmOax2W/IllnQYCXiCp4tJ+c PHGI4k4jNCgim+Dq8Gf8KGrhxi666WBzad/d6WV7XjVvIIhbHu17sYLa6DFSYK3/V2rC 3NBLay8W0CEyJDEcPwKl/c/vVhVqdACgwG2wtW003/T1zSkBO5KoZJavO8sWBarQQVbO jOzh54JGwiNErNmr+Zg8EzOvHDiEhEvBGDvZYFfh4QVD6U1dIEGtLHROGWM/9Dq520V4 LHXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=IYUblAxSUIQ6YomS6SAe7QOiq/9tC9/LzRRTchU+IxE=; b=0YQRzCh3s8iGf6QbdqE5ESH4VeSEW4vufC14gg3KqR2Kyq/27cBbptSIppss9KIlKE WHpu9U6uVk+Lb/iPd8aEJEfIH9tmRBLObjid8WzDq+YnpukVwcx9ax2z8ufttMV1FP46 /TrlOBQuEtn238iP8fHDp7k4eEzuCjYT1pk0fLWIBI4GOB0i/GyIl23UfWz43PMrBjw8 S0zcLQa8vhnkqH67ZJCQDBA0k35GMc789+MoFOdJiITqgEZlqOOQNbYlOHCoWxgans68 nJrDp4pDyQYC/1oev7NZLIQK5oC4f9ZseWTEFLKG6wpXoA3UJqTMztBlrKLgmXPlzD5M RNYQ== X-Gm-Message-State: ACgBeo2xpPNZcJPAr2Z7KB5rpUYyRjOgMOC0XD9Jwl5+NEfhPHxnlMGl bCdr5Q0nDZP/0wqrMP1LSwa4Kw== X-Received: by 2002:a17:902:d546:b0:16e:c70c:fdf5 with SMTP id z6-20020a170902d54600b0016ec70cfdf5mr30428690plf.100.1660172967179; Wed, 10 Aug 2022 16:09:27 -0700 (PDT) Received: from google.com (201.215.168.34.bc.googleusercontent.com. [34.168.215.201]) by smtp.gmail.com with ESMTPSA id s4-20020aa78bc4000000b0052d82ce65a9sm2631701pfd.143.2022.08.10.16.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 16:09:26 -0700 (PDT) Date: Wed, 10 Aug 2022 23:09:22 +0000 From: William McVicker To: Rob Herring Cc: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas , kernel-team@android.com, Vidya Sagar , kernel test robot , "Isaac J . Manjarres" , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] PCI: dwc: drop dependency on ZONE_DMA32 Message-ID: References: <20220810183536.1630940-1-willmcvicker@google.com> <20220810183536.1630940-2-willmcvicker@google.com> <20220810212716.GA557589-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220810212716.GA557589-robh@kernel.org> X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,FSL_HELO_FAKE,HK_RANDOM_ENVFROM,HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no 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 08/10/2022, Rob Herring wrote: > On Wed, Aug 10, 2022 at 06:35:34PM +0000, Will McVicker wrote: > > Re-work the msi_msg DMA allocation logic to use dma_alloc_coherent() > > which uses the coherent DMA mask to try and return an allocation within > > the DMA mask limits. This allows kernel configurations that disable > > ZONE_DMA32 to continue supporting a 32-bit DMA mask. Without this patch, > > the PCIe host device will fail to probe when ZONE_DMA32 is disabled. > > > > Fixes: 35797e672ff0 ("PCI: dwc: Fix MSI msi_msg DMA mapping") > > Reported-by: Isaac J. Manjarres > > Signed-off-by: Will McVicker > > --- > > .../pci/controller/dwc/pcie-designware-host.c | 23 ++++++++----------- > > 1 file changed, 9 insertions(+), 14 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c > > index 7746f94a715f..8f2222f51671 100644 > > --- a/drivers/pci/controller/dwc/pcie-designware-host.c > > +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > > @@ -272,9 +272,9 @@ static void dw_pcie_free_msi(struct dw_pcie_rp *pp) > > struct dw_pcie *pci = to_dw_pcie_from_pp(pp); > > struct device *dev = pci->dev; > > > > - dma_unmap_page(dev, pp->msi_data, PAGE_SIZE, DMA_FROM_DEVICE); > > - if (pp->msi_page) > > - __free_page(pp->msi_page); > > + dma_free_coherent(dev, PAGE_SIZE, pp->msi_page, pp->msi_data); > > + pp->msi_data = 0; > > + pp->msi_page = NULL; > > } > > } > > > > @@ -375,22 +375,17 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) > > dw_chained_msi_isr, pp); > > } > > > > - ret = dma_set_mask(dev, DMA_BIT_MASK(32)); > > + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); > > if (ret) > > dev_warn(dev, "Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n"); > > > > - pp->msi_page = alloc_page(GFP_DMA32); > > - pp->msi_data = dma_map_page(dev, pp->msi_page, 0, > > - PAGE_SIZE, DMA_FROM_DEVICE); > > - ret = dma_mapping_error(dev, pp->msi_data); > > - if (ret) { > > - dev_err(pci->dev, "Failed to map MSI data\n"); > > - __free_page(pp->msi_page); > > - pp->msi_page = NULL; > > + pp->msi_page = dma_alloc_coherent(dev, PAGE_SIZE, &pp->msi_data, > > + GFP_KERNEL); > > You can use the managed version, dmam_alloc_coherent(), and avoid the > freeing yourself. Also with that, I think you don't need 'msi_page'? > > Also, no need to alloc a whole page. A u32 or u64? should be fine. The > write never makes it to memory, so doesn't really matter. > > > + if (!pp->msi_page) { > > + dev_err(dev, "Failed to alloc and map MSI data\n"); > > pp->msi_data = 0; > > dw_pcie_free_msi(pp); > > - > > - return ret; > > + return -ENOMEM; > > } > > > > return 0; > > -- > > 2.37.1.559.g78731f0fdb-goog > > Thanks for the review Rob! I've updated the series to address your concerns. Regards, Will