From patchwork Wed Jan 24 15:01:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13529304 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34A4777622 for ; Wed, 24 Jan 2024 15:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706108510; cv=none; b=RBkFPYyW3H/oYcNJi4twAt2YUveOKSleOzd66hLKcrH+1c96rYQIb6hLgDypGqAjwYKFWgQ+OQntpeUQzP3AGkuXXLmzzc6dYZD4arjVHMtwqjM5nO+Df3rgnHB0IERKUqqDN+5W8YXITL4SsoSj0NHdh4wxo2L0C/d9flgYveg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706108510; c=relaxed/simple; bh=vXo7kwrg/JEtFg5VNFewRcL3UlxCm3whtvjszAzZPYw=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=CMITfJncLSdMjssUUWnTvdL/dQUBFoIz+xyjkodZ2V0wM8Hw8AMdW+9fkOmdmiiJWV6FMGSf5LcgwHSlmpRMnOHG+8igXsniohdGV4RK9E3BHfcvjwBUg/fySLtlKRoU0OOL62easx2QmWaeuNMXVj3k0VhS3wMm4Etc0bA5USQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=dyhySwho; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dyhySwho" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3387ef9fc62so5153493f8f.2 for ; Wed, 24 Jan 2024 07:01:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706108507; x=1706713307; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=wddH6dLZWFvD4sBtP23ayzipvN9tjMLSLEUIemLS/70=; b=dyhySwhofWH+JkOgzDfSLBlzS9igtUKpI70OvObtint2kwDXlu+crjO9IJGnpK4TI2 zjwSGBmTDmNyZ7UsPFTWn0XgAcLA7cHnQWozb14ep80vxlgnCsvKc+XAsee6vFQ1xw74 mxZT2wKqj1JIJ4Gl2MdzeWGElr85Lnyj8ss65BMn02is8cLtiQ7IBXMPhsEiuH/h2dKa By74+WvCjk4lIxVaq0FoAZ/8kq1IgZPlYsZhnFWSn7W5SOkn87eXMhJm3pnHB170beGM G0IUm0/bhnKz38V3tnQKWNqS+GnfnxrSZ8W8tVTQRGJSmzbjdbyXOIygJTVc1MOh3CMC 7f3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706108507; x=1706713307; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wddH6dLZWFvD4sBtP23ayzipvN9tjMLSLEUIemLS/70=; b=m08EAjq2UltRTDSHSgfBRLNmb1TKWGoGwxHjN0/zSUfvmOEahOazRHpHpPcUfYrd/a C1HngPL/NCgXC4n/Nqx+1Hm8GKCsIlMVnJi4EzvKkYAvZ6M5ekGHiiaadW5gwBj5Z3Qg 6CjygZXo8xnYxnJWsz+fO6CUHZwZXzYJDlhm6tNIEc33nh9bT7cQIKsDSjzxz9QCY912 JnV91eArU6xREptfb1L2OotLJ6/tQGgw/6vVY5bYW92Jikayov39tPZfyaIWotupBrkU bVj2B/p8aTliAyOXux5ZiFVHKdUxEACxg1fXes37SahAY0UGL465O1EPBkeNzqKCRd0+ DhGA== X-Gm-Message-State: AOJu0YywOSubXuMBTpOusXL8IBL0mgD4yjd9Fq4/M/q6vFOE3FltXqEF BQb/a7OnY+1ktgg6E0O8bX0h4Tb9FgmVr9cADQGflbnIoS53oe8IrMZg9NbhdII= X-Google-Smtp-Source: AGHT+IHXHhrcwAHRLUnkX2s024mT8pEXvkb38AMMNc+9E2uH9gcDtJhJhoQ9GTqAP9FJosVbKHujPg== X-Received: by 2002:adf:ef12:0:b0:337:bf29:b6ca with SMTP id e18-20020adfef12000000b00337bf29b6camr701919wro.23.1706108507315; Wed, 24 Jan 2024 07:01:47 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id o10-20020a5d62ca000000b00337d4ce6ab4sm15999360wrv.20.2024.01.24.07.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:01:46 -0800 (PST) Date: Wed, 24 Jan 2024 18:01:42 +0300 From: Dan Carpenter To: Niklas Cassel Cc: Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , Krzysztof =?utf-8?q?Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v4 1/2] PCI: dwc: Fix a 64bit bug in dw_pcie_ep_raise_msix_irq() Message-ID: <888c23ff-1ee4-4795-8c24-7631c6c37da6@moroto.mountain> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding The "msg_addr" variable is u64. However, the "aligned_offset" is an unsigned int. This means that when the code does: msg_addr &= ~aligned_offset; it will unintentionally zero out the high 32 bits. Use ALIGN_DOWN() to do the alignment instead. Cc: stable@vger.kernel.org Fixes: 2217fffcd63f ("PCI: dwc: endpoint: Fix dw_pcie_ep_raise_msix_irq() alignment support") Signed-off-by: Dan Carpenter Reviewed-by: Niklas Cassel Reviewed-by: Manivannan Sadhasivam --- v4: Add stable and r-b from Niklas v3: Use ALIGN_DOWN() v2: fix typo in commit message drivers/pci/controller/dwc/pcie-designware-ep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 5befed2dc02b..51679c6702cf 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -551,7 +551,7 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, } aligned_offset = msg_addr & (epc->mem->window.page_size - 1); - msg_addr &= ~aligned_offset; + msg_addr = ALIGN_DOWN(msg_addr, epc->mem->window.page_size); ret = dw_pcie_ep_map_addr(epc, func_no, 0, ep->msi_mem_phys, msg_addr, epc->mem->window.page_size); if (ret) From patchwork Wed Jan 24 15:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13529305 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F0B315BE for ; Wed, 24 Jan 2024 15:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706108638; cv=none; b=bLG37b1dpYOD/XUUOqJk7HojrHSr6NnxOxlpALC1XVKfF39t0oZxRX7U8BHtvbto5UPr/466sFF6im77O3XIgfxAqRhmeYHoDq/jnb79nMrvGTOzMlIGLruId6hlCCNmUdI2bPJQJe06abVg+V7MjT2XeCVQSd+yfjF8io8R58k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706108638; c=relaxed/simple; bh=T/pn351JESsRmM/aRPuZIGT3H4X/z2umZFJ27SQOtmM=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=a5wQg2vLsrAuEw8FQEg/3znh9Ij/aYLR/dLtzNOkG0FHsXsG707+vpAAnQGRP4nqyOlrruQDTJF95srJ2RqJg4Jw9yzvY6IA4kpM/pb/hu9S6K8Ujzz45l3Ho5BYBsOp/n62cviqI/WwKrVEHCgMeYRGjDd/UxbG2dSTN0YnQ9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Pf6e+/lA; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Pf6e+/lA" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40e76626170so61482385e9.2 for ; Wed, 24 Jan 2024 07:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706108635; x=1706713435; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=VlaR5UjpyG5Q22l5wBG4NSdMskPDkfH7d0hZ/q3K1b0=; b=Pf6e+/lAMoKPiAFz/fjTwAzAEOBeXmpzGuwQwb/M7m67wgWiZx+bn0IYip4CLyxFsP m6ZyFPZiQKxbOWFi+1ECBCzUgFyyMZmFNt8GYm/ftZbNeoDRZMqel2fpxy/9llpmkBRS lvVxM4T6Qp3IhSIy94H21WOF5Sosc2I+2kg99C5RcOlgRFAP1DpFxR0IbhfNrRhnt61o 3796hbD779jgNbpGLo9lASUT5TNGySAxEwuM2HD/fZK+Yo2xJzacXn/YHdk7b7KiZddz XwJLUAvYiml6DpuhPxpBZMAEj1uvz+CJJSPV0jdudh+NGdKPGYcBCdfKvQmpoBWHAQpD hcKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706108635; x=1706713435; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VlaR5UjpyG5Q22l5wBG4NSdMskPDkfH7d0hZ/q3K1b0=; b=J4CpbSET9X09bEI8Ri+DoCfGg5iVzEZWA1Pu6xax8p62lrSFJhoe9EZMA9pOCM/Lsj sBXLRGX1tfXgNlUnFuo81xUnS39SBRe2vIfIRuysgCUTc07cIu+w5Uq+Rd9Vqhf4kn+S Np5NM+iv1KhM8JB1UjkKsAwjss1kKHyibFiDF3NCv0nHzIYsg0nqvLCFaAXWgXQ/kseC juNVZ45/rmHrYXA1WHRpcdiX53P33K29YBmA/u9yWhr94wfzeNykO+Q0CjejOPb79oWd dlnI9+Bb01GieTGPmQ24wLrJ93aVqcaLgerpdQanSB6dZOIFGM/gfJUV23dTFgeeYvVE nb1g== X-Gm-Message-State: AOJu0YwTs74/t8VQKulSDlR1a2h7T5WoemSQ8Jpwcgu8lSxMJOq7RNZd WUzyOzy7mXIJWwFStFFKZf0K9I5cViMZmnqOXr2ujaBi3W4o/zktaXoZYh00aD8= X-Google-Smtp-Source: AGHT+IGjsZLHD8kGFRZjmgj+ilkWj1OOfr4o3eEgd2290Aodbjq6/EXsgNVRRYOC+8mBQzRIcutvbg== X-Received: by 2002:a05:600c:1d04:b0:40e:c337:fbe6 with SMTP id l4-20020a05600c1d0400b0040ec337fbe6mr1131335wms.106.1706108634709; Wed, 24 Jan 2024 07:03:54 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id f7-20020adff8c7000000b0033921c383b2sm13626449wrq.67.2024.01.24.07.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:03:54 -0800 (PST) Date: Wed, 24 Jan 2024 18:03:51 +0300 From: Dan Carpenter To: Jingoo Han Cc: Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , Krzysztof =?utf-8?q?Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v4 2/2] PCI: dwc: Cleanup in dw_pcie_ep_raise_msi_irq() Message-ID: <64ef42f0-5618-40fd-b715-0d412121045c@moroto.mountain> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <888c23ff-1ee4-4795-8c24-7631c6c37da6@moroto.mountain> X-Mailer: git-send-email haha only kidding I recently changed the alignment code in dw_pcie_ep_raise_msix_irq(). The code in dw_pcie_ep_raise_msi_irq() is similar so update it to match as well, just for consistency. (No effect on runtime, just a cleanup). Signed-off-by: Dan Carpenter Reviewed-by: Ilpo Järvinen Reviewed-by: Niklas Cassel Reviewed-by: Manivannan Sadhasivam --- v4: style improvements v3: use ALIGN_DOWN() v2: new patch drivers/pci/controller/dwc/pcie-designware-ep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 51679c6702cf..d2de41f02a77 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -482,9 +482,10 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, reg = ep_func->msi_cap + PCI_MSI_DATA_32; msg_data = dw_pcie_ep_readw_dbi(ep, func_no, reg); } - aligned_offset = msg_addr_lower & (epc->mem->window.page_size - 1); - msg_addr = ((u64)msg_addr_upper) << 32 | - (msg_addr_lower & ~aligned_offset); + msg_addr = ((u64)msg_addr_upper) << 32 | msg_addr_lower; + + aligned_offset = msg_addr & (epc->mem->window.page_size - 1); + msg_addr = ALIGN_DOWN(msg_addr, epc->mem->window.page_size); ret = dw_pcie_ep_map_addr(epc, func_no, 0, ep->msi_mem_phys, msg_addr, epc->mem->window.page_size); if (ret)