Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1202252imw; Sat, 16 Jul 2022 00:51:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1svH1vib1FmMi82HsPt85X9zGyfNNHpPCtZOBx9HxH7PhxOjCF38mkcOYUwt70RzKEt6cRB X-Received: by 2002:a65:6a04:0:b0:411:b3d3:a840 with SMTP id m4-20020a656a04000000b00411b3d3a840mr16082925pgu.99.1657957903177; Sat, 16 Jul 2022 00:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657957903; cv=none; d=google.com; s=arc-20160816; b=BcRtF2H/KNo3ABhqlUZwTAJlRKTZemgvBDw8DA1Hj7Ho1P2vXJ+kG6GquJ8Gs3EWiX f4qBEsb3dIAR7zlgFODkdROQuTCJI+TekiEuW6u7JgNi2S4KQC6CyrSkeCZSbx/PGskk Gs9zDqUFslLEen5fheVCltv74jAePmSWM2SsUrLOkivUhh37ZBrKEgPg6iWVjeWz1J43 Xb6cmS/n8EQy9zBB7DNJbBN+mju6v/Kzu5PhaCN4ZTp2ZDhhDVz2v9R6/j57E2j+EiXM GNzvP90pqqu106zqSQPZMCIYWl2Z5crkEUfO0EGxK2m3sBhj7C3jqx7LmTwjVGDVCyrH D4CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=8OWAUKYF6FizOpMBPsgBi93n6le35zPDIBgC15SFy0M=; b=cEEjDJ8Saup1MY9lEi3DvnCiSHEaX0AGpQaJfEGXZgSkmQVpf9J2x88/+gq0y4b2gz +sQ0yjthzNsyl/29hIcMC1HzCeH8DjNqTxD3jA7Yyog7JwQnPtufJ+RQCdDVateBSM4g /fQU8LjreG3f69CdzmZqrNNJ6m5Wk0Z2JrygaDQ+L2mr9eHTPS5X8LBaxYaGLbbPPIte /nHgpV/uGZ/FkqB08K0T4w/3uuJNmWxyHNatu+GdkoKyWJzfJn4Uap/+mfzor+p+NbSA McknYFdQrt+4WMJzFdXjMc2P3lbEsQaw5GL57jLXD/ZKj4fzErSo9KsgJ4Xf+klhHrkL TGAw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020aa78e13000000b00518820f0cbfsi7220379pfr.335.2022.07.16.00.51.27; Sat, 16 Jul 2022 00:51:43 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbiGPHGm (ORCPT + 99 others); Sat, 16 Jul 2022 03:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiGPHGl (ORCPT ); Sat, 16 Jul 2022 03:06:41 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18552FFE3 for ; Sat, 16 Jul 2022 00:06:37 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LlK3r5rqKzlVld; Sat, 16 Jul 2022 15:04:56 +0800 (CST) Received: from dggpemm500003.china.huawei.com (7.185.36.56) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 16 Jul 2022 15:06:34 +0800 Received: from localhost.localdomain (10.28.77.120) by dggpemm500003.china.huawei.com (7.185.36.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 16 Jul 2022 15:06:34 +0800 From: wangwudi To: CC: wangwudi , Thomas Gleixner , Marc Zyngier Subject: [PATCH] drivers: irqchip: Allocate alignment addr by ITS_BASER.Page_size Date: Sat, 16 Jul 2022 15:05:36 +0800 Message-ID: <1657955136-6622-1-git-send-email-wangwudi@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.28.77.120] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500003.china.huawei.com (7.185.36.56) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 The description of the ITS_BASER.Physical_Address field in the ARM GIC spec is as follows: "The address must be aligned to the size specified in the Page Size field." The Page_Size field in ITS_BASER might be RO. Currently, the address is aligned based on the system page_size, not the HW Page_Size field. In some case, this is in contradiction with the spec. For example: ITS_BASER.Page_Size indicate 16K, and kernel page size is 4K. If HW need 4K-size memory, the driver may alloc a 4K aligned address. This has been proven in hardware. Cc: Thomas Gleixner Cc: Marc Zyngier Signed-off-by: wangwudi --- drivers/irqchip/irq-gic-v3-its.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 5ff09de6c48f..0e25e887d45c 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2310,6 +2310,9 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, order = get_order(GITS_BASER_PAGES_MAX * psz); } + if ((psz > PAGE_SIZE) && (PAGE_ORDER_TO_SIZE(order) < psz)) { + order = get_order(psz); + } page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, order); if (!page) return -ENOMEM; -- 2.7.4