ahci_port_read_ncq_error is used from interrupt context, so you either have to
preallocate it during port attach (hi kettenis!) or fix your flags.

dlg

On 03/04/2011, at 11:38 PM, Kenneth R Westerback wrote:

> Another allocation/memory use made big mem friendly.
>
> .... Ken
>
> Index: ahci.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/ahci.c,v
> retrieving revision 1.172
> diff -u -p -r1.172 ahci.c
> --- ahci.c    28 Jan 2011 06:32:31 -0000      1.172
> +++ ahci.c    3 Apr 2011 13:35:05 -0000
> @@ -27,6 +27,7 @@
> #include <sys/timeout.h>
> #include <sys/queue.h>
> #include <sys/mutex.h>
> +#include <sys/pool.h>
>
> #include <machine/bus.h>
>
> @@ -391,8 +392,6 @@ struct ahci_port {
>       u_int32_t               ap_err_saved_active;
>       u_int32_t               ap_err_saved_active_cnt;
>
> -     u_int8_t                ap_err_scratch[512];
> -
> #ifdef AHCI_DEBUG
>       char                    ap_name[16];
> #define PORTNAME(_ap) ((_ap)->ap_name)
> @@ -3098,9 +3097,10 @@ ahci_port_read_ncq_error(struct ahci_por
> {
>       struct ahci_ccb                 *ccb;
>       struct ahci_cmd_hdr             *cmd_slot;
> -     u_int32_t                       cmd;
> +     u_int8_t                        *ap_err_scratch = NULL;
>       struct ata_fis_h2d              *fis;
>       int                             rc = EIO;
> +     u_int32_t                       cmd;
>
>       DPRINTF(AHCI_D_VERBOSE, "%s: read log page\n", PORTNAME(ap));
>
> @@ -3112,10 +3112,11 @@ ahci_port_read_ncq_error(struct ahci_por
>       ahci_port_start(ap, 0);
>
>       /* Prep error CCB for READ LOG EXT, page 10h, 1 sector. */
> +     ap_err_scratch = dma_alloc(DEV_BSIZE, PR_WAITOK | PR_ZERO);
>       ccb = ahci_get_err_ccb(ap);
>       ccb->ccb_xa.flags = ATA_F_NOWAIT | ATA_F_READ | ATA_F_POLL;
> -     ccb->ccb_xa.data = ap->ap_err_scratch;
> -     ccb->ccb_xa.datalen = 512;
> +     ccb->ccb_xa.data = ap_err_scratch;
> +     ccb->ccb_xa.datalen = DEV_BSIZE;
>       cmd_slot = ccb->ccb_cmd_hdr;
>       bzero(ccb->ccb_cmd_table, sizeof(struct ahci_cmd_table));
>
> @@ -3160,7 +3161,7 @@ err:
>               struct ata_log_page_10h         *log;
>               int                             err_slot;
>
> -             log = (struct ata_log_page_10h *)ap->ap_err_scratch;
> +             log = (struct ata_log_page_10h *)ap_err_scratch;
>               if (ISSET(log->err_regs.type, ATA_LOG_10H_TYPE_NOTQUEUED)) {
>                       /* Not queued bit was set - wasn't an NCQ error? */
>                       printf("%s: read NCQ error page, but not an NCQ "
> @@ -3181,6 +3182,9 @@ err:
>
>       /* Restore saved CMD register state */
>       ahci_pwrite(ap, AHCI_PREG_CMD, cmd);
> +
> +     if (ap_err_scratch)
> +             dma_free(ap_err_scratch, DEV_BSIZE);
>
>       return (rc);
> }

Reply via email to